net: dsa: add MDB support
[cascardo/linux.git] / fs / xfs / xfs_bmap_util.c
index d3c3d46..4ece4f2 100644 (file)
@@ -41,6 +41,7 @@
 #include "xfs_trace.h"
 #include "xfs_icache.h"
 #include "xfs_log.h"
+#include "xfs_rmap_btree.h"
 
 /* Kernel only BMAP related definitions and functions */
 
@@ -685,7 +686,7 @@ xfs_bmap_punch_delalloc_range(
                xfs_bmbt_irec_t imap;
                int             nimaps = 1;
                xfs_fsblock_t   firstblock;
-               xfs_bmap_free_t flist;
+               struct xfs_defer_ops dfops;
 
                /*
                 * Map the range first and check that it is a delalloc extent
@@ -716,18 +717,18 @@ xfs_bmap_punch_delalloc_range(
                WARN_ON(imap.br_blockcount == 0);
 
                /*
-                * Note: while we initialise the firstblock/flist pair, they
+                * Note: while we initialise the firstblock/dfops pair, they
                 * should never be used because blocks should never be
                 * allocated or freed for a delalloc extent and hence we need
                 * don't cancel or finish them after the xfs_bunmapi() call.
                 */
-               xfs_bmap_init(&flist, &firstblock);
+               xfs_defer_init(&dfops, &firstblock);
                error = xfs_bunmapi(NULL, ip, start_fsb, 1, 0, 1, &firstblock,
-                                       &flist, &done);
+                                       &dfops, &done);
                if (error)
                        break;
 
-               ASSERT(!xfs_defer_has_unfinished_work(&flist));
+               ASSERT(!xfs_defer_has_unfinished_work(&dfops));
 next_block:
                start_fsb++;
                remaining--;
@@ -884,7 +885,7 @@ xfs_alloc_file_space(
        int                     rt;
        xfs_trans_t             *tp;
        xfs_bmbt_irec_t         imaps[1], *imapp;
-       xfs_bmap_free_t         free_list;
+       struct xfs_defer_ops    dfops;
        uint                    qblocks, resblks, resrtextents;
        int                     error;
 
@@ -975,17 +976,17 @@ xfs_alloc_file_space(
 
                xfs_trans_ijoin(tp, ip, 0);
 
-               xfs_bmap_init(&free_list, &firstfsb);
+               xfs_defer_init(&dfops, &firstfsb);
                error = xfs_bmapi_write(tp, ip, startoffset_fsb,
                                        allocatesize_fsb, alloc_type, &firstfsb,
-                                       resblks, imapp, &nimaps, &free_list);
+                                       resblks, imapp, &nimaps, &dfops);
                if (error)
                        goto error0;
 
                /*
                 * Complete the transaction
                 */
-               error = xfs_bmap_finish(&tp, &free_list, NULL);
+               error = xfs_defer_finish(&tp, &dfops, NULL);
                if (error)
                        goto error0;
 
@@ -1008,7 +1009,7 @@ xfs_alloc_file_space(
        return error;
 
 error0:        /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
-       xfs_bmap_cancel(&free_list);
+       xfs_defer_cancel(&dfops);
        xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
 
 error1:        /* Just cancel transaction */
@@ -1026,7 +1027,7 @@ xfs_unmap_extent(
 {
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_trans        *tp;
-       struct xfs_bmap_free    free_list;
+       struct xfs_defer_ops    dfops;
        xfs_fsblock_t           firstfsb;
        uint                    resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
        int                     error;
@@ -1045,13 +1046,13 @@ xfs_unmap_extent(
 
        xfs_trans_ijoin(tp, ip, 0);
 
-       xfs_bmap_init(&free_list, &firstfsb);
+       xfs_defer_init(&dfops, &firstfsb);
        error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, &firstfsb,
-                       &free_list, done);
+                       &dfops, done);
        if (error)
                goto out_bmap_cancel;
 
-       error = xfs_bmap_finish(&tp, &free_list, NULL);
+       error = xfs_defer_finish(&tp, &dfops, ip);
        if (error)
                goto out_bmap_cancel;
 
@@ -1061,7 +1062,7 @@ out_unlock:
        return error;
 
 out_bmap_cancel:
-       xfs_bmap_cancel(&free_list);
+       xfs_defer_cancel(&dfops);
 out_trans_cancel:
        xfs_trans_cancel(tp);
        goto out_unlock;
@@ -1250,7 +1251,7 @@ xfs_shift_file_space(
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_trans        *tp;
        int                     error;
-       struct xfs_bmap_free    free_list;
+       struct xfs_defer_ops    dfops;
        xfs_fsblock_t           first_block;
        xfs_fileoff_t           stop_fsb;
        xfs_fileoff_t           next_fsb;
@@ -1328,19 +1329,19 @@ xfs_shift_file_space(
 
                xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-               xfs_bmap_init(&free_list, &first_block);
+               xfs_defer_init(&dfops, &first_block);
 
                /*
                 * We are using the write transaction in which max 2 bmbt
                 * updates are allowed
                 */
                error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb,
-                               &done, stop_fsb, &first_block, &free_list,
+                               &done, stop_fsb, &first_block, &dfops,
                                direction, XFS_BMAP_MAX_SHIFT_EXTENTS);
                if (error)
                        goto out_bmap_cancel;
 
-               error = xfs_bmap_finish(&tp, &free_list, NULL);
+               error = xfs_defer_finish(&tp, &dfops, NULL);
                if (error)
                        goto out_bmap_cancel;
 
@@ -1350,7 +1351,7 @@ xfs_shift_file_space(
        return error;
 
 out_bmap_cancel:
-       xfs_bmap_cancel(&free_list);
+       xfs_defer_cancel(&dfops);
 out_trans_cancel:
        xfs_trans_cancel(tp);
        return error;
@@ -1534,6 +1535,10 @@ xfs_swap_extents(
        __uint64_t      tmp;
        int             lock_flags;
 
+       /* XXX: we can't do this with rmap, will fix later */
+       if (xfs_sb_version_hasrmapbt(&mp->m_sb))
+               return -EOPNOTSUPP;
+
        tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
        if (!tempifp) {
                error = -ENOMEM;