From 0305138546dfaf6c3a2dfa52d2f28d941546b7ce Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Fri, 14 Sep 2012 13:43:01 -0400 Subject: [PATCH] --- yaml --- r: 332577 b: refs/heads/master c: b5bae2612af92fd8e7bcdcf7ce3e0259e8d341c9 h: refs/heads/master i: 332575: 4f9474a25905de165449c899f20f2db0fc39eae0 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/extent_io.c | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 09bb020a1115..ec1ebe3c1521 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ff44c6e36dc9dcc02652a1105b120bdf08cea9f7 +refs/heads/master: b5bae2612af92fd8e7bcdcf7ce3e0259e8d341c9 diff --git a/trunk/fs/btrfs/extent_io.c b/trunk/fs/btrfs/extent_io.c index 90bd9f768c0a..a2c21570adf5 100644 --- a/trunk/fs/btrfs/extent_io.c +++ b/trunk/fs/btrfs/extent_io.c @@ -3256,19 +3256,34 @@ int btree_write_cache_pages(struct address_space *mapping, break; } + spin_lock(&mapping->private_lock); + if (!PagePrivate(page)) { + spin_unlock(&mapping->private_lock); + continue; + } + eb = (struct extent_buffer *)page->private; + + /* + * Shouldn't happen and normally this would be a BUG_ON + * but no sense in crashing the users box for something + * we can survive anyway. + */ if (!eb) { + spin_unlock(&mapping->private_lock); WARN_ON(1); continue; } - if (eb == prev_eb) + if (eb == prev_eb) { + spin_unlock(&mapping->private_lock); continue; + } - if (!atomic_inc_not_zero(&eb->refs)) { - WARN_ON(1); + ret = atomic_inc_not_zero(&eb->refs); + spin_unlock(&mapping->private_lock); + if (!ret) continue; - } prev_eb = eb; ret = lock_extent_buffer_for_io(eb, fs_info, &epd);