rc = ll_vfs_getxattr(dentry, inode, LL_XATTR_NAME_ENCRYPTION_CONTEXT,
ctx, len);
+ /* used as encryption unit size */
+ if (S_ISREG(inode->i_mode))
+ inode->i_blkbits = LUSTRE_ENCRYPTION_BLOCKBITS;
return rc;
}
it = file->private_data; /* XXX: compat macro */
file->private_data = NULL; /* prevent ll_local_open assertion */
+ if (S_ISREG(inode->i_mode)) {
+ rc = llcrypt_file_open(inode, file);
+ if (rc)
+ GOTO(out_nofiledata, rc);
+ }
+
fd = ll_file_data_get();
if (fd == NULL)
GOTO(out_nofiledata, rc = -ENOMEM);
&req->rq_import->imp_connection->c_peer;
struct ost_body *body;
u32 client_cksum = 0;
+ struct inode *inode;
ENTRY;
} else {
rc = 0;
}
+
+ inode = page2inode(aa->aa_ppga[0]->pg);
+ if (inode && IS_ENCRYPTED(inode)) {
+ int idx;
+
+ if (!llcrypt_has_encryption_key(inode)) {
+ CDEBUG(D_SEC, "no enc key for ino %lu\n", inode->i_ino);
+ GOTO(out, rc);
+ }
+ for (idx = 0; idx < aa->aa_page_count; idx++) {
+ struct brw_page *pg = aa->aa_ppga[idx];
+ __u64 *p, *q;
+
+ /* do not decrypt if page is all 0s */
+ p = q = page_address(pg->pg);
+ while (p - q < PAGE_SIZE / sizeof(*p)) {
+ if (*p != 0)
+ break;
+ p++;
+ }
+ if (p - q == PAGE_SIZE / sizeof(*p))
+ continue;
+
+ rc = llcrypt_decrypt_pagecache_blocks(pg->pg,
+ PAGE_SIZE, 0);
+ if (rc)
+ GOTO(out, rc);
+ }
+ }
+
out:
if (rc >= 0)
lustre_get_wire_obdo(&req->rq_import->imp_connect_data,