Skip to content

Commit 965de0e

Browse files
Forty-BotAl Viro
authored andcommitted
Documentation: filesystems: update filesystem locking documentation
Documentation/filesystems/Locking no longer reflects current locking semantics. i_mutex is no longer used for locking, and has been superseded by i_rwsem. Additionally, ->iterate_shared() was not documented. Signed-off-by: Sean Anderson <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 030c7e0 commit 965de0e

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

Documentation/filesystems/Locking

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,31 @@ prototypes:
6969

7070
locking rules:
7171
all may block
72-
i_mutex(inode)
73-
lookup: yes
74-
create: yes
75-
link: yes (both)
76-
mknod: yes
77-
symlink: yes
78-
mkdir: yes
79-
unlink: yes (both)
80-
rmdir: yes (both) (see below)
81-
rename: yes (all) (see below)
72+
i_rwsem(inode)
73+
lookup: shared
74+
create: exclusive
75+
link: exclusive (both)
76+
mknod: exclusive
77+
symlink: exclusive
78+
mkdir: exclusive
79+
unlink: exclusive (both)
80+
rmdir: exclusive (both)(see below)
81+
rename: exclusive (all) (see below)
8282
readlink: no
8383
get_link: no
84-
setattr: yes
84+
setattr: exclusive
8585
permission: no (may not block if called in rcu-walk mode)
8686
get_acl: no
8787
getattr: no
8888
listxattr: no
8989
fiemap: no
9090
update_time: no
91-
atomic_open: yes
91+
atomic_open: exclusive
9292
tmpfile: no
9393

9494

95-
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
96-
victim.
95+
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem
96+
exclusive on victim.
9797
cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
9898

9999
See Documentation/filesystems/directory-locking for more detailed discussion
@@ -111,10 +111,10 @@ prototypes:
111111

112112
locking rules:
113113
all may block
114-
i_mutex(inode)
114+
i_rwsem(inode)
115115
list: no
116116
get: no
117-
set: yes
117+
set: exclusive
118118

119119
--------------------------- super_operations ---------------------------
120120
prototypes:
@@ -217,14 +217,14 @@ prototypes:
217217
locking rules:
218218
All except set_page_dirty and freepage may block
219219

220-
PageLocked(page) i_mutex
220+
PageLocked(page) i_rwsem
221221
writepage: yes, unlocks (see below)
222222
readpage: yes, unlocks
223223
writepages:
224224
set_page_dirty no
225225
readpages:
226-
write_begin: locks the page yes
227-
write_end: yes, unlocks yes
226+
write_begin: locks the page exclusive
227+
write_end: yes, unlocks exclusive
228228
bmap:
229229
invalidatepage: yes
230230
releasepage: yes
@@ -439,6 +439,7 @@ prototypes:
439439
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
440440
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
441441
int (*iterate) (struct file *, struct dir_context *);
442+
int (*iterate_shared) (struct file *, struct dir_context *);
442443
unsigned int (*poll) (struct file *, struct poll_table_struct *);
443444
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
444445
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
@@ -480,6 +481,10 @@ mutex or just to use i_size_read() instead.
480481
Note: this does not protect the file->f_pos against concurrent modifications
481482
since this is something the userspace has to take care about.
482483

484+
->iterate() is called with i_rwsem exclusive.
485+
486+
->iterate_shared() is called with i_rwsem at least shared.
487+
483488
->fasync() is responsible for maintaining the FASYNC bit in filp->f_flags.
484489
Most instances call fasync_helper(), which does that maintenance, so it's
485490
not normally something one needs to worry about. Return values > 0 will be

0 commit comments

Comments
 (0)