Return-Path: Received: from mail-qk0-f194.google.com ([209.85.220.194]:43068 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935126AbeEXC3U (ORCPT ); Wed, 23 May 2018 22:29:20 -0400 To: corbet@lwn.net, linux-doc@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Al Viro , Matthew Wilcox , Jeff Layton From: Sean Anderson Subject: [PATCH RESEND] Documentation: filesystems: update filesystem locking documentation Message-ID: Date: Wed, 23 May 2018 22:29:10 -0400 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="aS3VDlDxg6F3C6UjJ1TCTUkST2M7956IT" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aS3VDlDxg6F3C6UjJ1TCTUkST2M7956IT Content-Type: multipart/mixed; boundary="C0dUBgQp3Dhd45b44hB7XhVUbCxfDpTXf"; protected-headers="v1" From: Sean Anderson To: corbet@lwn.net, linux-doc@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Al Viro , Matthew Wilcox , Jeff Layton Message-ID: Subject: [PATCH RESEND] Documentation: filesystems: update filesystem locking documentation --C0dUBgQp3Dhd45b44hB7XhVUbCxfDpTXf Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 Reviewed-by: Jeff Layton --- Documentation/filesystems/Locking | 43 +++++++++++++++++-------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystem= s/Locking index 75d2d57e2c44..15853d522941 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -69,31 +69,31 @@ prototypes: =20 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 =20 =20 - 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. =20 See Documentation/filesystems/directory-locking for more detailed discus= sion @@ -111,10 +111,10 @@ prototypes: =20 locking rules: all may block - i_mutex(inode) + i_rwsem(inode) list: no get: no -set: yes +set: exclusive =20 --------------------------- super_operations ---------------------------= prototypes: @@ -217,14 +217,14 @@ prototypes: locking rules: All except set_page_dirty and freepage may block =20 - 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 modificat= ions since this is something the userspace has to take care about. =20 +->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_flag= s. 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 --=20 2.17.0 --C0dUBgQp3Dhd45b44hB7XhVUbCxfDpTXf-- --aS3VDlDxg6F3C6UjJ1TCTUkST2M7956IT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQGTBAEBCgB9FiEEkGEdW86NSNID6GAoPuiP7LShEG4FAlsGI35fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDkw NjExRDVCQ0U4RDQ4RDIwM0U4NjAyODNFRTg4RkVDQjRBMTEwNkUACgkQPuiP7LSh EG7bMwf6Ax50H6Ouf9HWESG6kx7M3Jbw+2LV+9kz6GocOXWYsg3O9tQyk6HwBcTJ Cxq7QW+gmQR5nU9M7PZ4SReLtWpQAEJzcYh5phnCHxEB1rvw7PXlIgkrJGutbx4W wHaObqx//u98X3AgTVnipxcp7MCWakxuxT1bIkI6Ti6FgKONE6EpqRxpP1fpqHcx X1IIavDhbSnEc9sG5qKGqUzW1eIgGOnW/W2cSA8+PiMHcDNGBPgaN4hDVP+rG9fA tbudNTqyRffxdWvskosg7lR8NbuT9YOdbcSAyb7G43BGToUN2m1o2i2FKmq85Q4N yj73ugpKXTtYkIdMp6VwIJa1uEtFXA== =6mdz -----END PGP SIGNATURE----- --aS3VDlDxg6F3C6UjJ1TCTUkST2M7956IT--