]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: rgw_mkdir and rgw_create return addresses
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 5 Nov 2015 15:15:41 +0000 (10:15 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:05:40 +0000 (12:05 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/include/rados/rgw_file.h
src/rgw/rgw_file.cc
src/test/librgw_file_cd.cc

index 4234c2ae061b666219b7eada12345bcb3d8d3298..7cfa5ec518dc4e6f39a3b4a7459b3b5f38a47ce4 100644 (file)
@@ -121,7 +121,7 @@ int rgw_statfs(struct rgw_fs *rgw_fs,
 int rgw_create(struct rgw_fs *rgw_fs,
               struct rgw_file_handle *parent_fh,
               const char *name, mode_t mode, struct stat *st,
-              struct rgw_file_handle *fh);
+              struct rgw_file_handle **fh);
 
 /*
   create a new directory
@@ -129,7 +129,7 @@ int rgw_create(struct rgw_fs *rgw_fs,
 int rgw_mkdir(struct rgw_fs *rgw_fs,
              struct rgw_file_handle *parent_fh,
              const char *name, mode_t mode, struct stat *st,
-             struct rgw_file_handle *fh);
+             struct rgw_file_handle **fh);
 
 /*
   rename object
index 36107e2cbbab0403a6a567c659e16a7016e8fc0f..1d0c15fcada514c05431647dac62963b993d56a2 100644 (file)
@@ -91,9 +91,9 @@ int rgw_statfs(struct rgw_fs *rgw_fs,
 int rgw_create(struct rgw_fs *rgw_fs,
               struct rgw_file_handle *parent_fh,
               const char *name, mode_t mode, struct stat *st,
-              struct rgw_file_handle *handle)
+              struct rgw_file_handle **fh)
 {
-  return 0;
+  return EINVAL;
 }
 
 /*
@@ -102,7 +102,7 @@ int rgw_create(struct rgw_fs *rgw_fs,
 int rgw_mkdir(struct rgw_fs *rgw_fs,
              struct rgw_file_handle *parent_fh,
              const char *name, mode_t mode, struct stat *st,
-             struct rgw_file_handle *handle)
+             struct rgw_file_handle **fh)
 {
   int rc;
 
@@ -129,6 +129,12 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
   RGWCreateBucketRequest req(cct, fs->get_user(), uri);
   rc = librgw.get_fe()->execute_req(&req);
 
+  /* XXX: atomicity */
+  RGWFileHandle* rgw_fh = fs->lookup_fh(parent, name);
+
+  struct rgw_file_handle *rfh = rgw_fh->get_fh();
+  *fh = rfh;
+
   return rc;
 }
 
index 417ecb4bf7610d65eed9058ab395a3cb06356d1b..31ce06c726c9509780b47e4b1def82c9caddff0b 100644 (file)
@@ -62,7 +62,7 @@ TEST(LibRGW, MOUNT) {
 TEST(LibRGW, CREATE_BUCKET) {
   if (do_create) {
     struct stat st;
-    struct rgw_file_handle fh;
+    struct rgw_file_handle *fh;
     int ret = rgw_mkdir(fs, fs->root_fh, bucket_name.c_str(), 755, &st, &fh);
     ASSERT_EQ(ret, 0);
   }
@@ -79,7 +79,7 @@ TEST(LibRGW, CREATE_BUCKET_MULTI) {
   if (do_multi) {
     int ret;
     struct stat st;
-    struct rgw_file_handle fh;
+    struct rgw_file_handle *fh;
     for (int ix = 0; ix < multi_cnt; ++ix) {
       string bn = bucket_name;
       bn += to_string(ix);