Whamcloud - gitweb
LU-12275 sec: support truncate for encrypted files
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index bb92058..4982a49 100644 (file)
@@ -919,6 +919,17 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo,
                oa->o_valid &= ~OBD_MD_LAYOUT_VERSION;
        }
 
+       if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & LUSTRE_ENCRYPT_FL) {
+               /* punch must be aware we are dealing with an encrypted file */
+               struct lu_attr la = {
+                       .la_valid = LA_FLAGS,
+                       .la_flags = LUSTRE_ENCRYPT_FL,
+               };
+
+               rc = dt_attr_set(env, dob, &la, th);
+               if (rc)
+                       GOTO(unlock, rc);
+       }
        rc = dt_punch(env, dob, start, OBD_OBJECT_EOF, th);
        if (rc)
                GOTO(unlock, rc);