]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mds: add truncate size handling support for fscrypt
authorXiubo Li <xiubli@redhat.com>
Thu, 14 Oct 2021 04:45:20 +0000 (12:45 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 13 Jan 2022 14:01:54 +0000 (22:01 +0800)
commit3b5a0ea4c6697c1b48a6863c528dbf9ae31fd433
treee53e05e535e02dde2099b4c4ac1aa81f6093d9ad
parentb73a04837d3f1acb66310f7239d24e86a04e45ae
mds: add truncate size handling support for fscrypt

The kclient will only send truncate requests with the modified and
encrypted last block contents when new size is smaller and is not
aligned to CEPH_FSCRYPT_BLOCK_SIZE, which is 4KB for now.

Or if the Fx caps is issued and the new size is larger the kclient
will buffer the truncating. Or it will send truncate requests wihtout
the last block filled.

When the fscrypt is enabled and when truncating with a smaller size,
both the old size and new size in the truncate request will always
be rounded up to CEPH_FSCRYPT_BLOCK_SIZE, which is 4K for now, in
kclient. For example if truncating a file size from 3KB to 2KB, the
MDS will always get old_size == new_size == 4KB. So we need to check
whether there has last block data passed together with the truncate
request to make sure whether truncating to a smaller size.

The kclinet will send it's 'change_attr' along with the truncate req,
and the MDS will compare it with the one in CInode just after the MDS
successfully xlockes the CInode's filelock, if they are different
that means it's possibly some clients have update the file or have
dirty caps just before MDS xlockes the CInode's filelock. We will let
the kclient retry it by returning a -EAGAIN errno.

Then the MDS will write the last block to OSD and then truncate
the size as normal.

Currently the last block contents will be journaled together with
the project inode only and it will be cleared after the truncate
being finished, and won't make it persistent together with the
CInode:inode_t in the metadata pool.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/Server.cc
src/mds/events/EMetaBlob.h
src/mds/fscrypt.h [new file with mode: 0644]
src/mds/mdstypes.h