btrfs-progs: do not reclaim extent buffer
authorNaohiro Aota <naota@elisp.net>
Tue, 30 Sep 2014 14:40:56 +0000 (23:40 +0900)
committerDavid Sterba <dsterba@suse.cz>
Fri, 10 Oct 2014 08:38:36 +0000 (10:38 +0200)
commitf32d749e66c2914d18f0acaad759e98fd829926a
tree713f72a87d5b117241171575f6e672b3685c6552
parent9ecbbe30ec29bc6d75cf4785081a20b8beeb6ba5
btrfs-progs: do not reclaim extent buffer

We should kill free_some_buffers() to stop reclaiming extent buffers or
we will hit a problem described below.

As of commit 53ee1bccf99cd5b474fe1aa857b7dd176e3a1407, we are not
counting a reference for tree->lru anymore. However free_some_buffers()
is still left and is reclaiming extent buffers whose @refs == 1. This
cause extent buffers to be reclaimed unintentionally. Thus the following
steps could happen:

1. A buffer at address A is reclaimed by free_some_buffers()
   (address A is also free()ed)
2. Some code call alloc_extent_buffer()
3. Address A is assigned to newly allocated buffer
4. You see a buffer pointed by A suddenly changed its content

This problem is also pointed out here and it has a reproducer:
https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg36703.html

This commit drop free_some_buffers() and related variables, and also it
modify extent_io_tree_cleanup() to catch non-free'ed buffers properly.

Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
extent_io.c