]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: declare encoder for Unix object attributes
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 25 Mar 2016 21:33:32 +0000 (17:33 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 20:10:22 +0000 (16:10 -0400)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.h

index 26b97b405f2487879c9967a92594b8077cd634ae..aa580c63743c8b8087b8cc34032c5de2433da7a8 100644 (file)
@@ -153,7 +153,7 @@ namespace rgw {
     using marker_cache_t = flat_map<uint64_t, dirent_string>;
     using name_cache_t = flat_map<dirent_string, uint8_t>;
 
-    struct state {
+    struct State {
       uint64_t dev;
       size_t size;
       uint64_t nlink;
@@ -163,7 +163,7 @@ namespace rgw {
       struct timespec ctime;
       struct timespec mtime;
       struct timespec atime;
-      state() : dev(0), size(0), nlink(1), owner_uid(0), owner_gid(0),
+      State() : dev(0), size(0), nlink(1), owner_uid(0), owner_gid(0),
                ctime{0,0}, mtime{0,0}, atime{0,0} {}
     } state;
 
@@ -522,6 +522,42 @@ namespace rgw {
       state.atime = ts;
     }
 
+    void encode(bufferlist& bl) const {
+      ENCODE_START(1, 1, bl);
+      ::encode(fh.fh_hk.bucket, bl);
+      ::encode(fh.fh_hk.object, bl);
+      ::encode(state.dev, bl);
+      ::encode(state.size, bl);
+      ::encode(state.nlink, bl);
+      ::encode(state.owner_uid, bl);
+      ::encode(state.owner_gid, bl);
+      ::encode(state.unix_mode, bl);
+      for (const auto& t : { state.ctime, state.mtime, state.atime }) {
+       ::encode(real_clock::from_timespec(t), bl);
+      }
+      ENCODE_FINISH(bl);
+    }
+
+    void decode(bufferlist::iterator& bl) {
+      DECODE_START(1, bl);
+      struct rgw_file_handle tfh;
+      ::decode(tfh.fh_hk.bucket, bl);
+      ::decode(tfh.fh_hk.object, bl);
+      assert(fh.fh_hk == tfh.fh_hk);
+      ::decode(state.dev, bl);
+      ::decode(state.size, bl);
+      ::decode(state.nlink, bl);
+      ::decode(state.owner_uid, bl);
+      ::decode(state.owner_gid, bl);
+      ::decode(state.unix_mode, bl);
+      ceph::real_time enc_time;
+      for (auto& t : { state.ctime, state.mtime, state.atime }) {
+       ::decode(enc_time, bl);
+       const_cast<struct timespec&>(t) = real_clock::to_timespec(enc_time);
+      }
+      DECODE_FINISH(bl);
+    }
+
     virtual bool reclaim();
 
     typedef cohort::lru::LRU<std::mutex> FhLRU;