From c1e5df9946fb4d4d0a1124de52dacec0493ae0ec Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 2 Jan 2006 22:31:00 +0000 Subject: [PATCH] Branch b1_4_mountconf b=9851 - moving towards live ost addition - encode fsname in config log resource - more robust error cleanup from server_fill_super - D_TRACE entry/exits --- lustre/include/linux/lustre_disk.h | 3 + lustre/llite/llite_lib.c | 2 +- lustre/lov/lov_obd.c | 44 +++++-- lustre/mds/handler.c | 4 + lustre/mgc/mgc_request.c | 52 ++++++-- lustre/mgs/mgs_handler.c | 3 +- lustre/obdclass/obd_mount.c | 257 ++++++++++++++++++++----------------- 7 files changed, 225 insertions(+), 140 deletions(-) diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index d035281..4d9dcb3 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -240,6 +240,9 @@ int config_log_end(char *instance); struct config_llog_data *config_log_get(char *name); void config_log_put(void); +/* mgc_request.c */ +int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id); + #endif diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index c4ab3b8..ec64ca6 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -512,7 +512,7 @@ int ll_fill_super(struct super_block *sb) RETURN(-ENOMEM); ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); - + /* Generate a string unique to this super, in case some joker tries to mount the same fs at two mount points. Use the address of the super itself.*/ diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index ee437a0..05f8c93 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -109,15 +109,17 @@ static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, int rc; ENTRY; - class_obd_list(); tgt_obd = class_find_client_obd(tgt_uuid, LUSTRE_OSC_NAME, &obd->obd_uuid); - + if (!tgt_obd) { CERROR("Target %s not attached\n", tgt_uuid->uuid); RETURN(-EINVAL); } + + CDEBUG(D_ERROR, "Connect tgt %s (%s)\n", (char *)tgt->uuid.uuid, + tgt_obd->obd_name); if (!tgt_obd->obd_set_up) { CERROR("Target %s not set up\n", tgt_uuid->uuid); @@ -260,7 +262,8 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) int rc; ENTRY; - CDEBUG(D_CONFIG, "Disconnecting lov target %s\n", obd->obd_uuid.uuid); + CDEBUG(D_CONFIG, "Disconnecting target %s from %s\n", + osc_obd->obd_name, obd->obd_name); lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lov_proc_dir) { @@ -432,7 +435,7 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) struct lov_tgt_desc *tgt; struct obd_export *exp_observer; __u32 bufsize; - __u32 size = 2; + __u32 size; obd_id params[2]; int rc, old_count; ENTRY; @@ -503,7 +506,7 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) if (osc_obd) osc_obd->obd_no_recov = 0; } - + /* NULL may need to change when we use flags for osc's */ rc = lov_connect_obd(obd, tgt, 1, NULL); if (rc || !obd->obd_observer) @@ -514,23 +517,35 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) llog_cat_initialize(obd->obd_observer, lov->desc.ld_tgt_count); params[0] = index; + /* FIXME we must try to mds_lov_read_objids insetad of obd_get_info + to allow the mdt to start before the ost */ rc = obd_get_info(tgt->ltd_exp, strlen("last_id"), "last_id", &size, ¶ms[1]); if (rc) GOTO(out, rc); exp_observer = obd->obd_observer->obd_self_export; - rc = obd_set_info(exp_observer, strlen("next_id"),"next_id", + rc = obd_set_info(exp_observer, strlen("next_id"), "next_id", sizeof(params), params); if (rc) GOTO(out, rc); - rc = lov_notify(obd, tgt->ltd_exp->exp_obd, 1); - GOTO(out, rc); + rc = lov_notify(obd, tgt->ltd_exp->exp_obd, OBD_NOTIFY_ACTIVE); + + /* if we added after the disconnect */ + if (lov->connects == 0) { + CERROR("Disconnected\n"); + rc = -ENODEV; + } + out: - if (rc && tgt->ltd_exp != NULL) - lov_disconnect_obd(obd, tgt); - return rc; + if (rc) { + CERROR("add failed (%d), deleting %s\n", rc, + (char *)tgt->uuid.uuid); + //lov_disconnect_obd(obd, tgt); + lov_del_obd(obd, &tgt->uuid, index, 0); + } + RETURN(rc); } /* Schedule a target for deletion */ @@ -556,7 +571,7 @@ lov_del_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) RETURN(-EINVAL); } - if (strncmp(uuidp->uuid, tgt->uuid.uuid, sizeof uuidp->uuid) != 0) { + if (!obd_uuid_equals(uuidp, &tgt->uuid)) { CERROR("LOV target UUID %s at index %d doesn't match %s.\n", tgt->uuid.uuid, index, uuidp->uuid); RETURN(-EINVAL); @@ -749,7 +764,10 @@ static int lov_cleanup(struct obd_device *obd) /* We should never get here - these should have been removed in the disconnect. */ if (!obd_uuid_empty(&tgt->uuid)) { - CERROR("lov tgt %d not cleaned!\n", i); + CERROR("lov tgt %d not cleaned!" + " deathrow=%d, lovrc=%d\n", + i, lov->death_row, + atomic_read(&lov->refcount)); lov_del_obd(obd, &tgt->uuid, i, 0); } } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index dbc7c50..041ff05 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2246,6 +2246,10 @@ static int mds_set_info(struct obd_export *exp, obd_count keylen, if (idx > mds->mds_lov_desc.ld_tgt_count) RETURN(-EINVAL); + /* FIXME realloc mds_lov_objids -- + see HEAD mds_dt_update_desc */ + LASSERT("FIXME must realloc mds_lov_objids"); + mds->mds_lov_objids[idx] = id; //mds->mds_lov_objids_valid = 1; diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 85c7dcb..637186d 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -183,6 +183,23 @@ err_decref: RETURN(rc); } +int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id) +{ + char *name_end; + + /* fsname is at most 8 chars long at the beginning of the logname + e.g. "lustre-MDT0001" or "lustre" */ + name_end = strchr(logname, '-'); + if (!name_end) + name_end = logname + strlen(logname); + LASSERT(name_end - logname <= 8); + + memcpy(&res_id->name[0], logname, name_end - logname); + CDEBUG(D_MGC, "log %s to resid "LPX64"\n", logname, res_id->name[0]); + return 0; +} +EXPORT_SYMBOL(mgc_logname2resid); + /* based on ll_mdc_blocking_ast */ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) @@ -191,6 +208,10 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, struct lustre_handle lockh; ENTRY; + /* FIXME should pass logname,sb as part of lock->l_ast_data, + lustre_get_process_log that. Or based on resource. + Either way, must have one lock per llog. */ + switch (flag) { case LDLM_CB_BLOCKING: /* mgs wants the lock, give it up... */ @@ -199,27 +220,39 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, ldlm_lock2handle(lock, &lockh); rc = ldlm_cli_cancel(&lockh); if (rc < 0) { - CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc); + CDEBUG(D_MGC, "ldlm_cli_cancel: %d\n", rc); RETURN(rc); } break; case LDLM_CB_CANCELING: { + char fsname[9]; + /* We've given up the lock, prepare ourselves to update. FIXME */ LDLM_ERROR(lock, "MGC cancel CB"); - //struct inode *inode = ll_inode_from_lock(lock); + //see struct inode *inode = ll_inode_from_lock(lock); + + memcpy(fsname, &lock->l_resource->lr_name.name[0], 8); + fsname[8] = 0; + CERROR("Lock res "LPX64" (%s)\n", + lock->l_resource->lr_name.name[0], fsname); + + /* Make sure not to re-enqueue when the mgc is stopping + (we get called from client_disconnect_export) */ + if (!lock->l_conn_export || + !lock->l_conn_export->exp_obd->u.cli.cl_conn_count) + break; + + CERROR("Re-enqueue all locks on fs '%s'\n", fsname); + /* reenque _all_ logs that match the beginning fsname - + clients and servers */ + /* in the MGC case I suspect this callback will trigger a new enqueue for the same lock (in a separate thread likely, which won't match the just-being-cancelled lock due to CBPENDING flag) + config llog processing */ - /* FIXME make sure not to re-enqueue when the mgc is stopping - (we get called from client_disconnect_export) */ - - CERROR("Lock res "LPU64"\n", lock->l_resource->lr_name.name[0]); - /* FIXME should pass logname,sb as part of lock->l_ast_data, - lustre_get_process_log that. Or based on resource. - Either way, must have one lock per llog. */ + //update_llog(); break; @@ -249,6 +282,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, LASSERT(type == LDLM_PLAIN); CDEBUG(D_MGC, "Enqueue for %s\n", (char *)data); + rc = mgc_logname2resid(data, &res_id); /* Search for already existing locks.*/ rc = ldlm_lock_match(obd->obd_namespace, 0, &res_id, type, diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 90f3310..c71287b 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -273,11 +273,12 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname, int rc, flags = 0; CERROR("mgs_lock %s\n", fsname); + rc = mgc_logname2resid(fsname, &res_id); rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, res_id, LDLM_PLAIN, NULL, LCK_EX, &flags, ldlm_blocking_ast, ldlm_completion_ast, - NULL, NULL, NULL, 0, NULL, lockh); + NULL, fsname, NULL, 0, NULL, lockh); if (rc) { CERROR("can't take cfg lock %d\n", rc); } diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index f93e398..c0984a4 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -25,7 +25,7 @@ #define DEBUG_SUBSYSTEM S_MGMT -#define D_MOUNT D_SUPER|D_CONFIG|D_ERROR +#define D_MOUNT D_SUPER|D_CONFIG|D_WARNING #define PRINT_CMD LCONSOLE #define PRINT_MASK D_WARNING @@ -68,16 +68,18 @@ static int server_register_mount(char *name, struct super_block *sb, { struct lustre_mount_info *lmi; char *name_cp; + ENTRY; + LASSERT(mnt); LASSERT(sb); OBD_ALLOC(lmi, sizeof(*lmi)); if (!lmi) - return -ENOMEM; + RETURN(-ENOMEM); OBD_ALLOC(name_cp, strlen(name) + 1); if (!name_cp) { OBD_FREE(lmi, sizeof(*lmi)); - return -ENOMEM; + RETURN(-ENOMEM); } strcpy(name_cp, name); @@ -88,7 +90,7 @@ static int server_register_mount(char *name, struct super_block *sb, OBD_FREE(lmi, sizeof(*lmi)); OBD_FREE(name_cp, strlen(name) + 1); CERROR("Already registered %s\n", name); - return -EEXIST; + RETURN(-EEXIST); } lmi->lmi_name = name_cp; lmi->lmi_sb = sb; @@ -100,20 +102,21 @@ static int server_register_mount(char *name, struct super_block *sb, CDEBUG(D_MOUNT, "reg_mnt %p from %s, vfscount=%d\n", lmi->lmi_mnt, name, atomic_read(&lmi->lmi_mnt->mnt_count)); - return 0; + RETURN(0); } /* when an obd no longer needs a mount */ static int server_deregister_mount(char *name) { struct lustre_mount_info *lmi; - + ENTRY; + down(&lustre_mount_info_lock); lmi = server_find_mount(name); if (!lmi) { up(&lustre_mount_info_lock); CERROR("%s not registered\n", name); - return -ENOENT; + RETURN(-ENOENT); } CDEBUG(D_MOUNT, "dereg_mnt %p from %s, vfscount=%d\n", @@ -124,7 +127,7 @@ static int server_deregister_mount(char *name) OBD_FREE(lmi, sizeof(*lmi)); up(&lustre_mount_info_lock); - return 0; + RETURN(0); } /* Deregister anyone referencing the mnt. Everyone should have @@ -157,6 +160,7 @@ struct lustre_mount_info *server_get_mount(char *name) { struct lustre_mount_info *lmi; struct lustre_sb_info *lsi; + ENTRY; down(&lustre_mount_info_lock); @@ -164,7 +168,7 @@ struct lustre_mount_info *server_get_mount(char *name) if (!lmi) { up(&lustre_mount_info_lock); CERROR("Can't find mount for %s\n", name); - return NULL; + RETURN(NULL); } lsi = s2lsi(lmi->lmi_sb); mntget(lmi->lmi_mnt); @@ -176,7 +180,7 @@ struct lustre_mount_info *server_get_mount(char *name) lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts), atomic_read(&lmi->lmi_mnt->mnt_count)); - return lmi; + RETURN(lmi); } static void unlock_mntput(struct vfsmount *mnt) @@ -195,13 +199,14 @@ int server_put_mount(char *name, struct vfsmount *mnt) { struct lustre_mount_info *lmi; struct lustre_sb_info *lsi; + ENTRY; down(&lustre_mount_info_lock); lmi = server_find_mount(name); if (!lmi) { up(&lustre_mount_info_lock); CERROR("Can't find mount for %s\n", name); - return -ENOENT; + RETURN(-ENOENT); } lsi = s2lsi(lmi->lmi_sb); LASSERT(lmi->lmi_mnt == mnt); @@ -224,7 +229,7 @@ int server_put_mount(char *name, struct vfsmount *mnt) /* this obd should never need the mount again */ server_deregister_mount(name); - return 0; + RETURN(0); } @@ -258,14 +263,15 @@ static int ldd_parse(struct lvfs_run_ctxt *mount_ctxt, loff_t off = 0; unsigned long len; int rc; - + ENTRY; + push_ctxt(&saved, mount_ctxt, NULL); file = filp_open(MOUNT_DATA_FILE, O_RDONLY, 0644); if (IS_ERR(file)) { rc = PTR_ERR(file); CERROR("cannot open %s: rc = %d\n", MOUNT_DATA_FILE, rc); - goto out; + GOTO(out, rc); } len = file->f_dentry->d_inode->i_size; @@ -296,7 +302,7 @@ out_close: filp_close(file, 0); out: pop_ctxt(&saved, mount_ctxt, NULL); - return(rc); + RETURN(rc); } static int ldd_write(struct lvfs_run_ctxt *mount_ctxt, @@ -307,6 +313,7 @@ static int ldd_write(struct lvfs_run_ctxt *mount_ctxt, loff_t off = 0; unsigned long len = sizeof(struct lustre_disk_data); int rc = 0; + ENTRY; LASSERT(ldd->ldd_magic == LDD_MAGIC); @@ -316,7 +323,7 @@ static int ldd_write(struct lvfs_run_ctxt *mount_ctxt, if (IS_ERR(file)) { rc = PTR_ERR(file); CERROR("cannot open %s: rc = %d\n", MOUNT_DATA_FILE, rc); - goto out; + GOTO(out, rc); } rc = lustre_fwrite(file, ldd, len, &off); @@ -333,7 +340,7 @@ out_close: filp_close(file, 0); out: pop_ctxt(&saved, mount_ctxt, NULL); - return(rc); + RETURN(rc); } #if 0 @@ -410,6 +417,7 @@ void config_log_put(void) up(&config_llog_lock); } +/* Add this log to our list of active logs */ static int config_log_add(char *name) { struct config_llog_data *cld; @@ -467,6 +475,7 @@ static void config_log_end_all(void) { struct list_head *tmp, *n; struct config_llog_data *cld; + ENTRY; down(&config_llog_lock); list_for_each_safe(tmp, n, &config_llog_list) { @@ -477,6 +486,7 @@ static void config_log_end_all(void) OBD_FREE(cld, sizeof(*cld)); } up(&config_llog_lock); + EXIT; } /**************** config llog ********************/ @@ -490,7 +500,6 @@ int config_log_start(struct super_block *sb, char *logname, struct lustre_cfg_bufs bufs; struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; - struct llog_ctxt *lctxt; int rc; ENTRY; @@ -501,12 +510,6 @@ int config_log_start(struct super_block *sb, char *logname, else config_log_add(logname); - lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); - if (!lctxt) { - CERROR("missing llog context\n"); - return(-EINVAL); - } - 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)); @@ -514,14 +517,23 @@ int config_log_start(struct super_block *sb, char *logname, rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - if (rc && !lmd_is_client(lsi->lsi_lmd)) { + if (rc && (rc != -EINTR) && !lmd_is_client(lsi->lsi_lmd)) { int rc2; + struct llog_ctxt *lctxt; + LCONSOLE_INFO("%s: The configuration '%s' could not be read " "from the MGS (%d). Trying local log.\n", mgc->obd_name, logname, rc); /* If we couldn't connect to the MGS, try reading a copy of the config log stored locally on disk */ - rc2 = class_config_parse_llog(lctxt, logname, cfg); + lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); + if (lctxt) { + rc2 = class_config_parse_llog(lctxt, logname, cfg); + } else { + CERROR("missing llog context\n"); + rc2 = -EINVAL; + } + if (rc2) { CERROR("%s: Can't read the local config (%d)\n", mgc->obd_name, rc2); @@ -595,6 +607,7 @@ static int server_start_mgs(struct super_block *sb) struct lustre_mount_info *lmi; char mgsname[] = "MGS"; int rc = 0; + ENTRY; LASSERT(mnt); /* It is impossible to have more than 1 MGS per node, since @@ -604,7 +617,7 @@ static int server_start_mgs(struct super_block *sb) lsi = s2lsi(lmi->lmi_sb); LCONSOLE_ERROR("The MGS service was already started from " "server %s\n", lsi->lsi_ldd->ldd_svname); - return -EALREADY; + RETURN(-EALREADY); } CDEBUG(D_CONFIG, "Start MGS service %s\n", mgsname); @@ -619,7 +632,7 @@ static int server_start_mgs(struct super_block *sb) LCONSOLE_ERROR("Failed to start MGS %s (%d). Is the 'mgs' " "module loaded?\n", mgsname, rc); - return rc; + RETURN(rc); } static int server_stop_mgs(struct super_block *sb) @@ -627,6 +640,7 @@ static int server_stop_mgs(struct super_block *sb) struct obd_device *obd; char mgsname[] = "MGS"; int rc; + ENTRY; CDEBUG(D_MOUNT, "Stop MGS service %s\n", mgsname); @@ -634,13 +648,13 @@ static int server_stop_mgs(struct super_block *sb) obd = class_name2obd(mgsname); if (!obd) { CDEBUG(D_CONFIG, "mgs %s not running\n", mgsname); - return -EALREADY; + RETURN(-EALREADY); } /* The MGS should always stop when we say so */ obd->obd_force = 1; rc = class_manual_cleanup(obd); - return rc; + RETURN(rc); } static struct obd_export *mgc_mgs_export = NULL; @@ -658,7 +672,8 @@ static int lustre_start_mgc(struct super_block *sb) lnet_process_id_t id; int recov_bk; int rc = 0, i; - + ENTRY; + LASSERT(lsi->lsi_lmd); obd = class_name2obd(mgcname); @@ -669,12 +684,12 @@ static int lustre_start_mgc(struct super_block *sb) or not? If there's truly one MGS per site, the MGS uuids _should_ all be the same. Maybe check here? */ - goto out; + GOTO(out, rc); } if (lsi->lsi_lmd->lmd_mgsnid_count == 0) { LCONSOLE_ERROR("No NIDs for the MGS were given.\n"); - return (-EINVAL); + RETURN(-EINVAL); } CDEBUG(D_MOUNT, "Start MGC %s\n", mgcname); @@ -683,7 +698,7 @@ static int lustre_start_mgc(struct super_block *sb) nid = lsi->lsi_lmd->lmd_mgsnid[0]; rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid), 0,0,0); if (rc < 0) - return rc; + RETURN(rc); /* Generate a unique uuid for each MGC - use the 1st non-loopback nid */ i = 0; @@ -699,7 +714,7 @@ static int lustre_start_mgc(struct super_block *sb) libcfs_nid2str(nid)); OBD_FREE(uuid, sizeof(struct obd_uuid)); if (rc) - return rc; + RETURN(rc); /* Add the redundant MGS nids */ for (i = 1; i < lsi->lsi_lmd->lmd_mgsnid_count; i++) { @@ -721,7 +736,7 @@ static int lustre_start_mgc(struct super_block *sb) obd = class_name2obd(mgcname); if (!obd) { CERROR("Can't find mgcobd %s\n", mgcname); - return (-ENOTCONN); + RETURN(-ENOTCONN); } /* Don't try to recover the mgs connection */ @@ -731,14 +746,14 @@ static int lustre_start_mgc(struct super_block *sb) sizeof(recov_bk), &recov_bk); if (rc) { CERROR("can't set init_recov_bk %d\n", rc); - goto out; + GOTO(out, rc); } /* We connect to the MGS at setup, and don't disconnect until cleanup */ rc = obd_connect(&mgc_conn, obd, &(obd->obd_uuid), NULL); if (rc) { CERROR("connect failed %d\n", rc); - goto out; + GOTO(out, rc); } exp = class_conn2export(&mgc_conn); @@ -753,7 +768,7 @@ out: /* Keep the mgc info in the sb. Note that many lsi's can point to the same mgc.*/ lsi->lsi_mgc = obd; - return rc; + RETURN(rc); } static int lustre_stop_mgc(struct super_block *sb) @@ -762,10 +777,13 @@ static int lustre_stop_mgc(struct super_block *sb) struct obd_device *obd; lnet_nid_t nid; int i, rc; + ENTRY; + if (!lsi) + RETURN(-ENOENT); obd = lsi->lsi_mgc; if (!obd) - return -ENOENT; + RETURN(-ENOENT); lsi->lsi_mgc = NULL; if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) { @@ -773,7 +791,7 @@ static int lustre_stop_mgc(struct super_block *sb) will call in here. */ CDEBUG(D_MOUNT, "mgc still has %d references.\n", atomic_read(&obd->u.cli.cl_mgc_refcount)); - return -EBUSY; + RETURN(-EBUSY); } if (mgc_mgs_export) @@ -782,7 +800,7 @@ static int lustre_stop_mgc(struct super_block *sb) rc = class_manual_cleanup(obd); if (rc) - return(rc); + RETURN(rc); /* class_add_uuid adds a nid even if the same uuid exists; we might delete any copy here. So they all better match. */ @@ -798,7 +816,7 @@ static int lustre_stop_mgc(struct super_block *sb) config_log_end_all(); - return 0; + RETURN(0); } /* Since there's only one mgc per node, we have to change it's fs to get @@ -807,7 +825,8 @@ static int server_mgc_set_fs(struct obd_device *mgc, struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); int rc; - + ENTRY; + CDEBUG(D_MOUNT, "Set mgc disk for %s\n", lsi->lsi_lmd->lmd_dev); /* cl_mgc_sem in mgc insures we sleep if the mgc_fs is busy */ @@ -818,18 +837,19 @@ static int server_mgc_set_fs(struct obd_device *mgc, struct super_block *sb) CERROR("can't set_fs %d\n", rc); } - return rc; + RETURN(rc); } static int server_mgc_clear_fs(struct obd_device *mgc) { int rc; - + ENTRY; + CDEBUG(D_MOUNT, "Unassign mgc disk\n"); rc = obd_set_info(mgc->obd_self_export, strlen("clear_fs"), "clear_fs", 0, NULL); - return rc; + RETURN(rc); } /* Stop MDS/OSS if nobody is using them */ @@ -838,6 +858,7 @@ static int server_stop_servers(struct super_block *sb) struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *obd; int rc; + ENTRY; /* if this was an MDT, and there are no more MDT's, clean up the MDS */ if (IS_MDT(lsi->lsi_ldd) && (obd = class_name2obd("MDS"))) { @@ -868,7 +889,7 @@ static int server_stop_servers(struct super_block *sb) rc = err; } } - return rc; + RETURN(rc); } /* Add this target to the fs, get a new index if needed */ @@ -881,6 +902,8 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt) lnet_process_id_t id; int i = 0; int rc; + ENTRY; + LASSERT(mgc); /* send MGMT_TARGET_ADD rpc via MGC, MGS should reply with an @@ -888,7 +911,7 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt) OBD_ALLOC(mti, sizeof(*mti)); if (!mti) { - return -ENOMEM; + RETURN(-ENOMEM); } strncpy(mti->mti_fsname, ldd->ldd_fsname, sizeof(mti->mti_fsname)); @@ -923,7 +946,7 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt) CDEBUG(D_MOUNT, "disconnect"); if (rc) { CERROR("add_target failed %d\n", rc); - goto out; + GOTO(out, rc); } /* If this flag is still set, it means we need to change our on-disk @@ -947,7 +970,7 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt) out: if (mti) OBD_FREE(mti, sizeof(*mti)); - return rc; + RETURN(rc); } /* Start targets */ @@ -957,7 +980,8 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) struct lustre_sb_info *lsi = s2lsi(sb); struct config_llog_instance cfg; int rc; - + ENTRY; + CDEBUG(D_MOUNT, "starting target %s\n", lsi->lsi_ldd->ldd_svname); /* If we're an MDT, make sure the global MDS is running */ @@ -970,7 +994,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) "MDS_uuid", 0, 0); if (rc) { CERROR("failed to start MDS: %d\n", rc); - goto out_servers; + GOTO(out_servers, rc); } } } @@ -984,7 +1008,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) "OSS_uuid", 0, 0); if (rc) { CERROR("failed to start OSS: %d\n", rc); - goto out_servers; + GOTO(out_servers, rc); } } } @@ -1001,7 +1025,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) if (rc) { CERROR("Initial connect failed for %s: %d\n", lsi->lsi_ldd->ldd_svname, rc); - goto out; + GOTO(out, rc); } } @@ -1009,7 +1033,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) (we can't pass the sb or mnt through class_process_config.) */ rc = server_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt); if (rc) - goto out; + GOTO(out, rc); /* Start targets using the llog named for the target */ cfg.cfg_instance = NULL; @@ -1017,14 +1041,12 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) if (rc) { CERROR("failed to start server %s: %d\n", lsi->lsi_ldd->ldd_svname, rc); - server_deregister_mount(lsi->lsi_ldd->ldd_svname); - goto out; + GOTO(out, rc); } if (!class_name2obd(lsi->lsi_ldd->ldd_svname)) { CERROR("no server named %s was started\n", lsi->lsi_ldd->ldd_svname); - server_deregister_mount(lsi->lsi_ldd->ldd_svname); rc = -ENXIO; } @@ -1033,9 +1055,7 @@ out: server_mgc_clear_fs(lsi->lsi_mgc); out_servers: - if (rc) - server_stop_servers(sb); - return(rc); + RETURN(rc); } /***************** mount **************/ @@ -1043,19 +1063,20 @@ out_servers: struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = NULL; + ENTRY; OBD_ALLOC(lsi, sizeof(*lsi)); if (!lsi) - return(NULL); + RETURN(NULL); OBD_ALLOC(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); if (!lsi->lsi_lmd) { OBD_FREE(lsi, sizeof(*lsi)); - return(NULL); + RETURN(NULL); } s2lsi_nocast(sb) = lsi; atomic_set(&lsi->lsi_mounts, 0); - return(lsi); + RETURN(lsi); } static int lustre_free_lsi(struct super_block *sb) @@ -1063,34 +1084,35 @@ static int lustre_free_lsi(struct super_block *sb) struct lustre_sb_info *lsi = s2lsi(sb); ENTRY; - if (lsi != NULL) { - if (atomic_read(&lsi->lsi_mounts) > 0) { - /* someone didn't call server_put_mount */ - /* FIXME this should assert */ - CERROR("There are still mounts on this sb!\n"); - RETURN(-EBUSY); - } - if (lsi->lsi_ldd != NULL) - OBD_FREE(lsi->lsi_ldd, sizeof(*lsi->lsi_ldd)); - - if (lsi->lsi_lmd != NULL) { - if (lsi->lsi_lmd->lmd_dev != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_dev, - strlen(lsi->lsi_lmd->lmd_dev) + 1); - if (lsi->lsi_lmd->lmd_opts != NULL) - OBD_FREE(lsi->lsi_lmd->lmd_opts, - strlen(lsi->lsi_lmd->lmd_opts) + 1); - OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); - } - - LASSERT(lsi->lsi_llsbi == NULL); + if (!lsi) + RETURN(0); - server_deregister_mount_all(lsi->lsi_srv_mnt); - - OBD_FREE(lsi, sizeof(*lsi)); - s2lsi_nocast(sb) = NULL; + if (atomic_read(&lsi->lsi_mounts) > 0) { + /* someone didn't call server_put_mount */ + /* FIXME this should assert */ + CERROR("There are still mounts on this sb!\n"); + RETURN(-EBUSY); + } + if (lsi->lsi_ldd != NULL) + OBD_FREE(lsi->lsi_ldd, sizeof(*lsi->lsi_ldd)); + + if (lsi->lsi_lmd != NULL) { + if (lsi->lsi_lmd->lmd_dev != NULL) + OBD_FREE(lsi->lsi_lmd->lmd_dev, + strlen(lsi->lsi_lmd->lmd_dev) + 1); + if (lsi->lsi_lmd->lmd_opts != NULL) + OBD_FREE(lsi->lsi_lmd->lmd_opts, + strlen(lsi->lsi_lmd->lmd_opts) + 1); + OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); } + LASSERT(lsi->lsi_llsbi == NULL); + + server_deregister_mount_all(lsi->lsi_srv_mnt); + + OBD_FREE(lsi, sizeof(*lsi)); + s2lsi_nocast(sb) = NULL; + RETURN(0); } @@ -1108,10 +1130,11 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) char *options = NULL; unsigned long page, s_flags; int rc; + ENTRY; OBD_ALLOC(ldd, sizeof(*ldd)); if (!ldd) - return(ERR_PTR(-ENOMEM)); + RETURN(ERR_PTR(-ENOMEM)); /* In the past, we have always used flags = 0. Note ext3/ldiskfs can't be mounted ro. */ @@ -1123,7 +1146,7 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); CERROR("premount failed: rc = %d\n", rc); - goto out_free; + GOTO(out_free, rc); } OBD_SET_CTXT_MAGIC(&mount_ctxt); @@ -1136,17 +1159,16 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) if (rc) { CERROR("premount parse options failed: rc = %d\n", rc); - goto out_free; + GOTO(out_free, rc); } /* Done with our pre-mount, now do the real mount. */ /* Glom up mount options */ page = __get_free_page(GFP_KERNEL); - if (!page) { - rc = -ENOMEM; - goto out_free; - } + if (!page) + GOTO(out_free, rc = -ENOMEM); + options = (char *)page; memset(options, 0, PAGE_SIZE); strcpy(options, ldd->ldd_mount_opts); @@ -1170,17 +1192,17 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); CERROR("do_kern_mount failed: rc = %d\n", rc); - goto out_free; + GOTO(out_free, rc); } lsi->lsi_ldd = ldd; /* freed at lsi cleanup */ CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt); - return(mnt); + RETURN(mnt); out_free: OBD_FREE(ldd, sizeof(*ldd)); lsi->lsi_ldd = NULL; - return(ERR_PTR(rc)); + RETURN(ERR_PTR(rc)); } static void server_put_super(struct super_block *sb) @@ -1189,7 +1211,8 @@ static void server_put_super(struct super_block *sb) struct obd_device *obd; struct vfsmount *mnt = lsi->lsi_srv_mnt; int rc; - + ENTRY; + CDEBUG(D_MOUNT, "server put_super %s\n", lsi->lsi_ldd->ldd_svname); config_log_end(lsi->lsi_ldd->ldd_svname); @@ -1208,6 +1231,7 @@ static void server_put_super(struct super_block *sb) class_manual_cleanup(obd); } else { CERROR("no obd %s\n", lsi->lsi_ldd->ldd_svname); + server_deregister_mount(lsi->lsi_ldd->ldd_svname); } server_stop_servers(sb); @@ -1227,28 +1251,32 @@ static void server_put_super(struct super_block *sb) /* drop the One True Mount */ unlock_mntput(mnt); + EXIT; } static void server_umount_begin(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - + ENTRY; + CDEBUG(D_MOUNT, "umount -f\n"); /* umount = normal umount -f = failover no third way to do LSI_UMOUNT_FORCE */ lsi->lsi_flags |= LSI_UMOUNT_FAILOVER; + EXIT; } static int server_statfs (struct super_block *sb, struct kstatfs *buf) { struct vfsmount *mnt = s2lsi(sb)->lsi_srv_mnt; - + ENTRY; + if (mnt && mnt->mnt_sb && mnt->mnt_sb->s_op->statfs) { int rc = mnt->mnt_sb->s_op->statfs(mnt->mnt_sb, buf); if (!rc) { buf->f_type = sb->s_magic; - return 0; + RETURN(0); } } @@ -1261,7 +1289,7 @@ static int server_statfs (struct super_block *sb, struct kstatfs *buf) buf->f_files = 1; buf->f_ffree = 0; buf->f_namelen = NAME_MAX; - return 0; + RETURN(0); } static struct super_operations server_ops = @@ -1383,14 +1411,7 @@ static int server_fill_super(struct super_block *sb) out_mnt: server_put_super(sb); -#if 0 - if (mgs_service) - server_stop_mgs(sb); - /* mgc is stopped in lustre_fill_super */ - unlock_mntput(mnt); -#endif out: - //if (lsi->lsi_ldd) class_del_profile(lsi->lsi_ldd->ldd_svname); RETURN(rc); } @@ -1401,20 +1422,22 @@ out: int lustre_common_put_super(struct super_block *sb) { int rc; + ENTRY; + CDEBUG(D_MOUNT, "dropping sb %p\n", sb); rc = lustre_stop_mgc(sb); if (rc && (rc != -ENOENT)) { if (rc != -EBUSY) { CERROR("Can't stop MGC: %d\n", rc); - return rc; + RETURN(rc); } /* BUSY just means that there's some other obd that needs the mgc. Let him clean it up. */ CDEBUG(D_MOUNT, "MGC busy, will stop later\n"); } rc = lustre_free_lsi(sb); - return rc; + RETURN(rc); } static void lmd_print(struct lustre_mount_data *lmd) @@ -1593,7 +1616,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) rc = (*client_fill_super)(sb); } } else { - CDEBUG(D_MOUNT, "Mounting server\n"); + CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev); rc = server_fill_super(sb); /* s_f_s calls lustre_start_mgc after the mount because we need the MGS nids which are stored on disk. Plus, we may @@ -1602,7 +1625,9 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) out: if (rc){ - CERROR("Unable to mount %s\n", lmd->lmd_dev); + /* s_f_s will call server_put_super on failure */ + CERROR("Unable to mount %s\n", + s2lsi(sb) ? lmd->lmd_dev : ""); lustre_stop_mgc(sb); lustre_free_lsi(sb); } else { -- 1.8.3.1