]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 5 Jun 2019 15:24:59 +0000 (11:24 -0400)
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>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index e69da2658ef39ff2ce4ee70b9fadaa45dd3da4fc..81781df082ec9014b8d8332d67009cfed1bbe27d 100644 (file)
@@ -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);
index fd562f51cb8249b273dca0308c6f32f693f10b2f..9e2286a5e42f0d199622ecb4464edfb27cd9b41e 100644 (file)
@@ -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) {