From bf077c4ecd3a25132b35d15cd936a4ea5ef89ea8 Mon Sep 17 00:00:00 2001 From: fanyong Date: Thu, 29 Nov 2007 03:59:48 +0000 Subject: [PATCH] Branch HEAD b=14135 i=nathan i=huanghua Original "mgc_logname2resid" process both "logname" (which consists of fsname-nodetype) and "fsname", it can not distinguish "-" contained fsname and the logname. Split it into two functions: "mgc_logname2resid" and "mgs_fsname2resid" for that. --- lustre/include/lustre_disk.h | 2 +- lustre/mdt/mdt_handler.c | 2 +- lustre/mgc/mgc_request.c | 41 ++++++++++++++++++++++++++--------------- lustre/mgs/mgs_handler.c | 2 +- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 2460aa7..fd8c664 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -281,7 +281,7 @@ struct mgs_target_info; int server_mti_print(char *title, struct mgs_target_info *mti); /* mgc_request.c */ -int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id); +int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id); #endif diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 89cb9b9..0827ff4 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4365,7 +4365,7 @@ static void mdt_allow_cli(struct mdt_device *m, unsigned int flag) if (flag & CONFIG_SYNC) m->mdt_fl_synced = 1; - if (m->mdt_fl_cfglog && m->mdt_fl_synced) + if (m->mdt_fl_cfglog /* bz11778: && m->mdt_fl_synced */) /* Open for clients */ m->mdt_md_dev.md_lu_dev.ld_obd->obd_no_conn = 0; } diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index ee8cd34..01d85bd 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -45,38 +45,49 @@ #include #include -int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id) +static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id) { - char *name_end; - int len; __u64 resname = 0; - /* fsname is at most 8 chars long at the beginning of the logname - e.g. "lustre-MDT0001" or "lustre" */ - name_end = strrchr(logname, '-'); - if (name_end) - len = name_end - logname; - else - len = strlen(logname); if (len > 8) { - CERROR("fsname too long: %s\n", logname); + CERROR("name too long: %s\n", name); return -EINVAL; } if (len <= 0) { - CERROR("missing fsname: %s\n", logname); + CERROR("missing name: %s\n", name); return -EINVAL; } - memcpy(&resname, logname, len); + memcpy(&resname, name, len); memset(res_id, 0, sizeof(*res_id)); /* Always use the same endianness for the resid */ res_id->name[0] = cpu_to_le64(resname); - CDEBUG(D_MGC, "log %s to resid "LPX64"/"LPX64" (%.8s)\n", logname, + CDEBUG(D_MGC, "log %s to resid "LPX64"/"LPX64" (%.8s)\n", name, res_id->name[0], res_id->name[1], (char *)&res_id->name[0]); return 0; } -EXPORT_SYMBOL(mgc_logname2resid); + +int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id) +{ + /* fsname is at most 8 chars long, maybe contain "-". + * e.g. "lustre", "CFS-000" */ + return mgc_name2resid(fsname, strlen(fsname), res_id); +} +EXPORT_SYMBOL(mgc_fsname2resid); + +int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id) +{ + char *name_end; + int len; + + /* logname consists of "fsname-nodetype". + * e.g. "lustre-MDT0001", "CFS-000-client" */ + name_end = strrchr(logname, '-'); + LASSERT(name_end); + len = name_end - logname; + return mgc_name2resid(logname, len, res_id); +} /********************** config llog list **********************/ static struct list_head config_llog_list = LIST_HEAD_INIT(config_llog_list); diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index b7c670e..338905e 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -293,7 +293,7 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname, int rc, flags = 0; ENTRY; - rc = mgc_logname2resid(fsname, &res_id); + rc = mgc_fsname2resid(fsname, &res_id); if (!rc) rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, NULL, LCK_EX, -- 1.8.3.1