]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: create explicit directory leaf objects in rgw_mkdir
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 1 Dec 2015 18:05:50 +0000 (13:05 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:09 +0000 (12:06 -0500)
There is some asymmetry here, since directories are also inferred
from object names containing embedded "/."

The obvious question seems to be, "when can a leaf directory be
garbage collected?"  The answer seems to be, "only explicitly."

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

index f221c3e4491abbca04ead3d37f9d5840aa2a880b..eb7c7c99398b75b02a55213f4b296648050a015a 100644 (file)
@@ -182,8 +182,13 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
     RGWCreateBucketRequest req(cct, fs->get_user(), uri);
     rc = librgw.get_fe()->execute_req(&req);
   } else {
-    /* pseudofs */
+    /* create an object representing the directory (naive version) */
+    buffer::list bl;
     fhr = fs->lookup_fh(parent, name, RGWFileHandle::FLAG_PSEUDO);
+    string dir_name = rgw_fh->full_object_name() + "/";
+    RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
+                        dir_name, bl);
+    rc = librgw.get_fe()->execute_req(&req);
   }
 
   rgw_fh = get<0>(fhr);
@@ -225,8 +230,11 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle* parent_fh,
     rc = librgw.get_fe()->execute_req(&req);
   } else {
     /*
-     * object
+     * leaf object
      */
+    /* XXXX we must peform a hard lookup to deduce the type of
+     * object to be deleted ("foo" vs. "foo/"), and as a side effect
+     * can do no further work if no object existed */
     string object_name{name};
     RGWDeleteObjRequest req(cct, fs->get_user(), parent->bucket_name(),
       object_name);