Whamcloud - gitweb
LU-16045 enc: force use of new enc xattr on new servers
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index daffa1c..a8c9e40 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)