From 3c2731c3916c19c44d6723954a2914c82bff011a Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 9 Feb 2006 23:13:23 +0000 Subject: [PATCH] Branch b1_4_mountconf b=10161 writeconf - all servers re-send registration info whenever they're told to update their config logs. MGS can then regenerate the logs for a live fs. --- lustre/include/linux/lustre_disk.h | 1 + lustre/include/linux/lustre_mgs.h | 2 +- lustre/include/linux/obd_class.h | 1 + lustre/mgc/mgc_request.c | 79 +++++++++++++------------------------- lustre/mgs/mgs_handler.c | 14 +++---- lustre/mgs/mgs_llog.c | 40 +++++++++++-------- lustre/obdclass/obd_mount.c | 67 +++++++++++++++++--------------- lustre/utils/mkfs_lustre.c | 57 +++++++++++++++------------ lustre/utils/mount_lustre.c | 4 +- 9 files changed, 131 insertions(+), 134 deletions(-) diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index 8b6f58d..acd02c5 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -302,6 +302,7 @@ int lustre_end_log(struct super_block *sb, char *logname, struct config_llog_instance *cfg); struct lustre_mount_info *server_get_mount(char *name); int server_put_mount(char *name, struct vfsmount *mnt); +int server_register_target(struct super_block *sb); /* mgc_request.c */ int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id); diff --git a/lustre/include/linux/lustre_mgs.h b/lustre/include/linux/lustre_mgs.h index eac0b6c..a36599b 100644 --- a/lustre/include/linux/lustre_mgs.h +++ b/lustre/include/linux/lustre_mgs.h @@ -27,11 +27,11 @@ struct fs_db { char fd_name[8]; struct list_head fd_list; + struct semaphore fd_sem; void* fd_ost_index_map; void* fd_mdt_index_map; __u32 fd_flags; __u32 fd_gen; - //FIXME add a semaphore for locking the fs_db (and logs) }; int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index cebe4e4..99e557f 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -118,6 +118,7 @@ int class_config_dump_llog(struct llog_ctxt *ctxt, char *name, /* list of active configuration logs */ struct config_llog_data { char *cld_logname; + struct super_block *cld_sb; struct ldlm_res_id cld_resid; struct config_llog_instance cld_cfg; struct list_head cld_list_chain; diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index b9f3ab4..b9f1b49 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -119,7 +119,8 @@ static void config_log_put(void) /* Add this log to our list of active logs. We have one active log per "mount" - client instance or servername. Each instance may be at a different point in the log. */ -static int config_log_add(char *logname, struct config_llog_instance *cfg) +static int config_log_add(char *logname, struct config_llog_instance *cfg, + struct super_block *sb) { struct config_llog_data *cld; int rc; @@ -137,6 +138,7 @@ static int config_log_add(char *logname, struct config_llog_instance *cfg) GOTO(out, rc = -ENOMEM); } strcpy(cld->cld_logname, logname); + cld->cld_sb = sb; cld->cld_cfg = *cfg; cld->cld_cfg.cfg_last_idx = 0; if (cfg->cfg_instance != NULL) { @@ -368,6 +370,12 @@ static int mgc_async_requeue(void *data) LASSERT(the_mgc); class_export_get(the_mgc->obd_self_export); + /* FIXME sleep a few seconds here to allow the server who caused + the lock revocation to finish its setup */ + + /* re-send server info every time, in case MGS needs to regen its + logs */ + server_register_target(cld->cld_sb); rc = mgc_process_log(the_mgc, cld); class_export_put(the_mgc->obd_self_export); @@ -554,8 +562,8 @@ out: } #endif -/* Get index and add to config llog, depending on flags */ -int mgc_target_add(struct obd_export *exp, struct mgs_target_info *mti) +/* Send target_add message to MGS */ +static int mgc_target_add(struct obd_export *exp, struct mgs_target_info *mti) { struct ptlrpc_request *req; struct mgs_target_info *req_mti, *rep_mti; @@ -591,41 +599,6 @@ int mgc_target_add(struct obd_export *exp, struct mgs_target_info *mti) RETURN(rc); } -/* Remove from config llog */ -int mgc_target_del(struct obd_export *exp, struct mgs_target_info *mti) -{ - struct ptlrpc_request *req; - struct mgs_target_info *req_mti, *rep_mti; - int size = sizeof(*req_mti); - int rc; - ENTRY; - - req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MGS_VERSION, - MGS_TARGET_DEL, 1, &size, NULL); - if (!req) - RETURN(rc = -ENOMEM); - - req_mti = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_mti)); - memcpy(req_mti, mti, sizeof(*req_mti)); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - int index; - rep_mti = lustre_swab_repbuf(req, 0, sizeof(*rep_mti), - lustre_swab_mgs_target_info); - index = rep_mti->mti_stripe_index; - if (index != mti->mti_stripe_index) { - CERROR ("OST DEL failed. rc=%d\n", index); - GOTO (out, rc = -EINVAL); - } - CERROR("OST DEL OK.(old index = %d)\n", index); - } -out: - ptlrpc_req_finished(req); - - RETURN(rc); -} - int mgc_set_info(struct obd_export *exp, obd_count keylen, void *key, obd_count vallen, void *val) { @@ -655,8 +628,10 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen, imp->imp_obd->obd_name, imp->imp_deactive, imp->imp_invalid, imp->imp_state); + /* can't put this in obdclass, module loop with ptlrpc*/ + /* remove 'invalid' flag */ ptlrpc_activate_import(imp); - // lustre_reconnect_mgc(obd); + /* reconnect */ ptlrpc_set_import_active(imp, 1); //ptlrpc_recover_import(imp); } @@ -815,8 +790,6 @@ static int mgc_copy_llog(struct obd_device *obd, struct llog_ctxt *rctxt, int rc, rc2; ENTRY; - CDEBUG(D_MGC, "Copy remote log %s\n", logname); - /* open local log */ rc = llog_create(lctxt, &local_llh, NULL, logname); if (rc) @@ -850,6 +823,8 @@ out_closel: rc2 = llog_close(local_llh); if (!rc) rc = rc2; + + CDEBUG(D_MGC, "Copied remote log %s (%d)\n", logname, rc); RETURN(rc); } @@ -862,6 +837,7 @@ static int mgc_process_log(struct obd_device *mgc, struct lustre_handle lockh; struct client_obd *cli = &mgc->u.cli; struct lvfs_run_ctxt saved; + struct lustre_sb_info *lsi = s2lsi(cld->cld_sb); int rc, rcl, flags = 0, must_pop = 0; ENTRY; @@ -881,16 +857,13 @@ static int mgc_process_log(struct obd_device *mgc, if (rcl) CERROR("Can't get cfg lock: %d\n", rcl); + lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); + /* Copy the setup log locally if we can. Don't mess around if we're running an MGS though (logs are already local). */ - /* FIXME What if MGC has a disk set up but a client/another server gets - updated in the meantime? We'll copy the other log onto the - currently set-up disk. This won't hurt the current disk, but - the other server won't get his update written to disk. Next time it - starts it will update, so this isn't a huge deal... */ - if (cli->cl_mgc_vfsmnt && - ((lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT)) != NULL) && - (class_name2obd(LUSTRE_MGS_OBDNAME) == NULL)) { + if (lctxt && lsi && (lsi->lsi_flags & LSI_SERVER) && + (lsi->lsi_srv_mnt == cli->cl_mgc_vfsmnt) && + !IS_MGS(lsi->lsi_ldd)) { push_ctxt(&saved, &mgc->obd_lvfs_ctxt, NULL); must_pop++; if (rcl == 0) @@ -960,21 +933,23 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) break; } case LCFG_LOV_DEL_OBD: - /* Unimplemented */ + /* FIXME */ CERROR("lov_del_obd unimplemented\n"); rc = -ENOSYS; break; case LCFG_LOG_START: { struct config_llog_data *cld; struct config_llog_instance *cfg; + struct super_block *sb; char *logname = lustre_cfg_string(lcfg, 1); - cfg = (struct config_llog_instance *)lustre_cfg_buf(lcfg, 2); + sb = *(struct super_block **)lustre_cfg_buf(lcfg, 3); + CDEBUG(D_MGC, "parse_log %s from %d\n", logname, cfg->cfg_last_idx); /* We're only called through here on the initial mount */ - config_log_add(logname, cfg); + config_log_add(logname, cfg, sb); cld = config_log_get(logname, cfg); if (IS_ERR(cld)) diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index f1087cf..9773839c 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -341,8 +341,8 @@ static int mgs_handle_target_add(struct ptlrpc_request *req) if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 | LDD_F_NEED_REGISTER))) { /* We're just here as a startup ping. */ - CDEBUG(D_MGS, "Server %s has started on %s\n", mti->mti_svname, - obd_export_nid2str(req->rq_export)); + CDEBUG(D_MGS, "Server %s is running on %s\n", + mti->mti_svname, obd_export_nid2str(req->rq_export)); rc = mgs_check_target(obd, mti); /* above will set appropriate mti flags */ if (!rc) @@ -365,14 +365,12 @@ static int mgs_handle_target_add(struct ptlrpc_request *req) down(&obd->u.mgs.mgs_log_sem); if (mti->mti_flags & LDD_F_WRITECONF) { - CERROR("regen all logs for fs %s\n", mti->mti_fsname); rc = mgs_erase_logs(obd, mti->mti_fsname); mti->mti_flags |= LDD_F_NEED_REGISTER; - /* FIXME regen the rest of the logs too. Special lock revoke - flag? */ - LCONSOLE_ERROR("All servers must be restarted in order to " - "regenerate the configuration logs.\n"); - + LCONSOLE_WARNING("Logs for fs %s were removed by user request. " + "All servers must re-register in order to " + "regenerate the client log.\n", + mti->mti_fsname); mti->mti_flags &= ~LDD_F_WRITECONF; mti->mti_flags |= LDD_F_REWRITE; } diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index c1929e0..2505fdf 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -140,8 +140,9 @@ static int mgs_get_db_from_llog(struct obd_device *obd, char *logname, int rc, rc2; ENTRY; + down(&db->fd_sem); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - + rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT), &loghandle, NULL, logname); if (rc) @@ -163,6 +164,7 @@ out_close: out_pop: pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + up(&db->fd_sem); RETURN(rc); } @@ -205,6 +207,7 @@ static struct fs_db *mgs_find_db(struct obd_device *obd, char *fsname) #define INDEX_MAP_SIZE 4096 +/* caller must hold the mgs->mgs_fs_db_lock */ static struct fs_db *mgs_new_db(struct obd_device *obd, char *fsname) { struct mgs_obd *mgs = &obd->u.mgs; @@ -223,11 +226,8 @@ static struct fs_db *mgs_new_db(struct obd_device *obd, char *fsname) } strncpy(db->fd_name, fsname, sizeof(db->fd_name)); - //INIT_LIST_HEAD(&db->ost_infos); - - spin_lock(&mgs->mgs_fs_db_lock); + sema_init(&db->fd_sem, 1); list_add(&db->fd_list, &mgs->mgs_fs_db_list); - spin_unlock(&mgs->mgs_fs_db_lock); RETURN(db); err: @@ -241,6 +241,8 @@ err: static void mgs_free_db(struct fs_db *db) { + /* wait for anyone with the sem */ + down(&db->fd_sem); list_del(&db->fd_list); OBD_FREE(db->fd_ost_index_map, INDEX_MAP_SIZE); OBD_FREE(db->fd_mdt_index_map, INDEX_MAP_SIZE); @@ -289,18 +291,22 @@ static inline void name_destroy(char *newname) static int mgs_find_or_make_db(struct obd_device *obd, char *name, struct fs_db **dbh) { + struct mgs_obd *mgs = &obd->u.mgs; struct fs_db *db; char *cliname; int rc = 0; + spin_lock(&mgs->mgs_fs_db_lock); db = mgs_find_db(obd, name); if (db) { + spin_unlock(&mgs->mgs_fs_db_lock); *dbh = db; return 0; } CDEBUG(D_MGS, "Creating new db\n"); db = mgs_new_db(obd, name); + spin_unlock(&mgs->mgs_fs_db_lock); if (!db) return -ENOMEM; @@ -398,15 +404,8 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) if (test_bit(mti->mti_stripe_index, imap)) { LCONSOLE_ERROR("Server %s requested index %d, but that " - "index is already in use in the %s " - "filesystem. This server " - "may have been reformatted, or the " - "index changed. (To reformat the entire " - "filesystem, specify 'destroy_fs' " - "when reformatting a MDT.)\n", - mti->mti_svname, mti->mti_stripe_index, - mti->mti_fsname); - /* FIXME implement destroy_fs! */ + "index is already in use\n", + mti->mti_svname, mti->mti_stripe_index); RETURN(-EADDRINUSE); } @@ -973,6 +972,7 @@ int mgs_write_log_target(struct obd_device *obd, return rc; } + down(&db->fd_sem); if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { rc = mgs_write_log_mdt(obd, db, mti); } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { @@ -981,6 +981,7 @@ int mgs_write_log_target(struct obd_device *obd, CERROR("Unknown target type %#x, can't create log for %s\n", mti->mti_flags, mti->mti_svname); } + up(&db->fd_sem); if (!rc) db->fd_flags &= ~FSDB_EMPTY; @@ -1191,11 +1192,12 @@ out_pop: int mgs_erase_logs(struct obd_device *obd, char *fsname) { struct mgs_obd *mgs = &obd->u.mgs; + static struct fs_db *db; struct list_head dentry_list; struct l_linux_dirent *dirent, *n; int rc, len = strlen(fsname); ENTRY; - + /* Find all the logs in the CONFIGS directory */ rc = dentry_readdir(obd, mgs->mgs_configs_dir, mgs->mgs_vfsmnt, &dentry_list); @@ -1204,6 +1206,13 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname) RETURN(rc); } + /* Delete the fs db */ + spin_lock(&mgs->mgs_fs_db_lock); + db = mgs_find_db(obd, fsname); + if (db) + mgs_free_db(db); + spin_unlock(&mgs->mgs_fs_db_lock); + list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) { list_del(&dirent->lld_list); if (strncmp(fsname, dirent->lld_name, len) == 0) { @@ -1212,6 +1221,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname) } OBD_FREE(dirent, sizeof(*dirent)); } + RETURN(rc); } diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 329a7e5..4d9d109 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -390,6 +390,7 @@ int lustre_process_log(struct super_block *sb, char *logname, lustre_cfg_bufs_reset(&bufs, mgc->obd_name); lustre_cfg_bufs_set_string(&bufs, 1, logname); lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg)); + lustre_cfg_bufs_set(&bufs, 3, &sb, sizeof(sb)); lcfg = lustre_cfg_new(LCFG_LOG_START, &bufs); rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); @@ -568,21 +569,6 @@ static int lustre_start_mgc(struct super_block *sb) strlen(KEY_INIT_RECOV_BACKUP), KEY_INIT_RECOV_BACKUP, sizeof(recov_bk), &recov_bk); - -#if 0 - /* induces a module loop with ptlrpc */ - if (imp->imp_invalid) { - /* Resurrect if we previously died */ - CDEBUG(D_MOUNT, "Reactivate %s %d:%d:%d\n", - imp->imp_obd->obd_name, - imp->imp_deactive, imp->imp_invalid, - imp->imp_state); - ptlrpc_activate_import(imp); - // lustre_reconnect_mgc(obd); - ptlrpc_set_import_active(imp, 1); - //ptlrpc_recover_import(imp); - } -#endif GOTO(out, rc = 0); } @@ -790,32 +776,26 @@ static int server_stop_servers(struct super_block *sb) RETURN(rc); } -/* Register an old or new target with the MGS. If needed MGS will construct - startup logs and assign index */ -static int server_register_target(struct super_block *sb, struct vfsmount *mnt) +static int server_sb2mti(struct super_block *sb, struct mgs_target_info *mti) { - struct lustre_sb_info *lsi = s2lsi(sb); - struct obd_device *mgc = lsi->lsi_mgc; + struct lustre_sb_info *lsi = s2lsi(sb); struct lustre_disk_data *ldd = lsi->lsi_ldd; - struct mgs_target_info *mti = NULL; - lnet_process_id_t id; + lnet_process_id_t id; int i = 0; - int rc; ENTRY; - LASSERT(mgc); - - OBD_ALLOC(mti, sizeof(*mti)); - if (!mti) { + if (!mti) RETURN(-ENOMEM); - } + if (!(lsi->lsi_flags & LSI_SERVER)) + RETURN(-EINVAL); + strncpy(mti->mti_fsname, ldd->ldd_fsname, sizeof(mti->mti_fsname)); strncpy(mti->mti_svname, ldd->ldd_svname, sizeof(mti->mti_svname)); mti->mti_nid_count = 0; - while ((rc = LNetGetId(i++, &id)) != -ENOENT) { + while (LNetGetId(i++, &id) != -ENOENT) { if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND) continue; mti->mti_nids[mti->mti_nid_count] = id.nid; @@ -836,6 +816,29 @@ static int server_register_target(struct super_block *sb, struct vfsmount *mnt) mti->mti_stripe_pattern = ldd->ldd_stripe_pattern; mti->mti_stripe_size = ldd->ldd_stripe_sz; mti->mti_stripe_offset = ldd->ldd_stripe_offset; + RETURN(0); +} + +/* Register an old or new target with the MGS. If needed MGS will construct + startup logs and assign index */ +int server_register_target(struct super_block *sb) +{ + struct lustre_sb_info *lsi = s2lsi(sb); + struct obd_device *mgc = lsi->lsi_mgc; + struct lustre_disk_data *ldd = lsi->lsi_ldd; + struct mgs_target_info *mti = NULL; + int rc; + ENTRY; + + LASSERT(mgc); + + if (!(lsi->lsi_flags & LSI_SERVER)) + RETURN(-EINVAL); + + OBD_ALLOC_PTR(mti); + rc = server_sb2mti(sb, mti); + if (rc) + GOTO(out, rc); CDEBUG(D_MOUNT, "%sregistration %s, fs=%s, %s, index=%04x, flags=%#x\n", mti->mti_flags & LDD_F_NEED_REGISTER ? "Initial " : "", @@ -872,7 +875,7 @@ static int server_register_target(struct super_block *sb, struct vfsmount *mnt) out: if (mti) - OBD_FREE(mti, sizeof(*mti)); + OBD_FREE_PTR(mti); RETURN(rc); } @@ -921,7 +924,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) server_mgc_set_fs(lsi->lsi_mgc, sb); /* Register with MGS */ - rc = server_register_target(sb, mnt); + rc = server_register_target(sb); if (rc && (lsi->lsi_ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER | LDD_F_UPGRADE14))){ CERROR("Required refistration failed for %s: %d\n", @@ -1654,4 +1657,6 @@ EXPORT_SYMBOL(lustre_process_log); EXPORT_SYMBOL(lustre_end_log); EXPORT_SYMBOL(server_get_mount); EXPORT_SYMBOL(server_put_mount); +EXPORT_SYMBOL(server_register_target); + diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index f2bba1f..2eb0f45 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -41,6 +41,7 @@ #include // for BLKGETSIZE64 #include #include +#include #include "obdctl.h" /* So obd.o will link */ @@ -59,6 +60,7 @@ static int print_only = 0; void usage(FILE *out) { + fprintf(out, "%s v"LUSTRE_VERSION_STRING"\n", progname); fprintf(out, "usage: %s [options] \n", progname); fprintf(out, "\t:block device or file (e.g /dev/sda or /tmp/ost1)\n" @@ -498,12 +500,13 @@ void print_ldd(char *str, struct lustre_disk_data *ldd) printf("Lustre FS: %s\n", ldd->ldd_fsname); printf("Mount type: %s\n", MT_STR(ldd)); printf("Flags: %#x\n", ldd->ldd_flags); - printf(" (%s%s%s%s%s%s)\n", + printf(" (%s%s%s%s%s%s%s)\n", IS_MDT(ldd) ? "MDT ":"", IS_OST(ldd) ? "OST ":"", IS_MGS(ldd) ? "MGS ":"", ldd->ldd_flags & LDD_F_NEED_INDEX ? "needs_index ":"", ldd->ldd_flags & LDD_F_NEED_REGISTER ? "must_register ":"", + ldd->ldd_flags & LDD_F_WRITECONF ? "writeconf ":"", ldd->ldd_flags & LDD_F_UPGRADE14 ? "upgrade1.4 ":""); printf("Persistent mount opts: %s\n", ldd->ldd_mount_opts); printf("MGS nids: "); @@ -789,10 +792,10 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, {"index", 1, 0, 'i'}, {"timeout", 1, 0, 't'}, {"verbose", 0, 0, 'v'}, - {"writeconf", 1, 0, 'w'}, + {"writeconf", 0, 0, 'w'}, {0, 0, 0, 0} }; - char *optstring = "b:C:d:n:f:hI:MGm:k:No:Opqrw:c:s:i:t:v"; + char *optstring = "b:C:d:n:f:hI:MGm:k:No:Opqrw:c:s:i:t:vw"; char opt; int longidx; @@ -962,7 +965,8 @@ int main(int argc, char *const argv[]) { struct mkfs_opts mop; char *mountopts = NULL; - char default_mountopts[1024] = ""; + char always_mountopts[512] = ""; + char default_mountopts[512] = ""; int ret = 0; if ((progname = strrchr(argv[0], '/')) != NULL) @@ -1056,24 +1060,25 @@ int main(int argc, char *const argv[]) switch (mop.mo_ldd.ldd_mount_type) { case LDD_MT_EXT3: case LDD_MT_LDISKFS: { - sprintf(default_mountopts, "errors=remount-ro"); + sprintf(always_mountopts, "errors=remount-ro"); if (IS_MDT(&mop.mo_ldd) || IS_MGS(&mop.mo_ldd)) - strcat(default_mountopts, + strcat(always_mountopts, ",iopen_nopriv,user_xattr"); if ((get_os_version() == 24) && IS_OST(&mop.mo_ldd)) - strcat(default_mountopts, ",asyncdel"); + strcat(always_mountopts, ",asyncdel"); +#if 0 /* Files created while extents are enabled cannot be read if mounted with a kernel that doesn't include the CFS patches.*/ if (IS_OST(&mop.mo_ldd) && mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS) { strcat(default_mountopts, ",extents,mballoc"); } - +#endif break; } case LDD_MT_SMFS: { mop.mo_flags |= MO_IS_LOOP; - sprintf(default_mountopts, "type=ext3,dev=%s", + sprintf(always_mountopts, "type=ext3,dev=%s", mop.mo_device); break; } @@ -1087,23 +1092,25 @@ int main(int argc, char *const argv[]) } } -#ifndef TUNEFS /* mkfs.lustre */ - if (mountopts) - /* If user specifies mount opts, assume no defaults */ - strcpy(mop.mo_ldd.ldd_mount_opts, mountopts); - /* sprintf(mop.mo_ldd.ldd_mount_opts, "%s,%s", - default_mountopts, mountopts); */ - else - strcpy(mop.mo_ldd.ldd_mount_opts, default_mountopts); -#else /* tunefs.lustre - if mountopts are specified, they override - whatever we had before, so no defaults. */ - if (mountopts) - strcpy(mop.mo_ldd.ldd_mount_opts, mountopts); - else if (*mop.mo_ldd.ldd_mount_opts == 0) - /* no mount opts were set ever, use the defaults. */ - strcpy(mop.mo_ldd.ldd_mount_opts, default_mountopts); - /* otherwise, use the old. */ + if (mountopts) { + /* If user specifies mount opts, don't use defaults, + but always use always_mountopts */ + sprintf(mop.mo_ldd.ldd_mount_opts, "%s,%s", + always_mountopts, mountopts); + } else { +#ifdef TUNEFS + if (*mop.mo_ldd.ldd_mount_opts == 0) + /* use the defaults unless old opts exist */ #endif + { + if (default_mountopts[0]) + sprintf(mop.mo_ldd.ldd_mount_opts, "%s,%s", + always_mountopts, default_mountopts); + else + strcpy(mop.mo_ldd.ldd_mount_opts, + always_mountopts); + } + } ldd_make_sv_name(&(mop.mo_ldd)); diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 7093b97..d25fa68 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -34,7 +34,7 @@ #include #include #include - +#include #include "obdctl.h" int verbose = 0; @@ -45,7 +45,7 @@ static char *progname = NULL; void usage(FILE *out) { - fprintf(out, "%s v2.0\n", progname); + fprintf(out, "%s v"LUSTRE_VERSION_STRING"\n", progname); fprintf(out, "usage: %s [-fhnv] [-o ] \n", progname); fprintf(out, -- 1.8.3.1