aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/extents.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2014-04-10 17:58:49 -0700
committerKent Overstreet <kmo@daterainc.com>2014-08-04 15:23:02 -0700
commit9aa61a992acceeec0d1de2cd99938421498659d5 (patch)
treed414fdba809e0193f0d19d5ea80180ef96f3a23e /drivers/md/bcache/extents.c
parentbcache: Fix a bug when detaching (diff)
downloadlinux-dev-9aa61a992acceeec0d1de2cd99938421498659d5.tar.xz
linux-dev-9aa61a992acceeec0d1de2cd99938421498659d5.zip
bcache: Fix a journal replay bug
journal replay wansn't validating pointers with bch_extent_invalid() before derefing, fixed Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/extents.c')
-rw-r--r--drivers/md/bcache/extents.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index 3a0de4cf9771..243de0bf15cd 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -474,9 +474,8 @@ out:
return false;
}
-static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
+bool __bch_extent_invalid(struct cache_set *c, const struct bkey *k)
{
- struct btree *b = container_of(bk, struct btree, keys);
char buf[80];
if (!KEY_SIZE(k))
@@ -485,16 +484,22 @@ static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
if (KEY_SIZE(k) > KEY_OFFSET(k))
goto bad;
- if (__ptr_invalid(b->c, k))
+ if (__ptr_invalid(c, k))
goto bad;
return false;
bad:
bch_extent_to_text(buf, sizeof(buf), k);
- cache_bug(b->c, "spotted extent %s: %s", buf, bch_ptr_status(b->c, k));
+ cache_bug(c, "spotted extent %s: %s", buf, bch_ptr_status(c, k));
return true;
}
+static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
+{
+ struct btree *b = container_of(bk, struct btree, keys);
+ return __bch_extent_invalid(b->c, k);
+}
+
static bool bch_extent_bad_expensive(struct btree *b, const struct bkey *k,
unsigned ptr)
{