]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add "fscrypt" flag support for inode_t
authorXiubo Li <xiubli@redhat.com>
Sun, 27 Sep 2020 03:53:55 +0000 (11:53 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Sat, 16 Jan 2021 01:30:39 +0000 (17:30 -0800)
If the client has set the "encryption.ctx" attribute, the MDS side
will set the "fscrypt" flag to truth, false as default.

The clients could use this flag to get to know whether the current
inodes are under enscrypted or not.

Fixes: https://tracker.ceph.com/issues/47162
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/Client.cc
src/client/Inode.h
src/mds/CInode.cc
src/mds/Server.cc
src/mds/mdstypes.h
src/messages/MClientReply.h

index 96f6fd02b45d5067e83ebda8b30ddeaf99dc91de..a21e65ec6dd9791db482b86cf7407e67662a455e 100644 (file)
@@ -1012,6 +1012,7 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from,
     in->snap_caps |= st->cap.caps;
   }
 
+  in->fscrypt = st->fscrypt;
   return in;
 }
 
index 66fc0411a319e20acdef2ef68a35c24b4fc4453a..4fa9c6938558ac86f3f3753d387fc0d8fef5e101 100644 (file)
@@ -166,6 +166,8 @@ struct Inode {
   version_t  inline_version;
   bufferlist inline_data;
 
+  bool fscrypt = false; // fscrypt enabled ?
+
   bool is_root()    const { return ino == MDS_INO_ROOT; }
   bool is_symlink() const { return (mode & S_IFMT) == S_IFLNK; }
   bool is_dir()     const { return (mode & S_IFMT) == S_IFDIR; }
index 1aab7637569a3425f4e4449fa6e8ae667b9a1cdf..4b159355e17f9b62f5111e92ba64d631b8d2a0ea 100644 (file)
@@ -3996,7 +3996,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
    * note: encoding matches MClientReply::InodeStat
    */
   if (session->info.has_feature(CEPHFS_FEATURE_REPLY_ENCODING)) {
-    ENCODE_START(5, 1, bl);
+    ENCODE_START(6, 1, bl);
     encode(oi->ino, bl);
     encode(snapid, bl);
     encode(oi->rdev, bl);
@@ -4041,6 +4041,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
     encode(snap_btime, bl);
     encode(file_i->rstat.rsnaps, bl);
     encode(snap_metadata, bl);
+    encode(file_i->fscrypt, bl);
     ENCODE_FINISH(bl);
   }
   else {
index 36d5f25011061c3b1b3c5d5f5c61afbbeab0009f..4fc87db91242ce0eb91ce3974547f6f8fb5c9ffe 100644 (file)
@@ -6090,6 +6090,8 @@ void Server::handle_client_setxattr(MDRequestRef& mdr)
   pi.inode->ctime = mdr->get_op_stamp();
   if (mdr->get_op_stamp() > pi.inode->rstat.rctime)
     pi.inode->rstat.rctime = mdr->get_op_stamp();
+  if (name == "encryption.ctx"sv)
+    pi.inode->fscrypt = true;
   pi.inode->change_attr++;
   pi.inode->xattr_version++;
 
index 3d95bacebcdf68838d3e9c69515542b36bba2153..158a447d96aaf570a7c99745cec4401607d6a9b7 100644 (file)
@@ -627,6 +627,8 @@ struct inode_t {
 
   std::basic_string<char,std::char_traits<char>,Allocator<char>> stray_prior_path; //stores path before unlink
 
+  bool fscrypt = false; // fscrypt enabled ?
+
 private:
   bool older_is_consistent(const inode_t &other) const;
 };
@@ -635,7 +637,7 @@ private:
 template<template<typename> class Allocator>
 void inode_t<Allocator>::encode(ceph::buffer::list &bl, uint64_t features) const
 {
-  ENCODE_START(16, 6, bl);
+  ENCODE_START(17, 6, bl);
 
   encode(ino, bl);
   encode(rdev, bl);
@@ -690,13 +692,15 @@ void inode_t<Allocator>::encode(ceph::buffer::list &bl, uint64_t features) const
   encode(export_ephemeral_random_pin, bl);
   encode(export_ephemeral_distributed_pin, bl);
 
+  encode(fscrypt, bl);
+
   ENCODE_FINISH(bl);
 }
 
 template<template<typename> class Allocator>
 void inode_t<Allocator>::decode(ceph::buffer::list::const_iterator &p)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(16, 6, 6, p);
+  DECODE_START_LEGACY_COMPAT_LEN(17, 6, 6, p);
 
   decode(ino, p);
   decode(rdev, p);
@@ -794,6 +798,12 @@ void inode_t<Allocator>::decode(ceph::buffer::list::const_iterator &p)
     export_ephemeral_distributed_pin = false;
   }
 
+  if (struct_v >= 17) {
+    decode(fscrypt, p);
+  } else {
+    fscrypt = 0;
+  }
+
   DECODE_FINISH(p);
 }
 
index 4fb8c19d8d078397a035f2fa074c8676b5b4b585..dca000a59bff473e400b5e5821ef9834f5e42e5d 100644 (file)
@@ -137,6 +137,8 @@ struct InodeStat {
   mds_rank_t dir_pin;
   std::map<std::string,std::string> snap_metadata;
 
+  bool fscrypt = false; // fscrypt enabled ?
+
  public:
   InodeStat() {}
   InodeStat(ceph::buffer::list::const_iterator& p, const uint64_t features) {
@@ -146,7 +148,7 @@ struct InodeStat {
   void decode(ceph::buffer::list::const_iterator &p, const uint64_t features) {
     using ceph::decode;
     if (features == (uint64_t)-1) {
-      DECODE_START(5, p);
+      DECODE_START(6, p);
       decode(vino.ino, p);
       decode(vino.snapid, p);
       decode(rdev, p);
@@ -200,6 +202,9 @@ struct InodeStat {
       if (struct_v >= 5) {
         decode(snap_metadata, p);
       }
+      if (struct_v >= 6) {
+        decode(fscrypt, p);
+      }
       DECODE_FINISH(p);
     }
     else {