if (IS_ERR(th))
GOTO(out, rc = PTR_ERR(th));
+ if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & LUSTRE_ENCRYPT_FL) {
+ /* punch must be aware we are dealing with an encrypted file */
+ la->la_valid |= LA_FLAGS;
+ la->la_flags |= LUSTRE_ENCRYPT_FL;
+ }
rc = dt_declare_attr_set(env, dob, la, th);
if (rc)
GOTO(stop, rc);
GOTO(unlock, rc);
}
- 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);
__u64 start, __u64 end, struct thandle *th)
{
struct osd_thandle *oh;
+ struct osd_object *obj = osd_dt_obj(dt);
struct inode *inode;
int rc;
ENTRY;
osd_trans_declare_op(env, oh, OSD_OT_PUNCH,
osd_dto_credits_noquota[DTO_ATTR_SET_BASE] + 3);
- inode = osd_dt_obj(dt)->oo_inode;
+ inode = obj->oo_inode;
LASSERT(inode);
rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
- i_projid_read(inode), 0, oh, osd_dt_obj(dt),
+ i_projid_read(inode), 0, oh, obj,
NULL, OSD_QID_BLK);
- if (rc == 0)
- rc = osd_trunc_lock(osd_dt_obj(dt), oh, false);
+ /* if object holds encrypted content, we need to make sure we truncate
+ * on an encryption unit boundary, or subsequent reads will get
+ * corrupted content
+ */
+ if (rc == 0) {
+ if (obj->oo_lma_flags & LUSTRE_ENCRYPT_FL &&
+ start & ~LUSTRE_ENCRYPTION_MASK)
+ start = (start & LUSTRE_ENCRYPTION_MASK) +
+ LUSTRE_ENCRYPTION_UNIT_SIZE;
+ ll_truncate_pagecache(inode, start);
+ rc = osd_trunc_lock(obj, oh, false);
+ }
RETURN(rc);
}
grow = true;
i_size_write(inode, start);
spin_unlock(&inode->i_lock);
- /* if object holds encrypted content, we need to make sure we truncate
- * on an encryption unit boundary, or subsequent reads will get
- * corrupted content
- */
- if (obj->oo_lma_flags & LUSTRE_ENCRYPT_FL &&
- start & ~LUSTRE_ENCRYPTION_MASK)
- start = (start & LUSTRE_ENCRYPTION_MASK) +
- LUSTRE_ENCRYPTION_UNIT_SIZE;
- ll_truncate_pagecache(inode, start);
/* optimize grow case */
if (grow) {
GOTO(out_sem, rc = -oh->ot_tx->tx_err);
if (attr && attr->la_valid & LA_FLAGS) {
- /* LMA is usually a part of bonus, no need to declare
- * anything else */
+ /* punch must be aware we are dealing with an encrypted file */
+ if (attr->la_flags & LUSTRE_ENCRYPT_FL)
+ obj->oo_lma_flags |= LUSTRE_ENCRYPT_FL;
}
if (attr && (attr->la_valid & (LA_UID | LA_GID | LA_PROJID))) {