]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: save etag and acl info in setattr 27881/head
authortaoCH <sebastien.chen92@gmail.com>
Fri, 15 Feb 2019 03:57:29 +0000 (19:57 -0800)
committerPrashant D <pdhange@redhat.com>
Tue, 30 Apr 2019 04:16:35 +0000 (00:16 -0400)
Fixes: https://tracker.ceph.com/issues/38327
Signed-off-by: Tao Chen <chentao@umcloud.com>
(cherry picked from commit f9f4e996ebf4cce79a45196d8aa796b07e03b7f7)

src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 9795f7e6dcc9d24cf2d2eceb3ecb0ad4e973e4f3..13d4c3e1b053967145cc939f4b6344b055204205 100644 (file)
@@ -146,6 +146,8 @@ namespace rgw {
            /* restore attributes */
            auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1);
            auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
+            rgw_fh->set_etag(*(req.get_attr(RGW_ATTR_ETAG)));
+            rgw_fh->set_acls(*(req.get_attr(RGW_ATTR_ACL)));
            if (ux_key && ux_attrs) {
               DecodeAttrsResult dar = rgw_fh->decode_attrs(ux_key, ux_attrs);
               if (get<0>(dar) || get<1>(dar)) {
@@ -180,6 +182,8 @@ namespace rgw {
            /* restore attributes */
            auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1);
            auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
+            rgw_fh->set_etag(*(req.get_attr(RGW_ATTR_ETAG)));
+            rgw_fh->set_acls(*(req.get_attr(RGW_ATTR_ACL)));
            if (ux_key && ux_attrs) {
               DecodeAttrsResult dar = rgw_fh->decode_attrs(ux_key, ux_attrs);
               if (get<0>(dar) || get<1>(dar)) {
@@ -653,6 +657,10 @@ namespace rgw {
        }
         if (st)
           (void) rgw_fh->stat(st);
+
+        rgw_fh->set_etag(*(req.get_attr(RGW_ATTR_ETAG)));
+        rgw_fh->set_acls(*(req.get_attr(RGW_ATTR_ACL))); 
+
        get<0>(mkr) = rgw_fh;
        rgw_fh->mtx.unlock();
       } else
@@ -685,6 +693,8 @@ namespace rgw {
   {
     int rc, rc2;
     buffer::list ux_key, ux_attrs;
+    buffer::list etag = rgw_fh->get_etag();
+    buffer::list acls = rgw_fh->get_acls();
 
     lock_guard guard(rgw_fh->mtx);
 
@@ -714,6 +724,8 @@ namespace rgw {
     /* save attrs */
     req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
     req.emplace_attr(RGW_ATTR_UNIX1, std::move(ux_attrs));
+    req.emplace_attr(RGW_ATTR_ETAG, std::move(etag));
+    req.emplace_attr(RGW_ATTR_ACL, std::move(acls));
 
     rc = rgwlib.get_fe()->execute_req(&req);
     rc2 = req.get_ret();
index 8c9436b2d400b9c57e4313d8a14c35ac158c34c4..747649622d80872ece5ba4d8aff8cee73912e6a2 100644 (file)
@@ -235,6 +235,9 @@ namespace rgw {
     uint16_t depth;
     uint32_t flags;
 
+    ceph::buffer::list etag;
+    ceph::buffer::list acls;
+
   public:
     const static std::string root_name;
 
@@ -370,6 +373,9 @@ namespace rgw {
     struct timespec get_ctime() const { return state.ctime; }
     struct timespec get_mtime() const { return state.mtime; }
 
+    const ceph::buffer::list& get_etag() const { return etag; }
+    const ceph::buffer::list& get_acls() const { return acls; }
+
     void create_stat(struct stat* st, uint32_t mask) {
       if (mask & RGW_SETATTR_UID)
        state.owner_uid = st->st_uid;
@@ -615,6 +621,14 @@ namespace rgw {
       state.atime = ts;
     }
 
+    void set_etag(const ceph::buffer::list& _etag ) {
+      etag = _etag;
+    }
+
+    void set_acls(const ceph::buffer::list& _acls ) {
+      acls = _acls;
+    }
+
     void encode(buffer::list& bl) const {
       ENCODE_START(2, 1, bl);
       ::encode(uint32_t(fh.fh_type), bl);
@@ -1851,6 +1865,11 @@ public:
     return 0;
   }
 
+  buffer::list* get_attr(const std::string& k) {
+    auto iter = attrs.find(k);
+    return (iter != attrs.end()) ? &(iter->second) : nullptr;
+  }
+
 }; /* RGWPutObjRequest */
 
 /*