]> git.itanic.dy.fi Git - linux-stable/commitdiff
xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags
authorChristoph Hellwig <hch@lst.de>
Wed, 25 Oct 2023 14:10:19 +0000 (16:10 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Nov 2023 14:05:18 +0000 (15:05 +0100)
Introduce a local boolean variable if FS_XFLAG_REALTIME to make the
checks for it more obvious, and de-densify a few of the conditionals
using it to make them more readable while at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231025141020.192413-4-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_ioctl.c

index a82470e027f7278ac4b3271cd67a27ed97235c77..022dc2dc78d2f72d7978226e0f50aecaf19f53b8 100644 (file)
@@ -1121,23 +1121,25 @@ xfs_ioctl_setattr_xflags(
        struct fileattr         *fa)
 {
        struct xfs_mount        *mp = ip->i_mount;
+       bool                    rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME);
        uint64_t                i_flags2;
 
-       /* Can't change realtime flag if any extents are allocated. */
-       if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
-           XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME))
-               return -EINVAL;
+       if (rtflag != XFS_IS_REALTIME_INODE(ip)) {
+               /* Can't change realtime flag if any extents are allocated. */
+               if (ip->i_df.if_nextents || ip->i_delayed_blks)
+                       return -EINVAL;
+       }
 
-       /* If realtime flag is set then must have realtime device */
-       if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
+       if (rtflag) {
+               /* If realtime flag is set then must have realtime device */
                if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
                    xfs_extlen_to_rtxmod(mp, ip->i_extsize))
                        return -EINVAL;
-       }
 
-       /* Clear reflink if we are actually able to set the rt flag. */
-       if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
-               ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+               /* Clear reflink if we are actually able to set the rt flag. */
+               if (xfs_is_reflink_inode(ip))
+                       ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+       }
 
        /* diflags2 only valid for v3 inodes. */
        i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);