diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2016-09-08 17:36:05 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2016-10-07 12:36:59 -0800 |
commit | bee085567b6b1b437298d9e62c2372d0756127eb (patch) | |
tree | a4f45d28689e4b4787b1c0b019408f21d53bedde | |
parent | b0644111eeacfad0939092acded3b0f8540d1f84 (diff) |
bcache: add printks for different phases of recovery
use mount -o verbose_recovery to enable
-rw-r--r-- | drivers/md/bcache/bcache.h | 6 | ||||
-rw-r--r-- | drivers/md/bcache/fs-gc.c | 25 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 15 |
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 b311aa2178fb..b201f992d1f8 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1319,10 +1319,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() @@ -1338,15 +1341,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; |