]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librgw: add lookup step in rgw_unlink
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 9 Dec 2015 16:18:19 +0000 (11:18 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:20 +0000 (12:06 -0500)
Implement the required check for underlying leaf object, since with
the current signature it is not known.

(Is that a fixed requirement? If we have previously done a lookup, we
already know the underlying object by name and type.)

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

index 794a0df3bf7239b6187cadc6999fa834c29ec72d..0fd0aba84383d35f5839f36d8d1bca18e8991dc0 100644 (file)
@@ -261,7 +261,7 @@ int rgw_rename(struct rgw_fs *rgw_fs,
 /*
   remove file or directory
 */
-int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handleparent_fh,
+int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
              const char *name)
 {
   int rc = 0;
@@ -281,13 +281,20 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle* parent_fh,
     /*
      * leaf object
      */
-    /* XXXX we must peform a hard lookup to deduce the type of
+    /* XXX 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);
-    rc = librgw.get_fe()->execute_req(&req);
+    struct rgw_file_handle *fh;
+    rc = rgw_lookup(rgw_fs, parent_fh, name, &fh, 0 /* flags */);
+    if (! rc)  {
+      /* rgw_fh ref+ */
+      RGWFileHandle* rgw_fh = get_rgwfh(fh);
+      RGWDeleteObjRequest req(cct, fs->get_user(), parent->bucket_name(),
+                             rgw_fh->full_object_name());
+      rc = librgw.get_fe()->execute_req(&req);
+      /* release */
+      (void) rgw_fh_rele(rgw_fs, fh, 0 /* flags */);
+    }
   }
 
   return rc;