From 9e40efc3b9658a9d92b6249fd15f1d849fd6f465 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 15 Apr 2021 13:04:38 -0400 Subject: [PATCH] client: send fscrypt_auth and fscrypt_file in MClientRequest ...and update the fscrypt_file field on setattr changes for size. Signed-off-by: Jeff Layton --- src/mds/Server.cc | 10 ++++++++++ src/messages/MClientRequest.h | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 62d0a473a30..2487a6b76bf 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -5026,6 +5026,12 @@ void Server::handle_client_setattr(MDRequestRef& mdr) __u32 mask = req->head.args.setattr.mask; __u32 access_mask = MAY_WRITE; + // No changes to encrypted inodes from legacy clients + if (!cur->get_inode()->fscrypt_file.empty() && req->get_header().version < 6) { + respond_to_request(mdr, -CEPHFS_EPERM); + return; + } + // xlock inode if (mask & (CEPH_SETATTR_MODE|CEPH_SETATTR_UID|CEPH_SETATTR_GID|CEPH_SETATTR_BTIME|CEPH_SETATTR_KILL_SGUID)) lov.add_xlock(&cur->authlock); @@ -5109,6 +5115,10 @@ void Server::handle_client_setattr(MDRequestRef& mdr) pi.inode->size = req->head.args.setattr.size; pi.inode->rstat.rbytes = pi.inode->size; } + if (req->get_header().version >= 6) { + pi.inode->fscrypt_file = req->fscrypt_file; + } + pi.inode->mtime = mdr->get_op_stamp(); // adjust client's max_size? diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 1e83ec3af1b..5a3f2ce74c8 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -67,7 +67,7 @@ WRITE_CLASS_ENCODER(SnapPayload) class MClientRequest final : public MMDSOp { private: - static constexpr int HEAD_VERSION = 5; + static constexpr int HEAD_VERSION = 6; static constexpr int COMPAT_VERSION = 1; public: @@ -101,6 +101,9 @@ public: std::string alternate_name; std::vector gid_list; + std::vector fscrypt_auth; + std::vector fscrypt_file; + /* XXX HACK */ mutable bool queued_for_replay = false; @@ -240,6 +243,10 @@ public: decode(gid_list, p); if (header.version >= 5) decode(alternate_name, p); + if (header.version >= 6) { + decode(fscrypt_auth, p); + decode(fscrypt_file, p); + } } void encode_payload(uint64_t features) override { @@ -262,6 +269,8 @@ public: encode(stamp, payload); encode(gid_list, payload); encode(alternate_name, payload); + encode(fscrypt_auth, payload); + encode(fscrypt_file, payload); } std::string_view get_type_name() const override { return "creq"; } -- 2.39.5