On 1/31/24 13:07, Dave Chinner wrote:
On Wed, Jan 31, 2024 at 12:52:34PM -0800, Bart Van Assche wrote:
+ inode_lock(inode);
+ inode->i_write_hint = hint;
+ inode_unlock(inode);
What is this locking serialising against? The inode may or may not
be locked when we access this in IO path, so why isn't this just
WRITE_ONCE() here and READ_ONCE() in the IO paths?
How about using WRITE_ONCE()/READ_ONCE() in the fcntl implementations and
regular reads in the I/O paths? Using F_SET_RW_HINT while I/O is ongoing
is racy - there are no guarantees about how F_SET_RW_HINT will affect I/O
that has already been submitted. Hence, I think that it is acceptable to
use regular reads for i_write_hint in the I/O paths.
Thanks,
Bart.