aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Van Assche <[email protected]>2024-02-02 12:39:24 -0800
committerChristian Brauner <[email protected]>2024-02-06 14:30:48 +0100
commitea7d898676d9e94558c46ba927db35403362389f (patch)
treea0e8fa62b729f1ab419178ec092fa20124bd831e
parentfe3944fb245ab99570552a3bf970b00058a9ca6d (diff)
fs: Propagate write hints to the struct block_device inode
Write hints applied with F_SET_RW_HINT on a block device affect the block device inode only. Propagate these hints to the inode associated with struct block_device because that is the inode used when writing back dirty pages. Cc: Alexander Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Jeff Layton <[email protected]> Cc: Chuck Lever <[email protected]> Cc: Kanchan Joshi <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
-rw-r--r--fs/fcntl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 00be0a710bba..8eb6d64a985b 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -317,6 +317,13 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd,
WRITE_ONCE(inode->i_write_hint, hint);
+ /*
+ * file->f_mapping->host may differ from inode. As an example,
+ * blkdev_open() modifies file->f_mapping.
+ */
+ if (file->f_mapping->host != inode)
+ WRITE_ONCE(file->f_mapping->host->i_write_hint, hint);
+
return 0;
}