Skip to contentSkip to conversation

ceph: always set the initial i_blkbits to CEPH_FSCRYPT_BLOCK_SHIFT

PATCH In review [email protected] 2 participants 3 messages Jan 18, 2024 – Jan 25, 2024 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: always set the initial i_blkbits to CEPH_FSCRYPT_BLOCK_SHIFT

From: Xiubo Li <[email protected]>

The fscrypt code will use i_blkbits to setup the 'ci_data_unit_bits' when allocating the new inode, but ceph will initiate i_blkbits ater when filling the inode, which is too late. Since the 'ci_data_unit_bits' will only be used by the fscrypt framework so initiating i_blkbits with CEPH_FSCRYPT_BLOCK_SHIFT is safe.

Fixes commit 5b1188847180 ("fscrypt: support crypto data unit size

less than filesystem block size")
URL: https://tracker.ceph.com/issues/64035

---
 fs/ceph/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/ceph/inode.c +2 -0
index 62af452cdba4..d96d97b31f68 100644
@@ -79,6 +79,8 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	inode->i_blkbits = CEPH_FSCRYPT_BLOCK_SHIFT;
+
 	if (!S_ISLNK(*mode)) {
 		err = ceph_pre_init_acls(dir, mode, as_ctx);
 		if (err < 0)
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, Jan 18, 2024 at 04:04:04PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

The fscrypt code will use i_blkbits to setup the 'ci_data_unit_bits' when allocating the new inode, but ceph will initiate i_blkbits ater when filling the inode, which is too late. Since the 'ci_data_unit_bits' will only be used by the fscrypt framework so initiating i_blkbits with CEPH_FSCRYPT_BLOCK_SHIFT is safe.

Fixes commit 5b1188847180 ("fscrypt: support crypto data unit size

less than filesystem block size")

The Fixes line should be one line, and the word "commit" should not be there

Quoted 11 lines

URL: https://tracker.ceph.com/issues/64035

---
 fs/ceph/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/ceph/inode.c +0 -0
index 62af452cdba4..d96d97b31f68 100644

fs/ceph/inode.c struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry, · line 86

Quoted 8 lines
fs/ceph/inode.c +2 -0
@@ -79,6 +79,8 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	inode->i_blkbits = CEPH_FSCRYPT_BLOCK_SHIFT;
+
 	if (!S_ISLNK(*mode)) {
 		err = ceph_pre_init_acls(dir, mode, as_ctx);
 		if (err < 0)

Looks good, you can add:

Sorry for the trouble; I need to start running xfstests on CephFS!

In the future please also Cc the fscrypt mailing list on things like this.

Maybe you'd like to also send a patch that updates the comment for fscrypt_prepare_new_inode() to clarify that i_blkbits needs to be set first?

- Eric

author
#2 lore raw
Quoted 9 lines · Eric Biggers
Quoted 8 lines · On Thu, Jan 18, 2024 at 04:04:04PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

The fscrypt code will use i_blkbits to setup the 'ci_data_unit_bits' when allocating the new inode, but ceph will initiate i_blkbits ater when filling the inode, which is too late. Since the 'ci_data_unit_bits' will only be used by the fscrypt framework so initiating i_blkbits with CEPH_FSCRYPT_BLOCK_SHIFT is safe.

Quoted 3 lines
Quoted 2 lines
Fixes commit 5b1188847180 ("fscrypt: support crypto data unit size

less than filesystem block size")

The Fixes line should be one line, and the word "commit" should not be there

Sure, I will fix it.

Quoted 21 lines
Quoted 11 lines

URL: https://tracker.ceph.com/issues/64035

---
  fs/ceph/inode.c | 2 ++
  1 file changed, 2 insertions(+)
fs/ceph/inode.c +0 -0
index 62af452cdba4..d96d97b31f68 100644

fs/ceph/inode.c struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry, · line 86

Quoted 8 lines
fs/ceph/inode.c +2 -0
@@ -79,6 +79,8 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
  	if (!inode)
  		return ERR_PTR(-ENOMEM);
 
+	inode->i_blkbits = CEPH_FSCRYPT_BLOCK_SHIFT;
+
  	if (!S_ISLNK(*mode)) {
  		err = ceph_pre_init_acls(dir, mode, as_ctx);
  		if (err < 0)

Looks good, you can add:

Quoted 3 lines

Sorry for the trouble; I need to start running xfstests on CephFS!

Thanks Eric, no worry, this will only be seen when the 'test_dummy_encryption' is enabled.

Quoted 1 line

In the future please also Cc the fscrypt mailing list on things like this.

Sure, I meant to Cc you but I think I forgot that. Sorry.

Quoted 2 lines

Maybe you'd like to also send a patch that updates the comment for fscrypt_prepare_new_inode() to clarify that i_blkbits needs to be set first?

Will fix it.

Thanks Eric.

- Xiubo

Quoted 2 lines

- Eric