Merge remote-tracking branch 'asoc/fix/dapm' into asoc-linus
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_bmap_util.c
index fa65f67737c579eb3642de4a1b680e4a429f2840..3bf4ad0d19e4f3203bdb36b23f74616f9c691741 100644 (file)
@@ -112,24 +112,17 @@ xfs_bmap_finish(
                return error;
        }
 
+       /*
+        * Get an EFD and free each extent in the list, logging to the EFD in
+        * the process. The remaining bmap free list is cleaned up by the caller
+        * on error.
+        */
        efd = xfs_trans_get_efd(*tp, efi, flist->xbf_count);
        for (free = flist->xbf_first; free != NULL; free = next) {
                next = free->xbfi_next;
 
-               /*
-                * Free the extent and log the EFD to dirty the transaction
-                * before handling errors. This ensures that the transaction is
-                * aborted, which:
-                *
-                * 1.) releases the EFI and frees the EFD
-                * 2.) shuts down the filesystem
-                *
-                * The bmap free list is cleaned up at a higher level.
-                */
-               error = xfs_free_extent(*tp, free->xbfi_startblock,
-                                       free->xbfi_blockcount);
-               xfs_trans_log_efd_extent(*tp, efd, free->xbfi_startblock,
-                                        free->xbfi_blockcount);
+               error = xfs_trans_free_extent(*tp, efd, free->xbfi_startblock,
+                                             free->xbfi_blockcount);
                if (error)
                        return error;
 
@@ -1481,7 +1474,7 @@ xfs_shift_file_space(
                                XFS_DIOSTRAT_SPACE_RES(mp, 0), 0,
                                XFS_QMOPT_RES_REGBLKS);
                if (error)
-                       goto out;
+                       goto out_trans_cancel;
 
                xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
@@ -1495,18 +1488,20 @@ xfs_shift_file_space(
                                &done, stop_fsb, &first_block, &free_list,
                                direction, XFS_BMAP_MAX_SHIFT_EXTENTS);
                if (error)
-                       goto out;
+                       goto out_bmap_cancel;
 
                error = xfs_bmap_finish(&tp, &free_list, &committed);
                if (error)
-                       goto out;
+                       goto out_bmap_cancel;
 
                error = xfs_trans_commit(tp);
        }
 
        return error;
 
-out:
+out_bmap_cancel:
+       xfs_bmap_cancel(&free_list);
+out_trans_cancel:
        xfs_trans_cancel(tp);
        return error;
 }