mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
Merge pull request #28370 from linuxbox2/wip-rgw-tntbucket
rgw_file: include tenant when hashing bucket names
This commit is contained in:
commit
7a38429a08
@ -942,6 +942,15 @@ namespace rgw {
|
||||
rele();
|
||||
} /* RGWLibFS::close */
|
||||
|
||||
inline std::ostream& operator<<(std::ostream &os, fh_key const &fhk) {
|
||||
os << "<fh_key: bucket=";
|
||||
os << fhk.fh_hk.bucket;
|
||||
os << "; object=";
|
||||
os << fhk.fh_hk.object;
|
||||
os << ">";
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream &os, struct timespec const &ts) {
|
||||
os << "<timespec: tv_sec=";
|
||||
os << ts.tv_sec;
|
||||
@ -1107,6 +1116,18 @@ namespace rgw {
|
||||
}
|
||||
}
|
||||
|
||||
fh_key RGWFileHandle::make_fhk(const std::string& name)
|
||||
{
|
||||
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(), tenant);
|
||||
}
|
||||
}
|
||||
|
||||
void RGWFileHandle::encode_attrs(ceph::buffer::list& ux_key1,
|
||||
ceph::buffer::list& ux_attrs1)
|
||||
{
|
||||
@ -1124,11 +1145,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);
|
||||
|
@ -111,16 +111,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)
|
||||
|
||||
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);
|
||||
fh_hk.object = XXH64(_o.c_str(), _o.length(), seed);
|
||||
std::string tb = _t + ":" + _b;
|
||||
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 {
|
||||
@ -140,6 +144,9 @@ namespace rgw {
|
||||
}
|
||||
DECODE_FINISH(bl);
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream &os, fh_key const &fhk);
|
||||
|
||||
}; /* fh_key */
|
||||
|
||||
WRITE_CLASS_ENCODER(fh_key);
|
||||
@ -522,14 +529,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) {
|
||||
@ -1058,15 +1058,15 @@ namespace rgw {
|
||||
|
||||
std::string obj_name{name};
|
||||
std::string key_name{parent->make_key_name(name)};
|
||||
fh_key fhk = parent->make_fhk(obj_name);
|
||||
|
||||
lsubdout(get_context(), rgw, 10)
|
||||
<< __func__ << " lookup called on "
|
||||
<< parent->object_name() << " for " << key_name
|
||||
<< " (" << obj_name << ")"
|
||||
<< " -> " << fhk
|
||||
<< dendl;
|
||||
|
||||
fh_key fhk = parent->make_fhk(obj_name);
|
||||
|
||||
retry:
|
||||
RGWFileHandle* fh =
|
||||
fh_cache.find_latch(fhk.fh_hk.object /* partition selector*/,
|
||||
|
Loading…
Reference in New Issue
Block a user