Skip to contentSkip to conversation

xfs: always call xfs_update_stable_writes in xfs_ioctl_setattr_xflags

PATCH In review Christoph Hellwig 2 participants 2 messages Nov 3 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: always call xfs_update_stable_writes in xfs_ioctl_setattr_xflags

Currently xfs_update_stable_writes() is never called when the RT flag is flipped because xfs_ioctl_setattr_xflags() updates ip->i_diflags before comparing the rtflag variable to XFS_IS_REALTIME_INODE(ip), and thus the stable flag can be set incorretly when flipping the realtime bit on an existing file.

Fix this by unconditionally calling xfs_update_stable_writes for regular files.

Fixes d528a6c1d4b6 ("xfs: data checksums require stable writes")
---
 fs/xfs/xfs_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_ioctl.c +1 -1
index f81b6e52ac40..36ba609a2593 100644
@@ -595,7 +595,7 @@ xfs_ioctl_setattr_xflags(
 	 * Make the stable writes flag match that of the device the inode
 	 * resides on when flipping the RT flag.
 	 */
-	if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
+	if (S_ISREG(VFS_I(ip)->i_mode))
 		xfs_update_stable_writes(ip);
 
 	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christoph Hellwig

Currently xfs_update_stable_writes() is never called when the RT flag is flipped because xfs_ioctl_setattr_xflags() updates ip->i_diflags before comparing the rtflag variable to XFS_IS_REALTIME_INODE(ip), and thus the stable flag can be set incorretly when flipping the realtime bit on an existing file.

Quoted 6 lines

Fix this by unconditionally calling xfs_update_stable_writes for regular files.

Fixes d528a6c1d4b6 ("xfs: data checksums require stable writes")

Looks good.

Quoted 21 lines
---
 fs/xfs/xfs_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_ioctl.c +1 -1
index f81b6e52ac40..36ba609a2593 100644
@@ -595,7 +595,7 @@ xfs_ioctl_setattr_xflags(
 	 * Make the stable writes flag match that of the device the inode
 	 * resides on when flipping the RT flag.
 	 */
-	if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
+	if (S_ISREG(VFS_I(ip)->i_mode))
 		xfs_update_stable_writes(ip);
 
 	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
Signature · 1 line
2.53.0