]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: create dir file handles w/correct type
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 6 Dec 2015 21:39:35 +0000 (16:39 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:15 +0000 (12:06 -0500)
RGW objects which happen to represent directories will always end
in '/', but the trailing slash will not be present in cached versions
of the name.

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

index 1c8f42ffcedec1d8e62dc77c154f59b09be7b2a4..b169bdf388e83b45ad3d260a993020f2ffa13871 100644 (file)
@@ -44,6 +44,7 @@ LookupFHResult RGWLibFS::stat_leaf(RGWFileHandle* parent,
   RGWLibFS* fs = parent->get_fs();
   LookupFHResult fhr{nullptr, 0};
   std::string object_name{path};
+  uint32_t cflags = RGWFileHandle::FLAG_NONE;
 
   for (auto ix : { 0, 1 }) {
     ignore(ix);
@@ -53,9 +54,10 @@ LookupFHResult RGWLibFS::stat_leaf(RGWFileHandle* parent,
     int rc = librgw.get_fe()->execute_req(&req);
     if ((rc == 0) &&
        (req.get_ret() == 0)) {
-      fhr = fs->lookup_fh(parent, path);
+      fhr = fs->lookup_fh(parent, path, cflags);
       break;
     }
+    cflags = RGWFileHandle::FLAG_DIRECTORY;
     object_name += "/";
   }
   return fhr;
index 321e6a45efce6a26f365e3954bd71f69f5962978..61cb8f89d78820cb7a21f92933dbcfae343aa9bb 100644 (file)
@@ -141,12 +141,13 @@ namespace rgw {
 
     static constexpr uint16_t MAX_DEPTH = 256;
 
-    static constexpr uint32_t FLAG_NONE =   0x0000;
-    static constexpr uint32_t FLAG_OPEN =   0x0001;
-    static constexpr uint32_t FLAG_ROOT =   0x0002;
-    static constexpr uint32_t FLAG_CREATE = 0x0004;
-    static constexpr uint32_t FLAG_PSEUDO = 0x0008;
-    static constexpr uint32_t FLAG_LOCK =   0x0010;
+    static constexpr uint32_t FLAG_NONE =    0x0000;
+    static constexpr uint32_t FLAG_OPEN =    0x0001;
+    static constexpr uint32_t FLAG_ROOT =    0x0002;
+    static constexpr uint32_t FLAG_CREATE =  0x0004;
+    static constexpr uint32_t FLAG_PSEUDO =  0x0008;
+    static constexpr uint32_t FLAG_DIRECTORY = 0x0010;
+    static constexpr uint32_t FLAG_LOCK =   0x0020;
 
     friend class RGWLibFS;
 
@@ -173,10 +174,10 @@ namespace rgw {
 
   public:
     RGWFileHandle(RGWLibFS* fs, uint32_t fs_inst, RGWFileHandle* _parent,
-                 const fh_key& _fhk, std::string& _name)
-      : parent(_parent), name(std::move(_name)), fhk(_fhk), flags(FLAG_NONE) {
+                 const fh_key& _fhk, std::string& _name, uint32_t _flags)
+      : parent(_parent), name(std::move(_name)), fhk(_fhk), flags(_flags) {
 
-      fh.fh_type = parent->is_root()
+      fh.fh_type = (parent->is_root() || (flags & FLAG_DIRECTORY))
        ? RGW_FS_TYPE_DIRECTORY : RGW_FS_TYPE_FILE;
 
       depth = parent->depth + 1;
@@ -476,7 +477,7 @@ namespace rgw {
       /* LATCHED */
       if ((! fh) &&
          (cflags & RGWFileHandle::FLAG_CREATE)) {
-       fh = new RGWFileHandle(this, get_inst(), parent, fhk, sname);
+       fh = new RGWFileHandle(this, get_inst(), parent, fhk, sname, cflags);
        intrusive_ptr_add_ref(fh); /* sentinel ref */
        fh_cache.insert_latched(fh, lat,
                                  RGWFileHandle::FHCache::FLAG_NONE);