From: nathan Date: Mon, 20 Feb 2006 18:47:20 +0000 (+0000) Subject: Branch b1_4_mountconf X-Git-Tag: v1_8_0_110~486^4~32 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=5870029f7754285d0b156706ffecc8b46f945ff8;p=fs%2Flustre-release.git Branch b1_4_mountconf b=9846 Add lctl conf_param path via ioctl to MGS to set LCFG_PARAMs in logs. Specifically, this allows things like: ./lctl conf_param lustre-mdtlov default_stripe_size=1055000 to be added to the MDT and client logs. --- diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index 1910f5c..bbfe342 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -100,17 +100,8 @@ struct lustre_disk_data { /* COMPAT_146 */ __u8 ldd_uuid[40]; /* server UUID */ /* end COMPAT_146 */ -/*1228*/ - /* These are required for writing mdt, ost,or client logs, - and are ignored after that. */ - /* FIXME these should be removed from here and set via ioctls or proc */ - int ldd_stripe_sz; - int ldd_stripe_count; - int ldd_stripe_pattern; - int ldd_stripe_offset; - int ldd_timeout; /* obd timeout */ -/*1248*/ - __u8 ldd_padding[4096 - 1248]; + + __u8 ldd_padding[4096 - 1228]; char ldd_mount_opts[4096]; /* target fs mount opts */ }; @@ -181,6 +172,7 @@ struct mkfs_opts { char mo_mkfsopts[128]; /* options to the backing-store mkfs */ char mo_loopdev[128]; /* in case a loop dev is needed */ __u64 mo_device_sz; /* in KB */ + int mo_stripe_count; int mo_flags; }; diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index ea692b4..b64635f 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -1000,10 +1000,6 @@ struct mgs_target_info { char mti_uuid[sizeof(struct obd_uuid)]; lnet_nid_t mti_nids[MTI_NIDS_MAX]; /* host nids */ lnet_nid_t mti_failnids[MTI_NIDS_MAX]; /* partner nids */ - __u64 mti_stripe_size; - __u64 mti_stripe_offset; - __u32 mti_stripe_count; /* how many objects are used */ - __u32 mti_stripe_pattern; /* PATTERN_RAID0, PATTERN_RAID1*/ __u32 mti_stripe_index; __u32 mti_nid_count; __u32 mti_failnid_count; diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 0aba5ff..ab2c862 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -453,7 +453,7 @@ static inline void obd_ioctl_freedata(char *buf, int len) #define OBD_IOC_PROCESS_CFG _IOWR('f', 184, long) #define OBD_IOC_DUMP_LOG _IOWR('f', 185, long) #define OBD_IOC_CLEAR_LOG _IOWR('f', 186, long) -#define OBD_IOC_START _IOWR('f', 187, long) +#define OBD_IOC_PARAM _IOW ('f', 187, long) #define OBD_IOC_CATLOGLIST _IOWR('f', 190, long) #define OBD_IOC_LLOG_INFO _IOWR('f', 191, long) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 48e46ef..8f00bd0 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -539,20 +539,6 @@ static int mgc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); } - case OBD_IOC_START: { - char *name = data->ioc_inlbuf1; - CERROR("getting config log %s\n", name); - /* FIXME Get llog from MGS */ - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - rc = class_config_parse_llog(ctxt, name, NULL); - if (rc < 0) - CERROR("Unable to process log: %s\n", name); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - GOTO(out, rc); - } default: CERROR("mgc_ioctl(): unrecognised ioctl %#x\n", cmd); GOTO(out, rc = -ENOTTY); @@ -589,17 +575,17 @@ static int mgc_target_register(struct obd_export *exp, req->rq_replen = lustre_msg_size(1, &rep_size); - CDEBUG(D_MGC, "requesting add for %s\n", mti->mti_svname); + CDEBUG(D_MGC, "register %s\n", mti->mti_svname); rc = ptlrpc_queue_wait(req); if (!rc) { rep_mti = lustre_swab_repbuf(req, 0, sizeof(*rep_mti), lustre_swab_mgs_target_info); memcpy(mti, rep_mti, sizeof(*rep_mti)); - CDEBUG(D_MGC, "target_add %s got index = %d\n", + CDEBUG(D_MGC, "register %s got index = %d\n", mti->mti_svname, mti->mti_stripe_index); } else { - CERROR("target_add failed. rc=%d\n", rc); + CERROR("register failed. rc=%d\n", rc); } ptlrpc_req_finished(req); diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index e7126a0..057dfad 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -349,7 +349,10 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) GOTO(out_nolock, rc); } - /* revoke the config lock so everyone will update */ + /* Revoke the config lock to make sure nobody is reading. */ + /* Although actually I think it should be alright if + someone was reading while we were updating the logs - if we + revoke at the end they will just update from where they left off. */ lockrc = mgs_get_cfg_lock(obd, mti->mti_fsname, &lockh); if (lockrc != ELDLM_OK) { LCONSOLE_ERROR("%s: Can't signal other nodes to update " @@ -361,7 +364,8 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) /* There can be only 1 server adding at a time - don't want log writing contention. */ - down(&obd->u.mgs.mgs_log_sem); + /* Actually this should be okay because of the per-fs fsdb sem */ + //down(&obd->u.mgs.mgs_log_sem); if (mti->mti_flags & LDD_F_WRITECONF) { rc = mgs_erase_logs(obd, mti->mti_fsname); @@ -406,7 +410,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) } out: - up(&obd->u.mgs.mgs_log_sem); + //up(&obd->u.mgs.mgs_log_sem); /* done with log update */ if (lockrc == ELDLM_OK) mgs_put_cfg_lock(&lockh); @@ -534,6 +538,124 @@ static inline int mgs_destroy_export(struct obd_export *exp) RETURN(0); } +/* from mdt_iocontrol */ +int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, + void *karg, void *uarg) +{ + struct obd_device *obd = exp->exp_obd; + struct obd_ioctl_data *data = karg; + struct lvfs_run_ctxt saved; + int rc = 0; + + ENTRY; + CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd); + + switch (cmd) { + + case OBD_IOC_DORECORD: + case OBD_IOC_PARAM: { + struct lustre_handle lockh; + struct lustre_cfg *lcfg; + struct llog_rec_hdr rec; + char fsname[32], *devname, *ptr; + int lockrc; + + CERROR("MGS param\n"); + + rec.lrh_len = llog_data_len(data->ioc_plen1); + + if (data->ioc_type == LUSTRE_CFG_TYPE) { + rec.lrh_type = OBD_CFG_REC; + } else { + CERROR("unknown cfg record type:%d \n", data->ioc_type); + RETURN(-EINVAL); + } + + OBD_ALLOC(lcfg, data->ioc_plen1); + if (lcfg == NULL) + RETURN(-ENOMEM); + rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1); + if (rc) { + OBD_FREE(lcfg, data->ioc_plen1); + RETURN(rc); + } + + if (lcfg->lcfg_bufcount < 1) + RETURN(-EINVAL); + + /* Extract fsname */ + /* FIXME COMPAT_146 this won't work with old names */ + memset(fsname, 0, sizeof(fsname)); + devname = lustre_cfg_string(lcfg, 0); + if (!devname) { + LCONSOLE_ERROR("No device specified\n"); + GOTO(out_free, rc = -ENODEV); + } + ptr = strchr(devname, '-'); + if (!ptr) { + /* assume devname is the fsname */ + //strncpy(fsname, devname, sizeof(fsname)); + LCONSOLE_ERROR("Unrecognized device %s\n", devname); + GOTO(out_free, rc = -ENODEV); + } else { + strncpy(fsname, devname, ptr - devname); + } + + CDEBUG(D_MGS, "set param on fs %s device %s\n", + fsname, devname); + + //down(&obd->u.mgs.mgs_log_sem); + rc = mgs_setparam(obd, fsname, lcfg); + //up(&obd->u.mgs.mgs_log_sem); + + if (rc) { + CERROR("setparam err %d\n", rc); + GOTO(out_free, rc); + } + + /* Revoke lock so everyone updates. Should be alright if + someone was reading while we were updating the logs. */ + lockrc = mgs_get_cfg_lock(obd, fsname, &lockh); + if (lockrc != ELDLM_OK) + CERROR("lock error %d for fs %s\n", lockrc, fsname); + else + mgs_put_cfg_lock(&lockh); +out_free: + OBD_FREE(lcfg, data->ioc_plen1); + RETURN(rc); + } + + case OBD_IOC_DUMP_LOG: { + struct llog_ctxt *ctxt = + llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + rc = class_config_dump_llog(ctxt, data->ioc_inlbuf1, NULL); + pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + if (rc) + RETURN(rc); + + RETURN(rc); + } + + case OBD_IOC_LLOG_CHECK: + case OBD_IOC_LLOG_INFO: + case OBD_IOC_LLOG_PRINT: { + struct llog_ctxt *ctxt = + llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + + push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); + rc = llog_ioctl(ctxt, cmd, data); + pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); + + RETURN(rc); + } + + default: + CDEBUG(D_INFO, "unknown command %x\n", cmd); + RETURN(-EINVAL); + } + RETURN(0); +} /* use obd ops to offer management infrastructure */ static struct obd_ops mgs_obd_ops = { @@ -544,7 +666,7 @@ static struct obd_ops mgs_obd_ops = { .o_precleanup = mgs_precleanup, .o_cleanup = mgs_cleanup, .o_destroy_export = mgs_destroy_export, - //.o_iocontrol = mgs_iocontrol, + .o_iocontrol = mgs_iocontrol, }; static int __init mgs_init(void) diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index d77b761..79e8c71 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -15,10 +15,10 @@ extern struct lvfs_callback_ops mgs_lvfs_ops; int mgs_init_fsdb_list(struct obd_device *obd); int mgs_cleanup_fsdb_list(struct obd_device *obd); int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti); -int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti); int mgs_write_log_target(struct obd_device *obd, struct mgs_target_info *mti); int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti); int mgs_erase_logs(struct obd_device *obd, char *fsname); +int mgs_setparam(struct obd_device *obd, char *fsname, struct lustre_cfg *lcfg); #endif diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 1adc4e9..a777c65 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -104,8 +104,8 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, CWARN("Unparsable MDC name %s, assuming index 0\n", lustre_cfg_string(lcfg, 0)); index = 0; - rc = 0; } + rc = 0; CDEBUG(D_MGS, "MDT index is %lu\n", index); set_bit(index, fsdb->fsdb_mdt_index_map); } @@ -412,7 +412,7 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) /******************** config log recording functions *********************/ -static int mgs_do_record(struct obd_device *obd, struct llog_handle *llh, +static int record_lcfg(struct obd_device *obd, struct llog_handle *llh, struct lustre_cfg *lcfg) { struct lvfs_run_ctxt saved; @@ -462,7 +462,7 @@ static int record_base(struct obd_device *obd, struct llog_handle *llh, lcfg = lustre_cfg_new(cmd, &bufs); lcfg->lcfg_nid = nid; - rc = mgs_do_record(obd, llh, lcfg); + rc = record_lcfg(obd, llh, lcfg); lustre_cfg_free(lcfg); @@ -514,7 +514,7 @@ static int record_lov_setup(struct obd_device *obd, struct llog_handle *llh, lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc)); lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - rc = mgs_do_record(obd, llh, lcfg); + rc = record_lcfg(obd, llh, lcfg); lustre_cfg_free(lcfg); return rc; @@ -559,7 +559,7 @@ static int record_marker(struct obd_device *obd, struct llog_handle *llh, lustre_cfg_bufs_set(&bufs, 1, &marker, sizeof(marker)); lcfg = lustre_cfg_new(LCFG_MARKER, &bufs); - rc = mgs_do_record(obd, llh, lcfg); + rc = record_lcfg(obd, llh, lcfg); lustre_cfg_free(lcfg); return rc; @@ -639,6 +639,31 @@ static int mgs_log_is_empty(struct obd_device *obd, char *name) /******************** config "macros" *********************/ +static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb, + char *logname, char *obdname, + struct lustre_cfg *lcfg) +{ + struct llog_handle *llh = NULL; + int rc; + ENTRY; + + if (mgs_log_is_empty(obd, logname)) { + CERROR("%s log is empty\n", logname); + RETURN(-ENODEV); + } + + rc = record_start_log(obd, &llh, logname); + rc = record_marker(obd, llh, fsdb, CM_START, obdname, "param"); + + rc = record_lcfg(obd, llh, lcfg); + //rc = record_param(obd, llh, lovname, s1, s2, s3, s4); + + rc = record_marker(obd, llh, fsdb, CM_END, obdname, "param"); + rc = record_end_log(obd, &llh); + + RETURN(rc); +} + /* lov is the first thing in the mdt and client logs */ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, struct mgs_target_info *mti, @@ -664,10 +689,11 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, RETURN(-ENOMEM); lovdesc->ld_magic = LOV_DESC_MAGIC; lovdesc->ld_tgt_count = 0; - lovdesc->ld_default_stripe_count = mti->mti_stripe_count; - lovdesc->ld_pattern = mti->mti_stripe_pattern; - lovdesc->ld_default_stripe_size = mti->mti_stripe_size; - lovdesc->ld_default_stripe_offset = mti->mti_stripe_offset; + /* Defaults. Can be changed later by lcfg config_param */ + lovdesc->ld_default_stripe_count = 1; + lovdesc->ld_pattern = LOV_PATTERN_RAID0; + lovdesc->ld_default_stripe_size = 1024 * 1024; + lovdesc->ld_default_stripe_offset = 0; sprintf((char*)lovdesc->ld_uuid.uuid, "%s_UUID", lovname); /* can these be the same? */ uuid = (char *)lovdesc->ld_uuid.uuid; @@ -722,7 +748,6 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb, { struct llog_handle *llh = NULL; char *cliname, *mdcname, *lovname, *nodeuuid, *mdcuuid; - char *s1, *s2, *s3, *s4, *s5; int rc, i, first_log = 0; ENTRY; @@ -773,28 +798,6 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb, */ rc = record_start_log(obd, &llh, mti->mti_svname); rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add mdt"); - - /* FIXME this should just be added via a MGS ioctl - OBD_IOC_LOV_SETSTRIPE / LL_IOC_LOV_SETSTRIPE. - Or, heck, just make them use lfs setstripe on the root... */ - if (!first_log) { - /* Fix default lov settings if they were set by something other - than the MDT. */ - OBD_ALLOC(s1, 256); - if (s1) { - s2 = sprintf(s1, "default_stripe_size="LPU64, - mti->mti_stripe_size) + s1 + 1; - s3 = sprintf(s2, "default_stripe_count=%u", - mti->mti_stripe_count) + s2 + 1; - s4 = sprintf(s3, "default_stripe_offset="LPU64, - mti->mti_stripe_offset) + s3 + 1; - s5 = sprintf(s4, "default_stripe_pattern=%u", - mti->mti_stripe_pattern) + s4 + 1; - LASSERT(s5 - s1 < 256); - record_param(obd, llh, lovname, s1, s2, s3, s4); - } - } - rc = record_mount_opt(obd, llh, mti->mti_svname, lovname, 0); rc = record_attach(obd, llh, mti->mti_svname, LUSTRE_MDS_NAME, mti->mti_uuid); @@ -829,11 +832,6 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb, */ rc = record_start_log(obd, &llh, cliname); rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add mdc"); - if (!first_log && s1) { - /* Record new lov settings */ - record_param(obd, llh, lovname, s1, s2, s3, s4); - OBD_FREE(s1, 256); - } for (i = 0; i < mti->mti_nid_count; i++) { CDEBUG(D_MGS, "add nid %s\n", libcfs_nid2str(mti->mti_nids[i])); rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid); @@ -1244,6 +1242,112 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname) RETURN(rc); } +/* from llog_swab */ +static void print_lustre_cfg(struct lustre_cfg *lcfg) +{ + int i; + ENTRY; + + CDEBUG(D_MGS, "lustre_cfg: %p\n", lcfg); + CDEBUG(D_MGS, "\tlcfg->lcfg_version: %#x\n", lcfg->lcfg_version); + + CDEBUG(D_MGS, "\tlcfg->lcfg_command: %#x\n", lcfg->lcfg_command); + CDEBUG(D_MGS, "\tlcfg->lcfg_num: %#x\n", lcfg->lcfg_num); + CDEBUG(D_MGS, "\tlcfg->lcfg_flags: %#x\n", lcfg->lcfg_flags); + CDEBUG(D_MGS, "\tlcfg->lcfg_nid: %s\n", libcfs_nid2str(lcfg->lcfg_nid)); + + CDEBUG(D_MGS, "\tlcfg->lcfg_bufcount: %d\n", lcfg->lcfg_bufcount); + if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT) + for (i = 0; i < lcfg->lcfg_bufcount; i++) { + CDEBUG(D_MGS, "\tlcfg->lcfg_buflens[%d]: %d %s\n", + i, lcfg->lcfg_buflens[i], + lustre_cfg_string(lcfg, i)); + } + EXIT; +} + +/* Set a permanent (config log) param for a target or fs */ +int mgs_setparam(struct obd_device *obd, char *fsname, struct lustre_cfg *lcfg) +{ + struct fs_db *fsdb; + char *devname; + int rc = 0; + ENTRY; + + print_lustre_cfg(lcfg); + + /* lustre-mdtlov, lustre-client, lustre-MDT0000 */ + devname = lustre_cfg_string(lcfg, 0); + + if (devname == NULL) { + /* Global setting across all fs's? */ + LCONSOLE_ERROR("Global settings not implemented yet!\n"); + RETURN(-ENOSYS); + } + + CDEBUG(D_MGS, "target: %s\n", devname); + +#if 0 + struct mgs_target_info *mti; + unsigned long index; + rc = server_name2index(devname, &index, NULL); + if (rc < 0) + /* Might be lov */ + CDEBUG(D_MGS, "Can't find index for %s\n", devname); + else { + /* Construct a fake mti out of the target name */ + OBD_ALLOC_PTR(mti); + if (!mti) + RETURN(-ENOMEM); + strncpy(mti->mti_svname, devname, sizeof(mti->mti_svname)); + memcpy(mti->mti_fsname, fsname, sizeof(mti->mti_fsname)); + mti->mti_flags = rc; /* rc from name2index is obd type */ + mti->mti_stripe_index = index; + rc = mgs_check_index(obd, mti); + if (rc != 1) { + CERROR("Target %s has not registered yet.\n", + mti->mti_svname); + rc = -ENODEV; + } + OBD_FREE_PTR(mti); + } +#endif + + rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb); + if (rc) + RETURN(rc); + if (fsdb->fsdb_flags & FSDB_EMPTY) { + CERROR("No filesystem targets for %s\n", fsname); + RETURN(-EINVAL); + } + + /* It's all special cases */ + + /* lustre-mdtlov, old lov_mdsA. */ + if (strstr(devname, "-mdtlov") + /* COMPAT_146 */ || (strncmp(devname, "lov_", 4) == 0)) { + char *lovname, *logname; + CDEBUG(D_MGS, "lov param, mod MDT and client\n"); + down(&fsdb->fsdb_sem); + name_create(fsname, "-MDT0000", &logname); + name_create(fsname, "-mdtlov", &lovname); + if (strcmp(lovname, devname) != 0) { + CWARN("weird/old lovname %s, hope you're right\n", + devname); + } + rc = mgs_write_log_direct(obd, fsdb, logname, devname, lcfg); + name_destroy(lovname); + name_destroy(logname); + name_create(fsname, "-client", &logname); + name_create(fsname, "-clilov", &lovname); + rc = mgs_write_log_direct(obd, fsdb, logname, lovname, lcfg); + name_destroy(lovname); + up(&fsdb->fsdb_sem); + } + + RETURN(rc); +} + #if 0 /******************** unused *********************/ @@ -1304,181 +1408,6 @@ out: return rc; } -/* from mdt_iocontrol */ -int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len, - void *karg, void *uarg) -{ - static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" }; - struct obd_device *obd = exp->exp_obd; - struct mgs_obd *mgs = &obd->u.mgs; - struct obd_ioctl_data *data = karg; - struct lvfs_run_ctxt saved; - int rc = 0; - - ENTRY; - CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd); - - switch (cmd) { - case OBD_IOC_RECORD: { - char *name = data->ioc_inlbuf1; - if (mgs->mgs_cfg_llh) - RETURN(-EBUSY); - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT), - &mgs->mgs_cfg_llh, NULL, name); - if (rc == 0) - llog_init_handle(mgs->mgs_cfg_llh, LLOG_F_IS_PLAIN, - &cfg_uuid); - else - mgs->mgs_cfg_llh = NULL; - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - RETURN(rc); - } - - case OBD_IOC_ENDRECORD: { - if (!mgs->mgs_cfg_llh) - RETURN(-EBADF); - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = llog_close(mgs->mgs_cfg_llh); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - mgs->mgs_cfg_llh = NULL; - RETURN(rc); - } - - case OBD_IOC_CLEAR_LOG: { - char *name = data->ioc_inlbuf1; - if (mgs->mgs_cfg_llh) - RETURN(-EBUSY); - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT), - &mgs->mgs_cfg_llh, NULL, name); - if (rc == 0) { - llog_init_handle(mgs->mgs_cfg_llh, LLOG_F_IS_PLAIN, - NULL); - rc = llog_destroy(mgs->mgs_cfg_llh); - llog_free_handle(mgs->mgs_cfg_llh); - } - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - mgs->mgs_cfg_llh = NULL; - RETURN(rc); - } - - case OBD_IOC_DORECORD: { - char *cfg_buf; - struct llog_rec_hdr rec; - if (!mgs->mgs_cfg_llh) - RETURN(-EBADF); - - rec.lrh_len = llog_data_len(data->ioc_plen1); - - if (data->ioc_type == LUSTRE_CFG_TYPE) { - rec.lrh_type = OBD_CFG_REC; - } else { - CERROR("unknown cfg record type:%d \n", data->ioc_type); - RETURN(-EINVAL); - } - - OBD_ALLOC(cfg_buf, data->ioc_plen1); - if (cfg_buf == NULL) - RETURN(-EINVAL); - rc = copy_from_user(cfg_buf, data->ioc_pbuf1, data->ioc_plen1); - if (rc) { - OBD_FREE(cfg_buf, data->ioc_plen1); - RETURN(rc); - } - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = llog_write_rec(mgs->mgs_cfg_llh, &rec, NULL, 0, - cfg_buf, -1); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - OBD_FREE(cfg_buf, data->ioc_plen1); - RETURN(rc); - - } - case OBD_IOC_PARSE: { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if (rc) - RETURN(rc); - - RETURN(rc); - } - - case OBD_IOC_DUMP_LOG: { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = class_config_dump_llog(ctxt, data->ioc_inlbuf1, NULL); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if (rc) - RETURN(rc); - - RETURN(rc); - } - - case OBD_IOC_SYNC: { - CDEBUG(D_HA, "syncing mgs %s\n", obd->obd_name); - rc = fsfilt_sync(obd, obd->u.mgs.mgs_sb); - RETURN(rc); - } - - case OBD_IOC_SET_READONLY: { - void *handle; - struct inode *inode = obd->u.mgs.mgs_sb->s_root->d_inode; - BDEVNAME_DECLARE_STORAGE(tmp); - CERROR("*** setting device %s read-only ***\n", - ll_bdevname(obd->u.mgs.mgs_sb, tmp)); - - handle = fsfilt_start(obd, inode, FSFILT_OP_MKNOD, NULL); - if (!IS_ERR(handle)) - rc = fsfilt_commit(obd, inode, handle, 1); - - CDEBUG(D_HA, "syncing mgs %s\n", obd->obd_name); - rc = fsfilt_sync(obd, obd->u.mgs.mgs_sb); - - lvfs_set_rdonly(lvfs_sbdev(obd->u.mgs.mgs_sb)); - RETURN(0); - } - - case OBD_IOC_LLOG_CHECK: - case OBD_IOC_LLOG_CANCEL: - case OBD_IOC_LLOG_REMOVE: { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - - push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - rc = llog_ioctl(ctxt, cmd, data); - pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - - RETURN(rc); - } - case OBD_IOC_LLOG_INFO: - case OBD_IOC_LLOG_PRINT: { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - - push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - rc = llog_ioctl(ctxt, cmd, data); - pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - - RETURN(rc); - } - - default: - CDEBUG(D_INFO, "unknown command %x\n", cmd); - RETURN(-EINVAL); - } - RETURN(0); -} #endif diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 04efe95..5f2a7f8 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -828,10 +828,6 @@ static int server_sb2mti(struct super_block *sb, struct mgs_target_info *mti) mti->mti_config_ver = 0; mti->mti_flags = ldd->ldd_flags; mti->mti_stripe_index = ldd->ldd_svindex; - mti->mti_stripe_count = ldd->ldd_stripe_count; - 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); } @@ -946,6 +942,10 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) (LDD_F_NEED_INDEX | LDD_F_UPDATE | LDD_F_UPGRADE14))){ CERROR("Required registration failed for %s: %d\n", lsi->lsi_ldd->ldd_svname, rc); + if (rc == -EIO) { + LCONSOLE_ERROR("Communication error with the MGS. Is " + "the MGS running?\n"); + } GOTO(out, rc); } diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index b3e09ff..bafc32e 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -636,10 +636,6 @@ void lustre_swab_mgs_target_info(struct mgs_target_info *mti) __swab64s(&mti->mti_nids[i]); __swab64s(&mti->mti_failnids[i]); } - __swab64s(&mti->mti_stripe_size); - __swab64s(&mti->mti_stripe_offset); - __swab32s(&mti->mti_stripe_count); - __swab32s(&mti->mti_stripe_pattern); __swab32s(&mti->mti_stripe_index); __swab32s(&mti->mti_nid_count); __swab32s(&mti->mti_failnid_count); diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 2b371d5..328a1a0 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -170,6 +170,9 @@ command_t cmdlist[] = { "usage: dump_log config-uuid-name"}, {"clear_log", jt_cfg_clear_log, 0, "delete current config log of recorded commands\n" "usage: clear_log config-name"}, + {"conf_param", jt_lcfg_mgsparam, 0, "set a permanent config param\n" + "usage: conf_param ...\n"}, + /* Device operations */ {"=== device operations ==", jt_noop, 0, "device operations"}, @@ -236,8 +239,8 @@ command_t cmdlist[] = { "usage: add_conn [priority]\n"}, {"del_conn ", jt_lcfg_del_conn, 0, "usage: del_conn \n"}, - {"param", jt_lcfg_param, 0, - "usage: param ...\n"}, + {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n" + "usage: local_param ...\n"}, /* Llog operations */ {"llog_catlist", jt_llog_catlist, 0, diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 8e2c434..fb5fcde 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -645,6 +645,7 @@ int jt_lcfg_del_conn(int argc, char **argv) return rc; } +/* Param set locally, directly on target */ int jt_lcfg_param(int argc, char **argv) { int i, rc; @@ -671,3 +672,56 @@ int jt_lcfg_param(int argc, char **argv) return rc; } +/* Param set in config log on MGS */ +/* conf_param key1=value1 [key2=value2...] */ +int jt_lcfg_mgsparam(int argc, char **argv) +{ + int i, rc, index_offset = 0; + struct lustre_cfg_bufs bufs; + struct lustre_cfg *lcfg; + + if ((argc >= LUSTRE_CFG_MAX_BUFCOUNT) || (argc <= 1)) + return CMD_HELP; + + if (!strchr(argv[1], '=')) { + /* Not key=val, assume */ + rc = jt_lcfg_device(2, argv); + if (rc) + return rc; + index_offset = 1; + } + + if (lcfg_devname == NULL) { + fprintf(stderr, "%s: please use 'cfg_device name' to set the " + "device name for config commands.\n", + jt_cmdname(argv[0])); + return -EINVAL; + } + + lustre_cfg_bufs_reset(&bufs, lcfg_devname); + + for (i = 1; i < (argc - index_offset); i++) { + lustre_cfg_bufs_set_string(&bufs, i, argv[i + index_offset]); + } + + /* We could put other opcodes here. */ + lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); + + rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); + lustre_cfg_free(lcfg); + if (rc < 0) { + fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), + strerror(rc = errno)); + if (rc == ENODEV) + fprintf(stderr, "Is the MGS running on this node?\n"); + if (rc == ENOSYS) + fprintf(stderr, "Make sure cfg_device is set first.\n"); + if (rc == EINVAL) + fprintf(stderr, "cfg_device should be of the form " + "'lustre-MDT0000'\n"); + } + + return rc; +} + + diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index fb220a4..1ca6a48 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -69,32 +69,30 @@ void usage(FILE *out) "\t\t--ost: object storage, mutually exclusive with mdt\n" "\t\t--mdt: metadata storage, mutually exclusive with ost\n" "\t\t--mgs: configuration management service - one per site\n" - "\toptions:\n" + "\toptions (in order of popularity):\n" "\t\t--mgsnid=[,<...>] : NID(s) of a remote mgs node\n" "\t\t\trequired for all targets other than the mgs node\n" "\t\t--fsname= : default is 'lustre'\n" + "\t\t--failover=[,<...>] : list of NIDs for the failover\n" + "\t\t\tpartners for this target\n" + "\t\t--index=#N : target index\n" /* FIXME implement 1.6.x "\t\t--configdev=: store configuration info\n" "\t\t\tfor this device on an alternate device\n" */ - "\t\t--failover=[,<...>] : list of NIDs for the failover\n" - "\t\t\tpartners for this target\n" + "\t\t--mountfsoptions= : permanent mount options\n" "\t\t--backfstype= : backing fs type (ext3, ldiskfs)\n" "\t\t--device-size=#N(KB) : device size for loop devices\n" - "\t\t--stripe-count=#N : default number of stripes\n" - "\t\t--stripe-size=#N(KB) : default stripe size\n" - "\t\t--index=#N : target index\n" - "\t\t--mountfsoptions= : permanent mount options\n" #ifndef TUNEFS "\t\t--mkfsoptions= : format options\n" "\t\t--reformat: overwrite an existing disk\n" + "\t\t--stripe-count-hint=#N : used for optimizing MDT inode size\n" #else "\t\t--nomgs: turn off MGS service on this MDT\n" "\t\t--writeconf: erase all config logs for this fs.\n" #endif "\t\t--print: just report what we would do; don't write to " "disk\n" - "\t\t--timeout= : system timeout period\n" "\t\t--verbose\n" "\t\t--quiet\n"); return; @@ -430,11 +428,12 @@ int make_lustre_backfs(struct mkfs_opts *mop) if (strstr(mop->mo_mkfsopts, "-I") == NULL) { long inode_size = 0; if (IS_MDT(&mop->mo_ldd)) { - if (mop->mo_ldd.ldd_stripe_count > 77) + if (mop->mo_stripe_count > 77) inode_size = 512; /* bz 7241 */ - else if (mop->mo_ldd.ldd_stripe_count > 34) + /* cray stripes across all osts (>60) */ + else if (mop->mo_stripe_count > 34) inode_size = 2048; - else if (mop->mo_ldd.ldd_stripe_count > 13) + else if (mop->mo_stripe_count > 13) inode_size = 1024; else inode_size = 512; @@ -792,9 +791,7 @@ void set_defaults(struct mkfs_opts *mop) mop->mo_ldd.ldd_mount_type = LDD_MT_LDISKFS; mop->mo_ldd.ldd_svindex = INDEX_UNASSIGNED; - mop->mo_ldd.ldd_stripe_count = 1; - mop->mo_ldd.ldd_stripe_sz = 1024 * 1024; - mop->mo_ldd.ldd_stripe_pattern = 0; + mop->mo_stripe_count = 1; } static inline void badopt(const char *opt, char *type) @@ -809,32 +806,28 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, { static struct option long_opt[] = { {"backfstype", 1, 0, 'b'}, + {"stripe-count-hint", 1, 0, 'c'}, {"configdev", 1, 0, 'C'}, {"device-size", 1, 0, 'd'}, - {"fsname",1, 0, 'n'}, {"failover", 1, 0, 'f'}, - {"help", 0, 0, 'h'}, - {"mdt", 0, 0, 'M'}, {"mgs", 0, 0, 'G'}, - {"mgsnid", 1, 0, 'm'}, + {"help", 0, 0, 'h'}, + {"index", 1, 0, 'i'}, {"mkfsoptions", 1, 0, 'k'}, - {"mountfsoptions", 1, 0, 'o'}, + {"mgsnid", 1, 0, 'm'}, + {"mdt", 0, 0, 'M'}, + {"fsname",1, 0, 'n'}, {"nomgs", 0, 0, 'N'}, + {"mountfsoptions", 1, 0, 'o'}, {"ost", 0, 0, 'O'}, {"print", 0, 0, 'p'}, {"quiet", 0, 0, 'q'}, {"reformat", 0, 0, 'r'}, - {"startupwait", 1, 0, 'w'}, - {"stripe-count", 1, 0, 'c'}, - {"stripe-size", 1, 0, 's'}, - {"stripe-index", 1, 0, 'i'}, - {"index", 1, 0, 'i'}, - {"timeout", 1, 0, 't'}, {"verbose", 0, 0, 'v'}, {"writeconf", 0, 0, 'w'}, {0, 0, 0, 0} }; - char *optstring = "b:C:d:n:f:hI:MGm:k:No:Opqrw:c:s:i:t:vw"; + char *optstring = "b:c:C:d:f:Ghi:k:m:Mn:No:Opqrvw"; char opt; int longidx; @@ -860,7 +853,7 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, "%d\n", progname, stripe_count); return 1; } - mop->mo_ldd.ldd_stripe_count = stripe_count; + mop->mo_stripe_count = stripe_count; } else { badopt(long_opt[longidx].name, "MDT"); return 1; @@ -965,18 +958,6 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, case 'r': mop->mo_flags |= MO_FORCEFORMAT; break; - case 's': - if (IS_MDT(&mop->mo_ldd)) { - mop->mo_ldd.ldd_stripe_sz = atol(optarg) * 1024; - } else { - badopt(long_opt[longidx].name, "MDT"); - return 1; - } - break; - case 't': - mop->mo_ldd.ldd_timeout = atol(optarg); - mop->mo_ldd.ldd_flags |= LDD_F_UPDATE; - break; case 'v': verbose++; break; diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index d01016c..2742a16 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -202,7 +202,7 @@ static const struct opt_map opt_map[] = { { "nouser_xattr", 1, 1, 0 }, /* Disable user xattr */ { "acl", 0, 0, 0 }, /* Enable ACL support */ { "noacl", 1, 1, 0 }, /* Disable ACL support */ - { "nosvc", 0, 0, 0 }, /* Only start MGS/MGC, no other services */ + { "nosvc", 0, 0, 0 }, /* Only start MGS/MGC, nothing else */ { "exclude", 0, 0, 0 }, /* OST exclusion list */ { NULL, 0, 0, 0 } }; diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 8a9a1f5..4a78e49 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -129,19 +129,6 @@ do { \ } \ } while (0) -int obd_record(enum cfg_record_type type, int len, void *ptr) -{ - struct obd_ioctl_data data; - - IOC_INIT(data); - data.ioc_type = type; - data.ioc_plen1 = len; - data.ioc_pbuf1 = ptr; - IOC_PACK("obd_record", data); - - return l_ioctl(OBD_DEV_ID, OBD_IOC_DORECORD, &data); -} - int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg) { int opc; @@ -165,6 +152,37 @@ int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg) return rc; } +int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg) +{ + struct obd_ioctl_data data; + static int mgs_device = -1; + int rc; + + /* Always operates on MGS dev */ + if (mgs_device == -1) { + static int do_device(char *func, char *devname); + do_disconnect(NULL, 1); + rc = do_device("mgsioc", "MGS"); + if (rc) { + errno = ENODEV; + return -1; + } + mgs_device = cur_device; + } + + IOC_INIT(data); + data.ioc_dev = mgs_device; + data.ioc_type = LUSTRE_CFG_TYPE; + data.ioc_plen1 = lustre_cfg_len(lcfg->lcfg_bufcount, + lcfg->lcfg_buflens); + data.ioc_pbuf1 = (void *)lcfg; + IOC_PACK(func, data); + + rc = l_ioctl(dev_id, OBD_IOC_PARAM, buf); + + return rc; +} + char *obdo_print(struct obdo *obd) { char buf[1024]; diff --git a/lustre/utils/obdctl.h b/lustre/utils/obdctl.h index 4155770..430bcdc 100644 --- a/lustre/utils/obdctl.h +++ b/lustre/utils/obdctl.h @@ -69,6 +69,7 @@ int jt_llog_remove(int argc, char **argv); int jt_llog_check(int argc, char **argv); int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg); +int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg); int parse_devname(char *func, char *name); char *jt_cmdname(char *func); @@ -89,6 +90,7 @@ int jt_lcfg_set_lustre_upcall(int argc, char **argv); int jt_lcfg_add_conn(int argc, char **argv); int jt_lcfg_del_conn(int argc, char **argv); int jt_lcfg_param(int argc, char **argv); +int jt_lcfg_mgsparam(int argc, char **argv); int obd_add_uuid(char *uuid, lnet_nid_t nid);