From: Barry Naujok Date: Mon, 21 Apr 2008 16:08:37 +0000 (+0000) Subject: Add lazy-counter enable/disable capability on existing filesystems X-Git-Tag: v2.10.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4af916f81ad9d543978276a11e6a619e984d3b5c;p=thirdparty%2Fxfsprogs-dev.git Add lazy-counter enable/disable capability on existing filesystems Merge of master-melb:xfs-cmds:30908a by kenmcd. Bump version to 2.9.8 --- diff --git a/VERSION b/VERSION index 379e64684..d01da0f56 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=9 -PKG_REVISION=7 +PKG_REVISION=8 PKG_BUILD=1 diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index ac86d128d..74d457c29 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -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] device" -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,25 @@ done 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` + if [ $status -ne 0 ] + then + echo "Conversion failed, is the filesystem unmounted?" + fi + fi ;; *) echo $USAGE 1>&2 exit 2 diff --git a/doc/CHANGES b/doc/CHANGES index ebe46f995..72a28015d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,14 @@ +xfsprogs-2.9.8 (21 April 2008) + - Add support for sb_features2 in wrong location in mkfs.xfs, + xfs_repair and xfs_db. + - Improve memory limits for libxfs cache in xfs_repair and added + a -m option to manually limit usage of xfs_repair. + - Add -c option to xfs_admin to turn lazy-counters on/off. + - Added support for mdp in libdisk/mkfs.xfs, thanks to + Hubert Verstraete. + - Add -p option to fsck.xfs, thanks to Markus Rothe. + - Cleanup sys v3 bzero/bcopy calls, thanks to Nigel Kukard. + xfsprogs-2.9.7 (1 Mar 2008) - Lazy superblock counters not yet the default with mkfs.xfs. - Add -y (another no-op) fsck option. diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index c38a94267..8e3155b2f 100644 --- a/man/man8/xfs_admin.8 +++ b/man/man8/xfs_admin.8 @@ -6,6 +6,8 @@ xfs_admin \- change parameters of an XFS filesystem [ .B \-eflu ] [ +.BR "\-c 0" | 1 +] [ .B \-L .I label ] [ @@ -53,6 +55,18 @@ Print the current filesystem label. .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. +.IP +With lazy-counters enabled, the superblock is not modified or logged on +every change of the free-space and inode counters. Instead, enough +information is kept in other parts of the filesystem to be able to +maintain the counter values without needing to keep them in the +superblock. This gives significant improvements in performance on some +configurations and metadata intensive workloads. +.TP .BI \-L " label" Set the filesystem label to .IR label . @@ -90,4 +104,5 @@ rather than its block special device name. .BR mount (8), .BR xfs_db (8), .BR xfs_growfs (8), +.BR xfs_repair (8), .BR xfs (5). diff --git a/man/man8/xfs_repair.8 b/man/man8/xfs_repair.8 index 8784c6e1d..d6cecb86a 100644 --- a/man/man8/xfs_repair.8 +++ b/man/man8/xfs_repair.8 @@ -9,6 +9,8 @@ xfs_repair \- repair an XFS filesystem .B \-m .I maxmem ] [ +.BI \-c " subopt" = value +] [ .B \-o .I subopt\c [\c @@ -100,6 +102,11 @@ This option overrides these limits. .B NOTE: These memory limits are only approximate and may use more than the specified limit. +.TP +.BI \-c " subopt" = value +Change filesystem parameters. Refer to +.BR xfs_admin (8) +for information on changing filesystem parameters. .HP .B \-o .I subopt\c @@ -532,6 +539,7 @@ fixed and/or improved. .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). diff --git a/repair/globals.h b/repair/globals.h index 2d5bce65a..9a78caee5 100644 --- a/repair/globals.h +++ b/repair/globals.h @@ -116,6 +116,8 @@ EXTERN char *log_name; /* Name of log device */ 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 */ diff --git a/repair/phase1.c b/repair/phase1.c index 3a25934a1..618796e81 100644 --- a/repair/phase1.c +++ b/repair/phase1.c @@ -105,6 +105,32 @@ phase1(xfs_mount_t *mp) do_warn(_("superblock has a features2 mismatch, 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")); diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 0e7e564ea..0efab9c3e 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -48,7 +48,7 @@ extern void incore_init(xfs_mount_t *); */ /* - * -o (user-supplied override options) + * -o: user-supplied override options */ char *o_opts[] = { @@ -65,6 +65,17 @@ char *o_opts[] = { 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 long max_mem_specified; /* in megabytes */ @@ -72,9 +83,23 @@ static long max_mem_specified; /* in megabytes */ static void usage(void) { - do_warn( -_("Usage: %s [-nLvV] [-m memMB] [-o subopt[=value]] [-l logdev] [-r rtdev] devname\n"), - progname); + do_warn(_( +"Usage: %s [options] device\n" +"\n" +"Options:\n" +" -f The device is a file\n" +" -L Force log zeroing. Do this as a last resort.\n" +" -l logdev Specifies the device where the external log resides.\n" +" -m maxmem Maximum amount of memory to be used in megabytes.\n" +" -n No modify mode, just checks the filesystem for damage.\n" +" -P Disables prefetching.\n" +" -r rtdev Specifies the device where the realtime section resides.\n" +" -v Verbose output.\n" +" -c subopts Change filesystem parameters - use xfs_admin.\n" +" -o subopts Override default behaviour, refer to man page.\n" +" -t interval Reporting interval in minutes.\n" +" -d Repair dangerously.\n" +" -V Reports version and exits.\n"), progname); exit(1); } @@ -89,7 +114,7 @@ err_string(int err_code) err_message[XR_BAD_MAGIC] = _("bad magic number"); err_message[XR_BAD_BLOCKSIZE] = _("bad blocksize field"); err_message[XR_BAD_BLOCKLOG] = _("bad blocksize log field"); - err_message[XR_BAD_VERSION] = _("bad version number"); + err_message[XR_BAD_VERSION] = _("bad or unsupported version"); err_message[XR_BAD_INPROGRESS] = _("filesystem mkfs-in-progress bit set"); err_message[XR_BAD_FS_SIZE_DATA] = @@ -193,7 +218,7 @@ process_args(int argc, char **argv) * XXX have to add suboption processing here * attributes, quotas, nlinks, aligned_inos, sb_fbits */ - while ((c = getopt(argc, argv, "o:fl:m:r:LnDvVdPt:")) != EOF) { + while ((c = getopt(argc, argv, "c:o:fl:m:r:LnDvVdPt:")) != EOF) { switch (c) { case 'D': dumpcore = 1; @@ -239,6 +264,22 @@ process_args(int argc, char **argv) } } 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;