From b9c614e81b3c27e43e28972607bdc274c1f96027 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 (cherry picked from commit f9f4e996ebf4cce79a45196d8aa796b07e03b7f7) --- 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 7fd5790dcbd37..9d89368da0329 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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(); diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 2f031e1a2124a..0a91e6be3c2e1 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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; @@ -372,6 +375,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; @@ -617,6 +623,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); @@ -1853,6 +1867,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.39.5