From dbd4f60002b98556e6fc8413e6eacf2aedfce6df Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Tue, 14 Aug 2012 21:55:36 +0200 Subject: [PATCH] hammer - Add tunable vfs.hammer.skip_redo This tunable can be used to change the behaviour of the redo recovery in the case a HAMMER filesystem is not able to mount. Following values are accepted: 0 - Run redo recovery normally and fail to mount if the operation fails (default). 1 - Run redo recovery, but don't fail to mount if the operation fails. 2 - Completely skip redo recovery (only for severe error conditions and/or debugging). Pointed-out-by: dillon --- share/man/man5/hammer.5 | 20 +++++++++++++++++++- sys/vfs/hammer/hammer.h | 1 + sys/vfs/hammer/hammer_recover.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/share/man/man5/hammer.5 b/share/man/man5/hammer.5 index 1f79973..f6e076c 100644 --- a/share/man/man5/hammer.5 +++ b/share/man/man5/hammer.5 @@ -29,7 +29,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 19, 2011 +.Dd August 14, 2012 .Dt HAMMER 5 .Os .Sh NAME @@ -103,6 +103,24 @@ After a non-graceful system shutdown, file systems will be brought back into a fully coherent state when mounting the file system, usually within a few seconds. .Pp +In the unlikely case +.Nm +mount fails due redo recovery (stage 2 recovery) being corrupted, a +workaround to skip this stage can be applied by setting the following tunable: +.Bd -literal -offset indent +vfs.hammer.skip_redo= +.Ed +.Pp +Possible values are: +.Bl -tag -width indent +.It 0 +Run redo recovery normally and fail to mount in the case of error (default). +.It 1 +Run redo recovery but continue mounting if an error appears. +.It 2 +Completely bypass redo recovery. +.El +.Pp Related commands: .Xr mount_hammer 8 .Ss Large File Systems & Multi Volume diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index f837a07..745d5f5 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -998,6 +998,7 @@ extern struct vop_ops hammer_spec_vops; extern struct vop_ops hammer_fifo_vops; extern struct bio_ops hammer_bioops; +extern int hammer_skip_redo; extern int hammer_debug_io; extern int hammer_debug_general; extern int hammer_debug_debug; diff --git a/sys/vfs/hammer/hammer_recover.c b/sys/vfs/hammer/hammer_recover.c index 0b699d2..d7566ca 100644 --- a/sys/vfs/hammer/hammer_recover.c +++ b/sys/vfs/hammer/hammer_recover.c @@ -116,6 +116,21 @@ #include "hammer.h" /* + * Specify the way we want to handle stage2 errors. + * + * Following values are accepted: + * + * 0 - Run redo recovery normally and fail to mount if + * the operation fails (default). + * 1 - Run redo recovery, but don't fail to mount if the + * operation fails. + * 2 - Completely skip redo recovery (only for severe error + * conditions and/or debugging. + */ +int hammer_skip_redo = 0; +TUNABLE_INT("vfs.hammer.skip_redo", &hammer_skip_redo); + +/* * Each rterm entry has a list of fifo offsets indicating termination * points. These are stripped as the scan progresses. */ @@ -529,6 +544,16 @@ hammer_recover_stage2(hammer_mount_t hmp, hammer_volume_t root_volume) KKASSERT(hmp->ronly == 0); RB_INIT(&rterm_root); + if (hammer_skip_redo == 1) + kprintf("HAMMER(%s) recovery redo marked as optional\n", + root_volume->ondisk->vol_name); + + if (hammer_skip_redo == 2) { + kprintf("HAMMER(%s) recovery redo skipped.\n", + root_volume->ondisk->vol_name); + return (0); + } + /* * Examine the UNDO FIFO. If it is empty the filesystem is clean * and no action need be taken. @@ -741,7 +766,13 @@ fatal: kprintf("HAMMER(%s) End redo recovery\n", root_volume->ondisk->vol_name); } - return (error); + + if (error && hammer_skip_redo == 1) + kprintf("HAMMER(%s) recovery redo error %d, " + " skipping.\n", root_volume->ondisk->vol_name, + error); + + return (hammer_skip_redo ? 0 : error); } /* -- 1.7.7.2