From f9f4e996ebf4cce79a45196d8aa796b07e03b7f7 Mon Sep 17 00:00:00 2001 From: taoCH Date: Thu, 14 Feb 2019 19:57:29 -0800 Subject: [PATCH] rgw_file: save etag and acl info in setattr Fixes: https://tracker.ceph.com/issues/38327 Signed-off-by: Tao Chen --- src/rgw/rgw_file.cc | 12 ++++++++++++ src/rgw/rgw_file.h | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 16bf507bbb4b..e2f188b7b34f 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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(); diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index d5be83352b8c..926ff3f94328 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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 */ /* -- 2.47.3