diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-01-11 02:15:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2007-01-11 21:18:21 -0500 |
commit | e3db7691e9f3dff3289f64e3d98583e28afe03db (patch) | |
tree | e05542d8d8bb545545c5b535381a8c1fcb369a03 /Documentation | |
parent | 07031e14c1127fc7e1a5b98dfcc59f434e025104 (diff) |
[PATCH] NFS: Fix race in nfs_release_page()
NFS: Fix race in nfs_release_page()
invalidate_inode_pages2() may find the dirty bit has been set on a page
owing to the fact that the page may still be mapped after it was locked.
Only after the call to unmap_mapping_range() are we sure that the page
can no longer be dirtied.
In order to fix this, NFS has hooked the releasepage() method and tries
to write the page out between the call to unmap_mapping_range() and the
call to remove_mapping(). This, however leads to deadlocks in the page
reclaim code, where the page may be locked without holding a reference
to the inode or dentry.
Fix is to add a new address_space_operation, launder_page(), which will
attempt to write out a dirty page without releasing the page lock.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Also, the bare SetPageDirty() can skew all sort of accounting leading to
other nasties.
[akpm@osdl.org: cleanup]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/filesystems/Locking | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 790ef6fbe495..28bfea75bcf2 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
@@ -171,6 +171,7 @@ prototypes: | |||
171 | int (*releasepage) (struct page *, int); | 171 | int (*releasepage) (struct page *, int); |
172 | int (*direct_IO)(int, struct kiocb *, const struct iovec *iov, | 172 | int (*direct_IO)(int, struct kiocb *, const struct iovec *iov, |
173 | loff_t offset, unsigned long nr_segs); | 173 | loff_t offset, unsigned long nr_segs); |
174 | int (*launder_page) (struct page *); | ||
174 | 175 | ||
175 | locking rules: | 176 | locking rules: |
176 | All except set_page_dirty may block | 177 | All except set_page_dirty may block |
@@ -188,6 +189,7 @@ bmap: yes | |||
188 | invalidatepage: no yes | 189 | invalidatepage: no yes |
189 | releasepage: no yes | 190 | releasepage: no yes |
190 | direct_IO: no | 191 | direct_IO: no |
192 | launder_page: no yes | ||
191 | 193 | ||
192 | ->prepare_write(), ->commit_write(), ->sync_page() and ->readpage() | 194 | ->prepare_write(), ->commit_write(), ->sync_page() and ->readpage() |
193 | may be called from the request handler (/dev/loop). | 195 | may be called from the request handler (/dev/loop). |
@@ -281,6 +283,12 @@ buffers from the page in preparation for freeing it. It returns zero to | |||
281 | indicate that the buffers are (or may be) freeable. If ->releasepage is zero, | 283 | indicate that the buffers are (or may be) freeable. If ->releasepage is zero, |
282 | the kernel assumes that the fs has no private interest in the buffers. | 284 | the kernel assumes that the fs has no private interest in the buffers. |
283 | 285 | ||
286 | ->launder_page() may be called prior to releasing a page if | ||
287 | it is still found to be dirty. It returns zero if the page was successfully | ||
288 | cleaned, or an error value if not. Note that in order to prevent the page | ||
289 | getting mapped back in and redirtied, it needs to be kept locked | ||
290 | across the entire operation. | ||
291 | |||
284 | Note: currently almost all instances of address_space methods are | 292 | Note: currently almost all instances of address_space methods are |
285 | using BKL for internal serialization and that's one of the worst sources | 293 | using BKL for internal serialization and that's one of the worst sources |
286 | of contention. Normally they are calling library functions (in fs/buffer.c) | 294 | of contention. Normally they are calling library functions (in fs/buffer.c) |