]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librgw: add pseudofs awareness to lookup_fh
authorMatt Benjamin <mbenjamin@redhat.com>
Mon, 30 Nov 2015 21:55:27 +0000 (16:55 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:04 +0000 (12:06 -0500)
And then allow rgw_mkdir() to create pseudofs vnodes, when parent
is not the root.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index cc80919691105574f91ec043608fb72771be2946..03be995d6a4728e912a8d69c04151930d91a19b9 100644 (file)
@@ -171,19 +171,23 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
     return -EINVAL;
   }
 
-  /* XXX: atomicity */
-  LookupFHResult fhr = fs->lookup_fh(parent, name);
-  RGWFileHandle* rgw_fh = get<0>(fhr);
+  LookupFHResult fhr;
+  RGWFileHandle* rgw_fh;
 
   if (parent->is_root()) {
-    /* mkdir in root creates a new bucket */
+    /* bucket */
+    fhr = fs->lookup_fh(parent, name);
     uri += "/"; /* XXX */
     uri += name;
     RGWCreateBucketRequest req(cct, fs->get_user(), uri);
     rc = librgw.get_fe()->execute_req(&req);
-  } else
-    rgw_fh->set_pseudo();
+  } else {
+    /* pseudofs */
+    LookupFHResult fhr =
+      fs->lookup_fh(parent, name, RGWFileHandle::FLAG_PSEUDO);
+  }
 
+  rgw_fh = get<0>(fhr);
   struct rgw_file_handle *rfh = rgw_fh->get_fh();
   *fh = rfh;
 
@@ -550,7 +554,7 @@ int rgw_write(struct rgw_fs *rgw_fs,
 
   /* XXX */
   RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
-                     rgw_fh->object_name(), bl);
+                      rgw_fh->full_object_name(), bl);
 
   int rc = librgw.get_fe()->execute_req(&req);
 
@@ -661,7 +665,7 @@ int rgw_readv(struct rgw_fs *rgw_fs,
   }
 
   RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
-                     rgw_fh->object_name(), bl);
+                      rgw_fh->full_object_name(), bl);
 
   int rc = librgw.get_fe()->execute_req(&req);
 
index b4e62c87d255f189c145a1dc4bc9022e6bf1999b..aef83778ca01bdddf256fce918e87f665495da1f 100644 (file)
@@ -171,12 +171,11 @@ namespace rgw {
       : parent(_parent), name(std::move(_name)), fhk(_fhk), flags(FLAG_NONE) {
 
       fh.fh_type = parent->is_root()
-       ? RGW_FS_TYPE_DIRECTORY : RGW_FS_TYPE_FILE;      
+       ? RGW_FS_TYPE_DIRECTORY : RGW_FS_TYPE_FILE;
 
       depth = parent->depth + 1;
 
       /* save constant fhk */
-      fh_key fhk(parent->bucket_name(), make_path());
       fh.fh_hk = fhk.fh_hk; /* XXX redundant in fh_hk */
 
       /* pointer to self */
@@ -235,7 +234,7 @@ namespace rgw {
 
     const std::string& object_name() const { return name; }
 
-    std::string make_path() {
+    std::string full_object_name() {
       if (depth <= 1) {
        return object_name();
       }
@@ -451,7 +450,8 @@ namespace rgw {
     }
 
     /* find or create an RGWFileHandle */
-    LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name) {
+    LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name,
+                            const uint32_t cflags = RGWFileHandle::FLAG_NONE) {
 
       std::string sname(name);
       RGWFileHandle::FHCache::Latch lat;
@@ -470,6 +470,8 @@ namespace rgw {
        intrusive_ptr_add_ref(fh); /* sentinel ref */
        fh_cache.insert_latched(fh, lat,
                                RGWFileHandle::FHCache::FLAG_NONE);
+       if (cflags & RGWFileHandle::FLAG_PSEUDO)
+         fh->set_pseudo();
        get<1>(fhr) = RGWFileHandle::FLAG_CREATE;
       }
       intrusive_ptr_add_ref(fh); /* call path/handle ref */