mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-23 23:45:27 +00:00
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. Signed-off-by: Kent Overstreet <kmo@daterainc.com> Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
This commit is contained in:
parent
f7cb20f03d
commit
1fa8455deb
1 changed files with 7 additions and 4 deletions
|
@ -1742,6 +1742,9 @@ static bool fix_overlapping_extents(struct btree *b,
|
||||||
if (bkey_cmp(insert, k) < 0) {
|
if (bkey_cmp(insert, k) < 0) {
|
||||||
bch_cut_front(insert, k);
|
bch_cut_front(insert, k);
|
||||||
} else {
|
} else {
|
||||||
|
if (bkey_cmp(&START_KEY(insert), &START_KEY(k)) > 0)
|
||||||
|
old_offset = KEY_START(insert);
|
||||||
|
|
||||||
if (bkey_written(b, k) &&
|
if (bkey_written(b, k) &&
|
||||||
bkey_cmp(&START_KEY(insert), &START_KEY(k)) <= 0) {
|
bkey_cmp(&START_KEY(insert), &START_KEY(k)) <= 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -1803,6 +1806,10 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
|
||||||
if (fix_overlapping_extents(b, k, &iter, op))
|
if (fix_overlapping_extents(b, k, &iter, op))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (KEY_DIRTY(k))
|
||||||
|
bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
|
||||||
|
KEY_START(k), KEY_SIZE(k));
|
||||||
|
|
||||||
while (m != end(i) &&
|
while (m != end(i) &&
|
||||||
bkey_cmp(k, &START_KEY(m)) > 0)
|
bkey_cmp(k, &START_KEY(m)) > 0)
|
||||||
prev = m, m = bkey_next(m);
|
prev = m, m = bkey_next(m);
|
||||||
|
@ -1831,10 +1838,6 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
|
||||||
insert: shift_keys(b, m, k);
|
insert: shift_keys(b, m, k);
|
||||||
copy: bkey_copy(m, k);
|
copy: bkey_copy(m, k);
|
||||||
merged:
|
merged:
|
||||||
if (KEY_DIRTY(k))
|
|
||||||
bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
|
|
||||||
KEY_START(k), KEY_SIZE(k));
|
|
||||||
|
|
||||||
bch_check_keys(b, "%u for %s", status, op_type(op));
|
bch_check_keys(b, "%u for %s", status, op_type(op));
|
||||||
|
|
||||||
if (b->level && !KEY_OFFSET(k))
|
if (b->level && !KEY_OFFSET(k))
|
||||||
|
|
Loading…
Add table
Reference in a new issue