From: Bart Van Assche Date: Fri, 2 Feb 2024 20:39:24 +0000 (-0800) Subject: fs: Propagate write hints to the struct block_device inode X-Git-Tag: v6.9-rc1~12^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea7d898676d9e94558c46ba927db35403362389f;p=thirdparty%2Fkernel%2Flinux.git 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 Cc: Christian Brauner Cc: Jens Axboe Cc: Christoph Hellwig Cc: Jeff Layton Cc: Chuck Lever Cc: Kanchan Joshi Signed-off-by: Bart Van Assche Link: https://lore.kernel.org/r/20240202203926.2478590-6-bvanassche@acm.org Signed-off-by: Christian Brauner --- diff --git a/fs/fcntl.c b/fs/fcntl.c index 00be0a710bbab..8eb6d64a985b0 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; }