Merge tag 'late-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[firefly-linux-kernel-4.4.55.git] / fs / ext4 / mballoc.c
index def84082a9a9b73deadc0d369c63a7ef981d8ea9..a9ff5e5137ca85306f408eda2cab09669962f603 100644 (file)
@@ -2105,6 +2105,7 @@ repeat:
                group = ac->ac_g_ex.fe_group;
 
                for (i = 0; i < ngroups; group++, i++) {
+                       cond_resched();
                        /*
                         * Artificially restricted ngroups for non-extent
                         * files makes group > ngroups possible on first loop.
@@ -4405,17 +4406,20 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 repeat:
                /* allocate space in core */
                *errp = ext4_mb_regular_allocator(ac);
-               if (*errp) {
-                       ext4_discard_allocated_blocks(ac);
-                       goto errout;
-               }
+               if (*errp)
+                       goto discard_and_exit;
 
                /* as we've just preallocated more space than
-                * user requested orinally, we store allocated
+                * user requested originally, we store allocated
                 * space in a special descriptor */
                if (ac->ac_status == AC_STATUS_FOUND &&
-                               ac->ac_o_ex.fe_len < ac->ac_b_ex.fe_len)
-                       ext4_mb_new_preallocation(ac);
+                   ac->ac_o_ex.fe_len < ac->ac_b_ex.fe_len)
+                       *errp = ext4_mb_new_preallocation(ac);
+               if (*errp) {
+               discard_and_exit:
+                       ext4_discard_allocated_blocks(ac);
+                       goto errout;
+               }
        }
        if (likely(ac->ac_status == AC_STATUS_FOUND)) {
                *errp = ext4_mb_mark_diskspace_used(ac, handle, reserv_clstrs);
@@ -4612,10 +4616,11 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
                BUG_ON(bh && (count > 1));
 
                for (i = 0; i < count; i++) {
+                       cond_resched();
                        if (!bh)
                                tbh = sb_find_get_block(inode->i_sb,
                                                        block + i);
-                       if (unlikely(!tbh))
+                       if (!tbh)
                                continue;
                        ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
                                    inode, tbh, block + i);