aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNick Piggin <nickpiggin@yahoo.com.au>2007-01-29 22:36:27 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-01-29 23:20:42 -0500
commit87df7241bd547da5d4d4a4e5397866dfe422e439 (patch)
treeffe1e90a761aa358ef95e351e0718cb3c377ad37 /fs
parent4cbf2aa35e1c189db234190fefc6c83b139ef963 (diff)
[PATCH] Fix try_to_free_buffer() locking
Fix commit ecdfc9787fe527491baefc22dce8b2dbd5b2908d Not to put too fine a point on it, but in a nutshell... __set_page_dirty_buffers() | try_to_free_buffers() ---------------------------+--------------------------- | spin_lock(private_lock); | drop_bufers() | spin_unlock(private_lock); spin_lock(private_lock) | !page_has_buffers() | spin_unlock(private_lock) | SetPageDirty() | | cancel_dirty_page() oops! Signed-off-by: Nick Piggin <npiggin@suse.de> Acked-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/buffer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 460f1c43238..1ad674fd348 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2844,7 +2844,6 @@ int try_to_free_buffers(struct page *page)
2844 2844
2845 spin_lock(&mapping->private_lock); 2845 spin_lock(&mapping->private_lock);
2846 ret = drop_buffers(page, &buffers_to_free); 2846 ret = drop_buffers(page, &buffers_to_free);
2847 spin_unlock(&mapping->private_lock);
2848 2847
2849 /* 2848 /*
2850 * If the filesystem writes its buffers by hand (eg ext3) 2849 * If the filesystem writes its buffers by hand (eg ext3)
@@ -2855,9 +2854,14 @@ int try_to_free_buffers(struct page *page)
2855 * Also, during truncate, discard_buffer will have marked all 2854 * Also, during truncate, discard_buffer will have marked all
2856 * the page's buffers clean. We discover that here and clean 2855 * the page's buffers clean. We discover that here and clean
2857 * the page also. 2856 * the page also.
2857 *
2858 * private_lock must be held over this entire operation in order
2859 * to synchronise against __set_page_dirty_buffers and prevent the
2860 * dirty bit from being lost.
2858 */ 2861 */
2859 if (ret) 2862 if (ret)
2860 cancel_dirty_page(page, PAGE_CACHE_SIZE); 2863 cancel_dirty_page(page, PAGE_CACHE_SIZE);
2864 spin_unlock(&mapping->private_lock);
2861out: 2865out:
2862 if (buffers_to_free) { 2866 if (buffers_to_free) {
2863 struct buffer_head *bh = buffers_to_free; 2867 struct buffer_head *bh = buffers_to_free;