Message ID | 20240130214911.1863909-6-bvanassche@acm.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Pass data lifetime information to SCSI disk devices | expand |
On 1/31/2024 3:18 AM, Bart Van Assche wrote: > 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. Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
diff --git a/fs/fcntl.c b/fs/fcntl.c index fc73c5fae43c..cfb52c3a4577 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -319,6 +319,17 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd, inode->i_write_hint = hint; inode_unlock(inode); + /* + * file->f_mapping->host may differ from inode. As an example, + * blkdev_open() modifies file->f_mapping. + */ + if (file->f_mapping->host != inode) { + inode = file->f_mapping->host; + inode_lock(inode); + inode->i_write_hint = hint; + inode_unlock(inode); + } + return 0; }
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 <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Christoph Hellwig <hch@lst.de> Cc: Jeff Layton <jlayton@kernel.org> Cc: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- fs/fcntl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)