summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-09-08 17:36:05 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-09-08 18:54:48 -0800
commit6e9e665255932b2dcc2985e3bbd603d7a673138d (patch)
tree21ce92e90a708310e36c3dd641dc0859ea853e6e
parent79fbd19ecc389089bd285a54667d816e46870790 (diff)
bcache: add printks for different phases of recovery
use mount -o verbose_recovery to enable
-rw-r--r--drivers/md/bcache/bcache.h6
-rw-r--r--drivers/md/bcache/fs-gc.c25
-rw-r--r--drivers/md/bcache/super.c15
3 files changed, 31 insertions, 15 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index bad67a4a2147..2101c3b96981 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -218,6 +218,12 @@
#define bch_err(c, fmt, ...) \
printk(KERN_ERR bch_fmt(c, fmt), ##__VA_ARGS__)
+#define bch_verbose(c, fmt, ...) \
+do { \
+ if ((c)->opts.verbose_recovery) \
+ bch_info(c, fmt, ##__VA_ARGS__); \
+} while (0)
+
/* Parameters that are useful for debugging, but should always be compiled in: */
#define BCH_DEBUG_PARAMS_ALWAYS() \
BCH_DEBUG_PARAM(key_merging_disabled, \
diff --git a/drivers/md/bcache/fs-gc.c b/drivers/md/bcache/fs-gc.c
index 99a9a7ac5679..d387ee33b1c9 100644
--- a/drivers/md/bcache/fs-gc.c
+++ b/drivers/md/bcache/fs-gc.c
@@ -18,7 +18,7 @@ struct nlink {
DECLARE_GENRADIX_TYPE(nlinks, struct nlink);
-static void inc_link(struct nlinks *links,
+static void inc_link(struct cache_set *c, struct nlinks *links,
u64 range_start, u64 *range_end,
u64 inum, unsigned count, bool dir)
{
@@ -29,6 +29,7 @@ static void inc_link(struct nlinks *links,
link = genradix_ptr_alloc(links, inum - range_start, GFP_KERNEL);
if (!link) {
+ bch_verbose(c, "allocation failed during fs gc - will need another pass");
*range_end = inum;
return;
}
@@ -53,7 +54,7 @@ static int bch_gc_walk_dirents(struct cache_set *c, struct nlinks *links,
struct bkey_s_c_dirent d;
u64 d_inum;
- inc_link(links, range_start, range_end, BCACHE_ROOT_INO, 2, false);
+ inc_link(c, links, range_start, range_end, BCACHE_ROOT_INO, 2, false);
for_each_btree_key(&iter, c, BTREE_ID_DIRENTS, POS_MIN, k) {
switch (k.k->type) {
@@ -62,12 +63,12 @@ static int bch_gc_walk_dirents(struct cache_set *c, struct nlinks *links,
d_inum = le64_to_cpu(d.v->d_inum);
if (d.v->d_type == DT_DIR) {
- inc_link(links, range_start, range_end,
+ inc_link(c, links, range_start, range_end,
d_inum, 2, false);
- inc_link(links, range_start, range_end,
+ inc_link(c, links, range_start, range_end,
d.k->p.inode, 1, true);
} else {
- inc_link(links, range_start, range_end,
+ inc_link(c, links, range_start, range_end,
d_inum, 1, false);
}
@@ -118,15 +119,13 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
"non empty directory with link count 0,inode nlink %u, dir links found %u",
i_nlink, link.dir_count);
- if (c->opts.verbose_recovery)
- bch_info(c, "deleting inum %llu", inode.k->p.inode);
+ bch_verbose(c, "deleting inum %llu", inode.k->p.inode);
return bch_inode_rm(c, inode.k->p.inode);
}
if (i_flags & BCH_INODE_I_SIZE_DIRTY) {
- if (c->opts.verbose_recovery)
- bch_info(c, "truncating inode %llu", inode.k->p.inode);
+ bch_verbose(c, "truncating inode %llu", inode.k->p.inode);
/*
* XXX: need to truncate partial blocks too here - or ideally
@@ -147,8 +146,7 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
}
if (i_flags & BCH_INODE_I_SECTORS_DIRTY) {
- if (c->opts.verbose_recovery)
- bch_info(c, "recounting sectors for inode %llu", inode.k->p.inode);
+ bch_verbose(c, "recounting sectors for inode %llu", inode.k->p.inode);
i_sectors = bch_count_inode_sectors(c, inode.k->p.inode);
if (i_sectors < 0)
@@ -158,9 +156,8 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
if (i_nlink != link.count + link.dir_count ||
i_flags & BCH_INODE_I_SECTORS_DIRTY ||
i_flags & BCH_INODE_I_SIZE_DIRTY) {
- if (c->opts.verbose_recovery &&
- i_nlink != link.count + link.dir_count)
- bch_info(c, "setting inum %llu nlinks from %u to %u",
+ if (i_nlink != link.count + link.dir_count)
+ bch_verbose(c, "setting inum %llu nlinks from %u to %u",
inode.k->p.inode, i_nlink,
link.count + link.dir_count);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index cdc2be4689c9..0ac28a458f37 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1318,10 +1318,13 @@ static const char *run_cache_set(struct cache_set *c)
goto err;
}
+ bch_verbose(c, "starting mark and sweep:");
+
err = "error in recovery";
if (bch_initial_gc(c, &journal))
goto err;
- pr_debug("bch_initial_gc() done");
+
+ bch_verbose(c, "mark and sweep done");
/*
* bch_journal_start() can't happen sooner, or btree_gc_finish()
@@ -1337,15 +1340,25 @@ static const char *run_cache_set(struct cache_set *c)
goto err;
}
+ bch_verbose(c, "starting journal replay:");
+
err = "journal replay failed";
if (bch_journal_replay(c, &journal))
goto err;
+ bch_verbose(c, "journal replay done");
+
+ bch_verbose(c, "starting fs gc:");
+
err = "error gcing inode nlinks";
if (bch_gc_inode_nlinks(c))
goto err;
+ bch_verbose(c, "fs gc done");
+
+ bch_verbose(c, "starting fsck:");
bch_fsck(c);
+ bch_verbose(c, "fsck done");
} else {
struct bkey_i_inode inode;
struct closure cl;