+
+ if (S_ISREG(mode))
+ set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags);
+ }
req->r_dentry = dget(dentry);
req->r_num_caps = 2;
@@ -1008,6 +1022,18 @@ static int ceph_symlink(struct user_namespace *mnt_userns, struct inode *dir,
ihold(dir);
if (IS_ENCRYPTED(req->r_new_inode)) {
+#ifdef CONFIG_FS_ENCRYPTION
+ struct ceph_inode_info *ci = ceph_inode(req->r_new_inode);
+
+ req->r_fscrypt_auth = kmemdup(ci->fscrypt_auth,
+ ci->fscrypt_auth_len,
+ GFP_KERNEL);
+ if (!req->r_fscrypt_auth) {
+ err = -ENOMEM;
+ goto out_req;
+ }
+#endif
+
err = prep_encrypted_symlink_target(req, dest);
if (err)
goto out_req;
@@ -1081,6 +1107,19 @@ static int ceph_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
goto out_req;
}
+#ifdef CONFIG_FS_ENCRYPTION
+ if (IS_ENCRYPTED(dir)) {
+ struct ceph_inode_info *ci = ceph_inode(req->r_new_inode);
+
+ req->r_fscrypt_auth = kmemdup(ci->fscrypt_auth,
+ ci->fscrypt_auth_len,
+ GFP_KERNEL);
+ if (!req->r_fscrypt_auth) {
+ err = -ENOMEM;
+ goto out_req;
+ }
+ }
+#endif
req->r_dentry = dget(dentry);
req->r_num_caps = 2;
req->r_parent = dir;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 61ffbda5b934..70ac41d6e0d4 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -771,9 +771,24 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
req->r_args.open.mask = cpu_to_le32(mask);
req->r_parent = dir;
ihold(dir);
- if (IS_ENCRYPTED(dir))
+ if (IS_ENCRYPTED(dir)) {
set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags);
+#ifdef CONFIG_FS_ENCRYPTION
+ if (new_inode) {
+ struct ceph_inode_info *ci = ceph_inode(new_inode);
+
+ req->r_fscrypt_auth = kmemdup(ci->fscrypt_auth,
+ ci->fscrypt_auth_len,
+ GFP_KERNEL);
+ if (!req->r_fscrypt_auth) {
+ err = -ENOMEM;
+ goto out_req;
+ }
+ }
+#endif
+ }
+
if (flags & O_CREAT) {
struct ceph_file_layout lo;