From: Sebastien Buisson Date: Tue, 8 Mar 2022 11:07:47 +0000 (+0100) Subject: LU-15625 sec: fix set_param -P for root squash X-Git-Tag: 2.15.51~99 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7b8449e8f9ed310376a191ec8dfa2f1cb6233377 LU-15625 sec: fix set_param -P for root squash lctl set_param -P needs to be fixed for root squash in order to properly propagate to clients. On server (MDT) side, the paramaters are mdt.*.*squash*. On client side, the parameters are llite.*.*squash*. So if the setting on MGS side is done as set_param -P *.*.root_squash and *.*.nosquash_nids, it works fine. But if it is done as set_param -P mdt.*.root_squash, this setting is not applied to client side. The solution is to have the settings translated into *.*.root_squash and *.*.nosquash_nids to make both sides happy. Also, to ensure client vs. server consistency, prevent set_param -P llite.*.root_squash. Signed-off-by: Sebastien Buisson Change-Id: I8984c9d9024d7a053e548ed15d1321b281d9940f Reviewed-on: https://review.whamcloud.com/46739 Tested-by: jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/uapi/linux/lustre/lustre_param.h b/lustre/include/uapi/linux/lustre/lustre_param.h index 284c63b..8b91770 100644 --- a/lustre/include/uapi/linux/lustre/lustre_param.h +++ b/lustre/include/uapi/linux/lustre/lustre_param.h @@ -68,6 +68,8 @@ #define PARAM_ACTIVE "active=" /* activate/deactivate */ #define PARAM_NETWORK "network=" /* bind on nid */ #define PARAM_ID_UPCALL "identity_upcall=" /* identity upcall */ +#define PARAM_ROOTSQUASH "root_squash=" /* root squash */ +#define PARAM_NOSQUASHNIDS "nosquash_nids=" /* no squash nids */ /* Prefixes for parameters handled by obd's proc methods (XXX_process_config) */ #define PARAM_OST "ost." diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index c276563..0762776 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -3919,6 +3919,21 @@ static int mgs_write_log_param2(const struct lu_env *env, goto end; } + /* root squash parameters must not be set on llite subsystem, this can + * lead to inconsistencies between client and server values + */ + if ((strstr(ptr, PARAM_NOSQUASHNIDS) || + strstr(ptr, PARAM_ROOTSQUASH)) && + strncmp(ptr, "llite.", strlen("llite.")) == 0) { + rc = -EINVAL; + CWARN("%s: cannot add %s param to llite subsystem, use mdt instead: rc=%d\n", + mgs->mgs_obd->obd_name, + strstr(ptr, PARAM_ROOTSQUASH) ? + PARAM_ROOTSQUASH : PARAM_NOSQUASHNIDS, + rc); + goto end; + } + rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, PARAMS_FILENAME, &bufs, mti->mti_svname, ptr); end: diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 8b2fcdc..6f49fc9 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -1261,6 +1261,7 @@ static ssize_t process_param2_config(struct lustre_cfg *lcfg) char *upcall = lustre_cfg_string(lcfg, 2); struct kobject *kobj = NULL; const char *subsys = param; + char *newparam = NULL; char *argv[] = { [0] = "/usr/sbin/lctl", [1] = "set_param", @@ -1277,15 +1278,15 @@ static ssize_t process_param2_config(struct lustre_cfg *lcfg) len = strcspn(param, ".="); if (!len) - return -EINVAL; + RETURN(-EINVAL); /* If we find '=' then its the top level sysfs directory */ if (param[len] == '=') - return class_set_global(param); + RETURN(class_set_global(param)); subsys = kstrndup(param, len, GFP_KERNEL); if (!subsys) - return -ENOMEM; + RETURN(-ENOMEM); kobj = kset_find_obj(lustre_kset, subsys); kfree(subsys); @@ -1316,6 +1317,22 @@ static ssize_t process_param2_config(struct lustre_cfg *lcfg) RETURN(-EINVAL); } + /* root_squash and nosquash_nids settings must be applied to + * global subsystem (*.) so that it is taken into account by + * both client and server sides. So do the equivalent of a + * 's / mdt. / *. /'. + */ + if ((strstr(param, PARAM_NOSQUASHNIDS) || + strstr(param, PARAM_ROOTSQUASH)) && + (param[0] != '*' || param[1] != '.')) { + newparam = kmalloc(strlen(param) + 1, GFP_NOFS); + if (!newparam) + RETURN(-ENOMEM); + + snprintf(newparam, strlen(param) + 1, "*%s", param + len); + argv[2] = (char *)newparam; + } + start = ktime_get(); rc = call_usermodehelper(argv[0], argv, NULL, UMH_WAIT_PROC); end = ktime_get(); @@ -1331,6 +1348,7 @@ static ssize_t process_param2_config(struct lustre_cfg *lcfg) rc = 0; } + kfree(newparam); RETURN(rc); }