]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use the xfs_da_args owner field to set new dir/attr block owner
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:37 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:00 +0000 (17:01 -0700)
Source kernel commit: 17a85dc64ae0804d33a2293686fc987a830a462d

When we're creating leaf, data, freespace, or dabtree blocks for
directories and xattrs, use the explicit owner field (instead of the
xfs_inode) to set the owner field.  This will enable online repair to
construct replacement data structures in a temporary file without having
to change the owner fields prior to swapping the new and old structures.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_attr_leaf.c
libxfs/xfs_attr_remote.c
libxfs/xfs_da_btree.c
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_data.c
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c

index 393e5e6cad9a1de29170096379706726169c3ab7..ed3b63f8c646575c9e0dab65924873114d57ef25 100644 (file)
@@ -1236,7 +1236,7 @@ xfs_attr3_leaf_create(
                ichdr.magic = XFS_ATTR3_LEAF_MAGIC;
 
                hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               hdr3->owner = cpu_to_be64(dp->i_ino);
+               hdr3->owner = cpu_to_be64(args->owner);
                uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
 
                ichdr.freemap[0].base = sizeof(struct xfs_attr3_leaf_hdr);
index 855d090c9e53327270cf886f04cb8036b74a4d22..2787d3fa365fb32223a2844a9ba71d7437868bfb 100644 (file)
@@ -521,8 +521,8 @@ xfs_attr_rmtval_set_value(
                        return error;
                bp->b_ops = &xfs_attr3_rmt_buf_ops;
 
-               xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset,
-                                      &valuelen, &src);
+               xfs_attr_rmtval_copyin(mp, bp, args->owner, &offset, &valuelen,
+                               &src);
 
                error = xfs_bwrite(bp); /* GROT: NOTE: synchronous write */
                xfs_buf_relse(bp);
index 8ace7622abce2b8b4e21047f028dc14afc87e1e0..3ad58ab04bf103fc3f6ac9ffe9098c40fe09c527 100644 (file)
@@ -482,7 +482,7 @@ xfs_da3_node_create(
                memset(hdr3, 0, sizeof(struct xfs_da3_node_hdr));
                ichdr.magic = XFS_DA3_NODE_MAGIC;
                hdr3->info.blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               hdr3->info.owner = cpu_to_be64(args->dp->i_ino);
+               hdr3->info.owner = cpu_to_be64(args->owner);
                uuid_copy(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid);
        } else {
                ichdr.magic = XFS_DA_NODE_MAGIC;
index 9d87735e7807681f96f3486e8e668e63b9bd11c7..c91559e59a942c15df306c857c63efb6a7d4192d 100644 (file)
@@ -160,12 +160,13 @@ xfs_dir3_block_read(
 
 static void
 xfs_dir3_block_init(
-       struct xfs_mount        *mp,
-       struct xfs_trans        *tp,
-       struct xfs_buf          *bp,
-       struct xfs_inode        *dp)
+       struct xfs_da_args      *args,
+       struct xfs_buf          *bp)
 {
-       struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
+       struct xfs_trans        *tp = args->trans;
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
+       struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
 
        bp->b_ops = &xfs_dir3_block_buf_ops;
        xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_BLOCK_BUF);
@@ -174,7 +175,7 @@ xfs_dir3_block_init(
                memset(hdr3, 0, sizeof(*hdr3));
                hdr3->magic = cpu_to_be32(XFS_DIR3_BLOCK_MAGIC);
                hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               hdr3->owner = cpu_to_be64(dp->i_ino);
+               hdr3->owner = cpu_to_be64(args->owner);
                uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
                return;
 
@@ -1006,7 +1007,7 @@ xfs_dir2_leaf_to_block(
        /*
         * Start converting it to block form.
         */
-       xfs_dir3_block_init(mp, tp, dbp, dp);
+       xfs_dir3_block_init(args, dbp);
 
        needlog = 1;
        needscan = 0;
@@ -1126,7 +1127,7 @@ xfs_dir2_sf_to_block(
        error = xfs_dir3_data_init(args, blkno, &bp);
        if (error)
                goto out_free;
-       xfs_dir3_block_init(mp, tp, bp, dp);
+       xfs_dir3_block_init(args, bp);
        hdr = bp->b_addr;
 
        /*
@@ -1166,7 +1167,7 @@ xfs_dir2_sf_to_block(
         * Create entry for .
         */
        dep = bp->b_addr + offset;
-       dep->inumber = cpu_to_be64(dp->i_ino);
+       dep->inumber = cpu_to_be64(args->owner);
        dep->namelen = 1;
        dep->name[0] = '.';
        xfs_dir2_data_put_ftype(mp, dep, XFS_DIR3_FT_DIR);
index aaf3f62af91e6d0ca529eb0e1af3605c8a185da1..6f3ccfeb69f7458e23c5c5ba6bba06df1cd302f7 100644 (file)
@@ -722,7 +722,7 @@ xfs_dir3_data_init(
                memset(hdr3, 0, sizeof(*hdr3));
                hdr3->magic = cpu_to_be32(XFS_DIR3_DATA_MAGIC);
                hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               hdr3->owner = cpu_to_be64(dp->i_ino);
+               hdr3->owner = cpu_to_be64(args->owner);
                uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
 
        } else
index 80cea8a275d885ccae7865e62f516dcda06ac986..8fbda22508df645f8a69e04ff06543d5a960c441 100644 (file)
@@ -302,12 +302,12 @@ xfs_dir3_leafn_read(
  */
 static void
 xfs_dir3_leaf_init(
-       struct xfs_mount        *mp,
-       struct xfs_trans        *tp,
+       struct xfs_da_args      *args,
        struct xfs_buf          *bp,
-       xfs_ino_t               owner,
        uint16_t                type)
 {
+       struct xfs_mount        *mp = args->dp->i_mount;
+       struct xfs_trans        *tp = args->trans;
        struct xfs_dir2_leaf    *leaf = bp->b_addr;
 
        ASSERT(type == XFS_DIR2_LEAF1_MAGIC || type == XFS_DIR2_LEAFN_MAGIC);
@@ -321,7 +321,7 @@ xfs_dir3_leaf_init(
                                         ? cpu_to_be16(XFS_DIR3_LEAF1_MAGIC)
                                         : cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
                leaf3->info.blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               leaf3->info.owner = cpu_to_be64(owner);
+               leaf3->info.owner = cpu_to_be64(args->owner);
                uuid_copy(&leaf3->info.uuid, &mp->m_sb.sb_meta_uuid);
        } else {
                memset(leaf, 0, sizeof(*leaf));
@@ -354,7 +354,6 @@ xfs_dir3_leaf_get_buf(
 {
        struct xfs_inode        *dp = args->dp;
        struct xfs_trans        *tp = args->trans;
-       struct xfs_mount        *mp = dp->i_mount;
        struct xfs_buf          *bp;
        int                     error;
 
@@ -367,7 +366,7 @@ xfs_dir3_leaf_get_buf(
        if (error)
                return error;
 
-       xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic);
+       xfs_dir3_leaf_init(args, bp, magic);
        xfs_dir3_leaf_log_header(args, bp);
        if (magic == XFS_DIR2_LEAF1_MAGIC)
                xfs_dir3_leaf_log_tail(args, bp);
index 44c8f3f2b07ea236845fd436cc74141c0729acdf..b00f783877eae81726ecb8c5bfc72328c874fd56 100644 (file)
@@ -346,7 +346,7 @@ xfs_dir3_free_get_buf(
                hdr.magic = XFS_DIR3_FREE_MAGIC;
 
                hdr3->hdr.blkno = cpu_to_be64(xfs_buf_daddr(bp));
-               hdr3->hdr.owner = cpu_to_be64(dp->i_ino);
+               hdr3->hdr.owner = cpu_to_be64(args->owner);
                uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_meta_uuid);
        } else
                hdr.magic = XFS_DIR2_FREE_MAGIC;