public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [REVIEW] Add lazy-counter conversion to xfs_repair
@ 2008-02-22  6:45 Barry Naujok
  2008-02-22 17:37 ` Eric Sandeen
  0 siblings, 1 reply; 5+ messages in thread
From: Barry Naujok @ 2008-02-22  6:45 UTC (permalink / raw)
  To: xfs@oss.sgi.com

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

In response to the thread "Differences in mkfs.xfs and xfs_info output.",  
xfs_repair has been improved to allow version changes/conversion of  
filesystems.

So, this patch introduces the first in an ongoing series of in-place  
filesystem version changes with xfs_repair and the "-c" (convert) option.

To turn on/off the lazy-superblock feature, run the following xfs_repair  
commmand on your filesystem:

# xfs_repair -c lazycount=[0|1] <device>

It is advised to run Dave Chinner's "detect and correct bad features2  
superblock field" patch with this patch as lazy-counters are stored in the  
features2 field in the superblock.


The next round of case-insensitive support patches will allow xfs_repair  
to convert filesystems to different CI versions (ie. -c  
name=[raw|ascii|unicode]).

Barry.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: convert.patch --]
[-- Type: text/x-patch; name=convert.patch, Size: 3457 bytes --]

Index: ci/xfsprogs/repair/globals.h
===================================================================
--- ci.orig/xfsprogs/repair/globals.h	2008-01-16 14:54:12.000000000 +1100
+++ ci/xfsprogs/repair/globals.h	2008-02-22 17:21:41.195651501 +1100
@@ -116,6 +116,8 @@
 EXTERN int	log_spec;		/* Log dev specified as option */
 EXTERN char	*rt_name;		/* Name of realtime device */
 EXTERN int	rt_spec;		/* Realtime dev specified as option */
+EXTERN int	convert_lazy_count;	/* Convert lazy-count mode on/off */
+EXTERN int	lazy_count;		/* What to set if to if converting */
 
 /* misc status variables */
 
Index: ci/xfsprogs/repair/phase1.c
===================================================================
--- ci.orig/xfsprogs/repair/phase1.c	2008-01-16 14:54:12.000000000 +1100
+++ ci/xfsprogs/repair/phase1.c	2008-02-22 17:29:38.285953524 +1100
@@ -91,6 +91,26 @@
 		primary_sb_modified = 1;
 	}
 
+	/*
+	 * apply any version changes or conversions after the primary
+	 * superblock has been verified or repaired
+	 */
+	if (convert_lazy_count) {
+		if (lazy_count && !xfs_sb_version_haslazysbcount(sb)) {
+			sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
+			sbp->sb_features2 |= XFS_SB_VERSION2_LAZYSBCOUNTBIT;
+			primary_sb_modified = 1;
+			do_log(_("        - Enabling lazy-counters\n"));
+		} else
+		if (!lazy_count && xfs_sb_version_haslazysbcount(sb)) {
+			sbp->sb_features2 &= ~XFS_SB_VERSION2_LAZYSBCOUNTBIT;
+			do_log(_("        - Disabling lazy-counters\n"));
+			primary_sb_modified = 1;
+		} else
+			do_log(_("        - Lazy-counters are already %s\n"),
+				lazy_count ? _("enabled") : _("disabled"));
+	}
+
 	if (primary_sb_modified)  {
 		if (!no_modify)  {
 			do_warn(_("writing modified primary superblock\n"));
Index: ci/xfsprogs/repair/xfs_repair.c
===================================================================
--- ci.orig/xfsprogs/repair/xfs_repair.c	2008-02-22 14:15:42.000000000 +1100
+++ ci/xfsprogs/repair/xfs_repair.c	2008-02-22 14:36:07.385247765 +1100
@@ -47,7 +47,7 @@
  */
 
 /*
- * -o (user-supplied override options)
+ * -o: user-supplied override options
  */
 
 char *o_opts[] = {
@@ -64,15 +64,25 @@
 	NULL
 };
 
+/*
+ * -c: conversion options
+ */
+
+char *c_opts[] = {
+#define CONVERT_LAZY_COUNT	0
+	"lazycount",
+	NULL
+};
+
+
 static int	ihash_option_used;
 static int	bhash_option_used;
 
 static void
 usage(void)
 {
-	do_warn(
-_("Usage: %s [-nLvV] [-o subopt[=value]] [-l logdev] [-r rtdev] devname\n"),
-		progname);
+	do_warn(_("Usage: %s [-nLPvV] [-c subopt=value] [-o subopt[=value]] "
+		"[-l logdev] [-r rtdev] devname\n"), progname);
 	exit(1);
 }
 
@@ -191,7 +201,7 @@
 	 * XXX have to add suboption processing here
 	 * attributes, quotas, nlinks, aligned_inos, sb_fbits
 	 */
-	while ((c = getopt(argc, argv, "o:fl:r:LnDvVdPMt:")) != EOF)  {
+	while ((c = getopt(argc, argv, "c:o:fl:r:LnDvVdPMt:")) != EOF)  {
 		switch (c) {
 		case 'D':
 			dumpcore = 1;
@@ -234,6 +244,22 @@
 				}
 			}
 			break;
+		case 'c':
+			p = optarg;
+			while (*p) {
+				char *val;
+
+				switch (getsubopt(&p, (constpp)c_opts, *val)) {
+				case CONVERT_LAZY_COUNT:
+					lazy_count = (int)strtol(val, 0, 0);
+					convert_lazy_count = 1;
+					break;
+				default:
+					unknown('c', val);
+					break;
+				}
+			}
+			break;
 		case 'l':
 			log_name = optarg;
 			log_spec = 1;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-25  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-22  6:45 [REVIEW] Add lazy-counter conversion to xfs_repair Barry Naujok
2008-02-22 17:37 ` Eric Sandeen
2008-02-23  5:06   ` David Chinner
2008-02-24 23:55   ` Barry Naujok
2008-02-25  0:05   ` Barry Naujok

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox