Skip to content

Commit 9c04138

Browse files
Christoph Hellwigbrauner
authored andcommitted
xfs: respect the stable writes flag on the RT device
Update the per-folio stable writes flag dependening on which device an inode resides on. 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 c421df0 commit 9c04138

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

fs/xfs/xfs_inode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,14 @@ extern void xfs_setup_inode(struct xfs_inode *ip);
569569
extern void xfs_setup_iops(struct xfs_inode *ip);
570570
extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init);
571571

572+
static inline void xfs_update_stable_writes(struct xfs_inode *ip)
573+
{
574+
if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev))
575+
mapping_set_stable_writes(VFS_I(ip)->i_mapping);
576+
else
577+
mapping_clear_stable_writes(VFS_I(ip)->i_mapping);
578+
}
579+
572580
/*
573581
* When setting up a newly allocated inode, we need to call
574582
* xfs_finish_inode_setup() once the inode is fully instantiated at

fs/xfs/xfs_ioctl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,14 @@ xfs_ioctl_setattr_xflags(
11501150
ip->i_diflags2 = i_flags2;
11511151

11521152
xfs_diflags_to_iflags(ip, false);
1153+
1154+
/*
1155+
* Make the stable writes flag match that of the device the inode
1156+
* resides on when flipping the RT flag.
1157+
*/
1158+
if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
1159+
xfs_update_stable_writes(ip);
1160+
11531161
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
11541162
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
11551163
XFS_STATS_INC(mp, xs_ig_attrchg);

fs/xfs/xfs_iops.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,13 @@ xfs_setup_inode(
12981298
gfp_mask = mapping_gfp_mask(inode->i_mapping);
12991299
mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
13001300

1301+
/*
1302+
* For real-time inodes update the stable write flags to that of the RT
1303+
* device instead of the data device.
1304+
*/
1305+
if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip))
1306+
xfs_update_stable_writes(ip);
1307+
13011308
/*
13021309
* If there is no attribute fork no ACL can exist on this inode,
13031310
* and it can't have any file capabilities attached to it either.

0 commit comments

Comments
 (0)