From: Xiubo Li <xiubli@xxxxxxxxxx> This patch series is based on the fscrypt_size_handling branch in https://github.com/lxbsz/linux.git, which is based Jeff's ceph-fscrypt-content-experimental branch in https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git, has reverted one useless commit and added some upstream commits. I will keep this patch set as simple as possible to review since this is still one framework code. It works and still in developing and need some feedbacks and suggestions for two corner cases below. ==== This approach is based on the discussion from V1 and V2, which will pass the encrypted last block contents to MDS along with the truncate request. This will send the encrypted last block contents to MDS along with the truncate request when truncating to a smaller size and at the same time new size does not align to BLOCK SIZE. The MDS side patch is raised in PR https://github.com/ceph/ceph/pull/43588, which is also based Jeff's previous great work in PR https://github.com/ceph/ceph/pull/41284. The MDS will use the filer.write_trunc(), which could update and truncate the file in one shot, instead of filer.truncate(). This just assume kclient won't support the inline data feature, which will be remove soon, more detail please see: https://tracker.ceph.com/issues/52916 Changed in V3: - Fix possibly corrupting the file just before the MDS acquires the xlock for FILE lock, another client has updated it. - Flush the pagecache buffer before reading the last block for the when filling the truncate request. - Some other minore fixes. Xiubo Li (4): ceph: add __ceph_get_caps helper support ceph: add __ceph_sync_read helper support ceph: return the real size readed when hit EOF ceph: add truncate size handling support for fscrypt fs/ceph/caps.c | 21 +++-- fs/ceph/file.c | 47 +++++++--- fs/ceph/inode.c | 182 ++++++++++++++++++++++++++++++++++-- fs/ceph/super.h | 5 + include/linux/ceph/crypto.h | 23 +++++ 5 files changed, 247 insertions(+), 31 deletions(-) create mode 100644 include/linux/ceph/crypto.h -- 2.27.0