[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    Btrfs: fix race in run_clustered_refs
From:       "Linux Kernel Mailing List" <linux-kernel () vger ! kernel ! org>
Date:       2012-08-29 18:41:08
Message-ID: 20120829184108.51CFA3404DB () ra ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/;a=commit;h=22cd2e7de7b0bd68fb668d23e1564707ca689510
Commit:     22cd2e7de7b0bd68fb668d23e1564707ca689510
Parent:     b12a3b1ea209d9dec02731fba58c3dbe7d31cfd8
Author:     Arne Jansen <sensille@gmx.net>
AuthorDate: Thu Aug 9 00:16:53 2012 -0600
Committer:  Chris Mason <chris.mason@oracle.com>
CommitDate: Tue Aug 28 16:53:35 2012 -0400

    Btrfs: fix race in run_clustered_refs
    
    With commit
    
    commit d1270cd91f308c9d22b2804720c36ccd32dbc35e
    Author: Arne Jansen <sensille@gmx.net>
    Date:   Tue Sep 13 15:16:43 2011 +0200
    
         Btrfs: put back delayed refs that are too new
    
    I added a window where the delayed_ref's head->ref_mod code can diverge
    from the sum of the remaining refs, because we release the head->mutex
    in the middle. This leads to btrfs_lookup_extent_info returning wrong
    numbers. This patch fixes this by adjusting the head's ref_mod with each
    delayed ref we run.
    
    Signed-off-by: Arne Jansen <sensille@gmx.net>
    Signed-off-by: Chris Mason <chris.mason@fusionio.com>
---
 fs/btrfs/extent-tree.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1bb408f..f16411d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2318,6 +2318,23 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
 		ref->in_tree = 0;
 		rb_erase(&ref->rb_node, &delayed_refs->root);
 		delayed_refs->num_entries--;
+		if (locked_ref) {
+			/*
+			 * when we play the delayed ref, also correct the
+			 * ref_mod on head
+			 */
+			switch (ref->action) {
+			case BTRFS_ADD_DELAYED_REF:
+			case BTRFS_ADD_DELAYED_EXTENT:
+				locked_ref->node.ref_mod -= ref->ref_mod;
+				break;
+			case BTRFS_DROP_DELAYED_REF:
+				locked_ref->node.ref_mod += ref->ref_mod;
+				break;
+			default:
+				WARN_ON(1);
+			}
+		}
 		spin_unlock(&delayed_refs->lock);
 
 		ret = run_one_delayed_ref(trans, root, ref, extent_op,
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic