Pārlūkot izejas kodu

Btrfs: fix race between allocate and release extent buffer.

Increase extent buffer's reference count while holding the lock.
Otherwise it can race with try_release_extent_buffer.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan, Zheng 15 gadi atpakaļ
vecāks
revīzija
f044ba7835
1 mainītis faili ar 1 papildinājumiem un 2 dzēšanām
  1. 1 2
      fs/btrfs/extent_io.c

+ 1 - 2
fs/btrfs/extent_io.c

@@ -3165,10 +3165,9 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
 		spin_unlock(&tree->buffer_lock);
 		goto free_eb;
 	}
-	spin_unlock(&tree->buffer_lock);
-
 	/* add one reference for the tree */
 	atomic_inc(&eb->refs);
+	spin_unlock(&tree->buffer_lock);
 	return eb;
 
 free_eb: