Commit 8ea60779 authored by Kirill Smelkov's avatar Kirill Smelkov

vfs: document that read/write & friends are called with file.f_pos_lock held

Commit 9c225f26 ("vfs: atomic f_pos accesses as per POSIX") added
locking on read/write/lseek for regular files so that the file position
is updated atomically.

Commit 10dce8af ("fs: stream_open - opener for stream-like files so
that read and write can run simultaneously without deadlock") removed
that locking if a file is stream-like, so that e.g. read don't deadlock
simultaneous write.

Document that file.f_pos_lock is held on read/write & co for regular
files.

In the documentation we can ignore the fact that f_pos_lock is not taken
if there is only one single thread using the file, because it is just an
optimization and does not affect semantic, by which multiple read /
write cannot run simultaneously.
Signed-off-by: Kirill Smelkov's avatarKirill Smelkov <kirr@nexedi.com>
parent 2d06b235
......@@ -893,15 +893,20 @@ struct file_operations {
Again, all methods are called without any locks being held, unless
otherwise noted.
llseek: called when the VFS needs to move the file position index
llseek: called when the VFS needs to move the file position index.
file.f_pos_lock is held for regular files.
read: called by read(2) and related system calls
read: called by read(2) and related system calls.
file.f_pos_lock is held for regular files.
read_iter: possibly asynchronous read with iov_iter as destination
read_iter: possibly asynchronous read with iov_iter as destination.
file.f_pos_lock is held for regular files.
write: called by write(2) and related system calls
write: called by write(2) and related system calls.
file.f_pos_lock is held for regular files.
write_iter: possibly asynchronous write with iov_iter as source
write_iter: possibly asynchronous write with iov_iter as source.
file.f_pos_lock is held for regular files.
iopoll: called when aio wants to poll for completions on HIPRI iocbs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment