From: Jeff Layton Date: Thu, 15 Apr 2021 17:04:38 +0000 (-0400) Subject: client: send fscrypt_auth and fscrypt_file in MClientRequest X-Git-Tag: v18.0.0~1381^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e40efc3b9658a9d92b6249fd15f1d849fd6f465;p=ceph.git 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 --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 62d0a473a300..2487a6b76bf1 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 1e83ec3af1bd..5a3f2ce74c8c 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"; }