From 6122ab639c8e3d6afe9a3c8e3e49173cd2a064a3 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 21 Mar 2019 19:03:57 -0400 Subject: [PATCH] bcachefs: More debug params for testing of recovery paths Signed-off-by: Kent Overstreet --- fs/bcachefs/bcachefs.h | 6 +++++- fs/bcachefs/btree_gc.c | 4 +++- fs/bcachefs/recovery.c | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index ea648753aec0..5a9b776558f6 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -278,7 +278,11 @@ do { \ "cached data") \ BCH_DEBUG_PARAM(force_reconstruct_read, \ "Force reads to use the reconstruct path, when reading" \ - "from erasure coded extents") + "from erasure coded extents") \ + BCH_DEBUG_PARAM(test_restart_gc, \ + "Test restarting mark and sweep gc when bucket gens change")\ + BCH_DEBUG_PARAM(test_reconstruct_alloc, \ + "Test reconstructing the alloc btree") #define BCH_DEBUG_PARAMS_ALL() BCH_DEBUG_PARAMS_ALWAYS() BCH_DEBUG_PARAMS_DEBUG() diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index c899a77bf891..0069d6cb6e5d 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -750,7 +750,9 @@ again: c->gc_count++; out: - if (!ret && test_bit(BCH_FS_FIXED_GENS, &c->flags)) { + if (!ret && + (test_bit(BCH_FS_FIXED_GENS, &c->flags) || + (!iter && test_restart_gc(c)))) { /* * XXX: make sure gens we fixed got saved */ diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 24101023a5b9..d7be535f3cc1 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -277,6 +277,10 @@ int bch2_fs_recovery(struct bch_fs *c) if (r->error) goto err; + if (i == BTREE_ID_ALLOC && + test_reconstruct_alloc(c)) + continue; + err = "error reading btree root"; ret = bch2_btree_root_read(c, i, &r->key, r->level); if (ret) {