Whamcloud - gitweb
LU-16045 enc: force use of new enc xattr on new servers 36/48036/3
authorSebastien Buisson <sbuisson@ddn.com>
Mon, 25 Jul 2022 14:39:56 +0000 (16:39 +0200)
committerOleg Drokin <green@whamcloud.com>
Sat, 10 Sep 2022 00:53:10 +0000 (00:53 +0000)
When an older client uses encryption with a newer server, the client
wants to see the encryption context in security.c xattr. But
internally on server side, we force use of newer encryption.c xattr
for consistency purpose. When required, the encryption context is put
in the request to the client as usual, which interprets it as desired.

Lustre-change: https://review.whamcloud.com/48035
Lustre-commit: afa4c31087f21fef8d64f572e08a7bec77bc7325

Fixes: 4231fab66e ("LU-13717 sec: make client encryption compatible with ext4")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I667e123bdff912acc270666e8c74ebda6f0534e7
Reviewed-on: https://review.whamcloud.com/48036
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_internal.h

index 1986d27..88d2967 100644 (file)
@@ -627,7 +627,9 @@ static inline int mdo_declare_xattr_set(const struct lu_env *env,
        int rc;
 
        rc = dt_declare_xattr_set(env, next, buf, name, fl, handle);
-       if (rc >= 0 && strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) {
+       if (rc >= 0 &&
+           (strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0 ||
+            strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT_OLD) == 0)) {
                struct lu_attr la = { 0 };
 
                la.la_valid = LA_FLAGS;
@@ -657,7 +659,8 @@ static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
         * being created or migrated (LU_XATTR_CREATE flag not set), or
         * if it is empty.
         */
-       if ((strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) &&
+       if ((strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0 ||
+            strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT_OLD) == 0) &&
            (!S_ISDIR(mdd_object_type(obj)) ||
             !(fl & LU_XATTR_CREATE) ||
             (rc = mdd_dir_is_empty(env, obj)) == 0)) {
@@ -665,6 +668,11 @@ static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
 
                la.la_valid = LA_FLAGS;
                la.la_flags = LUSTRE_ENCRYPT_FL;
+               /* if this is an old client using the old enc xattr name,
+                * switch to the new name for consistency
+                */
+               if (strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT_OLD) == 0)
+                       name = LL_XATTR_NAME_ENCRYPTION_CONTEXT;
                rc = dt_attr_set(env, next, &la, handle);
        }
        if (rc >= 0)