From 32cad13e1dea06e8b83d315393c2a8b5fd4a3a48 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 15 Oct 2009 13:21:48 +0000 Subject: [PATCH] b=19689 i=adilger i=bobijam i=nathan o=Jim Garlick Change tunefs.lustre and mkfs.lustre --mountfsoptions so that exactly the specified mount options are used. Leaving off any "mandatory" mount options is an error. Leaving off any default mount options causes a warning, but is allowed. Change errors=remount-ro from mandatory to default. Sanitize the mount string before storing it. Update man pages accordingly. This hopefully makes two awkward situations less so: - making errors=panic the default (before we had to append errors=remount-ro and hope ldiskfs parsing caused the last option to override the first) - setting other mount options on the OST's dropped mballoc,extents without warning. --- lustre/ChangeLog | 9 +++++ lustre/doc/mkfs.lustre.8 | 9 ++++- lustre/doc/tunefs.lustre.8 | 27 ++++++++------ lustre/tests/cfg/local.sh | 2 +- lustre/utils/mkfs_lustre.c | 88 ++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 117 insertions(+), 18 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 114ac3e..15df089 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -11,6 +11,15 @@ tbd Sun Microsystems, Inc. * Recommended e2fsprogs version: 1.41.6.sun1 Severity : normal +Bugzilla : 19689 +Description: Change tunefs.lustre and mkfs.lustre --mountfsoptions so that + exactly the specified mount options are used. Leaving off + any "mandatory" mount options is an error. Leaving off any + default mount options causes a warning, but is allowed. + Change errors=remount-ro from mandatory to default. Sanitize + the mount string before storing it. Update man pages accordingly. + +Severity : normal Bugzilla : 20302 Description: mds_getattr() should return 0, even if mds_fid2entry() fails with -ENOENT. Also fix in ptlrpc_expire_one_request() to print signed diff --git a/lustre/doc/mkfs.lustre.8 b/lustre/doc/mkfs.lustre.8 index ab14db5..d79a4cc 100644 --- a/lustre/doc/mkfs.lustre.8 +++ b/lustre/doc/mkfs.lustre.8 @@ -59,7 +59,14 @@ Force a particular OST or MDT index Format options for the backing fs. For example, ext3 options could be set here. .TP .BI \--mountfsoptions= opts -Set permanent mount options, equivalent to setting in /etc/fstab +Set the mount options that will be used when mounting the backing fs. +WARNING: unlike earlier versions of \fBmkfs.lustre\fR, this version completely +replaces the default mount options with those specified on the command line, +issuing a warning on stderr if any of the default mount options are omitted. +The defaults for \fIldiskfs\fR are +OST: \fIerrors=remount-ro,mballoc,extents\fR; +MGS/MDT: \fIerrors=remount-ro,iopen_nopriv,user_xattr\fR. +\fBDO NOT\fR alter the default mount options unless you know what you are doing. .TP .BI \--mgsnode= nid,... Set the NID(s) of the MGS node, required for all targets other than the MGS. diff --git a/lustre/doc/tunefs.lustre.8 b/lustre/doc/tunefs.lustre.8 index ec1c46b..a795720 100644 --- a/lustre/doc/tunefs.lustre.8 +++ b/lustre/doc/tunefs.lustre.8 @@ -8,7 +8,7 @@ tunefs.lustre \- modify the Lustre configuration information on a disk .SH SYNOPSIS .br .B tunefs.lustre -[options] +[options] .I device .br .SH DESCRIPTION @@ -33,22 +33,29 @@ Only print what would be done; does not affect the disk .BI \--erase-params Remove all previous parameter info .TP -.BI \--failnode= nid,... +.BI \--failnode= nid,... Set the NID(s) of a failover partner. This option can be repeated as desired. .TP -.BI \--fsname= filesystem_name +.BI \--fsname= filesystem_name The Lustre filesystem this service will be part of. Default is 'lustre' .TP .BI \--index= index -Force a particular OST or MDT index +Force a particular OST or MDT index .TP .BI \--mountfsoptions= opts -Set permanent mount options, equivalent to setting in /etc/fstab +Set the mount options that will be used when mounting the backing fs. +WARNING: unlike earlier versions of \fBtunefs.lustre\fR, this version +completely replaces the existing mount options with those specified on +the command line, issuing a warning on stderr if any of the default +mount options are omitted. The defaults for ldiskfs are +OST: \fIerrors=remount-ro,mballoc,extents\fR; +MGS/MDT: \fIerrors=remount-ro,iopen_nopriv,user_xattr\fR. +\fBDO NOT\fR alter the default mount options unless you know what you are doing. .TP .BI \--mgs Add a configuration management service to this target .TP -.BI \--mgsnode= nid,... +.BI \--mgsnode= nid,... Set the NID(s) of the MGS node, required for all targets other than the MGS. .TP .BI \--nomgs @@ -64,7 +71,7 @@ Print more information. Erase all config logs for the filesystem that this MDT is part of, and regenerate them. This is very dangerous. All clients and servers should be stopped. -All targets must then be restarted to regenerate the logs. +All targets must then be restarted to regenerate the logs. No clients should be started until all targets have restarted. In general this should be executed on the MDT only, not the OSTs. @@ -78,7 +85,7 @@ since they should all be contacting the same MGS.) Add a failover NID location for this target .TP .B tunefs.lustre --mgs --mdt --fsname=testfs /dev/sda -Upgrade an old 1.4.X Lustre MDT to 1.6. The new filesystem name is "testfs". +Upgrade an old 1.4.X Lustre MDT to 1.6. The new filesystem name is "testfs". .TP .B tunefs.lustre --writeconf --mgs --mdt --fsname=testfs /dev/sda1 Upgrade an old 1.4.X Lustre MDT to 1.6, and start with brand-new 1.6 @@ -88,8 +95,8 @@ configuration logs. All old servers and clients must be stopped. Please report all bugs to Sun Microsystems using http://bugzilla.lustre.org/ .SH AVAILABILITY .B tunefs.lustre -is part of the -.BR Lustre (7) +is part of the +.BR Lustre (7) filesystem package and is available from Sun Microsystems, Inc via .br http://downloads.lustre.org diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index b1ccb7b..1db93d8 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -13,7 +13,7 @@ TMP=${TMP:-/tmp} MDSDEV=${MDSDEV:-$TMP/${FSNAME}-mdt} MDSSIZE=${MDSSIZE:-400000} -MDSOPT=${MDSOPT:-"--mountfsoptions=acl"} +MDSOPT=${MDSOPT:-"--mountfsoptions=errors=remount-ro,iopen_nopriv,user_xattr,acl"} mdsfailover_dev=${mdsfailover_dev:-$MDSDEV} diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index a10b616..15204fb 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -62,6 +62,7 @@ #include #include #include +#include #ifdef __linux__ /* kp30.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h which @@ -1382,6 +1383,76 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, return 0; } +/* Search for opt in mntlist, returning true if found. + */ +static int in_mntlist(char *opt, char *mntlist) +{ + char *ml, *mlp, *item, *ctx; + + if (!(ml = strdup(mntlist))) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } + mlp = ml; + while ((item = strtok_r(mlp, ",", &ctx))) { + if (!strcmp(opt, item)) + break; + mlp = NULL; + } + free(ml); + return (item != NULL); +} + +/* Issue a message on stderr for every item in wanted_mountopts that is not + * present in mountopts. The justwarn boolean toggles between error and + * warning message. Return an error count. + */ +static int check_mountfsoptions(char *mountopts, char *wanted_mountopts, + int justwarn) +{ + char *ml, *mlp, *item, *ctx; + int errors = 0; + + if (!(ml = strdup(wanted_mountopts))) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } + mlp = ml; + while ((item = strtok_r(mlp, ",", &ctx))) { + if (!in_mntlist(item, mountopts)) { + fprintf(stderr, "%s: %s mount option `%s' is missing\n", + progname, justwarn ? "Warning: default" + : "Error: mandatory", item); + errors++; + } + mlp = NULL; + } + free(ml); + return errors; +} + +/* Trim embedded white space, leading and trailing commas from string s. + */ +static void trim_mountfsoptions(char *s) +{ + char *p; + + for (p = s; *p; ) { + if (isspace(*p)) { + memmove(p, p + 1, strlen(p + 1) + 1); + continue; + } + p++; + } + + while (s[0] == ',') + memmove(&s[0], &s[1], strlen(&s[1]) + 1); + + p = s + strlen(s) - 1; + while (p >= s && *p == ',') + *p-- = '\0'; +} + int main(int argc, char *const argv[]) { struct mkfs_opts mop; @@ -1486,7 +1557,8 @@ int main(int argc, char *const argv[]) case LDD_MT_EXT3: case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: { - sprintf(always_mountopts, "errors=remount-ro"); + strscat(default_mountopts, ",errors=remount-ro", + sizeof(default_mountopts)); if (IS_MDT(ldd) || IS_MGS(ldd)) strscat(always_mountopts, ",iopen_nopriv,user_xattr", sizeof(always_mountopts)); @@ -1506,7 +1578,7 @@ int main(int argc, char *const argv[]) } case LDD_MT_SMFS: { mop.mo_flags |= MO_IS_LOOP; - sprintf(always_mountopts, "type=ext3,dev=%s", + sprintf(always_mountopts, ",type=ext3,dev=%s", mop.mo_device); break; } @@ -1521,10 +1593,13 @@ int main(int argc, char *const argv[]) } if (mountopts) { - /* If user specifies mount opts, don't use defaults, - but always use always_mountopts */ - sprintf(ldd->ldd_mount_opts, "%s,%s", - always_mountopts, mountopts); + trim_mountfsoptions(mountopts); + (void)check_mountfsoptions(mountopts, default_mountopts, 1); + if (check_mountfsoptions(mountopts, always_mountopts, 0)) { + ret = EINVAL; + goto out; + } + sprintf(ldd->ldd_mount_opts, "%s", mountopts); } else { #ifdef TUNEFS if (ldd->ldd_mount_opts[0] == 0) @@ -1533,6 +1608,7 @@ int main(int argc, char *const argv[]) { sprintf(ldd->ldd_mount_opts, "%s%s", always_mountopts, default_mountopts); + trim_mountfsoptions(ldd->ldd_mount_opts); } } -- 1.8.3.1