Whamcloud - gitweb
LU-15625 sec: fix set_param -P for root squash 39/46739/2
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 8 Mar 2022 11:07:47 +0000 (12:07 +0100)
committerOleg Drokin <green@whamcloud.com>
Mon, 27 Jun 2022 04:57:05 +0000 (04:57 +0000)
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 <sbuisson@ddn.com>
Change-Id: I8984c9d9024d7a053e548ed15d1321b281d9940f
Reviewed-on: https://review.whamcloud.com/46739
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_param.h
lustre/mgs/mgs_llog.c
lustre/obdclass/obd_config.c

index 284c63b..8b91770 100644 (file)
@@ -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_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."
 
 /* Prefixes for parameters handled by obd's proc methods (XXX_process_config) */
 #define PARAM_OST              "ost."
index c276563..0762776 100644 (file)
@@ -3919,6 +3919,21 @@ static int mgs_write_log_param2(const struct lu_env *env,
                goto end;
        }
 
                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:
        rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, PARAMS_FILENAME, &bufs,
                          mti->mti_svname, ptr);
 end:
index 8b2fcdc..6f49fc9 100644 (file)
@@ -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 *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",
        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)
 
        len = strcspn(param, ".=");
        if (!len)
-               return -EINVAL;
+               RETURN(-EINVAL);
 
        /* If we find '=' then its the top level sysfs directory */
        if (param[len] == '=')
 
        /* 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)
 
        subsys = kstrndup(param, len, GFP_KERNEL);
        if (!subsys)
-               return -ENOMEM;
+               RETURN(-ENOMEM);
 
        kobj = kset_find_obj(lustre_kset, subsys);
        kfree(subsys);
 
        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);
        }
 
                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();
        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;
        }
 
                       rc = 0;
        }
 
+       kfree(newparam);
        RETURN(rc);
 }
 
        RETURN(rc);
 }