Index: ci/xfsprogs/repair/globals.h =================================================================== --- ci.orig/xfsprogs/repair/globals.h 2008-02-25 13:44:10.591103786 +1100 +++ ci/xfsprogs/repair/globals.h 2008-02-25 13:44:14.562591674 +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-02-25 13:44:10.591103786 +1100 +++ ci/xfsprogs/repair/phase1.c 2008-02-25 13:44:14.562591674 +1100 @@ -103,6 +103,32 @@ "location, correcting\n")); } + /* + * apply any version changes or conversions after the primary + * superblock has been verified or repaired + * + * Send output to stdout as do_log and everything else in repair + * is sent to stderr and there is no "quiet" option. xfs_admin + * will filter stderr but not stdout. This situation must be improved. + */ + if (convert_lazy_count) { + if (lazy_count && !xfs_sb_version_haslazysbcount(sb)) { + sb->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; + sb->sb_features2 |= XFS_SB_VERSION2_LAZYSBCOUNTBIT; + primary_sb_modified = 1; + printf(_("Enabling lazy-counters\n")); + } else + if (!lazy_count && xfs_sb_version_haslazysbcount(sb)) { + sb->sb_features2 &= ~XFS_SB_VERSION2_LAZYSBCOUNTBIT; + printf(_("Disabling lazy-counters\n")); + primary_sb_modified = 1; + } else { + printf(_("Lazy-counters are already %s\n"), + lazy_count ? _("enabled") : _("disabled")); + exit(0); /* no conversion required, exit */ + } + } + 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-25 13:44:10.599102754 +1100 +++ ci/xfsprogs/repair/xfs_repair.c 2008-02-25 13:44:14.562591674 +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; Index: ci/xfsprogs/db/xfs_admin.sh =================================================================== --- ci.orig/xfsprogs/db/xfs_admin.sh 2008-02-25 13:44:10.623099660 +1100 +++ ci/xfsprogs/db/xfs_admin.sh 2008-02-25 13:44:14.650580328 +1100 @@ -3,20 +3,23 @@ # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. # -OPTS="" -USAGE="Usage: xfs_admin [-efjluV] [-L label] [-U uuid] special" +status=0 +DB_OPTS="" +REPAIR_OPTS="" +USAGE="Usage: xfs_admin [-efjluV] [-c 0|1] [-L label] [-U uuid] special" -while getopts "efjluL:U:V" c +while getopts "efjluc:L:U:V" c do case $c in - e) OPTS=$OPTS" -c 'version extflg'";; - f) OPTS=$OPTS" -f";; - j) OPTS=$OPTS" -c 'version log2'";; - l) OPTS=$OPTS" -r -c label";; - L) OPTS=$OPTS" -c 'label "$OPTARG"'";; - u) OPTS=$OPTS" -r -c uuid";; - U) OPTS=$OPTS" -c 'uuid "$OPTARG"'";; - V) OPTS=$OPTS" -V";; + c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;; + e) DB_OPTS=$DB_OPTS" -c 'version extflg'";; + f) DB_OPTS=$DB_OPTS" -f";; + j) DB_OPTS=$DB_OPTS" -c 'version log2'";; + l) DB_OPTS=$DB_OPTS" -r -c label";; + L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";; + u) DB_OPTS=$DB_OPTS" -r -c uuid";; + U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";; + V) DB_OPTS=$DB_OPTS" -V";; \?) echo $USAGE 1>&2 exit 2 ;; @@ -25,8 +28,21 @@ set -- extra $@ shift $OPTIND case $# in - 1) eval xfs_db -x -p xfs_admin $OPTS $1 - status=$? + 1) if [ -n "$DB_OPTS" ] + then + eval xfs_db -x -p xfs_admin $DB_OPTS $1 + status=$? + fi + if [ -n "$REPAIR_OPTS" ] + then + # Hide normal repair output which is sent to stderr + # assuming the filesystem is fine when a user is + # running xfs_admin. + # Ideally, we need to improve the output behaviour + # of repair for this purpose (say a "quiet" mode). + eval xfs_repair $REPAIR_OPTS $1 2> /dev/null + status=`expr $? + $status` + fi ;; *) echo $USAGE 1>&2 exit 2 Index: ci/xfsprogs/man/man8/xfs_admin.8 =================================================================== --- ci.orig/xfsprogs/man/man8/xfs_admin.8 2008-02-25 13:44:10.679092440 +1100 +++ ci/xfsprogs/man/man8/xfs_admin.8 2008-02-25 13:44:14.698574139 +1100 @@ -6,6 +6,8 @@ [ .B \-eflu ] [ +.BR "\-c 0" | 1 +] [ .B \-L .I label ] [ @@ -53,6 +55,11 @@ .B \-u Print the current filesystem UUID (Universally Unique IDentifier). .TP +.BR "\-c 0" | 1 +Enable (1) or disable (0) lazy-counters in the filesystem. +This operation may take quite a bit of time on large filesystems as the +entire filesystem needs to be scanned when this option is changed. +.TP .BI \-L " label" Set the filesystem label to .IR label . @@ -90,4 +97,5 @@ .BR mount (8), .BR xfs_db (8), .BR xfs_growfs (8), +.BR xfs_repair (8), .BR xfs (5). Index: ci/xfsprogs/man/man8/xfs_repair.8 =================================================================== --- ci.orig/xfsprogs/man/man8/xfs_repair.8 2008-02-25 13:44:10.707088830 +1100 +++ ci/xfsprogs/man/man8/xfs_repair.8 2008-02-25 13:44:14.698574139 +1100 @@ -6,6 +6,8 @@ [ .B \-dfLnPv ] [ +.BI \-c " subopt" = value +] [ .B \-o .I subopt\c [\c @@ -85,6 +87,11 @@ .B xfs_repair should not modify the filesystem but should only scan the filesystem and indicate what repairs would have been made. +.TP +.BI \-c " subopt" = value +Change filesystem parameters. Refer to +.BR xfs_admin (8) +for information on changing filesytem parameters. .HP .B \-o .I subopt\c @@ -517,6 +524,7 @@ .BR dd (1), .BR mkfs.xfs (8), .BR umount (8), +.BR xfs_admin (8), .BR xfs_check (8), .BR xfs_metadump (8), .BR xfs (5).