From: nathan Date: Wed, 19 Jul 2006 23:52:36 +0000 (+0000) Subject: Branch b1_5 X-Git-Tag: v1_7_0_51~2^13~5^2~3 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=bfc75ad0bab98b7009cf382a7151a1990753a2e4;p=fs%2Flustre-release.git Branch b1_5 b=10737 Incorporate tunefs.lustre param changes into config logs. The tunefs "update" flag alone means update without rewriting the entire log. I knew I had it there for a reason. Also, record the target responsible for a parameter change in the markers, instead of the affected log name --- diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 0e9184e..11ce3ac 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -51,7 +51,7 @@ #define LDD_F_REWRITE_LDD 0x0080 /* rewrite the LDD */ #define LDD_F_WRITECONF 0x0100 /* regenerate all logs for this fs */ #define LDD_F_UPGRADE14 0x0200 /* COMPAT_14 */ -#define MTI_F_IOCTL 0x0400 /* only used in mti */ +#define LDD_F_PARAM_FNID 0x0400 /* process failover nids as params */ enum ldd_mount_type { LDD_MT_EXT3 = 0, diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 7bfa53d..d6d6424 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -388,7 +388,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) rc = mgs_erase_logs(obd, mti->mti_fsname); LCONSOLE_WARN("%s: Logs for fs %s were removed by user " "request. All servers must be restarted " - "in order to regenerate the client log." + "in order to regenerate the logs." "\n", obd->obd_name, mti->mti_fsname); } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { rc = mgs_erase_log(obd, mti->mti_svname); @@ -396,7 +396,6 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) "request.\n", obd->obd_name, mti->mti_fsname); } - mti->mti_flags &= ~LDD_F_WRITECONF; mti->mti_flags |= LDD_F_UPDATE; } @@ -408,8 +407,10 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) GOTO(out, rc); } - mti->mti_flags &= ~LDD_F_UPGRADE14; - /* Turn off the upgrade flag permanently */ + /* Turn off all other update-related flags; we're done. */ + mti->mti_flags &= ~(LDD_F_UPGRADE14 | + LDD_F_VIRGIN | LDD_F_UPDATE | + LDD_F_NEED_INDEX | LDD_F_WRITECONF); mti->mti_flags |= LDD_F_REWRITE_LDD; } /* end COMPAT_146 */ @@ -418,7 +419,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) CDEBUG(D_MGS, "updating %s, index=%d\n", mti->mti_svname, mti->mti_stripe_index); - /* create the log for the new target + /* create or update the target log and update the client/mdt logs */ rc = mgs_write_log_target(obd, mti); if (rc) { @@ -428,7 +429,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) } mti->mti_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE | - LDD_F_NEED_INDEX); + LDD_F_NEED_INDEX | LDD_F_WRITECONF); mti->mti_flags |= LDD_F_REWRITE_LDD; } @@ -444,6 +445,9 @@ out_nolock: rep_mti = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*rep_mti)); memcpy(rep_mti, mti, sizeof(*rep_mti)); + + /* Flush logs to disk */ + fsfilt_sync(obd, obd->u.mgs.mgs_sb); RETURN(rc); } diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 1ab0fd0..f8989be 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -436,7 +436,10 @@ int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti) RETURN(0); } - +/* Return codes: + 0 newly marked as in use + <0 err + +EALREADY for update of an old index */ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) { struct fs_db *fsdb; @@ -748,11 +751,12 @@ static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb, /* write the lcfg in all logs for the given fs */ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb, - char *fsname, struct lustre_cfg *lcfg) + struct mgs_target_info *mti, struct lustre_cfg *lcfg) { struct mgs_obd *mgs = &obd->u.mgs; struct list_head dentry_list; struct l_linux_dirent *dirent, *n; + char *fsname = mti->mti_fsname; char *logname; int rc, len = strlen(fsname); ENTRY; @@ -783,7 +787,7 @@ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb, if (strncmp(fsname, dirent->lld_name, len) == 0) { CDEBUG(D_MGS, "Changing log %s\n", dirent->lld_name); rc = mgs_write_log_direct(obd, fsdb, dirent->lld_name, - dirent->lld_name, lcfg); + mti->mti_svname, lcfg); } OBD_FREE(dirent, sizeof(*dirent)); } @@ -1194,6 +1198,9 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb, if (!mti->mti_params) RETURN(0); + /* FIXME we should cancel out old settings of the same parameters, + and skip settings that are the same as old values */ + while (ptr < end) { while (*ptr == ' ') ptr++; @@ -1222,7 +1229,7 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb, rc = 0; /* We already processed failovers params for new targets in mgs_write_log_target */ - if (mti->mti_flags & MTI_F_IOCTL) { + if (mti->mti_flags & LDD_F_PARAM_FNID) { CDEBUG(D_MGS, "Adding failnode\n"); rc = mgs_write_log_add_failnid(obd, fsdb, mti); } @@ -1239,8 +1246,7 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb, lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs); lcfg->lcfg_num = timeout; /* modify all servers and clients */ - rc = mgs_write_log_direct_all(obd, fsdb, mti->mti_fsname, - lcfg); + rc = mgs_write_log_direct_all(obd, fsdb, mti, lcfg); lustre_cfg_free(lcfg); GOTO(end_while, rc); } @@ -1342,19 +1348,19 @@ int mgs_write_log_target(struct obd_device *obd, /* COMPAT_146 */ if (mti->mti_flags & LDD_F_UPGRADE14) { if (rc == EALREADY) { - CDEBUG(D_MGS, "Found index for %s old log, upgrading\n", - mti->mti_svname); + CDEBUG(D_MGS, "Found index %d for %s 1.4 log, upgrading\n", + mti->mti_stripe_index, mti->mti_svname); } else { LCONSOLE_ERROR("Failed to find %s in the old client " "log\n", mti->mti_svname); + /* Not in client log? Upgrade anyhow...*/ /* RETURN(-EINVAL); */ } /* end COMPAT_146 */ } else { if (rc == EALREADY) { /* Update a target entry in the logs */ - LCONSOLE_WARN("Found index %d for %s, " - "attempting to write log anyhow\n", + LCONSOLE_WARN("Found index %d for %s, updating log\n", mti->mti_stripe_index, mti->mti_svname); /* FIXME mark old log sections as invalid, inc config ver #, add new log sections. @@ -1373,19 +1379,28 @@ int mgs_write_log_target(struct obd_device *obd, down(&fsdb->fsdb_sem); - if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { - rc = mgs_write_log_mdt(obd, fsdb, mti); - } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { - rc = mgs_write_log_ost(obd, fsdb, mti); + if (mti->mti_flags & + (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) { + /* Generate a log from scratch */ + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { + rc = mgs_write_log_mdt(obd, fsdb, mti); + } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { + rc = mgs_write_log_ost(obd, fsdb, mti); + } else { + CERROR("Unknown target type %#x, can't create log for " + "%s\n", mti->mti_flags, mti->mti_svname); + } + if (rc) { + CERROR("Can't write logs for %s (%d)\n", + mti->mti_svname, rc); + GOTO(out_up, rc); + } } else { - CERROR("Unknown target type %#x, can't create log for %s\n", - mti->mti_flags, mti->mti_svname); - } - if (rc) { - CERROR("Can't write logs for %s (%d)\n", mti->mti_svname, rc); - GOTO(out_up, rc); + /* Just update the params from tunefs in mgs_write_log_params */ + CDEBUG(D_MGS, "Update params for %s\n", mti->mti_svname); + mti->mti_flags |= LDD_F_PARAM_FNID; } - + rc = mgs_write_log_params(obd, fsdb, mti); out_up: @@ -1569,7 +1584,7 @@ int mgs_setparam(struct obd_device *obd, char *fsname, struct lustre_cfg *lcfg) rc = server_name2index(devname, &mti->mti_stripe_index, NULL); if (rc < 0) GOTO(out, rc); - mti->mti_flags = rc | MTI_F_IOCTL; + mti->mti_flags = rc | LDD_F_PARAM_FNID; strncpy(mti->mti_params, lustre_cfg_string(lcfg, 1), sizeof(mti->mti_params)); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 72b725f..0dfb5fe 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -958,6 +958,9 @@ int server_register_target(struct super_block *sb) label = fsfilt_get_label(mgc, lsi->lsi_srv_mnt->mnt_sb); if (label) CDEBUG(D_MOUNT, "Disk label changed to %s\n", label); + + /* Flush the new ldd to disk */ + fsfilt_sync(mgc, lsi->lsi_srv_mnt->mnt_sb); } out: diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 2f87989..0cf96c1 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -119,13 +119,18 @@ load_modules() { } unload_modules() { - set -x lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug - local MODULES=`$LCTL modules | awk '{ print $2 }'` - rmmod $MODULES >/dev/null 2>&1 + local MODULES=$($LCTL modules | awk '{ print $2 }') + rmmod $MODULES >/dev/null 2>&1 || true # do it again, in case we tried to unload ksocklnd too early - lsmod | grep lnet > /dev/null && rmmod $MODULES >/dev/null 2>&1 - lsmod | grep lnet && echo "modules still loaded" && cat $LPROC/devices && return 1 + lsmod | grep libcfs > /dev/null && rmmod $MODULES >/dev/null 2>&1 || true + MODULES=$($LCTL modules | awk '{ print $2 }') + if [ -n "$MODULES" ]; then + echo "modules still loaded" + echo $MODULES + cat $LPROC/devices + return 2 + fi HAVE_MODULES=false LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true) diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 3babc75..47e2aea 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -86,14 +86,9 @@ void usage(FILE *out) "\t\t\trequired for all targets other than the mgs node\n" "\t\t--fsname= : default is 'lustre'\n" "\t\t--failnode=[,<...>] : NID(s) of a failover partner\n" -#ifndef TUNEFS - /* Use lctl conf_param on a live system, not tunefs. - Currently, new/modified params written here are checked - only on the first mount. */ "\t\t--param = : set a permanent parameter\n" "\t\t\te.g. --param sys.timeout=40\n" "\t\t\t --param lov.stripe.size=4194304\n" -#endif "\t\t--index=#N : target index (i.e. ost index within the lov)\n" /* FIXME implement 1.6.x "\t\t--configdev=: store configuration info\n" @@ -1008,6 +1003,8 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, break; case 'e': mop->mo_ldd.ldd_params[0] = '\0'; + /* Must update the mgs logs */ + mop->mo_ldd.ldd_flags |= LDD_F_UPDATE; break; case 'f': { char *nids = convert_hostnames(optarg); @@ -1018,6 +1015,8 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, free(nids); if (rc) return rc; + /* Must update the mgs logs */ + mop->mo_ldd.ldd_flags |= LDD_F_UPDATE; break; } case 'G': @@ -1027,6 +1026,13 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, usage(stdout); return 1; case 'i': + if (!(mop->mo_ldd.ldd_flags & + (LDD_F_UPGRADE14 | LDD_F_VIRGIN | + LDD_F_WRITECONF))) { + fprintf(stderr, "%s: cannot change the index of" + " a registered target\n", progname); + return 1; + } if (IS_MDT(&mop->mo_ldd) || IS_OST(&mop->mo_ldd)) { mop->mo_ldd.ldd_svindex = atol(optarg); mop->mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX; @@ -1040,6 +1046,13 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, sizeof(mop->mo_mkfsopts) - 1); break; case 'L': + if (!(mop->mo_ldd.ldd_flags & + (LDD_F_UPGRADE14 | LDD_F_VIRGIN | + LDD_F_WRITECONF))) { + fprintf(stderr, "%s: cannot change the name of" + " a registered target\n", progname); + return 1; + } if (strlen(optarg) > 8) { fprintf(stderr, "%s: filesystem name must be " "<= 8 chars\n", progname); @@ -1080,6 +1093,8 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, rc = add_param(mop->mo_ldd.ldd_params, NULL, optarg); if (rc) return rc; + /* Must update the mgs logs */ + mop->mo_ldd.ldd_flags |= LDD_F_UPDATE; break; case 'q': verbose--; @@ -1181,6 +1196,7 @@ int main(int argc, char *const argv[]) goto out; ldd = &mop.mo_ldd; + if (!(IS_MDT(ldd) || IS_OST(ldd) || IS_MGS(ldd))) { fatal(); fprintf(stderr, "must set target type: MDT,OST,MGS\n");