From 8e249d43f19a4d227c76e6def41d7eb19e6a207f Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Wed, 5 Dec 2012 10:32:43 +0800 Subject: [PATCH] LU-2190 mountconf: zfs processes mount parameters Add zfs support to store/fetch lustre mount parameters into/from dataset properties. Signed-off-by: Lai Siyao Change-Id: I1ca6255cc19ef99727c639432741164993b09bd8 Reviewed-on: http://review.whamcloud.com/4732 Reviewed-by: Alex Zhuravlev Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/utils/mount_utils_zfs.c | 74 ++++-------------------------------------- 1 file changed, 6 insertions(+), 68 deletions(-) diff --git a/lustre/utils/mount_utils_zfs.c b/lustre/utils/mount_utils_zfs.c index 124fdf6..f697934 100644 --- a/lustre/utils/mount_utils_zfs.c +++ b/lustre/utils/mount_utils_zfs.c @@ -42,10 +42,7 @@ #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; @@ -152,21 +149,6 @@ static int zfs_set_prop_str(zfs_handle_t *zhp, char *prop, char *val) 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) { @@ -229,22 +211,11 @@ int zfs_write_ldd(struct mkfs_opts *mop) 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; + } + ret = zfs_set_prop_str(zhp, LDD_PARAMS_PROP, ldd->ldd_params); 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; } -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. @@ -361,20 +312,7 @@ int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd) 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; -- 1.8.3.1