]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: save etag and acl info in setattr 26439/head
authortaoCH <sebastien.chen92@gmail.com>
Fri, 15 Feb 2019 03:57:29 +0000 (19:57 -0800)
committerchentao <chentao@umcloud.com>
Tue, 19 Feb 2019 02:55:17 +0000 (18:55 -0800)
Fixes: https://tracker.ceph.com/issues/38327
Signed-off-by: Tao Chen <chentao@umcloud.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 16bf507bbb4bc98e90e3bc4576f20f5f21a65fb5..e2f188b7b34fd36704bb15bf27ea63ef0c2c9745 100644 (file)
@@ -147,6 +147,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)) {
@@ -181,6 +183,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)) {
@@ -677,6 +681,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
@@ -810,6 +818,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);
 
@@ -839,6 +849,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 d5be83352b8caa5a909026086072fa62262930ed..926ff3f943284cd2c0b1f7cbe9dde6196affb311 100644 (file)
@@ -237,6 +237,9 @@ namespace rgw {
     uint16_t depth;
     uint32_t flags;
 
+    ceph::buffer::list etag;
+    ceph::buffer::list acls;
+
   public:
     const static std::string root_name;
 
@@ -382,6 +385,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;
@@ -639,6 +645,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);
@@ -1879,6 +1893,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 */
 
 /*