From 059f1ea77e6d1906842340cc88acd949f6bae58b Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 5 Jun 2019 07:25:35 -0400 Subject: [PATCH] rgw_file: include tenant in hashes of object Because bucket names are taken as object names in the top of an export. Make hashing by tenant general to avoid disjoint hashing of bucket. Fixes: http://tracker.ceph.com/issues/40118 Signed-off-by: Matt Benjamin (cherry picked from commit 8e0fd5fbfa7c770f6b668e79b772179946027bce) --- src/rgw/rgw_file.cc | 10 +++++----- src/rgw/rgw_file.h | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index b1341675af3..b2e20c4c498 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -983,13 +983,13 @@ namespace rgw { fh_key RGWFileHandle::make_fhk(const std::string& name) { - if (depth <= 1) { - std::string tenanted_name = - get_fs()->get_user()->user_id.to_str() + ":" + name; - return fh_key(fhk.fh_hk.object, tenanted_name.c_str()); + std::string tenant = get_fs()->get_user()->user_id.to_str(); + if (depth == 0) { + /* S3 bucket -- assert mount-at-bucket case reaches here */ + return fh_key(name, name, tenant); } else { std::string key_name = make_key_name(name.c_str()); - return fh_key(fhk.fh_hk.bucket, key_name.c_str()); + return fh_key(fhk.fh_hk.bucket, key_name.c_str(), tenant); } } diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index d60fe03acc9..025854c6814 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -109,18 +109,20 @@ namespace rgw { fh_hk.object = ok; } - fh_key(const uint64_t bk, const char *_o) + fh_key(const uint64_t bk, const char *_o, const std::string& _t) : version(0) { fh_hk.bucket = bk; - fh_hk.object = XXH64(_o, ::strlen(_o), seed); + std::string to = _t + ":" + _o; + fh_hk.object = XXH64(to.c_str(), to.length(), seed); } fh_key(const std::string& _b, const std::string& _o, const std::string& _t /* tenant */) : version(0) { std::string tb = _t + ":" + _b; - fh_hk.bucket = XXH64(tb.c_str(), _o.length(), seed); - fh_hk.object = XXH64(_o.c_str(), _o.length(), seed); + std::string to = _t + ":" + _o; + fh_hk.bucket = XXH64(tb.c_str(), tb.length(), seed); + fh_hk.object = XXH64(to.c_str(), to.length(), seed); } void encode(buffer::list& bl) const { -- 2.47.3