Skip to content

Commit 754df8c

Browse files
Christoph Hellwiggregkh
authored andcommitted
xfs: respect the stable writes flag on the RT device
[ Upstream commit 9c04138414c00ae61421f36ada002712c4bac94a ] 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]> Signed-off-by: Leah Rumancik <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bc4ad69 commit 754df8c

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
@@ -1153,6 +1153,14 @@ xfs_ioctl_setattr_xflags(
11531153
ip->i_diflags2 = i_flags2;
11541154

11551155
xfs_diflags_to_iflags(ip, false);
1156+
1157+
/*
1158+
* Make the stable writes flag match that of the device the inode
1159+
* resides on when flipping the RT flag.
1160+
*/
1161+
if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
1162+
xfs_update_stable_writes(ip);
1163+
11561164
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
11571165
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
11581166
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
@@ -1291,6 +1291,13 @@ xfs_setup_inode(
12911291
gfp_mask = mapping_gfp_mask(inode->i_mapping);
12921292
mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
12931293

1294+
/*
1295+
* For real-time inodes update the stable write flags to that of the RT
1296+
* device instead of the data device.
1297+
*/
1298+
if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip))
1299+
xfs_update_stable_writes(ip);
1300+
12941301
/*
12951302
* If there is no attribute fork no ACL can exist on this inode,
12961303
* and it can't have any file capabilities attached to it either.

0 commit comments

Comments
 (0)