]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: fix 2 attr decoding issues
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 13 Apr 2016 01:31:46 +0000 (21:31 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 13 Apr 2016 01:31:46 +0000 (21:31 -0400)
* fix general timestamp decoding (changing to a pointer notation)
* capture (std::swap) req_state->bucket_attrs in RGWLibStatBucketRequest

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 19a35e1964d0f641f3ae989c36b534e4dd5837d6..1a1007d2ec4ae1d5c1adbe6d971411b9fbc1d01a 100644 (file)
@@ -54,7 +54,11 @@ namespace rgw {
                      RGWFileHandle::FLAG_BUCKET);
       if (get<0>(fhr)) {
        RGWFileHandle* rgw_fh = get<0>(fhr);
-       rgw_fh->set_times(req.get_ctime());
+       /* restore attributes */
+       auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
+       if (ux_attrs) {
+         rgw_fh->decode_attrs(ux_attrs);
+       }
       }
     }
     return fhr;
@@ -376,15 +380,16 @@ namespace rgw {
           (rc2 == 0))) {
       /* op failed */
       rgw_fh->flags |= RGWFileHandle::FLAG_DELETED;
-      rgw_fh->mtx.unlock();
+      rgw_fh->mtx.unlock(); /* !LOCKED */
       unref(rgw_fh);
       get<0>(mkr) = nullptr;
       /* fixup rc */
       if (!rc)
        rc = rc2;
+    } else {
+      rgw_fh->mtx.unlock(); /* !LOCKED */
     }
 
-    rgw_fh->mtx.unlock(); /* !LOCKED */
     get<1>(mkr) = rc;
 
     return mkr;
index 2acd77d8fe904f7bae2c37ecf13551763bc0c051..17649521c5fa4b8733d74b4fdbb8040cccbc0eba 100644 (file)
@@ -524,6 +524,7 @@ namespace rgw {
 
     void encode(buffer::list& bl) const {
       ENCODE_START(1, 1, bl);
+      ::encode(uint32_t(fh.fh_type), bl);
       ::encode(fh.fh_hk.bucket, bl);
       ::encode(fh.fh_hk.object, bl);
       ::encode(state.dev, bl);
@@ -541,6 +542,9 @@ namespace rgw {
     void decode(bufferlist::iterator& bl) {
       DECODE_START(1, bl);
       struct rgw_file_handle tfh;
+      uint32_t fh_type;
+      ::decode(fh_type, bl);
+      tfh.fh_type = static_cast<enum rgw_fh_type>(fh_type);
       ::decode(tfh.fh_hk.bucket, bl);
       ::decode(tfh.fh_hk.object, bl);
       assert(fh.fh_hk == tfh.fh_hk);
@@ -551,9 +555,9 @@ namespace rgw {
       ::decode(state.owner_gid, bl);
       ::decode(state.unix_mode, bl);
       ceph::real_time enc_time;
-      for (auto& t : { state.ctime, state.mtime, state.atime }) {
+      for (auto t : { &(state.ctime), &(state.mtime), &(state.atime) }) {
        ::decode(enc_time, bl);
-       const_cast<struct timespec&>(t) = real_clock::to_timespec(enc_time);
+       *t = real_clock::to_timespec(enc_time);
       }
       DECODE_FINISH(bl);
     }
@@ -1677,6 +1681,7 @@ class RGWStatBucketRequest : public RGWLibRequest,
 {
 public:
   std::string uri;
+  std::map<std::string, buffer::list> attrs;
 
   RGWStatBucketRequest(CephContext* _cct, RGWUserInfo *_user,
                       const std::string& _path)
@@ -1685,6 +1690,11 @@ public:
     op = this;
   }
 
+  buffer::list* get_attr(const std::string& k) {
+    auto iter = attrs.find(k);
+    return (iter != attrs.end()) ? &(iter->second) : nullptr;
+  }
+
   virtual bool only_bucket() { return false; }
 
   virtual int op_init() {
@@ -1727,6 +1737,7 @@ public:
 
   virtual void send_response() {
     bucket.creation_time = get_state()->bucket_info.creation_time;
+    std::swap(attrs, get_state()->bucket_attrs);
   }
 
   bool matched() {