Skip to content

Commit c421df0

Browse files
Christoph Hellwigbrauner
authored andcommitted
xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 1898efc commit c421df0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

fs/xfs/xfs_ioctl.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,23 +1121,25 @@ xfs_ioctl_setattr_xflags(
11211121
struct fileattr *fa)
11221122
{
11231123
struct xfs_mount *mp = ip->i_mount;
1124+
bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME);
11241125
uint64_t i_flags2;
11251126

1126-
/* Can't change realtime flag if any extents are allocated. */
1127-
if ((ip->i_df.if_nextents || ip->i_delayed_blks) &&
1128-
XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME))
1129-
return -EINVAL;
1127+
if (rtflag != XFS_IS_REALTIME_INODE(ip)) {
1128+
/* Can't change realtime flag if any extents are allocated. */
1129+
if (ip->i_df.if_nextents || ip->i_delayed_blks)
1130+
return -EINVAL;
1131+
}
11301132

1131-
/* If realtime flag is set then must have realtime device */
1132-
if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
1133+
if (rtflag) {
1134+
/* If realtime flag is set then must have realtime device */
11331135
if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
11341136
xfs_extlen_to_rtxmod(mp, ip->i_extsize))
11351137
return -EINVAL;
1136-
}
11371138

1138-
/* Clear reflink if we are actually able to set the rt flag. */
1139-
if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
1140-
ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1139+
/* Clear reflink if we are actually able to set the rt flag. */
1140+
if (xfs_is_reflink_inode(ip))
1141+
ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1142+
}
11411143

11421144
/* diflags2 only valid for v3 inodes. */
11431145
i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags);

0 commit comments

Comments
 (0)