From 53ee1bccf99cd5b474fe1aa857b7dd176e3a1407 Mon Sep 17 00:00:00 2001 From: Liu Bo Date: Thu, 28 Nov 2013 00:08:24 +0800 Subject: Btrfs-progs: fix the mismatch of extent buffer's space Now we set @refs to 2 on creating a new extent buffer, meanwhile we allocate the needed free space, but we don't give enough free_extent_buffer() to reduce the eb's references to zero so that the eb can finally be freed, so the problem is we has decrease the referene count of backrefs to zero, which ends up releasing the space occupied by the eb, and this space can be allocated again for something else(another eb or disk), usually a crash(core dump) will occur, I've hit a crash in rb_insert() because another eb re-use the space while the original one is floating around. We should do the same thing as the kernel code does, it's necessary to initialize @refs to 1 instead of 2, this helps us get rid of the above problem. Signed-off-by: Liu Bo Signed-off-by: David Sterba Signed-off-by: Chris Mason --- extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extent_io.c') diff --git a/extent_io.c b/extent_io.c index ad07b9cd..a127e543 100644 --- a/extent_io.c +++ b/extent_io.c @@ -580,7 +580,7 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree, eb->start = bytenr; eb->len = blocksize; - eb->refs = 2; + eb->refs = 1; eb->flags = 0; eb->tree = tree; eb->fd = -1; -- cgit v1.2.3