From: Matt Benjamin Date: Wed, 9 Dec 2015 16:18:19 +0000 (-0500) Subject: librgw: add lookup step in rgw_unlink X-Git-Tag: v10.1.0~382^2~127 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b9f306577a539c1142512af6f046d487f61f01ed;p=ceph.git librgw: add lookup step in rgw_unlink 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 794a0df3bf72..0fd0aba84383 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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_handle* parent_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;