]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: introduce RGW_LOOKUP_FLAG_CREATE
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 8 Nov 2015 23:54:58 +0000 (18:54 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:05:50 +0000 (12:05 -0500)
The current API relies on rgw_lookup and rgw_lookup_filehandle to
return file handle instances, and like POSIX, needs to deal in some
way with the NFS/POSIX open-for-create concept.

For now, allow rgw_lookup to return the canonical instance for an
object being created, i.e., if the option RGW_LOOKUP_FLAG_CREATE
is passed.  (I added an RGW_OPEN_FLAG_CREATE also, but it doesn't
do anything.)

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

index 7cfa5ec518dc4e6f39a3b4a7459b3b5f38a47ce4..040426ef7a019be7ebad2b0ea0878a96952a6b67 100644 (file)
@@ -79,6 +79,9 @@ struct rgw_statvfs {
 /*
   lookup object by name (POSIX style)
 */
+#define RGW_LOOKUP_FLAG_NONE    0x0000
+#define RGW_LOOKUP_FLAG_CREATE  0x0001
+
 int rgw_lookup(struct rgw_fs *rgw_fs,
              struct rgw_file_handle *parent_fh, const char *path,
              struct rgw_file_handle **fh, uint32_t flags);
@@ -184,6 +187,9 @@ int rgw_truncate(struct rgw_fs *rgw_fs,
 /*
    open file
 */
+#define RGW_OPEN_FLAG_NONE    0x0000
+#define RGW_OPEN_FLAG_CREATE  0x0001
+
 int rgw_open(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
            uint32_t flags);
 
index bd64f116ed89ba14b3b0d236cb4c7a1c063620c9..828760bf938e147493f934a0d56b977f42e4fba0 100644 (file)
@@ -255,8 +255,9 @@ int rgw_lookup(struct rgw_fs *rgw_fs,
                          RGWStatObjRequest::FLAG_NONE);
 
     int rc = librgw.get_fe()->execute_req(&req);
-    if ((rc != 0) ||
-       (req.get_ret() != 0))
+    if (((rc != 0) ||
+           (req.get_ret() != 0)) &&
+       (! (flags & RGW_LOOKUP_FLAG_CREATE)))
       return ENOENT;
 
     rgw_fh = fs->lookup_fh(parent, path);
index adc9629de3b32154afbca872e6fc654752d64dc3..f35503e251975015ef21af343a2e374ec00f64b4 100644 (file)
@@ -219,7 +219,7 @@ TEST(LibRGW, LIST_OBJECTS) {
 TEST(LibRGW, LOOKUP_OBJECT) {
   if (do_get || do_put || do_bulk || do_readv || do_writev) {
     int ret = rgw_lookup(fs, bucket_fh, object_name.c_str(), &object_fh,
-                       0 /* flags */);
+                       RGW_LOOKUP_FLAG_CREATE);
     ASSERT_EQ(ret, 0);
   }
 }