xfs: make the reserved block permission flag explicit in xfs_attr_set
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 16:48:07 +0000 (09:48 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 23 Apr 2024 14:47:03 +0000 (07:47 -0700)
Make the use of reserved blocks an explicit parameter to xfs_attr_set.
Userspace setting XFS_ATTR_ROOT attrs should continue to be able to use
it, but for online repairs we can back out and therefore do not care.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr.h
fs/xfs/scrub/attr_repair.c
fs/xfs/xfs_xattr.c

index df8418671c379520f590c9a1ce288bbdd2e7c657..c98145596f029dc699fc68feabcb29eacaf9abd4 100644 (file)
@@ -952,7 +952,7 @@ xfs_attr_lookup(
  * Make a change to the xattr structure.
  *
  * The caller must have initialized @args, attached dquots, and must not hold
- * any ILOCKs.
+ * any ILOCKs.  Reserved data blocks may be used if @rsvd is set.
  *
  * Returns -EEXIST for XFS_ATTRUPDATE_CREATE if the name already exists.
  * Returns -ENOATTR for XFS_ATTRUPDATE_REMOVE if the name does not exist.
@@ -961,12 +961,12 @@ xfs_attr_lookup(
 int
 xfs_attr_set(
        struct xfs_da_args      *args,
-       enum xfs_attr_update    op)
+       enum xfs_attr_update    op,
+       bool                    rsvd)
 {
        struct xfs_inode        *dp = args->dp;
        struct xfs_mount        *mp = dp->i_mount;
        struct xfs_trans_res    tres;
-       bool                    rsvd = (args->attr_filter & XFS_ATTR_ROOT);
        int                     error, local;
        int                     rmt_blks = 0;
        unsigned int            total;
index d12583dd7eecbea312b4bf9ed57385469a628b12..43dee4cbaab2515cb5207b53651fcdee00bcad41 100644 (file)
@@ -558,7 +558,7 @@ enum xfs_attr_update {
        XFS_ATTRUPDATE_REPLACE, /* set value, fail if attr does not exist */
 };
 
-int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op);
+int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op, bool rsvd);
 int xfs_attr_set_iter(struct xfs_attr_intent *attr);
 int xfs_attr_remove_iter(struct xfs_attr_intent *attr);
 bool xfs_attr_check_namespace(unsigned int attr_flags);
index 67c0ec0d1dbba60af74dde17ee44fc146e72b762..cbcc446d5119b2fa3e70e1b106450dbd35186681 100644 (file)
@@ -606,7 +606,7 @@ xrep_xattr_insert_rec(
         * already exists, we'll just drop it during the rebuild.
         */
        xfs_attr_sethash(&args);
-       error = xfs_attr_set(&args, XFS_ATTRUPDATE_CREATE);
+       error = xfs_attr_set(&args, XFS_ATTRUPDATE_CREATE, false);
        if (error == -EEXIST)
                error = 0;
 
index bbdbe9026658d9475907eb2dbed8b0a8e171cefb..ab3d22f662f280cd08bcc463599c2286d2b351ba 100644 (file)
@@ -110,7 +110,7 @@ xfs_attr_change(
        args->whichfork = XFS_ATTR_FORK;
        xfs_attr_sethash(args);
 
-       return xfs_attr_set(args, op);
+       return xfs_attr_set(args, op, args->attr_filter & XFS_ATTR_ROOT);
 }