This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rgw_sal_motr, motr_gc: [CORTX-33148] Add MotrGC class
For Garbage Collection, cortx-rgw needs a MotrGC thread which works concurrently to delete all the stale objects. Added the MotrGC class and the interface to configure and start GC workers. Signed-off-by: Sumedh A. Kulkarni <sumedh.a.kulkarni@seagate.com>
- Loading branch information
1 parent
ca167f5
commit 0a50508
Showing
6 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=2 sw=2 expandtab ft=cpp | ||
|
||
/* | ||
* Garbage Collector implementation for the CORTX Motr backend | ||
* | ||
* Copyright (C) 2022 Seagate Technology LLC and/or its Affiliates | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#include "gc.h" | ||
|
||
void *MotrGC::entry() { | ||
std::unique_lock<std::mutex> lk(mtx); | ||
ldpp_dout(dpp, 10) << __func__ << ": Motr GC started" << dendl; | ||
|
||
do { | ||
ldpp_dout(dpp, 10) << __func__ << ": In a Motr GC loop." << dendl; | ||
cv.wait_for(lk, std::chrono::milliseconds(gc_interval * 10)); | ||
} while (! stop_signalled); | ||
|
||
ldpp_dout(dpp, 0) << __func__ << ": Stop signalled called.#" | ||
<< stop_signalled << dendl; | ||
return nullptr; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=2 sw=2 expandtab ft=cpp | ||
|
||
/* | ||
* Garbage Collector Classes for the CORTX Motr backend | ||
* | ||
* Copyright (C) 2022 Seagate Technology LLC and/or its Affiliates | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#ifndef __MOTR_GC_H__ | ||
#define __MOTR_GC_H__ | ||
|
||
#include "rgw_sal_motr.h" | ||
#include "common/Thread.h" | ||
#include <mutex> | ||
#include <condition_variable> | ||
|
||
class MotrGC : public Thread { | ||
private: | ||
const DoutPrefixProvider *dpp; | ||
rgw::sal::Store *store; | ||
std::mutex mtx; | ||
std::condition_variable cv; | ||
bool stop_signalled = false; | ||
uint32_t gc_interval = 60*60; // default: 24*60*60 sec | ||
uint32_t gc_obj_min_wait = 60*60; // 60*60sec default | ||
|
||
public: | ||
MotrGC(const DoutPrefixProvider *_dpp, rgw::sal::Store* _store) : | ||
dpp(_dpp), store(_store) {} | ||
|
||
void *entry() override; | ||
|
||
void signal_stop() { | ||
std::lock_guard<std::mutex> lk_guard(mtx); | ||
stop_signalled = true; | ||
cv.notify_all(); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters