Skip to content

Commit ea7d898

Browse files
bvanasschebrauner
authored andcommitted
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 <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> Cc: Kanchan Joshi <joshi.k@samsung.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20240202203926.2478590-6-bvanassche@acm.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fe3944f commit ea7d898

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/fcntl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd,
317317

318318
WRITE_ONCE(inode->i_write_hint, hint);
319319

320+
/*
321+
* file->f_mapping->host may differ from inode. As an example,
322+
* blkdev_open() modifies file->f_mapping.
323+
*/
324+
if (file->f_mapping->host != inode)
325+
WRITE_ONCE(file->f_mapping->host->i_write_hint, hint);
326+
320327
return 0;
321328
}
322329

0 commit comments

Comments
 (0)