From: Matt Benjamin Date: Wed, 13 Apr 2016 01:31:46 +0000 (-0400) Subject: rgw_file: fix 2 attr decoding issues X-Git-Tag: v10.2.0~8^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5b608ed66100e82dcc2313b503e09a26dc2b8940;p=ceph.git rgw_file: fix 2 attr decoding issues * fix general timestamp decoding (changing to a pointer notation) * capture (std::swap) req_state->bucket_attrs in RGWLibStatBucketRequest Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 19a35e1964d0..1a1007d2ec4a 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -54,7 +54,11 @@ namespace rgw { RGWFileHandle::FLAG_BUCKET); if (get<0>(fhr)) { RGWFileHandle* rgw_fh = get<0>(fhr); - rgw_fh->set_times(req.get_ctime()); + /* restore attributes */ + auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1); + if (ux_attrs) { + rgw_fh->decode_attrs(ux_attrs); + } } } return fhr; @@ -376,15 +380,16 @@ namespace rgw { (rc2 == 0))) { /* op failed */ rgw_fh->flags |= RGWFileHandle::FLAG_DELETED; - rgw_fh->mtx.unlock(); + rgw_fh->mtx.unlock(); /* !LOCKED */ unref(rgw_fh); get<0>(mkr) = nullptr; /* fixup rc */ if (!rc) rc = rc2; + } else { + rgw_fh->mtx.unlock(); /* !LOCKED */ } - rgw_fh->mtx.unlock(); /* !LOCKED */ get<1>(mkr) = rc; return mkr; diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 2acd77d8fe90..17649521c5fa 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -524,6 +524,7 @@ namespace rgw { void encode(buffer::list& bl) const { ENCODE_START(1, 1, bl); + ::encode(uint32_t(fh.fh_type), bl); ::encode(fh.fh_hk.bucket, bl); ::encode(fh.fh_hk.object, bl); ::encode(state.dev, bl); @@ -541,6 +542,9 @@ namespace rgw { void decode(bufferlist::iterator& bl) { DECODE_START(1, bl); struct rgw_file_handle tfh; + uint32_t fh_type; + ::decode(fh_type, bl); + tfh.fh_type = static_cast(fh_type); ::decode(tfh.fh_hk.bucket, bl); ::decode(tfh.fh_hk.object, bl); assert(fh.fh_hk == tfh.fh_hk); @@ -551,9 +555,9 @@ namespace rgw { ::decode(state.owner_gid, bl); ::decode(state.unix_mode, bl); ceph::real_time enc_time; - for (auto& t : { state.ctime, state.mtime, state.atime }) { + for (auto t : { &(state.ctime), &(state.mtime), &(state.atime) }) { ::decode(enc_time, bl); - const_cast(t) = real_clock::to_timespec(enc_time); + *t = real_clock::to_timespec(enc_time); } DECODE_FINISH(bl); } @@ -1677,6 +1681,7 @@ class RGWStatBucketRequest : public RGWLibRequest, { public: std::string uri; + std::map attrs; RGWStatBucketRequest(CephContext* _cct, RGWUserInfo *_user, const std::string& _path) @@ -1685,6 +1690,11 @@ public: op = this; } + buffer::list* get_attr(const std::string& k) { + auto iter = attrs.find(k); + return (iter != attrs.end()) ? &(iter->second) : nullptr; + } + virtual bool only_bucket() { return false; } virtual int op_init() { @@ -1727,6 +1737,7 @@ public: virtual void send_response() { bucket.creation_time = get_state()->bucket_info.creation_time; + std::swap(attrs, get_state()->bucket_attrs); } bool matched() {