summaryrefslogtreecommitdiff
path: root/fs/ceph/crypto.h
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2022-08-25 16:31:11 +0300
committerIlya Dryomov <idryomov@gmail.com>2023-08-24 12:24:35 +0300
commit5c64737d253683b7d138dde0da513a9ade16a170 (patch)
tree60488c781afb08bec5b1de8a82e2878b441fad27 /fs/ceph/crypto.h
parentd4d518871574ebbd53f054c16c085caa0a77b83d (diff)
downloadlinux-5c64737d253683b7d138dde0da513a9ade16a170.tar.xz
ceph: add truncate size handling support for fscrypt
This will transfer the encrypted last block contents to the MDS along with the truncate request only when the new size is smaller and not aligned to the fscrypt BLOCK size. When the last block is located in the file hole, the truncate request will only contain the header. The MDS could fail to do the truncate if there has another client or process has already updated the RADOS object which contains the last block, and will return -EAGAIN, then the kclient needs to retry it. The RMW will take around 50ms, and will let it retry 20 times for now. Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/crypto.h')
-rw-r--r--fs/ceph/crypto.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h
index 7a03275f3ad5..b735b3f144a7 100644
--- a/fs/ceph/crypto.h
+++ b/fs/ceph/crypto.h
@@ -26,6 +26,27 @@ struct ceph_fname {
bool no_copy;
};
+/*
+ * Header for the crypted file when truncating the size, this
+ * will be sent to MDS, and the MDS will update the encrypted
+ * last block and then truncate the size.
+ */
+struct ceph_fscrypt_truncate_size_header {
+ __u8 ver;
+ __u8 compat;
+
+ /*
+ * It will be sizeof(assert_ver + file_offset + block_size)
+ * if the last block is empty when it's located in a file
+ * hole. Or the data_len will plus CEPH_FSCRYPT_BLOCK_SIZE.
+ */
+ __le32 data_len;
+
+ __le64 change_attr;
+ __le64 file_offset;
+ __le32 block_size;
+} __packed;
+
struct ceph_fscrypt_auth {
__le32 cfa_version;
__le32 cfa_blob_len;