Whamcloud - gitweb
LU-2190 mountconf: zfs processes mount parameters
authorLai Siyao <laisiyao@whamcloud.com>
Wed, 5 Dec 2012 02:32:43 +0000 (10:32 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 05:02:41 +0000 (00:02 -0500)
Add zfs support to store/fetch lustre mount parameters into/from
dataset properties.

Signed-off-by: Lai Siyao <laisiyao@whamcloud.com>
Change-Id: I1ca6255cc19ef99727c639432741164993b09bd8
Reviewed-on: http://review.whamcloud.com/4732
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/utils/mount_utils_zfs.c

index 124fdf6..f697934 100644 (file)
 #define LDD_UUID_PROP                   "lustre:uuid"
 #define LDD_USERDATA_PROP               "lustre:userdata"
 #define LDD_MOUNTOPTS_PROP              "lustre:mountopts"
 #define LDD_UUID_PROP                   "lustre:uuid"
 #define LDD_USERDATA_PROP               "lustre:userdata"
 #define LDD_MOUNTOPTS_PROP              "lustre:mountopts"
-#define LDD_MGSNODE_PROP                "lustre:mgsnode"
-#define LDD_FAILNODE_PROP               "lustre:failnode"
-#define LDD_FAILMODE_PROP               "lustre:failmode"
-#define LDD_IDENTITY_UPCALL_PROP        "lustre:identity_upcall"
+#define LDD_PARAMS_PROP                        "lustre:params"
 
 /* indicate if the ZFS OSD has been successfully setup */
 static int osd_zfs_setup = 0;
 
 /* indicate if the ZFS OSD has been successfully setup */
 static int osd_zfs_setup = 0;
@@ -152,21 +149,6 @@ static int zfs_set_prop_str(zfs_handle_t *zhp, char *prop, char *val)
        return ret;
 }
 
        return ret;
 }
 
-static int zfs_set_prop_param(zfs_handle_t *zhp, struct lustre_disk_data *ldd,
-                             char *param, char *prop)
-{
-       char *str;
-       int ret = 0;
-
-       if (get_param(ldd->ldd_params, param, &str) == 0) {
-               vprint("  %s=%s\n", prop, str);
-               ret = zfs_prop_set(zhp, prop, str);
-               free(str);
-       }
-
-       return ret;
-}
-
 static int osd_check_zfs_setup(void)
 {
        if (osd_zfs_setup == 0) {
 static int osd_check_zfs_setup(void)
 {
        if (osd_zfs_setup == 0) {
@@ -229,22 +211,11 @@ int zfs_write_ldd(struct mkfs_opts *mop)
        if (ret)
                goto out_close;
 
        if (ret)
                goto out_close;
 
-       ret = zfs_set_prop_param(zhp, ldd, PARAM_MGSNODE, LDD_MGSNODE_PROP);
-       if (ret)
-               goto out_close;
-
-       ret = zfs_set_prop_param(zhp, ldd, PARAM_FAILNODE, LDD_FAILNODE_PROP);
-       if (ret)
-               goto out_close;
-
-       ret = zfs_set_prop_param(zhp, ldd, PARAM_FAILMODE, LDD_FAILMODE_PROP);
-       if (ret)
-               goto out_close;
-
-       ret = zfs_set_prop_param(zhp, ldd, PARAM_MDT PARAM_ID_UPCALL,
-                                LDD_IDENTITY_UPCALL_PROP);
-       if (ret)
+       if (strlen(ldd->ldd_params) > ZAP_MAXVALUELEN) {
+               ret = E2BIG;
                goto out_close;
                goto out_close;
+       }
+       ret = zfs_set_prop_str(zhp, LDD_PARAMS_PROP, ldd->ldd_params);
 
 out_close:
        zfs_close(zhp);
 
 out_close:
        zfs_close(zhp);
@@ -293,26 +264,6 @@ static int zfs_get_prop_str(zfs_handle_t *zhp, char *prop, char *val)
        return ret;
 }
 
        return ret;
 }
 
-static int zfs_get_prop_param(zfs_handle_t *zhp, struct lustre_disk_data *ldd,
-               char *param, char *prop)
-{
-       nvlist_t *propval;
-       char *propstr;
-       int ret;
-
-       ret = nvlist_lookup_nvlist(zfs_get_user_props(zhp), prop, &propval);
-       if (ret)
-               return ret;
-
-       ret = nvlist_lookup_string(propval, ZPROP_VALUE, &propstr);
-       if (ret)
-               return ret;
-
-       ret = add_param(ldd->ldd_params, param, propstr);
-
-       return ret;
-}
-
 /*
  * Read the server config as properties associated with the dataset.
  * Missing entries as not treated error and are simply skipped.
 /*
  * Read the server config as properties associated with the dataset.
  * Missing entries as not treated error and are simply skipped.
@@ -361,20 +312,7 @@ int zfs_read_ldd(char *ds,  struct lustre_disk_data *ldd)
        if (ret && (ret != ENOENT))
                goto out_close;
 
        if (ret && (ret != ENOENT))
                goto out_close;
 
-       ret = zfs_get_prop_param(zhp, ldd, PARAM_MGSNODE, LDD_MGSNODE_PROP);
-       if (ret && (ret != ENOENT))
-               goto out_close;
-
-       ret = zfs_get_prop_param(zhp, ldd, PARAM_FAILNODE, LDD_FAILNODE_PROP);
-       if (ret && (ret != ENOENT))
-               goto out_close;
-
-       ret = zfs_get_prop_param(zhp, ldd, PARAM_FAILMODE, LDD_FAILMODE_PROP);
-       if (ret && (ret != ENOENT))
-               goto out_close;
-
-       ret = zfs_get_prop_param(zhp, ldd, PARAM_MDT PARAM_ID_UPCALL,
-                                LDD_IDENTITY_UPCALL_PROP);
+       ret = zfs_get_prop_str(zhp, LDD_PARAMS_PROP, ldd->ldd_params);
        if (ret && (ret != ENOENT))
                goto out_close;
 
        if (ret && (ret != ENOENT))
                goto out_close;