]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw_file: include tenant in hashes of object
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 5 Jun 2019 11:25:35 +0000 (07:25 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 5 Jun 2019 15:25:06 +0000 (11:25 -0400)
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 <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 81781df082ec9014b8d8332d67009cfed1bbe27d..cf6c0f5303956961cb41de2b8a9f637ecda243e1 100644 (file)
@@ -1109,13 +1109,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);
     }
   }
 
index 9e2286a5e42f0d199622ecb4464edfb27cd9b41e..8ae249ef4182530cab477a72a1d306e589b83ccc 100644 (file)
@@ -111,18 +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,
           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 {