From: Jeff Layton Date: Thu, 25 Aug 2022 13:31:24 +0000 (-0400) Subject: ceph: set i_blkbits to crypto block size for encrypted inodes X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1801c9c5851c3719c018dc9f986005e21e81c81;p=ceph-client.git ceph: set i_blkbits to crypto block size for encrypted inodes Some of the underlying infrastructure for fscrypt relies on i_blkbits being aligned to the crypto blocksize. Reviewed-by: Xiubo Li Signed-off-by: Jeff Layton --- diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 5782e6e2b024..6cb791bc8701 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -988,13 +988,6 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, issued |= __ceph_caps_dirty(ci); new_issued = ~issued & info_caps; - /* directories have fl_stripe_unit set to zero */ - if (le32_to_cpu(info->layout.fl_stripe_unit)) - inode->i_blkbits = - fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1; - else - inode->i_blkbits = CEPH_BLOCK_SHIFT; - __ceph_update_quota(ci, iinfo->max_bytes, iinfo->max_files); #ifdef CONFIG_FS_ENCRYPTION @@ -1020,6 +1013,15 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, ceph_decode_timespec64(&ci->i_snap_btime, &iinfo->snap_btime); } + /* directories have fl_stripe_unit set to zero */ + if (IS_ENCRYPTED(inode)) + inode->i_blkbits = CEPH_FSCRYPT_BLOCK_SHIFT; + else if (le32_to_cpu(info->layout.fl_stripe_unit)) + inode->i_blkbits = + fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1; + else + inode->i_blkbits = CEPH_BLOCK_SHIFT; + if ((new_version || (new_issued & CEPH_CAP_LINK_SHARED)) && (issued & CEPH_CAP_LINK_EXCL) == 0) set_nlink(inode, le32_to_cpu(info->nlink));