]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: permit dirent offset computation 16275/head
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 11 Jul 2017 23:30:12 +0000 (19:30 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 12 Jul 2017 04:56:58 +0000 (00:56 -0400)
The new dirent chunking feature in nfs-ganesha 2.5 includes an
optimization inspired by RGW NFS, and avoids invalidating modified
dirs when the underlying FSAL can project the offset of a
name in it's parent directory, independent of other entries (e.g.,
if offset is a stable hash).

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

index add86df471de6391838569ee60894897a72ab74f..95ca603c9653f98251621a897ac4ff3376e6ab74 100644 (file)
@@ -27,7 +27,7 @@ extern "C" {
 
 #define LIBRGW_FILE_VER_MAJOR 1
 #define LIBRGW_FILE_VER_MINOR 1
-#define LIBRGW_FILE_VER_EXTRA 3
+#define LIBRGW_FILE_VER_EXTRA 4
 
 #define LIBRGW_FILE_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
 #define LIBRGW_FILE_VERSION_CODE LIBRGW_FILE_VERSION(LIBRGW_FILE_VER_MAJOR, LIBRGW_FILE_VER_MINOR, LIBRGW_FILE_VER_EXTRA)
@@ -217,6 +217,14 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
                rgw_readdir_cb rcb, void *cb_arg, bool *eof,
                uint32_t flags);
 
+/* project offset of dirent name */
+#define RGW_DIRENT_OFFSET_FLAG_NONE 0x0000
+
+int rgw_dirent_offset(struct rgw_fs *rgw_fs,
+                     struct rgw_file_handle *parent_fh,
+                     const char *name, int64_t *offset,
+                     uint32_t flags);
+
 /*
    get unix attributes for object
 */
index ca8a5c4b4b879af7e85b6252691382cea0881232..344c29bb41968fe6f85ea13826984e71a734277d 100644 (file)
@@ -1796,6 +1796,22 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
   return rc;
 }
 
+/* project offset of dirent name */
+int rgw_dirent_offset(struct rgw_fs *rgw_fs,
+                     struct rgw_file_handle *parent_fh,
+                     const char *name, int64_t *offset,
+                     uint32_t flags)
+{
+  RGWFileHandle* parent = get_rgwfh(parent_fh);
+  if ((! parent)) {
+    /* bad parent */
+    return -EINVAL;
+  }
+  std::string sname{name};
+  int rc = parent->offset_of(sname, offset, flags);
+  return rc;
+}
+
 /*
    read data from file
 */
index b93b592840930771d518461fa5bff4c013b0c04e..374e55200a110d1bcaa42f7719bf4a83b10cd3d8 100644 (file)
@@ -504,6 +504,14 @@ namespace rgw {
       return nullptr;
     }
 
+    int offset_of(const std::string& name, int64_t *offset, uint32_t flags) {
+      if (unlikely(! is_dir())) {
+       return -EINVAL;
+      }
+      *offset = XXH64(name.c_str(), name.length(), fh_key::seed);
+      return 0;
+    }
+
     bool is_open() const { return flags & FLAG_OPEN; }
     bool is_root() const { return flags & FLAG_ROOT; }
     bool is_bucket() const { return flags & FLAG_BUCKET; }