]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: save etag and acl info in setattr 27904/head
authortaoCH <sebastien.chen92@gmail.com>
Fri, 15 Feb 2019 03:57:29 +0000 (19:57 -0800)
committerPrashant D <pdhange@redhat.com>
Wed, 1 May 2019 08:36:13 +0000 (04:36 -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 3516950b3b7b2fec23300b86194fa6d6e0c58a4d..5c0a4d3beffbd40fb8d6defb4d363575695c94f1 100644 (file)
@@ -148,6 +148,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)) {
@@ -182,6 +184,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)) {
@@ -678,6 +682,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
@@ -811,6 +819,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);
 
@@ -840,6 +850,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 bc695eb0d0b3d17c61dcf28755a854f06e2975fd..1bd9433240370b2c518178c1474aeed0cf83f96d 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);
@@ -1884,6 +1898,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 */
 
 /*