}
/* For interoperability between 1.8 and 2.0. */
-#define CFG_GROUP_UPCALL "mdt.group_upcall"
-#define CFG_QUOTA_TYPE_OLD "mdt.quota_type"
-#define CFG_QUOTA_TYPE_NEW "mdd.quota_type"
-#define CFG_ROOT_SQUASH_OLD "mdt.rootsquash"
-#define CFG_ROOT_SQUASH_NEW "mdt.root_squash"
-#define CFG_NOSQUASH_NID_OLD "mdt.nosquash_nid"
-#define CFG_NOSQUASH_NID_NEW "mdt.nosquash_nids"
+static struct cfg_interop_param mdt_interop_param[] = {
+ { "mdt.group_upcall", NULL },
+ { "mdt.quota_type", "mdd.quota_type" },
+ { "mdt.rootsquash", "mdt.root_squash" },
+ { "mdt.nosquash_nid", "mdt.nosquash_nids" },
+ { NULL }
+};
/* used by MGS to process specific configurations */
static int mdt_process_config(const struct lu_env *env,
struct obd_device *obd = d->ld_obd;
/* For interoperability between 1.8 and 2.0. */
+ struct cfg_interop_param *ptr = NULL;
struct lustre_cfg *old_cfg = NULL;
char *param = NULL;
- char *new_name = NULL;
param = lustre_cfg_string(cfg, 1);
if (param == NULL) {
break;
}
- /* Skip old "mdt.group_upcall" param. */
- if (strncmp(param, CFG_GROUP_UPCALL,
- strlen(CFG_GROUP_UPCALL)) == 0) {
- CWARN("For 1.8 interoperability, skip this %s."
- " It is obsolete.\n", CFG_GROUP_UPCALL);
- break;
- }
-
- /* Rename old "mdt.quota_type" to "mdd.quota_type". */
- if (strncmp(param, CFG_QUOTA_TYPE_OLD,
- strlen(CFG_QUOTA_TYPE_OLD)) == 0) {
- CWARN("Found old param %s, changed it to %s.\n",
- CFG_QUOTA_TYPE_OLD, CFG_QUOTA_TYPE_NEW);
- new_name = CFG_QUOTA_TYPE_NEW;
+ ptr = class_find_old_param(param, mdt_interop_param);
+ if (ptr != NULL) {
+ if (ptr->new_param == NULL) {
+ CWARN("For 1.8 interoperability, skip this %s."
+ " It is obsolete.\n", ptr->old_param);
+ break;
+ }
- } else if (strncmp(param, CFG_ROOT_SQUASH_OLD,
- strlen(CFG_ROOT_SQUASH_OLD)) == 0) {
- /* Rename old "mdt.rootsquash" to "mdt.root_squash". */
CWARN("Found old param %s, changed it to %s.\n",
- CFG_ROOT_SQUASH_OLD, CFG_ROOT_SQUASH_NEW);
- new_name = CFG_ROOT_SQUASH_NEW;
-
- } else if (strncmp(param, CFG_NOSQUASH_NID_OLD,
- strlen(CFG_NOSQUASH_NID_OLD)) == 0 &&
- param[strlen(CFG_NOSQUASH_NID_OLD)] != 's') {
- /*
- * Rename old "mdt.nosquash_nid" to
- * "mdt.nosquash_nids".
- */
- CWARN("Found old param %s, changed it to %s.\n",
- CFG_NOSQUASH_NID_OLD, CFG_NOSQUASH_NID_NEW);
- new_name = CFG_NOSQUASH_NID_NEW;
- }
+ ptr->old_param, ptr->new_param);
- if (new_name != NULL) {
old_cfg = cfg;
- cfg = lustre_cfg_rename(old_cfg, new_name);
+ cfg = lustre_cfg_rename(old_cfg, ptr->new_param);
if (IS_ERR(cfg)) {
rc = PTR_ERR(cfg);
break;
EXPORT_SYMBOL(class_find_param);
/**
+ * Check whether the proc parameter \a param is an old parameter or not from
+ * the array \a ptr which contains the mapping from old parameters to new ones.
+ * If it's an old one, then return the pointer to the cfg_interop_param struc-
+ * ture which contains both the old and new parameters.
+ *
+ * \param param proc parameter
+ * \param ptr an array which contains the mapping from
+ * old parameters to new ones
+ *
+ * \retval valid-pointer pointer to the cfg_interop_param structure
+ * which contains the old and new parameters
+ * \retval NULL \a param or \a ptr is NULL,
+ * or \a param is not an old parameter
+ */
+struct cfg_interop_param *class_find_old_param(const char *param,
+ struct cfg_interop_param *ptr)
+{
+ char *value = NULL;
+ int name_len = 0;
+
+ if (param == NULL || ptr == NULL)
+ RETURN(NULL);
+
+ value = strchr(param, '=');
+ if (value == NULL)
+ name_len = strlen(param);
+ else
+ name_len = value - param;
+
+ while (ptr->old_param != NULL) {
+ if (strncmp(param, ptr->old_param, name_len) == 0 &&
+ name_len == strlen(ptr->old_param))
+ RETURN(ptr);
+ ptr++;
+ }
+
+ RETURN(NULL);
+}
+EXPORT_SYMBOL(class_find_old_param);
+
+/**
* Finds a parameter in \a params and copies it to \a copy.
*
* Leading spaces are skipped. Next space or end of string is the