summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-05 13:54:11 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-05 15:52:41 -0800
commit16235a7acb9543d60470170bb2a09956364626cd (patch)
treed15ada4e4c07c9aa076d2ec2e796a21d0c9467b2
parent609442dad4acff77a3ce03064cc4c90c817b5213 (diff)
downloadceph-16235a7acb9543d60470170bb2a09956364626cd.tar.gz
rgw: radosgw-admin object unlink
Add a radosgw-admin option to remove object from bucket index Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_admin.cc14
-rw-r--r--src/rgw/rgw_rados.cc26
-rw-r--r--src/rgw/rgw_rados.h2
-rw-r--r--src/test/cli/radosgw-admin/help.t1
4 files changed, 43 insertions, 0 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index 9984427de3a..f0781504efc 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -46,6 +46,7 @@ void _usage()
cerr << " bucket unlink unlink bucket from specified user\n";
cerr << " bucket stats returns bucket statistics\n";
cerr << " bucket info show bucket information\n";
+ cerr << " object unlink unlink object from bucket index\n";
cerr << " pool add add an existing pool for data placement\n";
cerr << " pool rm remove an existing pool from data placement set\n";
cerr << " pools list list placement active set\n";
@@ -124,6 +125,7 @@ enum {
OPT_BUCKET_LINK,
OPT_BUCKET_UNLINK,
OPT_BUCKET_STATS,
+ OPT_OBJECT_UNLINK,
OPT_POLICY,
OPT_POOL_ADD,
OPT_POOL_RM,
@@ -201,6 +203,7 @@ static int get_cmd(const char *cmd, const char *prev_cmd, bool *need_more)
strcmp(cmd, "key") == 0 ||
strcmp(cmd, "buckets") == 0 ||
strcmp(cmd, "bucket") == 0 ||
+ strcmp(cmd, "object") == 0 ||
strcmp(cmd, "pool") == 0 ||
strcmp(cmd, "pools") == 0 ||
strcmp(cmd, "log") == 0 ||
@@ -253,6 +256,9 @@ static int get_cmd(const char *cmd, const char *prev_cmd, bool *need_more)
return OPT_BUCKET_UNLINK;
if (strcmp(cmd, "stats") == 0)
return OPT_BUCKET_STATS;
+ } else if (strcmp(prev_cmd, "object") == 0) {
+ if (strcmp(cmd, "unlink") == 0)
+ return OPT_OBJECT_UNLINK;
} else if (strcmp(prev_cmd, "log") == 0) {
if (strcmp(cmd, "list") == 0)
return OPT_LOG_LIST;
@@ -1496,5 +1502,13 @@ next:
}
}
+ if (opt_cmd == OPT_OBJECT_UNLINK) {
+ int ret = rgwstore->remove_obj_from_index(bucket, object);
+ if (ret < 0) {
+ cerr << "ERROR: remove_obj_from_index() returned error: " << cpp_strerror(-ret) << std::endl;
+ return 1;
+ }
+ }
+
return 0;
}
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 9592d438b54..a5655a9038e 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -2751,6 +2751,32 @@ int RGWRados::cls_obj_usage_log_trim(string& oid, string& user, uint64_t start_e
return r;
}
+int RGWRados::remove_obj_from_index(rgw_bucket& bucket, const string& oid)
+{
+ librados::IoCtx io_ctx;
+
+ int r = open_bucket_ctx(bucket, io_ctx);
+ if (r < 0)
+ return r;
+
+ string dir_oid = dir_oid_prefix;
+ dir_oid.append(bucket.marker);
+
+ rgw_bucket_dir_entry entry;
+ entry.epoch = (uint64_t)-1; // ULLONG_MAX, needed to that objclass doesn't skip out request
+ entry.name = oid;
+
+ bufferlist updates;
+ updates.append(CEPH_RGW_REMOVE);
+ ::encode(entry, updates);
+
+ bufferlist out;
+
+ r = io_ctx.exec(dir_oid, "rgw", "dir_suggest_changes", updates, out);
+
+ return r;
+}
+
int RGWRados::check_disk_state(librados::IoCtx io_ctx,
rgw_bucket& bucket,
rgw_bucket_dir_entry& list_state,
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 4acd8e8da80..7d681c9e74b 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -583,6 +583,8 @@ public:
/// clean up/process any temporary objects older than given date[/time]
int remove_temp_objects(string date, string time);
+ int remove_obj_from_index(rgw_bucket& bucket, const string& oid);
+
private:
int process_intent_log(rgw_bucket& bucket, string& oid,
time_t epoch, int flags, bool purge);
diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t
index 75a18aaa455..b7aeb75548c 100644
--- a/src/test/cli/radosgw-admin/help.t
+++ b/src/test/cli/radosgw-admin/help.t
@@ -17,6 +17,7 @@
bucket unlink unlink bucket from specified user
bucket stats returns bucket statistics
bucket info show bucket information
+ object unlink unlink object from bucket index
pool add add an existing pool for data placement
pool rm remove an existing pool from data placement set
pools list list placement active set