linux/drivers/md/bcache
Kent Overstreet d24a6e1087 bcache: Fix dirty_data accounting
Dirty data accounting wasn't quite right - firstly, we were adding the key we're
inserting after it could have merged with another dirty key already in the
btree, and secondly we could sometimes pass the wrong offset to
bcache_dev_sectors_dirty_add() for dirty data we were overwriting - which is
important when tracking dirty data by stripe.

NOTE FOR BACKPORTERS: For 3.10 (and 3.11?) there's other accounting fixes
necessary that got squashed in with other patches; the full patch against 3.10
is 408cc2f47eeac93a, available at:
  git://evilpiepirate.org/~kent/linux-bcache.git bcache-3.10-writeback-fixes

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: linux-stable <stable@vger.kernel.org> # >= v3.10

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 2a46036..4a12b2f 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1817,7 +1817,8 @@ static bool fix_overlapping_extents(struct btree *b, struct bkey *insert,
 			if (KEY_START(k) > KEY_START(insert) + sectors_found)
 				goto check_failed;

-			if (KEY_PTRS(replace_key) != KEY_PTRS(k))
+			if (KEY_PTRS(k) != KEY_PTRS(replace_key) ||
+			    KEY_DIRTY(k) != KEY_DIRTY(replace_key))
 				goto check_failed;

 			/* skip past gen */
2013-12-16 14:22:16 -08:00
..
alloc.c bcache: Don't bother with bucket refcount for btree node allocations 2013-11-10 21:56:34 -08:00
bcache.h bcache: Bypass torture test 2013-11-10 21:56:43 -08:00
bset.c bcache: Delete some slower inline asm 2013-11-10 21:56:42 -08:00
bset.h bcache: Kill bch_next_recurse_key() 2013-11-10 21:56:39 -08:00
btree.c bcache: Fix dirty_data accounting 2013-12-16 14:22:16 -08:00
btree.h bcache: Avoid deadlocking in garbage collection 2013-11-10 21:56:38 -08:00
closure.c bcache: Drop some closure stuff 2013-11-10 21:56:10 -08:00
closure.h bcache: Drop some closure stuff 2013-11-10 21:56:10 -08:00
debug.c bcache: Bypass torture test 2013-11-10 21:56:43 -08:00
debug.h bcache: Bypass torture test 2013-11-10 21:56:43 -08:00
io.c bcache: Use standard utility code 2013-07-01 14:43:53 -07:00
journal.c bcache: Pull on disk data structures out into a separate header 2013-11-10 21:56:33 -08:00
journal.h bcache: Pull on disk data structures out into a separate header 2013-11-10 21:56:33 -08:00
Kconfig bcache: Debug code improvements 2013-11-10 21:56:34 -08:00
Makefile
movinggc.c bcache: Break up struct search 2013-11-10 21:56:32 -08:00
request.c bcache: Bypass torture test 2013-11-10 21:56:43 -08:00
request.h bcache: Move sector allocator to alloc.c 2013-11-10 21:56:32 -08:00
stats.c bcache: Break up struct search 2013-11-10 21:56:32 -08:00
stats.h bcache: Break up struct search 2013-11-10 21:56:32 -08:00
super.c bcache: defensively handle format strings 2013-11-10 21:56:43 -08:00
sysfs.c bcache: Bypass torture test 2013-11-10 21:56:43 -08:00
sysfs.h bcache: Don't export utility code, prefix with bch_ 2013-03-28 12:50:55 -06:00
trace.c bcache: Break up struct search 2013-11-10 21:56:32 -08:00
util.c bcache: Move spinlock into struct time_stats 2013-11-10 21:56:40 -08:00
util.h bcache: Move spinlock into struct time_stats 2013-11-10 21:56:40 -08:00
writeback.c bcache: Use uninterruptible sleep in writeback 2013-12-16 14:04:57 -08:00
writeback.h bcache: Fix sysfs splat on shutdown with flash only devs 2013-11-10 21:56:41 -08:00