Skip to contentSkip to conversation

ceph: don't allow changing layout on encrypted files/directories

RFC PATCH In review Luis Henriques 2 participants 2 messages Aug 17, 2021 – Aug 18, 2021 Ceph client

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 ceph: don't allow changing layout on encrypted files/directories

Encryption is currently only supported on files/directories with layouts where stripe_count=1. Forbid changing layouts when encryption is involved.

---
Changes since v1:
- dropped changes to ceph_sync_setxattr(), MDS shall be responsible for preventing layout changes on encrypted dirs/files

 fs/ceph/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ceph/ioctl.c +4 -0
index 477ecc667aee..480d18bb2ff0 100644
@@ -294,6 +294,10 @@ static long ceph_set_encryption_policy(struct file *file, unsigned long arg)
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 
+	/* encrypted directories can't have striped layout */
+	if (ci->i_layout.stripe_count > 1)
+		return -EINVAL;
+
 	ret = vet_mds_for_fscrypt(file);
 	if (ret)
 		return ret;
#1 lore raw
Quoted 17 lines · Luis Henriques

Encryption is currently only supported on files/directories with layouts where stripe_count=1. Forbid changing layouts when encryption is involved.

---
Changes since v1:
- dropped changes to ceph_sync_setxattr(), MDS shall be responsible for preventing layout changes on encrypted dirs/files

 fs/ceph/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ceph/ioctl.c +0 -0
index 477ecc667aee..480d18bb2ff0 100644

fs/ceph/ioctl.c static long ceph_set_encryption_policy(struct file *file, unsigned long arg) · line 303

Quoted 10 lines
fs/ceph/ioctl.c +4 -0
@@ -294,6 +294,10 @@ static long ceph_set_encryption_policy(struct file *file, unsigned long arg)
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 
+	/* encrypted directories can't have striped layout */
+	if (ci->i_layout.stripe_count > 1)
+		return -EINVAL;
+
 	ret = vet_mds_for_fscrypt(file);
 	if (ret)
 		return ret;

Thanks Luis. I've gone ahead and merged this into my fscrypt pile.

Signature · 1 line
Jeff Layton <[email protected]>