From: Matt Benjamin Date: Wed, 15 May 2019 19:53:32 +0000 (-0400) Subject: rgw_file: include tenant when hashing bucket names X-Git-Tag: v15.1.0~2540^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b800a9de83dff23a150ed7d236cb61c8b7d971ae;p=ceph-ci.git rgw_file: include tenant when hashing bucket names Prevent identical paths from distinct tenants from colliding in RGW NFS handle cache. Fixes: http://tracker.ceph.com/issues/40118 Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index e69da2658ef..81781df082e 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1107,6 +1107,18 @@ 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()); + } else { + std::string key_name = make_key_name(name.c_str()); + return fh_key(fhk.fh_hk.bucket, key_name.c_str()); + } + } + void RGWFileHandle::encode_attrs(ceph::buffer::list& ux_key1, ceph::buffer::list& ux_attrs1) { @@ -1124,11 +1136,7 @@ namespace rgw { fh_key fhk; auto bl_iter_key1 = ux_key1->cbegin(); decode(fhk, bl_iter_key1); - if (fhk.version >= 2) { - ceph_assert(this->fh.fh_hk == fhk.fh_hk); - } else { - get<0>(dar) = true; - } + get<0>(dar) = true; auto bl_iter_unix1 = ux_attrs1->cbegin(); decode(*this, bl_iter_unix1); diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index fd562f51cb8..9e2286a5e42 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -116,10 +116,12 @@ namespace rgw { fh_hk.bucket = bk; fh_hk.object = XXH64(_o, ::strlen(_o), seed); } - - fh_key(const std::string& _b, const std::string& _o) + + fh_key(const std::string& _b, const std::string& _o, + const std::string& _t /* tenant */) : version(0) { - fh_hk.bucket = XXH64(_b.c_str(), _o.length(), seed); + 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); } @@ -522,14 +524,7 @@ namespace rgw { return key_name; } - fh_key make_fhk(const std::string& name) const { - if (depth <= 1) - return fh_key(fhk.fh_hk.object, name.c_str()); - else { - std::string key_name = make_key_name(name.c_str()); - return fh_key(fhk.fh_hk.bucket, key_name.c_str()); - } - } + fh_key make_fhk(const std::string& name); void add_marker(uint64_t off, const rgw_obj_key& marker, uint8_t obj_type) {