]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: send fscrypt_auth and fscrypt_file in MClientRequest
authorJeff Layton <jlayton@redhat.com>
Thu, 15 Apr 2021 17:04:38 +0000 (13:04 -0400)
committerXiubo Li <xiubli@redhat.com>
Thu, 13 Jan 2022 13:08:42 +0000 (21:08 +0800)
...and update the fscrypt_file field on setattr changes for size.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/mds/Server.cc
src/messages/MClientRequest.h

index 62d0a473a300a1375cc0a4956d20f741e9522625..2487a6b76bf19a1af7a18d1fd496cc28813ca12d 100644 (file)
@@ -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?
index 1e83ec3af1bdadd483009cab5d9fba16654ceca0..5a3f2ce74c8ceeaee6c6c26b67c06aa86e9b6b73 100644 (file)
@@ -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<uint64_t> gid_list;
 
+  std::vector<uint8_t> fscrypt_auth;
+  std::vector<uint8_t> 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"; }