]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: don't abuse fs_private
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 10 Nov 2015 00:19:52 +0000 (19:19 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:05:51 +0000 (12:05 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 828760bf938e147493f934a0d56b977f42e4fba0..29c50f803df5fc91d7c6aac4cef84cceed1e759c 100644 (file)
@@ -47,7 +47,8 @@ extern "C" {
   int rc = 0;
 
   /* stash access data for "mount" */
-  RGWLibFS* new_fs = new RGWLibFS(uid, acc_key, sec_key);
+  RGWLibFS* new_fs = new RGWLibFS(static_cast<CephContext*>(rgw), uid, acc_key,
+                                 sec_key);
   assert(new_fs);
 
   rc = new_fs->authorize(librgw.get_store());
@@ -244,10 +245,15 @@ int rgw_lookup(struct rgw_fs *rgw_fs,
   RGWFileHandle* rgw_fh;
 
   if (parent->is_root()) {
-    /* XXX if lookup is in the root, then (for now) just get a handle */
-    rgw_fh = fs->lookup_fh(parent, path);
-    if (! rgw_fh)
-      return ENOENT;
+    /* special: lookup on root itself */
+    if (strcmp(path, "/") == 0) {
+      rgw_fh = parent->ref();
+    } else {
+      /* name lookup in root--for now) just get a handle */
+      rgw_fh = fs->lookup_fh(parent, path);
+      if (! rgw_fh)
+       return ENOENT;
+    }
   } else {
     std::string object_name{path};
     RGWStatObjRequest req(cct, fs->get_user(),
@@ -263,7 +269,7 @@ int rgw_lookup(struct rgw_fs *rgw_fs,
     rgw_fh = fs->lookup_fh(parent, path);
     if (! rgw_fh)
       return ENOENT;
-  }
+  } /* !root */
 
   struct rgw_file_handle *rfh = rgw_fh->get_fh();
   *fh = rfh;
index b1801901c4954f19c48026614c775a541db31419..2eb3da14775e8392bcd70c8363b5e381bfaa762b 100644 (file)
@@ -191,6 +191,11 @@ namespace rgw {
       }
     }
 
+    RGWFileHandle* ref() {
+      intrusive_ptr_add_ref(this);
+      return this;
+    }
+
     inline void rele() {
       intrusive_ptr_release(this);
     }
@@ -248,6 +253,7 @@ namespace rgw {
 
   class RGWLibFS
   {
+    CephContext* cct;
     struct rgw_fs fs;
     RGWFileHandle root_fh;
 
@@ -262,8 +268,9 @@ namespace rgw {
     std::string fsid;
     
   public:
-    RGWLibFS(const char *_uid, const char *_user_id, const char* _key)
-      : root_fh(this),  uid(_uid), key(_user_id, _key) {
+    RGWLibFS(CephContext* _cct, const char *_uid, const char *_user_id,
+           const char* _key)
+      : cct(_cct), root_fh(this),  uid(_uid), key(_user_id, _key) {
 
       /* no bucket may be named rgw_fs_inst-(.*) */
       fsid = RGWFileHandle::root_name + "rgw_fs_inst-" +
@@ -339,7 +346,7 @@ namespace rgw {
     }
 
     CephContext* get_context() {
-      return static_cast<CephContext*>(get_fs()->fs_private);
+      return cct;
     }
 
     struct rgw_fs* get_fs() { return &fs; }