aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems/Locking
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-01-11 02:15:39 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2007-01-11 21:18:21 -0500
commite3db7691e9f3dff3289f64e3d98583e28afe03db (patch)
treee05542d8d8bb545545c5b535381a8c1fcb369a03 /Documentation/filesystems/Locking
parent07031e14c1127fc7e1a5b98dfcc59f434e025104 (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/filesystems/Locking')
-rw-r--r--Documentation/filesystems/Locking8
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
175locking rules: 176locking rules:
176 All except set_page_dirty may block 177 All except set_page_dirty may block
@@ -188,6 +189,7 @@ bmap: yes
188invalidatepage: no yes 189invalidatepage: no yes
189releasepage: no yes 190releasepage: no yes
190direct_IO: no 191direct_IO: no
192launder_page: no yes
191 193
192 ->prepare_write(), ->commit_write(), ->sync_page() and ->readpage() 194 ->prepare_write(), ->commit_write(), ->sync_page() and ->readpage()
193may be called from the request handler (/dev/loop). 195may 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
281indicate that the buffers are (or may be) freeable. If ->releasepage is zero, 283indicate that the buffers are (or may be) freeable. If ->releasepage is zero,
282the kernel assumes that the fs has no private interest in the buffers. 284the 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
287it is still found to be dirty. It returns zero if the page was successfully
288cleaned, or an error value if not. Note that in order to prevent the page
289getting mapped back in and redirtied, it needs to be kept locked
290across 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
285using BKL for internal serialization and that's one of the worst sources 293using BKL for internal serialization and that's one of the worst sources
286of contention. Normally they are calling library functions (in fs/buffer.c) 294of contention. Normally they are calling library functions (in fs/buffer.c)