Skip to contentSkip to conversation

Documentation: filesystems: update filesystem locking documentation

PATCH RESEND In review Sean Anderson 2 participants 4 messages May 24, 2018 – Jun 7, 2018

Subsystems (2)

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 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.

---
 Documentation/filesystems/Locking | 43 +++++++++++++++++--------------
 1 file changed, 24 insertions(+), 19 deletions(-)
Documentation/filesystems/Locking +24 -19
index 75d2d57e2c44..15853d522941 100644
@@ -69,31 +69,31 @@ prototypes:
 
 locking rules:
 	all may block
-		i_mutex(inode)
-lookup:		yes
-create:		yes
-link:		yes (both)
-mknod:		yes
-symlink:	yes
-mkdir:		yes
-unlink:		yes (both)
-rmdir:		yes (both)	(see below)
-rename:	yes (all)	(see below)
+		i_rwsem(inode)
+lookup:		shared
+create:		exclusive
+link:		exclusive (both)
+mknod:		exclusive
+symlink:	exclusive
+mkdir:		exclusive
+unlink:		exclusive (both)
+rmdir:		exclusive (both)(see below)
+rename:		exclusive (all)	(see below)
 readlink:	no
 get_link:	no
-setattr:	yes
+setattr:	exclusive
 permission:	no (may not block if called in rcu-walk mode)
 get_acl:	no
 getattr:	no
 listxattr:	no
 fiemap:		no
 update_time:	no
-atomic_open:	yes
+atomic_open:	exclusive
 tmpfile:	no
 
 
-	Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
-victim.
+	Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem
+	exclusive on victim.
 	cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
 
 See Documentation/filesystems/directory-locking for more detailed discussion
@@ -111,10 +111,10 @@ prototypes:
 
 locking rules:
 	all may block
-		i_mutex(inode)
+		i_rwsem(inode)
 list:		no
 get:		no
-set:		yes
+set:		exclusive
 
 --------------------------- super_operations ---------------------------
 prototypes:
@@ -217,14 +217,14 @@ prototypes:
 locking rules:
 	All except set_page_dirty and freepage may block
 
-			PageLocked(page)	i_mutex
+			PageLocked(page)	i_rwsem
 writepage:		yes, unlocks (see below)
 readpage:		yes, unlocks
 writepages:
 set_page_dirty		no
 readpages:
-write_begin:		locks the page		yes
-write_end:		yes, unlocks		yes
+write_begin:		locks the page		exclusive
+write_end:		yes, unlocks		exclusive
 bmap:
 invalidatepage:		yes
 releasepage:		yes
@@ -439,6 +439,7 @@ prototypes:
 	ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
 	ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
 	int (*iterate) (struct file *, struct dir_context *);
+	int (*iterate_shared) (struct file *, struct dir_context *);
 	unsigned int (*poll) (struct file *, struct poll_table_struct *);
 	long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
 	long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
@@ -480,6 +481,10 @@ mutex or just to use i_size_read() instead.
 Note: this does not protect the file->f_pos against concurrent modifications
 since this is something the userspace has to take care about.
 
+->iterate() is called with i_rwsem exclusive.
+
+->iterate_shared() is called with i_rwsem at least shared.
+
 ->fasync() is responsible for maintaining the FASYNC bit in filp->f_flags.
 Most instances call fasync_helper(), which does that maintenance, so it's
 not normally something one needs to worry about.  Return values > 0 will be
Signature · 1 line
2.17.0
maintainer
#1 lore raw
Quoted 3 lines · Sean Anderson

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.

Your mission, should you choose to accept it, shall be to locate the old sig regarding the usual reaction to use of Quoted-Printable...

IOW, fix your mail setup. Applied, but...

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 5 lines

Your mission, should you choose to accept it, shall be to locate the old sig regarding the usual reaction to use of Quoted-Printable...

IOW, fix your mail setup. Applied, but.

Not sure what you mean by "Quoted-Printable"... Is PGP/MIME the incorrect way to send messages? I've switched to the "traditional" option for this one, and I've enabled "mail.strictly_mime" in my settings. Let me know if this fixes things for you. -----BEGIN PGP SIGNATURE-----

iQGTBAEBCgB9FiEEkGEdW86NSNID6GAoPuiP7LShEG4FAlsW6JxfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDkw NjExRDVCQ0U4RDQ4RDIwM0U4NjAyODNFRTg4RkVDQjRBMTEwNkUACgkQPuiP7LSh EG6W6wf+MS92RRCzMWTlvdUQZhIdMMzLBwlU3D4Y6eiEWzRz1o7IJxmW+0hmUCws xo2uC1iUifRSrulYMHOmB5kCRIjL5grpadiJRlJzO1/EKkV4MUA4LlVqh9Z2sXae o8bxC42/NF+7XKrABBuB+xzi51XGYXG4TevoB/FIMzQIHtnQ0EOkQomAxClm31gx HbV/GKraYYseINuQ3m1hOdKD+Ior4laySpqbPZLx+8wumIzArlcsXJiw3BpF194W Blmt5mDNybRPNObEk6huRXsbxoFq95Cu1w8UzFCp2fI6XOZlS9Z+ZrpKixpzFJ2p lkEPDgrxEeWIA2nxuIsFGwzPnibrpA==
=4mdc
-----END PGP SIGNATURE-----

maintainer
#3 lore raw
Quoted 7 lines · Sean Anderson

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 4 lines

Your mission, should you choose to accept it, shall be to locate the old sig regarding the usual reaction to use of Quoted-Printable...

Quoted 6 lines
Quoted 1 line

IOW, fix your mail setup. Applied, but.

Not sure what you mean by "Quoted-Printable"... Is PGP/MIME the incorrect way to send messages? I've switched to the "traditional" option for this one, and I've enabled "mail.strictly_mime" in my settings. Let me know if this fixes things for you.

Useful test: if git am barfs on your mail (which it does for the first posting in the thread), you are going to annoy people...