class POSIXUserDB;
class POSIXAccountDB;
-struct POSIXAccountDBOpAccountInfo : DBOpAccountInfo {};
-
struct POSIXUserDBOpUserInfo : DBOpUserInfo {};
struct POSIXUserDBOpInfo : DBOpInfo {};
struct POSIXUserDBOpPrepareParams : DBOpPrepareParams {};
+struct POSIXAccountDBOpAccountInfo : DBOpAccountInfo {};
+
struct POSIXAccountDBOpInfo : DBOpInfo {};
struct POSIXAccountDBOpPrepareInfo : DBOpPrepareInfo {};
class POSIXUserDB : public SQLiteDB {
private:
const std::string db_name;
+ const std::string lc_head_table;
+ const std::string lc_entry_table;
rgw::sal::Driver* driver;
protected:
POSIXUserDB(std::string db_name, CephContext *_cct) : SQLiteDB(db_name, _cct),
db_name(db_name),
+ lc_head_table(db_name+"_lc_head_table"),
+ lc_entry_table(db_name+"_lc_entry_table"),
cct(_cct),
dp(_cct, ceph_subsys_rgw, "rgw POSIXUserDBStore backend: ")
{ DB::set_context(cct); }
virtual int InitPrepareParams(const DoutPrefixProvider *dpp,
DBOpPrepareParams &p_params,
DBOpParams* params) override { return 0; }
- virtual int createLCTables(const DoutPrefixProvider *dpp) override { return 0; }
+ virtual int createLCTables(const DoutPrefixProvider *dpp) override { return SQLiteDB::createLCTables(dpp); }
+ const std::string getLCHeadTable() { return lc_head_table; }
+ const std::string getLCEntryTable() { return lc_entry_table; }
virtual int ListAllBuckets(const DoutPrefixProvider *dpp, DBOpParams *params) override { return 0; }
virtual int ListAllUsers(const DoutPrefixProvider *dpp, DBOpParams *params) override { return 0; }
#include "include/scope_guard.h"
#include "common/Clock.h" // for ceph_clock_now()
#include "common/errno.h"
+#include "rgw_lc.h"
#define dout_subsys ceph_subsys_rgw
#define dout_context g_ceph_context
}
}
}
+
+ lc = new RGWLC();
+ lc->initialize(cct, this);
+
+ if (use_lc_thread) {
+ ret = userDB->createLCTables(dpp);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << "Failed to create LC tables, ret=" << ret << dendl;
+ return ret;
+ }
+ lc->start_processor();
+ }
+
ldpp_dout(dpp, 20) << "root_fd: " << root_dir->get_fd() << dendl;
quota_handler = RGWQuotaHandler::generate_handler(dpp, this, true);
return 0;
}
+std::unique_ptr<Lifecycle> POSIXDriver::get_lifecycle(void)
+{
+ return std::make_unique<POSIXLifecycle>(this);
+}
+
std::unique_ptr<Writer> POSIXDriver::get_append_writer(const DoutPrefixProvider *dpp,
optional_yield y,
rgw::sal::Object* _head_obj,
// Bucket info is stored as an attribute, but not in attrs[]
bufferlist bl;
encode(info, bl);
- Attrs extra_attrs;
+ Attrs orig_attrs, extra_attrs;
extra_attrs[RGW_POSIX_ATTR_BUCKET_INFO] = bl;
+ ret = dir->read_attrs(dpp, y, orig_attrs);
+
+ for (auto attr : orig_attrs) {
+ if (auto found = attrs.find(attr.first); found == attrs.end()) {
+ /* Attribute needs to be erased */
+ remove_x_attr(dpp, y, dir->get_fd(), attr.first, get_name());
+ }
+ }
+
return dir->write_attrs(dpp, y, attrs, &extra_attrs);
}
return 0;
}
+int POSIXLifecycle::get_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ LCEntry& entry)
+{
+ return driver->get_user_db()->get_entry(oid, marker, entry);
+}
+
+int POSIXLifecycle::get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ LCEntry& entry)
+{
+ return driver->get_user_db()->get_next_entry(oid, marker, entry);
+}
+
+int POSIXLifecycle::set_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCEntry& entry)
+{
+ return driver->get_user_db()->set_entry(oid, entry);
+}
+
+int POSIXLifecycle::list_entries(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ uint32_t max_entries, std::vector<LCEntry>& entries)
+{
+ return driver->get_user_db()->list_entries(oid, marker, max_entries, entries);
+}
+
+int POSIXLifecycle::rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCEntry& entry)
+{
+ return driver->get_user_db()->rm_entry(oid, entry);
+}
+
+int POSIXLifecycle::get_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, LCHead& head)
+{
+ return driver->get_user_db()->get_head(oid, head);
+}
+
+int POSIXLifecycle::put_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCHead& head)
+{
+ return driver->get_user_db()->put_head(oid, head);
+}
+
+std::unique_ptr<LCSerializer> POSIXLifecycle::get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie)
+{
+ return std::make_unique<LCPOSIXSerializer>(driver, oid, lock_name, cookie);
+}
+
} } // namespace rgw::sal
extern "C" {
#include "bucket_cache.h"
#include "posixDB.h"
+class RGWLC;
+
namespace rgw { namespace sal {
class POSIXDriver;
int root_fd;
RGWSyncModuleInstanceRef sync_module;
RGWQuotaHandler* quota_handler{nullptr};
+ RGWLC* lc{nullptr};
+ bool use_lc_thread;
public:
POSIXDriver(CephContext *_cct) : StoreDriver(), cct(_cct), zone(this)
cct = _cct;
}
+ POSIXDriver& set_run_lc_thread(bool _use_lc_thread) {
+ use_lc_thread = _use_lc_thread;
+ return *this;
+ }
+
virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp);
virtual const std::string get_name() const override { return "posix"; }
virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) override { return "PLACEHOLDER"; };
virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override;
virtual int cluster_stat(RGWClusterStat& stats) override;
- virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override { return nullptr; } // TODO: implement
+ virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override;
virtual std::unique_ptr<Restore> get_restore(void) { return nullptr; }
virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override { return 0; }
optional_yield y,
const std::string& topic_queue) override { return -ENOTSUP; }
- virtual RGWLC* get_rgwlc(void) override { return NULL; } // TODO: Lifecycle not currently supported
+ virtual RGWLC* get_rgwlc(void) override { return lc; }
virtual rgw::restore::Restore* get_rgwrestore(void) { return nullptr; }
virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return NULL; }
virtual int unlock(const DoutPrefixProvider* dpp, optional_yield y) override;
};
+class LCPOSIXSerializer : public StoreLCSerializer {
+public:
+ LCPOSIXSerializer(POSIXDriver* driver, const std::string& oid, const std::string& lock_name, const std::string& cookie) {}
+
+ virtual int try_lock(const DoutPrefixProvider* dpp, ceph::timespan dur, optional_yield y) override { return 0; }
+ virtual int unlock(const DoutPrefixProvider* dpp, optional_yield y) override { return 0; }
+};
+
+class POSIXLifecycle : public Lifecycle {
+ POSIXDriver* driver;
+
+public:
+ POSIXLifecycle(POSIXDriver* _driver) : driver(_driver) {}
+ virtual ~POSIXLifecycle() = default;
+
+ virtual int get_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ LCEntry& entry) override;
+ virtual int get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ LCEntry& entry) override;
+ virtual int set_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCEntry& entry) override;
+ virtual int list_entries(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const std::string& marker,
+ uint32_t max_entries,
+ std::vector<LCEntry>& entries) override;
+ virtual int rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCEntry& entry) override;
+ virtual int get_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, LCHead& head) override;
+ virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCHead& head) override;
+
+ virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie) override;
+};
+
} } // namespace rgw::sal