* [PATCH] Documentation: filesystems: update filesystem locking documentation
@ 2017-07-31 15:53 Sean Anderson
2017-07-31 17:23 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Sean Anderson @ 2017-07-31 15:53 UTC (permalink / raw)
To: linux-fsdevel, linux-doc; +Cc: corbet
[-- Attachment #1.1: Type: text/plain, Size: 2491 bytes --]
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 <seanga2@gmail.com>
---
Documentation/filesystems/Locking | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index fe25787ff6d4..b098d2e50b7f 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -69,8 +69,8 @@ prototypes:
locking rules:
all may block
- i_mutex(inode)
-lookup: yes
+ i_rwsem(inode)
+lookup: shared
create: yes
link: yes (both)
mknod: yes
@@ -92,7 +92,7 @@ atomic_open: yes
tmpfile: no
- Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
+ Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem on
victim.
cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
@@ -111,7 +111,7 @@ prototypes:
locking rules:
all may block
- i_mutex(inode)
+ i_rwsem(inode)
list: no
get: no
set: yes
@@ -217,7 +217,7 @@ 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:
@@ -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 held.
+
+->iterate_shared() is called with i_rwsem 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
--
2.13.2
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Documentation: filesystems: update filesystem locking documentation
2017-07-31 15:53 [PATCH] Documentation: filesystems: update filesystem locking documentation Sean Anderson
@ 2017-07-31 17:23 ` Matthew Wilcox
2017-08-01 11:09 ` [PATCH v2] " Sean Anderson
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2017-07-31 17:23 UTC (permalink / raw)
To: Sean Anderson; +Cc: linux-fsdevel, linux-doc, corbet
On Mon, Jul 31, 2017 at 11:53:35AM -0400, Sean Anderson wrote:
> - i_mutex(inode)
> -lookup: yes
> + i_rwsem(inode)
> +lookup: shared
> create: yes
Could you change all the 'yes' to 'exclusive' when it's changed from mutex
to rwsem?
> link: yes (both)
> mknod: yes
> @@ -92,7 +92,7 @@ atomic_open: yes
> tmpfile: no
>
>
> - Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
> + Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem on
> victim.
> cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
>
> @@ -111,7 +111,7 @@ prototypes:
>
> locking rules:
> all may block
> - i_mutex(inode)
> + i_rwsem(inode)
> list: no
> get: no
> set: yes
> @@ -217,7 +217,7 @@ 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:
> @@ -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 held.
> +
> +->iterate_shared() is called with i_rwsem 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
> --
> 2.13.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] Documentation: filesystems: update filesystem locking documentation
2017-07-31 17:23 ` Matthew Wilcox
@ 2017-08-01 11:09 ` Sean Anderson
2017-08-01 11:15 ` Jeff Layton
2017-08-01 14:22 ` Jonathan Corbet
0 siblings, 2 replies; 5+ messages in thread
From: Sean Anderson @ 2017-08-01 11:09 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: linux-fsdevel, linux-doc, corbet
[-- Attachment #1.1: Type: text/plain, Size: 3586 bytes --]
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 <seanga2@gmail.com>
---
v2: changed 'yes's to 'exclusive's when describing i_rwsem usage
Documentation/filesystems/Locking | 43 ++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index fe25787ff6d4..c0cab97d2b1a 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -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
--
2.13.2
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] Documentation: filesystems: update filesystem locking documentation
2017-08-01 11:09 ` [PATCH v2] " Sean Anderson
@ 2017-08-01 11:15 ` Jeff Layton
2017-08-01 14:22 ` Jonathan Corbet
1 sibling, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2017-08-01 11:15 UTC (permalink / raw)
To: Sean Anderson, Matthew Wilcox; +Cc: linux-fsdevel, linux-doc, corbet
On Tue, 2017-08-01 at 07:09 -0400, Sean Anderson wrote:
> 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 <seanga2@gmail.com>
> ---
> v2: changed 'yes's to 'exclusive's when describing i_rwsem usage
>
> Documentation/filesystems/Locking | 43 ++++++++++++++++++++++-----------------
> 1 file changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
> index fe25787ff6d4..c0cab97d2b1a 100644
> --- a/Documentation/filesystems/Locking
> +++ b/Documentation/filesystems/Locking
> @@ -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
Reviewed-by: Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] Documentation: filesystems: update filesystem locking documentation
2017-08-01 11:09 ` [PATCH v2] " Sean Anderson
2017-08-01 11:15 ` Jeff Layton
@ 2017-08-01 14:22 ` Jonathan Corbet
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Corbet @ 2017-08-01 14:22 UTC (permalink / raw)
To: Sean Anderson; +Cc: Matthew Wilcox, linux-fsdevel, linux-doc
On Tue, 1 Aug 2017 07:09:10 -0400
Sean Anderson <seanga2@gmail.com> wrote:
> 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 <seanga2@gmail.com>
So should I pick this up, or are we waiting for Al to finish
unpacking ... ?
jon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-01 14:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 15:53 [PATCH] Documentation: filesystems: update filesystem locking documentation Sean Anderson
2017-07-31 17:23 ` Matthew Wilcox
2017-08-01 11:09 ` [PATCH v2] " Sean Anderson
2017-08-01 11:15 ` Jeff Layton
2017-08-01 14:22 ` Jonathan Corbet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.