Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: refactor logging in gc and lc #24530

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions src/rgw/rgw_gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std
}

class RGWGCIOManager {
const DoutPrefixProvider* dpp;
CephContext *cct;
RGWGC *gc;

Expand All @@ -150,7 +151,8 @@ class RGWGCIOManager {
size_t max_aio{MAX_AIO_DEFAULT};

public:
RGWGCIOManager(CephContext *_cct, RGWGC *_gc) : cct(_cct),
RGWGCIOManager(const DoutPrefixProvider* _dpp, CephContext *_cct, RGWGC *_gc) : dpp(_dpp),
cct(_cct),
gc(_gc),
remove_tags(cct->_conf->rgw_gc_max_objs) {
max_aio = cct->_conf->rgw_gc_max_concurrent_io;
Expand Down Expand Up @@ -194,13 +196,13 @@ class RGWGCIOManager {

if (io.type == IO::IndexIO) {
if (ret < 0) {
ldout(cct, 0) << "WARNING: gc cleanup of tags on gc shard index=" << io.index << " returned error, ret=" << ret << dendl;
ldpp_dout(dpp, 0) << "WARNING: gc cleanup of tags on gc shard index=" << io.index << " returned error, ret=" << ret << dendl;
}
goto done;
}

if (ret < 0) {
ldout(cct, 0) << "WARNING: could not remove oid=" << io.oid << ", ret=" << ret << dendl;
ldpp_dout(dpp, 0) << "WARNING: could not remove oid=" << io.oid << ", ret=" << ret << dendl;
goto done;
}

Expand Down Expand Up @@ -239,7 +241,7 @@ class RGWGCIOManager {
/* we already cleared list of tags, this prevents us from ballooning in case of
* a persistent problem
*/
ldout(cct, 0) << "WARNING: failed to remove tags on gc shard index=" << index << " ret=" << ret << dendl;
ldpp_dout(dpp, 0) << "WARNING: failed to remove tags on gc shard index=" << index << " ret=" << ret << dendl;
return;
}
ios.push_back(index_io);
Expand Down Expand Up @@ -273,7 +275,7 @@ int RGWGC::process(int index, int max_secs, bool expired_only,

int ret = l.lock_exclusive(&store->gc_pool_ctx, obj_names[index]);
if (ret == -EBUSY) { /* already locked by another gc processor */
dout(10) << "RGWGC::process() failed to acquire lock on " << obj_names[index] << dendl;
ldpp_dout(this, 10) << "RGWGC::process() failed to acquire lock on " << obj_names[index] << dendl;
return 0;
}
if (ret < 0)
Expand Down Expand Up @@ -313,7 +315,7 @@ int RGWGC::process(int index, int max_secs, bool expired_only,
ctx = new IoCtx;
ret = rgw_init_ioctx(store->get_rados_handle(), obj.pool, *ctx);
if (ret < 0) {
dout(0) << "ERROR: failed to create ioctx pool=" << obj.pool << dendl;
ldpp_dout(this, 0) << "ERROR: failed to create ioctx pool=" << obj.pool << dendl;
continue;
}
last_pool = obj.pool;
Expand All @@ -323,13 +325,13 @@ int RGWGC::process(int index, int max_secs, bool expired_only,

const string& oid = obj.key.name; /* just stored raw oid there */

dout(5) << "gc::process: removing " << obj.pool << ":" << obj.key.name << dendl;
ldpp_dout(this, 5) << "gc::process: removing " << obj.pool << ":" << obj.key.name << dendl;
ObjectWriteOperation op;
cls_refcount_put(op, info.tag, true);

ret = io_manager.schedule_io(ctx, oid, &op, index, info.tag);
if (ret < 0) {
ldout(store->ctx(), 0) << "WARNING: failed to schedule deletion for oid=" << oid << dendl;
ldpp_dout(this, 0) << "WARNING: failed to schedule deletion for oid=" << oid << dendl;
}

if (going_down()) // leave early, even if tag isn't removed, it's ok
Expand All @@ -353,7 +355,7 @@ int RGWGC::process(bool expired_only)

const int start = ceph::util::generate_random_number(0, max_objs - 1);

RGWGCIOManager io_manager(store->ctx(), this);
RGWGCIOManager io_manager(this, store->ctx(), this);

for (int i = 0; i < max_objs; i++) {
int index = (i + start) % max_objs;
Expand All @@ -375,7 +377,7 @@ bool RGWGC::going_down()

void RGWGC::start_processor()
{
worker = new GCWorker(cct, this);
worker = new GCWorker(this, cct, this);
worker->create("rgw_gc");
}

Expand All @@ -390,15 +392,25 @@ void RGWGC::stop_processor()
worker = NULL;
}

unsigned RGWGC::get_subsys() const
{
return dout_subsys;
}

std::ostream& RGWGC::gen_prefix(std::ostream& out) const
{
return out << "garbage collection: ";
}

void *RGWGC::GCWorker::entry() {
do {
utime_t start = ceph_clock_now();
dout(2) << "garbage collection: start" << dendl;
ldpp_dout(dpp, 2) << "garbage collection: start" << dendl;
int r = gc->process(true);
if (r < 0) {
dout(0) << "ERROR: garbage collection process() returned error r=" << r << dendl;
ldpp_dout(dpp, 0) << "ERROR: garbage collection process() returned error r=" << r << dendl;
}
dout(2) << "garbage collection: stop" << dendl;
ldpp_dout(dpp, 2) << "garbage collection: stop" << dendl;

if (gc->going_down())
break;
Expand Down
11 changes: 9 additions & 2 deletions src/rgw/rgw_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class RGWGCIOManager;

class RGWGC {
class RGWGC : public DoutPrefixProvider {
CephContext *cct;
RGWRados *store;
int max_objs;
Expand All @@ -28,13 +28,14 @@ class RGWGC {
int tag_index(const string& tag);

class GCWorker : public Thread {
const DoutPrefixProvider *dpp;
CephContext *cct;
RGWGC *gc;
Mutex lock;
Cond cond;

public:
GCWorker(CephContext *_cct, RGWGC *_gc) : cct(_cct), gc(_gc), lock("GCWorker") {}
GCWorker(const DoutPrefixProvider *_dpp, CephContext *_cct, RGWGC *_gc) : dpp(_dpp), cct(_cct), gc(_gc), lock("GCWorker") {}
void *entry() override;
void stop();
};
Expand Down Expand Up @@ -64,6 +65,12 @@ class RGWGC {
bool going_down();
void start_processor();
void stop_processor();

CephContext *get_cct() const override { return store->ctx(); }
unsigned get_subsys() const;

std::ostream& gen_prefix(std::ostream& out) const;

};


Expand Down
Loading