From: Casey Bodley Date: Wed, 31 Jul 2019 21:05:40 +0000 (-0400) Subject: radosgw-admin: 'datalog trim' takes shard-id and loops until done X-Git-Tag: v13.2.7~37^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1e2df19cf6093621854f7b3d75373017d8ea4fe8;p=ceph.git radosgw-admin: 'datalog trim' takes shard-id and loops until done Fixes: https://tracker.ceph.com/issues/41045 Signed-off-by: Casey Bodley (cherry picked from commit b9af497b2ae445b858fbdf5b7c311770714a58da) Conflicts: store->data_log instead of store->svc()->datalog_rados src/rgw/rgw_admin.cc src/rgw/rgw_bucket.cc no null_yield src/rgw/services/svc_datalog_rados.cc (not present in luminous) src/rgw/services/svc_datalog_rados.h --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 81fd13ef55c3..aceb4e3f0e2e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -7463,9 +7463,20 @@ next: if (ret < 0) return -ret; - RGWDataChangesLog *log = store->data_log; - ret = log->trim_entries(start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker); - if (ret < 0) { + if (!specified_shard_id) { + cerr << "ERROR: requires a --shard-id" << std::endl; + return EINVAL; + } + + // loop until -ENODATA + do { + auto datalog = store->data_log; + ret = datalog->trim_entries(shard_id, start_time.to_real_time(), + end_time.to_real_time(), + start_marker, end_marker); + } while (ret == 0); + + if (ret < 0 && ret != -ENODATA) { cerr << "ERROR: trim_entries(): " << cpp_strerror(-ret) << std::endl; return -ret; } diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 9fc88a9bf202..d6a013d2da13 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -2198,32 +2198,11 @@ int RGWDataChangesLog::get_info(int shard_id, RGWDataChangesLogInfo *info) int RGWDataChangesLog::trim_entries(int shard_id, const real_time& start_time, const real_time& end_time, const string& start_marker, const string& end_marker) { - int ret; - if (shard_id > num_shards) return -EINVAL; - ret = store->time_log_trim(oids[shard_id], start_time, end_time, start_marker, end_marker); - - if (ret == -ENOENT || ret == -ENODATA) - ret = 0; - - return ret; -} - -int RGWDataChangesLog::trim_entries(const real_time& start_time, const real_time& end_time, - const string& start_marker, const string& end_marker) -{ - for (int shard = 0; shard < num_shards; shard++) { - int ret = store->time_log_trim(oids[shard], start_time, end_time, start_marker, end_marker); - if (ret == -ENOENT || ret == -ENODATA) { - continue; - } - if (ret < 0) - return ret; - } - - return 0; + return store->time_log_trim(oids[shard_id], start_time, end_time, + start_marker, end_marker, nullptr); } bool RGWDataChangesLog::going_down() diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 39c1d9d61867..ad5f8f6abf49 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -512,8 +512,6 @@ public: bool *truncated); int trim_entries(int shard_id, const real_time& start_time, const real_time& end_time, const string& start_marker, const string& end_marker); - int trim_entries(const real_time& start_time, const real_time& end_time, - const string& start_marker, const string& end_marker); int get_info(int shard_id, RGWDataChangesLogInfo *info); int lock_exclusive(int shard_id, timespan duration, string& zone_id, string& owner_id) { return store->lock_exclusive(store->get_zone_params().log_pool, oids[shard_id], duration, zone_id, owner_id);