]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: add an explicit owner field to xfs_da_args
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:00:59 +0000 (17:00 -0700)
Source kernel commit: 9eef772f3a194f6841850e45dacdf4207ec7da84

Add an explicit owner field to xfs_da_args, which will make it easier
for online fsck to set the owner field of the temporary directory and
xattr structures that it builds to repair damaged metadata.

Note: I hopefully found all the xfs_da_args definitions by looking for
automatic stack variable declarations and xfs_da_args.dp assignments:

git grep -E '(args.*dp =|struct xfs_da_args[[:space:]]*[a-z0-9][a-z0-9]*)'

Note that callers of xfs_attr_{get,set,change} can set the owner to zero
(or leave it unset) to have the default set to args->dp.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_attr.c
libxfs/xfs_attr_leaf.c
libxfs/xfs_bmap.c
libxfs/xfs_da_btree.h
libxfs/xfs_dir2.c
libxfs/xfs_exchmaps.c

index caf04daa73cf4987e9b37c7e73f5e90ca84ffa9d..21b5d922b71dc1fe5fb018fb6c215ba1c4d98363 100644 (file)
@@ -262,6 +262,8 @@ xfs_attr_get(
        if (xfs_is_shutdown(args->dp->i_mount))
                return -EIO;
 
+       if (!args->owner)
+               args->owner = args->dp->i_ino;
        args->geo = args->dp->i_mount->m_attr_geo;
        args->whichfork = XFS_ATTR_FORK;
        args->hashval = xfs_da_hashname(args->name, args->namelen);
@@ -935,6 +937,8 @@ xfs_attr_set(
        if (error)
                return error;
 
+       if (!args->owner)
+               args->owner = args->dp->i_ino;
        args->geo = mp->m_attr_geo;
        args->whichfork = XFS_ATTR_FORK;
        args->hashval = xfs_da_hashname(args->name, args->namelen);
index a44312cdc67595f64e5b648b4608b95dcea5b511..393e5e6cad9a1de29170096379706726169c3ab7 100644 (file)
@@ -901,6 +901,7 @@ xfs_attr_shortform_to_leaf(
        nargs.whichfork = XFS_ATTR_FORK;
        nargs.trans = args->trans;
        nargs.op_flags = XFS_DA_OP_OKNOENT;
+       nargs.owner = args->owner;
 
        sfe = xfs_attr_sf_firstentry(sf);
        for (i = 0; i < sf->count; i++) {
@@ -1103,6 +1104,7 @@ xfs_attr3_leaf_to_shortform(
        nargs.whichfork = XFS_ATTR_FORK;
        nargs.trans = args->trans;
        nargs.op_flags = XFS_DA_OP_OKNOENT;
+       nargs.owner = args->owner;
 
        for (i = 0; i < ichdr.count; entry++, i++) {
                if (entry->flags & XFS_ATTR_INCOMPLETE)
index b089f53e0df52d4efd2d7b986d44599e1b369da7..8683342294a1b4c4f5d0938c48155b049fbe7257 100644 (file)
@@ -970,6 +970,7 @@ xfs_bmap_add_attrfork_local(
                dargs.total = dargs.geo->fsbcount;
                dargs.whichfork = XFS_DATA_FORK;
                dargs.trans = tp;
+               dargs.owner = ip->i_ino;
                return xfs_dir2_sf_to_block(&dargs);
        }
 
index 706baf36e1751146ede959bd8eaf3becbf62a27d..7fb13f26edaa7bed7a57c9edfc3c4c0b68d40f5a 100644 (file)
@@ -79,6 +79,7 @@ typedef struct xfs_da_args {
        int             rmtvaluelen2;   /* remote attr value length in bytes */
        uint32_t        op_flags;       /* operation flags */
        enum xfs_dacmp  cmpresult;      /* name compare result for lookups */
+       xfs_ino_t       owner;          /* inode that owns the dir/attr data */
 } xfs_da_args_t;
 
 /*
index 530c3e22a169e2f143e4c8f92d865718a97f6ae0..803fb82b29332d1e5b9f969e7a4499a30d80b83d 100644 (file)
@@ -249,6 +249,7 @@ xfs_dir_init(
        args->geo = dp->i_mount->m_dir_geo;
        args->dp = dp;
        args->trans = tp;
+       args->owner = dp->i_ino;
        error = xfs_dir2_sf_create(args, pdp->i_ino);
        kfree(args);
        return error;
@@ -294,6 +295,7 @@ xfs_dir_createname(
        args->whichfork = XFS_DATA_FORK;
        args->trans = tp;
        args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
+       args->owner = dp->i_ino;
        if (!inum)
                args->op_flags |= XFS_DA_OP_JUSTCHECK;
 
@@ -382,6 +384,7 @@ xfs_dir_lookup(
        args->whichfork = XFS_DATA_FORK;
        args->trans = tp;
        args->op_flags = XFS_DA_OP_OKNOENT;
+       args->owner = dp->i_ino;
        if (ci_name)
                args->op_flags |= XFS_DA_OP_CILOOKUP;
 
@@ -455,6 +458,7 @@ xfs_dir_removename(
        args->total = total;
        args->whichfork = XFS_DATA_FORK;
        args->trans = tp;
+       args->owner = dp->i_ino;
 
        if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) {
                rval = xfs_dir2_sf_removename(args);
@@ -516,6 +520,7 @@ xfs_dir_replace(
        args->total = total;
        args->whichfork = XFS_DATA_FORK;
        args->trans = tp;
+       args->owner = dp->i_ino;
 
        if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) {
                rval = xfs_dir2_sf_replace(args);
index 37e58d0885da4ea01f93534484d7233e1c79a11f..6160beef1886228ab40a80f5248b144a6709fdfc 100644 (file)
@@ -426,6 +426,7 @@ xfs_exchmaps_attr_to_sf(
                .geo            = tp->t_mountp->m_attr_geo,
                .whichfork      = XFS_ATTR_FORK,
                .trans          = tp,
+               .owner          = xmi->xmi_ip2->i_ino,
        };
        struct xfs_buf          *bp;
        int                     forkoff;
@@ -456,6 +457,7 @@ xfs_exchmaps_dir_to_sf(
                .geo            = tp->t_mountp->m_dir_geo,
                .whichfork      = XFS_DATA_FORK,
                .trans          = tp,
+               .owner          = xmi->xmi_ip2->i_ino,
        };
        struct xfs_dir2_sf_hdr  sfh;
        struct xfs_buf          *bp;