Skip to contentSkip to conversation

ceph: inherit exactly the encryption info from parent for subdirs

PATCH New [email protected] 1 participant 1 message Mar 18, 2022 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: inherit exactly the encryption info from parent for subdirs

From: Xiubo Li <[email protected]>

There is no need to create new nonce for the subdirs, since the encyrption will be used to encrypt/dencrypt the dentry name only. And later in the request reply it will fill the encryption info which is exactly inherit from the parent.

This could help us simplify the snapshot supporting. And no need to parse the inode from a long snap name and search it from the cache, which may not exist.

---

This depends on the ceph PR:
https://github.com/ceph/ceph/pull/45516

And mds will always send the parent's encryption info back when creating directories.

 fs/ceph/inode.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ceph/inode.c +9 -3
index 7b670e2405c1..f005213fe48b 100644
@@ -91,9 +91,15 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
 	if (err < 0)
 		goto out_err;
 
-	err = ceph_fscrypt_prepare_context(dir, inode, as_ctx);
-	if (err)
-		goto out_err;
+	/*
+	 * For subdirs they will inherit the whole encrytion info
+	 * from their parent.
+	 */
+	if (!S_ISDIR(*mode)) {
+		err = ceph_fscrypt_prepare_context(dir, inode, as_ctx);
+		if (err)
+			goto out_err;
+	}
 
 	return inode;
 out_err:
Signature · 1 line
2.27.0