Skip to content

Commit bc4ad69

Browse files
Christoph Hellwiggregkh
authored andcommitted
xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags
[ Upstream commit c421df0b19430417a04f68919fc3d1943d20ac04 ] 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]> Signed-off-by: Leah Rumancik <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7880b1f commit bc4ad69

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
@@ -1120,23 +1120,25 @@ xfs_ioctl_setattr_xflags(
11201120
struct fileattr *fa)
11211121
{
11221122
struct xfs_mount *mp = ip->i_mount;
1123+
bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME);
11231124
uint64_t i_flags2;
11241125

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

1130-
/* If realtime flag is set then must have realtime device */
1131-
if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
1132+
if (rtflag) {
1133+
/* If realtime flag is set then must have realtime device */
11321134
if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
11331135
(ip->i_extsize % mp->m_sb.sb_rextsize))
11341136
return -EINVAL;
1135-
}
11361137

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

11411143
/* Don't allow us to set DAX mode for a reflinked file for now. */
11421144
if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))

0 commit comments

Comments
 (0)