From aea68c8a80664fb56d1b67a0e9077446bb0d317b Mon Sep 17 00:00:00 2001 From: fanyong Date: Thu, 29 Nov 2007 04:06:24 +0000 Subject: [PATCH] Branch b1_6 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/mgc/mgc_request.c | 46 ++++++++++++++++++++++++++++---------------- lustre/mgs/mgs_handler.c | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 204c183..805cf40 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/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index ee88068..8a671a1 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -45,38 +45,50 @@ #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 95227e4..f47a658 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -288,7 +288,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