]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: include tenant when hashing bucket names
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 15 May 2019 19:53:32 +0000 (15:53 -0400)
committerNathan Cutler <ncutler@suse.com>
Wed, 24 Jul 2019 14:39:01 +0000 (16:39 +0200)
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 <mbenjamin@redhat.com>
(cherry picked from commit b800a9de83dff23a150ed7d236cb61c8b7d971ae)

Conflicts:
src/rgw/rgw_file.cc
- ceph_assert

src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 73765e1394ecfda50890616cf5423ffe12c7254d..b1341675af39ba63c8d63789c482286ef1792bd4 100644 (file)
@@ -981,6 +981,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)
   {
@@ -998,11 +1010,7 @@ namespace rgw {
     fh_key fhk;
     auto bl_iter_key1  = const_cast<buffer::list*>(ux_key1)->begin();
     decode(fhk, bl_iter_key1);
-    if (fhk.version >= 2) {
-      assert(this->fh.fh_hk == fhk.fh_hk);
-    } else {
-      get<0>(dar) = true;
-    }
+    get<0>(dar) = true;
 
     auto bl_iter_unix1 = const_cast<buffer::list*>(ux_attrs1)->begin();
     decode(*this, bl_iter_unix1);
index 422260af29742c3115a609612e10d52e032b47a9..d60fe03acc9dbaba614619c3ebe20ee784c3fcb7 100644 (file)
@@ -114,10 +114,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);
     }
 
@@ -518,14 +520,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) {