]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ceph: always set initial i_blkbits to CEPH_FSCRYPT_BLOCK_SHIFT
authorXiubo Li <xiubli@redhat.com>
Thu, 18 Jan 2024 06:24:41 +0000 (14:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2024 18:14:26 +0000 (19:14 +0100)
[ Upstream commit bbb20ea993f46743f7429092ddc52f1a5c5428ef ]

The fscrypt code will use i_blkbits to setup 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 ci_data_unit_bits will only
be used by the fscrypt framework so initiating i_blkbits with
CEPH_FSCRYPT_BLOCK_SHIFT is safe.

Link: https://tracker.ceph.com/issues/64035
Fixes: 5b1188847180 ("fscrypt: support crypto data unit size less than filesystem block size")
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ceph/inode.c

index 0679240f06db924e9aba25052675268885c4bd04..7d41c3e03476bc3c3181ee14b68bbe9cf6f76b1b 100644 (file)
@@ -78,6 +78,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)