]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Zipper - Virtual base classes 46879/head
authorDaniel Gryniewicz <dang@redhat.com>
Mon, 16 May 2022 13:38:03 +0000 (09:38 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Fri, 1 Jul 2022 18:11:07 +0000 (14:11 -0400)
In order to support filters, make the base classes in Zipper pure
virtual.  Then, derive from them a set of Store base classes, that
implement common code used by stores, and a set of Filter base classes
that automatically pass through to the next layer.  Modify the stores to
derive from the Store base classes.

This implements the pure virtual base classes, the Store base classes,
and a framework of the Filter base classes.

Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
22 files changed:
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/rgw/rgw_admin.cc
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_filter.h [new file with mode: 0644]
src/rgw/rgw_sal_motr.cc
src/rgw/rgw_sal_motr.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h
src/rgw/rgw_sal_store.h [new file with mode: 0644]
src/rgw/store/dbstore/common/dbstore.cc
src/rgw/store/dbstore/common/dbstore.h
src/rgw/store/dbstore/sqlite/sqliteDB.cc
src/rgw/store/dbstore/tests/dbstore_tests.cc
src/test/rgw/test_rgw_lua.cc

index 4667de8994d5a70d98348ddc497065d9e2d7d22f..72195378b91cc26f4d6c65995a7f8cd2f1045b80 100644 (file)
@@ -965,7 +965,7 @@ int cls_rgw_lc_put_head(IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& h
   return r;
 }
 
-int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, string& marker,
+int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, const string& marker,
                              cls_rgw_lc_entry& entry)
 {
   bufferlist in, out;
index 508ea7089a276eeaffe33caca9009e5b0c8d235f..57d55548b1eeb2cff681f9a6cead595447c1a9be 100644 (file)
@@ -609,7 +609,7 @@ int cls_rgw_gc_list(librados::IoCtx& io_ctx, std::string& oid, std::string& mark
 #ifndef CLS_CLIENT_HIDE_IOCTX
 int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
 int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
-int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, std::string& marker, cls_rgw_lc_entry& entry);
+int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
 int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
 int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
 int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
index fd3b72b39fd7705f9ee3f7fa643cbc4743afe1db..19cf667ecf4af7a27a65b614f8bd8fdb709f6e37 100644 (file)
@@ -8175,7 +8175,7 @@ next:
 
   if (opt_cmd == OPT::LC_LIST) {
     formatter->open_array_section("lifecycle_list");
-    vector<rgw::sal::Lifecycle::LCEntry> bucket_lc_map;
+    vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> bucket_lc_map;
     string marker;
     int index{0};
 #define MAX_LC_LIST_ENTRIES 100
@@ -8192,16 +8192,16 @@ next:
       }
       for (const auto& entry : bucket_lc_map) {
         formatter->open_object_section("bucket_lc_info");
-        formatter->dump_string("bucket", entry.bucket);
-       formatter->dump_string("shard", entry.oid);
+        formatter->dump_string("bucket", entry->get_bucket());
+       formatter->dump_string("shard", entry->get_oid());
        char exp_buf[100];
-       time_t t{time_t(entry.start_time)};
+       time_t t{time_t(entry->get_start_time())};
        if (std::strftime(
              exp_buf, sizeof(exp_buf),
              "%a, %d %b %Y %T %Z", std::gmtime(&t))) {
          formatter->dump_string("started", exp_buf);
        }
-        string lc_status = LC_STATUS[entry.status];
+        string lc_status = LC_STATUS[entry->get_status()];
         formatter->dump_string("status", lc_status);
         formatter->close_section(); // objs
         formatter->flush(cout);
index da2bd841e58320771923d8d4097b80de7681db9e..c4604d3e4fecec838bfce6460db7b558b3dc2539 100644 (file)
@@ -276,11 +276,11 @@ void RGWLC::finalize()
 
 static inline std::ostream& operator<<(std::ostream &os, rgw::sal::Lifecycle::LCEntry& ent) {
   os << "<ent: bucket=";
-  os << ent.bucket;
+  os << ent.get_bucket();
   os << "; start_time=";
-  os << rgw_to_asctime(utime_t(time_t(ent.start_time), 0));
+  os << rgw_to_asctime(utime_t(time_t(ent.get_start_time()), 0));
   os << "; status=";
-  os << LC_STATUS[ent.status];
+  os << LC_STATUS[ent.get_status()];
   os << ">";
   return os;
 }
@@ -1719,9 +1719,9 @@ int RGWLC::bucket_lc_post(int index, int max_lock_sec,
       }
       goto clean;
     } else if (result < 0) {
-      entry.status = lc_failed;
+      entry.set_status(lc_failed);
     } else {
-      entry.status = lc_complete;
+      entry.set_status(lc_complete);
     }
 
     ret = sal_lc->set_entry(obj_names[index],  entry);
@@ -1739,12 +1739,12 @@ clean:
 } /* RGWLC::bucket_lc_post */
 
 int RGWLC::list_lc_progress(string& marker, uint32_t max_entries,
-                           vector<rgw::sal::Lifecycle::LCEntry>& progress_map,
+                           vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
                            int& index)
 {
   progress_map.clear();
   for(; index < max_objs; index++, marker="") {
-    vector<rgw::sal::Lifecycle::LCEntry> entries;
+    vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
     int ret = sal_lc->list_entries(obj_names[index], marker, max_entries, entries);
     if (ret < 0) {
       if (ret == -ENOENT) {
@@ -1756,11 +1756,12 @@ int RGWLC::list_lc_progress(string& marker, uint32_t max_entries,
       }
     }
     progress_map.reserve(progress_map.size() + entries.size());
-    progress_map.insert(progress_map.end(), entries.begin(), entries.end());
+    std::move(begin(entries), end(entries), std::back_inserter(progress_map));
+    //progress_map.insert(progress_map.end(), entries.begin(), entries.end());
 
     /* update index, marker tuple */
     if (progress_map.size() > 0)
-      marker = progress_map.back().bucket;
+      marker = progress_map.back()->get_bucket();
 
     if (progress_map.size() >= max_entries)
       break;
@@ -1883,7 +1884,7 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
     sal_lc->get_serializer(lc_index_lock_name, obj_names[index],
                           std::string()));
 
-  rgw::sal::Lifecycle::LCEntry entry;
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
   if (max_lock_secs <= 0) {
     return -EAGAIN;
   }
@@ -1902,10 +1903,10 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
   std::unique_lock<rgw::sal::LCSerializer> lock(
     *(serializer.get()), std::adopt_lock);
 
-  ret = sal_lc->get_entry(obj_names[index], bucket_entry_marker, entry);
+  ret = sal_lc->get_entry(obj_names[index], bucket_entry_marker, &entry);
   if (ret >= 0) {
-    if (entry.status == lc_processing) {
-      if (expired_session(entry.start_time)) {
+    if (entry->get_status() == lc_processing) {
+      if (expired_session(entry->get_start_time())) {
        ldpp_dout(this, 5) << "RGWLC::process_bucket(): STALE lc session found for: " << entry
                           << " index: " << index << " worker ix: " << worker->ix
                           << " (clearing)"
@@ -1922,7 +1923,7 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
   }
 
   /* do nothing if no bucket */
-  if (entry.bucket.empty()) {
+  if (entry->get_bucket().empty()) {
     return ret;
   }
 
@@ -1930,11 +1931,11 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
                     << " index: " << index << " worker ix: " << worker->ix
                     << dendl;
 
-  entry.status = lc_processing;
-  ret = sal_lc->set_entry(obj_names[index], entry);
+  entry->set_status(lc_processing);
+  ret = sal_lc->set_entry(obj_names[index], *entry);
   if (ret < 0) {
     ldpp_dout(this, 0) << "RGWLC::process_bucket() failed to set obj entry "
-                      << obj_names[index] << entry.bucket << entry.status
+                      << obj_names[index] << entry->get_bucket() << entry->get_status()
                       << dendl;
     return ret;
   }
@@ -1944,8 +1945,8 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
                     << dendl;
 
   lock.unlock();
-  ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once);
-  bucket_lc_post(index, max_lock_secs, entry, ret, worker);
+  ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
+  bucket_lc_post(index, max_lock_secs, *entry, ret, worker);
 
   return ret;
 } /* RGWLC::process_bucket */
@@ -1995,9 +1996,9 @@ inline int RGWLC::advance_head(const std::string& lc_shard,
                               time_t start_date)
 {
   int ret{0};
-  rgw::sal::Lifecycle::LCEntry next_entry;
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> next_entry;
 
-  ret = sal_lc->get_next_entry(lc_shard, entry.bucket, next_entry);
+  ret = sal_lc->get_next_entry(lc_shard, entry.get_bucket(), &next_entry);
   if (ret < 0) {
     ldpp_dout(this, 0) << "RGWLC::process() failed to get obj entry "
                       << lc_shard << dendl;
@@ -2005,8 +2006,8 @@ inline int RGWLC::advance_head(const std::string& lc_shard,
   }
 
   /* save the next position */
-  head.marker = next_entry.bucket;
-  head.start_date = start_date;
+  head.set_marker(next_entry->get_bucket());
+  head.set_start_date(start_date);
 
   ret = sal_lc->put_head(lc_shard, head);
   if (ret < 0) {
@@ -2025,8 +2026,8 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
   int ret{0};
   const auto& lc_shard = obj_names[index];
 
-  rgw::sal::Lifecycle::LCHead head{};
-  rgw::sal::Lifecycle::LCEntry entry; //string = bucket_name:bucket_id, start_time, int = LC_BUCKET_STATUS
+  std::unique_ptr<rgw::sal::Lifecycle::LCHead> head;
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry; //string = bucket_name:bucket_id, start_time, int = LC_BUCKET_STATUS
 
   ldpp_dout(this, 5) << "RGWLC::process(): ENTER: "
          << "index: " << index << " worker ix: " << worker->ix
@@ -2060,7 +2061,7 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
     utime_t now = ceph_clock_now();
 
     /* preamble: find an inital bucket/marker */
-    ret = sal_lc->get_head(lc_shard, head);
+    ret = sal_lc->get_head(lc_shard, &head);
     if (ret < 0) {
       ldpp_dout(this, 0) << "RGWLC::process() failed to get obj head "
           << lc_shard << ", ret=" << ret << dendl;
@@ -2069,36 +2070,36 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
 
     /* if there is nothing at head, try to reinitialize head.marker with the
      * first entry in the queue */
-    if (head.marker.empty() &&
-       allow_shard_rollover(cct, now, head.shard_rollover_date) /* prevent multiple passes by diff.
+    if (head->get_marker().empty() &&
+       allow_shard_rollover(cct, now, head->get_shard_rollover_date()) /* prevent multiple passes by diff.
                                                                  * rgws,in same cycle */) {
 
       ldpp_dout(this, 5) << "RGWLC::process() process shard rollover lc_shard=" << lc_shard
-                        << " head.marker=" << head.marker
-                        << " head.shard_rollover_date=" << head.shard_rollover_date
+                        << " head.marker=" << head->get_marker()
+                        << " head.shard_rollover_date=" << head->get_shard_rollover_date()
                         << dendl;
 
-      vector<rgw::sal::Lifecycle::LCEntry> entries;
-      int ret = sal_lc->list_entries(lc_shard, head.marker, 1, entries);
+      vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
+      int ret = sal_lc->list_entries(lc_shard, head->get_marker(), 1, entries);
       if (ret < 0) {
        ldpp_dout(this, 0) << "RGWLC::process() sal_lc->list_entries(lc_shard, head.marker, 1, "
                           << "entries) returned error ret==" << ret << dendl;
        goto exit;
       }
       if (entries.size() > 0) {
-       entry = entries.front();
-       head.marker = entry.bucket;
-       head.start_date = now;
-       head.shard_rollover_date = 0;
+       entry = std::move(entries.front());
+       head->set_marker(entry->get_bucket());
+       head->set_start_date(now);
+       head->set_shard_rollover_date(0);
       }
     } else {
       ldpp_dout(this, 0) << "RGWLC::process() head.marker !empty() at START for shard=="
                         << lc_shard << " head last stored at "
-                        << rgw_to_asctime(utime_t(time_t(head.start_date), 0))
+                        << rgw_to_asctime(utime_t(time_t(head->get_start_date()), 0))
                         << dendl;
 
       /* fetches the entry pointed to by head.bucket */
-      ret = sal_lc->get_entry(lc_shard, head.marker, entry);
+      ret = sal_lc->get_entry(lc_shard, head->get_marker(), &entry);
       if (ret < 0) {
        ldpp_dout(this, 0) << "RGWLC::process() sal_lc->get_entry(lc_shard, head.marker, entry) "
                           << "returned error ret==" << ret << dendl;
@@ -2106,9 +2107,9 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
       }
     }
 
-    if (! entry.bucket.empty()) {
-      if (entry.status == lc_processing) {
-        if (expired_session(entry.start_time)) {
+    if (entry && !entry->get_bucket().empty()) {
+      if (entry->get_status() == lc_processing) {
+        if (expired_session(entry->get_start_time())) {
           ldpp_dout(this, 5)
               << "RGWLC::process(): STALE lc session found for: " << entry
               << " index: " << index << " worker ix: " << worker->ix
@@ -2118,17 +2119,17 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
               << "RGWLC::process(): ACTIVE entry: " << entry
               << " index: " << index << " worker ix: " << worker->ix << dendl;
          /* skip to next entry */
-         if (advance_head(lc_shard, head, entry, now) < 0) {
+         if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
            goto exit;
          }
              /* done with this shard */
-         if (head.marker.empty()) {
+         if (head->get_marker().empty()) {
            ldpp_dout(this, 5) <<
              "RGWLC::process() cycle finished lc_shard="
                               << lc_shard
                               << dendl;
-           head.shard_rollover_date = ceph_clock_now();
-           ret = sal_lc->put_head(lc_shard,  head);
+           head->set_shard_rollover_date(ceph_clock_now());
+           ret = sal_lc->put_head(lc_shard, *head.get());
            if (ret < 0) {
              ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
                                 << lc_shard
@@ -2139,23 +2140,23 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
           continue;
         }
       } else {
-       if ((entry.status == lc_complete) &&
-           already_run_today(cct, entry.start_time)) {
+       if ((entry->get_status() == lc_complete) &&
+           already_run_today(cct, entry->get_start_time())) {
          /* skip to next entry */
-         if (advance_head(lc_shard, head, entry, now) < 0) {
+         if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
            goto exit;
          }
          ldpp_dout(this, 5) << "RGWLC::process() worker ix; " << worker->ix
-                            << " SKIP processing for already-processed bucket " << entry.bucket
+                            << " SKIP processing for already-processed bucket " << entry->get_bucket()
                             << dendl;
          /* done with this shard */
-         if (head.marker.empty()) {
+         if (head->get_marker().empty()) {
            ldpp_dout(this, 5) <<
              "RGWLC::process() cycle finished lc_shard="
                               << lc_shard
                               << dendl;
-           head.shard_rollover_date = ceph_clock_now();
-           ret = sal_lc->put_head(lc_shard,  head);
+           head->set_shard_rollover_date(ceph_clock_now());
+           ret = sal_lc->put_head(lc_shard, *head.get());
            if (ret < 0) {
              ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
                                 << lc_shard
@@ -2182,18 +2183,18 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
            << " index: " << index << " worker ix: " << worker->ix
            << dendl;
 
-    entry.status = lc_processing;
-    entry.start_time = now;
+    entry->set_status(lc_processing);
+    entry->set_start_time(now);
 
-    ret = sal_lc->set_entry(lc_shard, entry);
+    ret = sal_lc->set_entry(lc_shard, *entry);
     if (ret < 0) {
       ldpp_dout(this, 0) << "RGWLC::process() failed to set obj entry "
-             << lc_shard << entry.bucket << entry.status << dendl;
+             << lc_shard << entry->get_bucket() << entry->get_status() << dendl;
       goto exit;
     }
 
     /* advance head for next waiter, then process */
-    if (advance_head(lc_shard, head, entry, now) < 0) {
+    if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
       goto exit;
     }
 
@@ -2204,7 +2205,7 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
     /* drop lock so other instances can make progress while this
      * bucket is being processed */
     lock->unlock();
-    ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once);
+    ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
 
     /* postamble */
     //bucket_lc_post(index, max_lock_secs, entry, ret, worker);
@@ -2219,7 +2220,7 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
       /* XXXX are we SURE the only way result could == ENOENT is when
        * there is no such bucket?  It is currently the value returned
        * from bucket_lc_process(...) */
-      ret = sal_lc->rm_entry(lc_shard,  entry);
+      ret = sal_lc->rm_entry(lc_shard,  *entry);
       if (ret < 0) {
         ldpp_dout(this, 0) << "RGWLC::process() failed to remove entry "
                           << lc_shard << " (nonfatal)"
@@ -2227,11 +2228,11 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
        /* not fatal, could result from a race */
       }
     } else if (ret < 0) {
-      entry.status = lc_failed;
+      entry->set_status(lc_failed);
     } else {
-      entry.status = lc_complete;
+      entry->set_status(lc_complete);
     }
-    ret = sal_lc->set_entry(lc_shard,  entry);
+    ret = sal_lc->set_entry(lc_shard,  *entry);
     if (ret < 0) {
       ldpp_dout(this, 0) << "RGWLC::process() failed to set entry on "
           << lc_shard << dendl;
@@ -2240,13 +2241,13 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
     }
 
     /* done with this shard */
-    if (head.marker.empty()) {
+    if (head->get_marker().empty()) {
       ldpp_dout(this, 5) <<
        "RGWLC::process() cycle finished lc_shard="
                         << lc_shard
                         << dendl;
-      head.shard_rollover_date = ceph_clock_now();
-      ret = sal_lc->put_head(lc_shard,  head);
+      head->set_shard_rollover_date(ceph_clock_now());
+      ret = sal_lc->put_head(lc_shard,  *head.get());
       if (ret < 0) {
        ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
                           << lc_shard
@@ -2389,9 +2390,9 @@ static int guard_lc_modify(const DoutPrefixProvider *dpp,
   get_lc_oid(cct, bucket_lc_key, &oid);
 
   /* XXX it makes sense to take shard_id for a bucket_id? */
-  rgw::sal::Lifecycle::LCEntry entry;
-  entry.bucket = bucket_lc_key;
-  entry.status = lc_uninitial;
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry = sal_lc->get_entry();
+  entry->set_bucket(bucket_lc_key);
+  entry->set_status(lc_uninitial);
   int max_lock_secs = cct->_conf->rgw_lc_lock_max_time;
 
   rgw::sal::LCSerializer* lock = sal_lc->get_serializer(lc_index_lock_name,
@@ -2414,7 +2415,7 @@ static int guard_lc_modify(const DoutPrefixProvider *dpp,
           << oid << ", ret=" << ret << dendl;
       break;
     }
-    ret = f(sal_lc, oid, entry);
+    ret = f(sal_lc, oid, *entry.get());
     if (ret < 0) {
       ldpp_dout(dpp, 0) << "RGWLC::RGWPutLC() failed to set entry on "
           << oid << ", ret=" << ret << dendl;
@@ -2446,7 +2447,7 @@ int RGWLC::set_bucket_config(rgw::sal::Bucket* bucket,
 
   ret = guard_lc_modify(this, store, sal_lc.get(), b, cookie,
                        [&](rgw::sal::Lifecycle* sal_lc, const string& oid,
-                           const rgw::sal::Lifecycle::LCEntry& entry) {
+                           rgw::sal::Lifecycle::LCEntry& entry) {
     return sal_lc->set_entry(oid, entry);
   });
 
@@ -2471,7 +2472,7 @@ int RGWLC::remove_bucket_config(rgw::sal::Bucket* bucket,
 
   ret = guard_lc_modify(this, store, sal_lc.get(), b, cookie,
                        [&](rgw::sal::Lifecycle* sal_lc, const string& oid,
-                           const rgw::sal::Lifecycle::LCEntry& entry) {
+                           rgw::sal::Lifecycle::LCEntry& entry) {
     return sal_lc->rm_entry(oid, entry);
   });
 
@@ -2500,13 +2501,13 @@ int fix_lc_shard_entry(const DoutPrefixProvider *dpp,
   std::string lc_oid;
   get_lc_oid(store->ctx(), bucket_lc_key, &lc_oid);
 
-  rgw::sal::Lifecycle::LCEntry entry;
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
   // There are multiple cases we need to encounter here
   // 1. entry exists and is already set to marker, happens in plain buckets & newly resharded buckets
   // 2. entry doesn't exist, which usually happens when reshard has happened prior to update and next LC process has already dropped the update
   // 3. entry exists matching the current bucket id which was after a reshard (needs to be updated to the marker)
   // We are not dropping the old marker here as that would be caught by the next LC process update
-  int ret = sal_lc->get_entry(lc_oid, bucket_lc_key, entry);
+  int ret = sal_lc->get_entry(lc_oid, bucket_lc_key, &entry);
   if (ret == 0) {
     ldpp_dout(dpp, 5) << "Entry already exists, nothing to do" << dendl;
     return ret; // entry is already existing correctly set to marker
@@ -2524,7 +2525,7 @@ int fix_lc_shard_entry(const DoutPrefixProvider *dpp,
       store, sal_lc, bucket->get_key(), cookie,
       [&lc_oid](rgw::sal::Lifecycle* slc,
                              const string& oid,
-                             const rgw::sal::Lifecycle::LCEntry& entry) {
+                             rgw::sal::Lifecycle::LCEntry& entry) {
        return slc->set_entry(lc_oid, entry);
       });
 
index d50af2c3cf5aa0cbd2a2424d2691fc1c0ffceb84..e62ab480f81975a2a624514855d9232a06d456f0 100644 (file)
@@ -528,7 +528,8 @@ public:
   bool expired_session(time_t started);
   time_t thread_stop_at();
   int list_lc_progress(std::string& marker, uint32_t max_entries,
-                      std::vector<rgw::sal::Lifecycle::LCEntry>&, int& index);
+                      std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>&,
+                      int& index);
   int bucket_lc_process(std::string& shard_id, LCWorker* worker, time_t stop_at,
                        bool once);
   int bucket_lc_post(int index, int max_lock_sec,
index 717725fc0ed0a7d8a3f6fba8feb5042cfb7742d8..7afcbc4444836ba07b691b579268a7a7774bee67 100644 (file)
@@ -6467,10 +6467,10 @@ bool RGWCompleteMultipart::check_previously_completed(const RGWMultiCompleteUplo
 void RGWCompleteMultipart::complete()
 {
   /* release exclusive lock iff not already */
-  if (unlikely(serializer && serializer->locked)) {
+  if (unlikely(serializer && serializer->is_locked())) {
     int r = serializer->unlock();
     if (r < 0) {
-      ldpp_dout(this, 0) << "WARNING: failed to unlock " << serializer->oid << dendl;
+      ldpp_dout(this, 0) << "WARNING: failed to unlock " << serializer << dendl;
     }
   }
   send_response();
index 38ea670f34ddee146d7b368b5296ac9114caaa47..2bbec2b1fbdf31aad6ead6bc1c7a6baf569b697b 100644 (file)
@@ -8367,7 +8367,7 @@ int RGWRados::process_gc(bool expired_only)
 }
 
 int RGWRados::list_lc_progress(string& marker, uint32_t max_entries,
-                              vector<rgw::sal::Lifecycle::LCEntry>& progress_map,
+                              vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
                               int& index)
 {
   return lc->list_lc_progress(marker, max_entries, progress_map, index);
index 2051b0a027c5ee12e05de240d689210198421d16..6354dae81417acc21c26377133c033feea676d96 100644 (file)
@@ -1483,7 +1483,8 @@ public:
 
   int process_lc(const std::unique_ptr<rgw::sal::Bucket>& optional_bucket);
   int list_lc_progress(std::string& marker, uint32_t max_entries,
-                      std::vector<rgw::sal::Lifecycle::LCEntry>& progress_map, int& index);
+                      std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
+                      int& index);
 
   int bucket_check_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
                          std::map<RGWObjCategory, RGWStorageStats> *existing_stats,
index b308389992e599f8c4f98041feff58d61161fc3a..586eba096737c3d61742f1798173dd5ff785503e 100644 (file)
@@ -22,7 +22,6 @@
 #include "rgw_datalog_notify.h"
 #include "include/random.h"
 
-class RGWGetDataCB;
 class RGWAccessListFilter;
 class RGWLC;
 class RGWObjManifest;
@@ -261,7 +260,7 @@ class Completions {
   using Attrs = std::map<std::string, ceph::buffer::list>;
 
 /**
- * @brief Base singleton representing a Store or stacking layer
+ * @brief Base singleton representing a Store or Filter
  *
  * The Store is the base abstraction of the SAL layer.  It represents a base storage
  * mechanism, or a intermediate stacking layer.  There is a single instance of a given
@@ -358,9 +357,7 @@ class Store {
     /** Enable or disable a set of bucket.  e.g. if a User is suspended */
     virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) = 0;
     /** Get a new request ID */
-    virtual uint64_t get_new_req_id() {
-      return ceph::util::generate_random_number<uint64_t>();
-    }
+    virtual uint64_t get_new_req_id() = 0;
     /** Get a handler for bucket sync policy. */
     virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp,
                                        std::optional<rgw_zone_id> zone,
@@ -467,16 +464,8 @@ class Store {
  * attributes, and statistics (including usage) about the User.
  */
 class User {
-  protected:
-    RGWUserInfo info;
-    RGWObjVersionTracker objv_tracker;
-    Attrs attrs;
-
   public:
-    User() : info() {}
-    User(const rgw_user& _u) : info() { info.user_id = _u; }
-    User(const RGWUserInfo& _i) : info(_i) {}
-    User(User& _o) = default;
+    User() {}
     virtual ~User() = default;
 
     /** Clone a copy of this user.  Used when modification is necessary of the copy */
@@ -505,35 +494,37 @@ class User {
                            optional_yield y) = 0;
 
     /** Get the display name for this User */
-    virtual std::string& get_display_name() { return info.display_name; }
+    virtual std::string& get_display_name() = 0;
     /** Get the tenant name for this User */
-    const std::string& get_tenant() { return info.user_id.tenant; }
+    virtual const std::string& get_tenant() = 0;
     /** Set the tenant name for this User */
-    void set_tenant(std::string& _t) { info.user_id.tenant = _t; }
+    virtual void set_tenant(std::string& _t) = 0;
     /** Get the namespace for this User */
-    const std::string& get_ns() { return info.user_id.ns; }
+    virtual const std::string& get_ns() = 0;
     /** Set the namespace for this User */
-    void set_ns(std::string& _ns) { info.user_id.ns = _ns; }
+    virtual void set_ns(std::string& _ns) = 0;
     /** Clear the namespace for this User */
-    void clear_ns() { info.user_id.ns.clear(); }
+    virtual void clear_ns() = 0;
     /** Get the full ID for this User */
-    const rgw_user& get_id() const { return info.user_id; }
+    virtual const rgw_user& get_id() const = 0;
     /** Get the type of this User */
-    uint32_t get_type() const { return info.type; }
+    virtual uint32_t get_type() const = 0;
     /** Get the maximum number of buckets allowed for this User */
-    int32_t get_max_buckets() const { return info.max_buckets; }
+    virtual int32_t get_max_buckets() const = 0;
     /** Get the capabilities for this User */
-    const RGWUserCaps& get_caps() const { return info.caps; }
+    virtual const RGWUserCaps& get_caps() const = 0;
     /** Get the version tracker for this User */
-    virtual RGWObjVersionTracker& get_version_tracker() { return objv_tracker; }
+    virtual RGWObjVersionTracker& get_version_tracker() = 0;
     /** Get the cached attributes for this User */
-    virtual Attrs& get_attrs() { return attrs; }
+    virtual Attrs& get_attrs() = 0;
     /** Set the cached attributes fro this User */
-    virtual void set_attrs(Attrs& _attrs) { attrs = _attrs; }
+    virtual void set_attrs(Attrs& _attrs) = 0;
+    /** Check if a User is empty */
+    virtual bool empty() = 0;
     /** Check if a User pointer is empty */
-    static bool empty(User* u) { return (!u || u->info.user_id.id.empty()); }
+    static bool empty(User* u) { return (!u || u->empty()); }
     /** Check if a User unique_pointer is empty */
-    static bool empty(std::unique_ptr<User>& u) { return (!u || u->info.user_id.id.empty()); }
+    static bool empty(std::unique_ptr<User>& u) { return (!u || u->empty()); }
     /** Read the User attributes from the backing Store */
     virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
     /** Set the attributes in attrs, leaving any other existing attrs set, and
@@ -564,10 +555,13 @@ class User {
     virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
 
     /* dang temporary; will be removed when User is complete */
-    RGWUserInfo& get_info() { return info; }
+    virtual RGWUserInfo& get_info() = 0;
+
+    /** Print the User to @a out */
+    virtual void print(std::ostream& out) const = 0;
 
     friend inline std::ostream& operator<<(std::ostream& out, const User& u) {
-      out << u.info.user_id;
+      u.print(out);
       return out;
     }
 
@@ -575,7 +569,7 @@ class User {
       if (!u)
        out << "<NULL>";
       else
-       out << u->info.user_id;
+       u->print(out);
       return out;
     }
 
@@ -583,8 +577,6 @@ class User {
       out << p.get();
       return out;
     }
-
-    friend class Bucket;
 };
 
 /**
@@ -596,14 +588,6 @@ class User {
  * can access the contents of the bucket, and in what ways.
  */
 class Bucket {
-  protected:
-    RGWBucketEnt ent;
-    RGWBucketInfo info;
-    User* owner = nullptr;
-    Attrs attrs;
-    obj_version bucket_version;
-    ceph::real_time mtime;
-
   public:
 
     /**
@@ -647,31 +631,6 @@ class Bucket {
     };
 
     Bucket() = default;
-    Bucket(User* _u) :
-      owner(_u) { }
-    Bucket(const rgw_bucket& _b) { ent.bucket = _b; info.bucket = _b; }
-    Bucket(const RGWBucketEnt& _e) : ent(_e) {
-      info.bucket = ent.bucket;
-      info.placement_rule = ent.placement_rule;
-      info.creation_time = ent.creation_time;
-    }
-    Bucket(const RGWBucketInfo& _i) : info(_i) {
-      ent.bucket = info.bucket;
-      ent.placement_rule = info.placement_rule;
-      ent.creation_time = info.creation_time;
-    }
-    Bucket(const rgw_bucket& _b, User* _u) :
-      owner(_u) { ent.bucket = _b; info.bucket = _b; }
-    Bucket(const RGWBucketEnt& _e, User* _u) : ent(_e), owner(_u) {
-      info.bucket = ent.bucket;
-      info.placement_rule = ent.placement_rule;
-      info.creation_time = ent.creation_time;
-    }
-    Bucket(const RGWBucketInfo& _i, User* _u) : info(_i), owner(_u) {
-      ent.bucket = info.bucket;
-      ent.placement_rule = info.placement_rule;
-      ent.creation_time = info.creation_time;
-    }
     virtual ~Bucket() = default;
 
     /** Get an @a Object belonging to this bucket */
@@ -679,9 +638,9 @@ class Bucket {
     /** List the contents of this bucket */
     virtual int list(const DoutPrefixProvider* dpp, ListParams&, int, ListResults&, optional_yield y) = 0;
     /** Get the cached attributes associated with this bucket */
-    virtual Attrs& get_attrs(void) { return attrs; }
+    virtual Attrs& get_attrs(void) = 0;
     /** Set the cached attributes on this bucket */
-    virtual int set_attrs(Attrs a) { attrs = a; return 0; }
+    virtual int set_attrs(Attrs a) = 0;
     /** Remove this bucket from the backing store */
     virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children, bool forward_to_master, req_info* req_info, optional_yield y) = 0;
     /** Remove this bucket, bypassing garbage collection.  May be removed */
@@ -695,9 +654,7 @@ class Bucket {
     virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) = 0;
 
     // XXXX hack
-    void set_owner(rgw::sal::User* _owner) {
-      owner = _owner;
-    }
+    virtual void set_owner(rgw::sal::User* _owner) = 0;
 
     /** Load this bucket from the backing store.  Requires the key to be set, fills other fields.
      * If @a get_stats is true, then statistics on the bucket are also looked up. */
@@ -726,9 +683,9 @@ class Bucket {
     /** Check to see if the given user is the owner of this bucket */
     virtual bool is_owner(User* user) = 0;
     /** Get the owner of this bucket */
-    virtual User* get_owner(void) { return owner; };
+    virtual User* get_owner(void) = 0;
     /** Get the owner of this bucket in the form of an ACLOwner object */
-    virtual ACLOwner get_acl_owner(void) { return ACLOwner(info.owner); };
+    virtual ACLOwner get_acl_owner(void) = 0;
     /** Check in the backing store if this bucket is empty */
     virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
     /** Chec k if the given size fits within the quota */
@@ -757,38 +714,40 @@ class Bucket {
     virtual int purge_instance(const DoutPrefixProvider* dpp) = 0;
 
     /** Check if this instantiation is empty */
-    bool empty() const { return info.bucket.name.empty(); }
+    virtual bool empty() const = 0;
     /** Get the cached name of this bucket */
-    const std::string& get_name() const { return info.bucket.name; }
+    virtual const std::string& get_name() const = 0;
     /** Get the cached tenant of this bucket */
-    const std::string& get_tenant() const { return info.bucket.tenant; }
+    virtual const std::string& get_tenant() const = 0;
     /** Get the cached marker of this bucket */
-    const std::string& get_marker() const { return info.bucket.marker; }
+    virtual const std::string& get_marker() const = 0;
     /** Get the cached ID of this bucket */
-    const std::string& get_bucket_id() const { return info.bucket.bucket_id; }
+    virtual const std::string& get_bucket_id() const = 0;
     /** Get the cached size of this bucket */
-    size_t get_size() const { return ent.size; }
+    virtual size_t get_size() const = 0;
     /** Get the cached rounded size of this bucket */
-    size_t get_size_rounded() const { return ent.size_rounded; }
+    virtual size_t get_size_rounded() const = 0;
     /** Get the cached object count of this bucket */
-    uint64_t get_count() const { return ent.count; }
+    virtual uint64_t get_count() const = 0;
     /** Get the cached placement rule of this bucket */
-    rgw_placement_rule& get_placement_rule() { return info.placement_rule; }
+    virtual rgw_placement_rule& get_placement_rule() = 0;
     /** Get the cached creation time of this bucket */
-    ceph::real_time& get_creation_time() { return info.creation_time; }
+    virtual ceph::real_time& get_creation_time() = 0;
     /** Get the cached modification time of this bucket */
-    ceph::real_time& get_modification_time() { return mtime; }
+    virtual ceph::real_time& get_modification_time() = 0;
     /** Get the cached version of this bucket */
-    obj_version& get_version() { return bucket_version; }
+    virtual obj_version& get_version() = 0;
     /** Set the cached version of this bucket */
-    void set_version(obj_version &ver) { bucket_version = ver; }
+    virtual void set_version(obj_version &ver) = 0;
     /** Check if this bucket is versioned */
-    bool versioned() { return info.versioned(); }
+    virtual bool versioned() = 0;
     /** Check if this bucket has versioning enabled */
-    bool versioning_enabled() { return info.versioning_enabled(); }
+    virtual bool versioning_enabled() = 0;
 
     /** Check if a Bucket pointer is empty */
     static bool empty(Bucket* b) { return (!b || b->empty()); }
+    /** Check if a Bucket unique pointer is empty */
+    static bool empty(std::unique_ptr<Bucket> b) { return (!b || b->empty()); }
     /** Clone a copy of this bucket.  Used when modification is necessary of the copy */
     virtual std::unique_ptr<Bucket> clone() = 0;
 
@@ -811,11 +770,14 @@ class Bucket {
                                 CephContext* cct) = 0;
 
     /* dang - This is temporary, until the API is completed */
-    rgw_bucket& get_key() { return info.bucket; }
-    RGWBucketInfo& get_info() { return info; }
+    virtual rgw_bucket& get_key() = 0;
+    virtual RGWBucketInfo& get_info() = 0;
+
+    /** Print the User to @a out */
+    virtual void print(std::ostream& out) const = 0;
 
     friend inline std::ostream& operator<<(std::ostream& out, const Bucket& b) {
-      out << b.info.bucket;
+      b.print(out);
       return out;
     }
 
@@ -823,7 +785,7 @@ class Bucket {
       if (!b)
        out << "<NULL>";
       else
-       out << b->info.bucket;
+       b->print(out);
       return out;
     }
 
@@ -832,20 +794,10 @@ class Bucket {
       return out;
     }
 
-    bool operator==(const Bucket& b) const {
-      return (info.bucket.tenant == b.info.bucket.tenant) &&
-            (info.bucket.name == b.info.bucket.name) &&
-            (info.bucket.bucket_id == b.info.bucket.bucket_id);
-    }
-    bool operator!=(const Bucket& b) const {
-      return (info.bucket.tenant != b.info.bucket.tenant) ||
-            (info.bucket.name != b.info.bucket.name) ||
-            (info.bucket.bucket_id != b.info.bucket.bucket_id);
-    }
+    virtual bool operator==(const Bucket& b) const = 0;
+    virtual bool operator!=(const Bucket& b) const = 0;
 
     friend class BucketList;
-  protected:
-    virtual void set_ent(RGWBucketEnt& _ent) { ent = _ent; info.bucket = ent.bucket; info.placement_rule = ent.placement_rule; }
 };
 
 /**
@@ -880,7 +832,7 @@ public:
   void set_truncated(bool trunc) { truncated = trunc; }
   /** Add a bucket to the list.  Takes ownership of the bucket */
   void add(std::unique_ptr<Bucket> bucket) {
-    buckets.emplace(bucket->info.bucket.name, std::move(bucket));
+    buckets.emplace(bucket->get_name(), std::move(bucket));
   }
   /** The number of buckets in this list */
   size_t count() const { return buckets.size(); }
@@ -902,12 +854,6 @@ public:
  * is written to, it is replaced, and the old data is not accessible.
  */
 class Object {
-  protected:
-    RGWObjState state; /**< The key and primary metadata for the object */
-    Bucket* bucket; /**< @a Bucket containing this object */
-    Attrs attrs; /**< Cache of attributes for this object */
-    bool delete_marker{false}; /**< True if this object has a delete marker */
-
   public:
 
     /**
@@ -976,23 +922,7 @@ class Object {
       virtual int delete_obj(const DoutPrefixProvider* dpp, optional_yield y) = 0;
     };
 
-    Object()
-      : state(),
-      bucket(nullptr),
-      attrs()
-      {}
-    Object(const rgw_obj_key& _k)
-      : state(),
-      bucket(),
-      attrs()
-      { state.obj.key = _k; }
-    Object(const rgw_obj_key& _k, Bucket* _b)
-      : state(),
-      bucket(_b),
-      attrs()
-      { state.obj.init(_b->get_key(), _k); }
-    Object(Object& _o) = default;
-
+    Object() {}
     virtual ~Object() = default;
 
     /** Shortcut synchronous delete call for common deletes */
@@ -1023,42 +953,25 @@ class Object {
     /** Set the ACL for this object */
     virtual int set_acl(const RGWAccessControlPolicy& acl) = 0;
     /** Mark further operations on this object as being atomic */
-    virtual void set_atomic() {
-      state.is_atomic = true;
-    }
+    virtual void set_atomic() = 0;
     /** Check if this object is atomic */
-    bool is_atomic() { return state.is_atomic; }
+    virtual bool is_atomic() = 0;
     /** Pre-fetch data when reading */
-    virtual void set_prefetch_data() {
-      state.prefetch_data = true;
-    }
+    virtual void set_prefetch_data() = 0;
     /** Check if this object should prefetch */
-    bool is_prefetch_data() { return state.prefetch_data; }
+    virtual bool is_prefetch_data() = 0;
     /** Mark data as compressed */
-    virtual void set_compressed() {
-      state.compressed = true;
-    }
+    virtual void set_compressed() = 0;
     /** Check if this object is compressed */
-    bool is_compressed() { return state.compressed; }
+    virtual bool is_compressed() = 0;
     /** Invalidate cached info about this object, except atomic, prefetch, and
      * compressed */
-    virtual void invalidate() {
-      rgw_obj obj = state.obj;
-      bool is_atomic = state.is_atomic;
-      bool prefetch_data = state.prefetch_data;
-      bool compressed = state.compressed;
-
-      state = RGWObjState();
-      state.obj = obj;
-      state.is_atomic = is_atomic;
-      state.prefetch_data = prefetch_data;
-      state.compressed = compressed;
-    }
+    virtual void invalidate() = 0;
 
     /** Check to see if this object has an empty key.  This means it's uninitialized */
-    bool empty() const { return state.obj.empty(); }
+    virtual bool empty() const = 0;
     /** Get the name of this object */
-    const std::string &get_name() const { return state.obj.key.name; }
+    virtual const std::string &get_name() const = 0;
 
     /** Get the object state for this object.  Will be removed in the future */
     virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) = 0;
@@ -1099,43 +1012,43 @@ class Object {
     virtual int dump_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f) = 0;
 
     /** Get the cached attributes for this object */
-    Attrs& get_attrs(void) { return state.attrset; }
+    virtual Attrs& get_attrs(void) = 0;
     /** Get the (const) cached attributes for this object */
-    const Attrs& get_attrs(void) const { return state.attrset; }
+    virtual const Attrs& get_attrs(void) const = 0;
     /** Set the cached attributes for this object */
-    virtual int set_attrs(Attrs a) { state.attrset = a; state.has_attrs = true; return 0; }
+    virtual int set_attrs(Attrs a) = 0;
     /** Check to see if attributes are cached on this object */
-    bool has_attrs(void) { return state.has_attrs; }
+    virtual bool has_attrs(void) = 0;
     /** Get the cached modification time for this object */
-    ceph::real_time get_mtime(void) const { return state.mtime; }
+    virtual ceph::real_time get_mtime(void) const = 0;
     /** Get the cached size for this object */
-    uint64_t get_obj_size(void) const { return state.size; }
+    virtual uint64_t get_obj_size(void) const = 0;
     /** Get the bucket containing this object */
-    Bucket* get_bucket(void) const { return bucket; }
+    virtual Bucket* get_bucket(void) const = 0;
     /** Set the bucket containing this object */
-    void set_bucket(Bucket* b) { bucket = b; state.obj.bucket = b->get_key(); }
+    virtual void set_bucket(Bucket* b) = 0;
     /** Get the sharding hash representation of this object */
-    std::string get_hash_source(void) { return state.obj.index_hash_source; }
+    virtual std::string get_hash_source(void) = 0;
     /** Set the sharding hash representation of this object */
-    void set_hash_source(std::string s) { state.obj.index_hash_source = s; }
+    virtual void set_hash_source(std::string s) = 0;
     /** Build an Object Identifier string for this object */
-    std::string get_oid(void) const { return state.obj.key.get_oid(); }
+    virtual std::string get_oid(void) const = 0;
     /** True if this object is a delete marker (newest version is deleted) */
-    bool get_delete_marker(void) { return delete_marker; }
+    virtual bool get_delete_marker(void) = 0;
     /** True if this object is stored in the extra data pool */
-    bool get_in_extra_data(void) { return state.obj.is_in_extra_data(); }
+    virtual bool get_in_extra_data(void) = 0;
     /** Set the in_extra_data field */
-    void set_in_extra_data(bool i) { state.obj.set_in_extra_data(i); }
+    virtual void set_in_extra_data(bool i) = 0;
     /** Helper to sanitize object size, offset, and end values */
     int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
     /** Set the cached size of this object */
-    void set_obj_size(uint64_t s) { state.size = s; }
+    virtual void set_obj_size(uint64_t s) = 0;
     /** Set the cached name of this object */
-    virtual void set_name(const std::string& n) { state.obj.key = n; }
+    virtual void set_name(const std::string& n) = 0;
     /** Set the cached key of this object */
-    virtual void set_key(const rgw_obj_key& k) { state.obj.key = k; }
+    virtual void set_key(const rgw_obj_key& k) = 0;
     /** Get an rgw_obj representing this object */
-    virtual rgw_obj get_obj(void) const { return state.obj; }
+    virtual rgw_obj get_obj(void) const = 0;
 
     /** Restore the previous swift version of this object */
     virtual int swift_versioning_restore(bool& restored,   /* out */
@@ -1164,34 +1077,37 @@ class Object {
     virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val,
                                    bool must_exist, optional_yield y) = 0;
 
-    /** Check to see if the give object pointer is uninitialized */
+    /** Check to see if the given object pointer is uninitialized */
     static bool empty(Object* o) { return (!o || o->empty()); }
+    /** Check to see if the given object unique pointer is uninitialized */
+    static bool empty(std::unique_ptr<Object> o) { return (!o || o->empty()); }
     /** Get a unique copy of this object */
     virtual std::unique_ptr<Object> clone() = 0;
 
     /* dang - This is temporary, until the API is completed */
     /** Get the key for this object */
-    rgw_obj_key& get_key() { return state.obj.key; }
+    virtual rgw_obj_key& get_key() = 0;
     /** Set the instance for this object */
-    void set_instance(const std::string &i) { state.obj.key.set_instance(i); }
+    virtual void set_instance(const std::string &i) = 0;
     /** Get the instance for this object */
-    const std::string &get_instance() const { return state.obj.key.instance; }
+    virtual const std::string &get_instance() const = 0;
     /** Check to see if this object has an instance set */
-    bool have_instance(void) { return state.obj.key.have_instance(); }
+    virtual bool have_instance(void) = 0;
     /** Clear the instance on this object */
-    void clear_instance() { state.obj.key.instance.clear(); }
+    virtual void clear_instance() = 0;
+
+    /** Print the User to @a out */
+    virtual void print(std::ostream& out) const = 0;
 
     friend inline std::ostream& operator<<(std::ostream& out, const Object& o) {
-      if (o.bucket)
-       out << o.bucket << ":";
-      out << o.state.obj.key;
+      o.print(out);
       return out;
     }
     friend inline std::ostream& operator<<(std::ostream& out, const Object* o) {
       if (!o)
        out << "<NULL>";
       else
-       out << *o;
+       o->print(out);
       return out;
     }
     friend inline std::ostream& operator<<(std::ostream& out, const std::unique_ptr<Object>& p) {
@@ -1204,9 +1120,6 @@ class Object {
  * @brief Abstraction of a single part of a multipart upload
  */
 class MultipartPart {
-protected:
-  std::string oid;
-
 public:
   MultipartPart() = default;
   virtual ~MultipartPart() = default;
@@ -1231,12 +1144,8 @@ public:
  * set of upload parts.
  */
 class MultipartUpload {
-protected:
-  Bucket* bucket;
-  std::map<uint32_t, std::unique_ptr<MultipartPart>> parts;
-  jspan_context trace_ctx{false, false};
 public:
-  MultipartUpload(Bucket* _bucket) : bucket(_bucket) {}
+  MultipartUpload() = default;
   virtual ~MultipartUpload() = default;
 
   /** Get the name of the object representing this upload in the backing store */
@@ -1251,10 +1160,10 @@ public:
   virtual ceph::real_time& get_mtime() = 0;
 
   /** Get all the cached parts that make up this upload */
-  std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() { return parts; }
+  virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() = 0;
 
   /** Get the trace context of this upload */
-  const jspan_context& get_trace() { return trace_ctx; }
+  virtual const jspan_context& get_trace() = 0;
 
   /** Get the Object that represents this upload */
   virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() = 0;
@@ -1291,17 +1200,18 @@ public:
                          uint64_t part_num,
                          const std::string& part_num_str) = 0;
 
+  /** Print the Upload to @a out */
+  virtual void print(std::ostream& out) const = 0;
+
   friend inline std::ostream& operator<<(std::ostream& out, const MultipartUpload& u) {
-    out << u.get_meta();
-    if (!u.get_upload_id().empty())
-      out << ":" << u.get_upload_id();
+    u.print(out);
     return out;
   }
   friend inline std::ostream& operator<<(std::ostream& out, const MultipartUpload* u) {
     if (!u)
       out << "<NULL>";
     else
-      out << *u;
+      u->print(out);
     return out;
   }
   friend inline std::ostream& operator<<(std::ostream& out, const
@@ -1314,7 +1224,8 @@ public:
 /**
  * @brief Interface of a lock/serialization
  */
-struct Serializer {
+class Serializer {
+public:
   Serializer() = default;
   virtual ~Serializer() = default;
 
@@ -1322,24 +1233,39 @@ struct Serializer {
   virtual int try_lock(const DoutPrefixProvider *dpp, utime_t dur, optional_yield y) = 0;
   /** Unlock the lock */
   virtual int unlock()  = 0;
+
+  /** Print the Serializer to @a out */
+  virtual void print(std::ostream& out) const = 0;
+
+  friend inline std::ostream& operator<<(std::ostream& out, const Serializer& s) {
+    s.print(out);
+    return out;
+  }
+  friend inline std::ostream& operator<<(std::ostream& out, const Serializer* s) {
+    if (!s)
+      out << "<NULL>";
+    else
+      s->print(out);
+    return out;
+  }
 };
 
 /** @brief Abstraction of a serializer for multipart uploads
  */
-struct MPSerializer : Serializer {
-  bool locked;
-  std::string oid;
-  MPSerializer() : locked(false) {}
+class MPSerializer : public Serializer {
+public:
+  MPSerializer() = default;
   virtual ~MPSerializer() = default;
 
-  void clear_locked() {
-    locked = false;
-  }
+  virtual void clear_locked() = 0;
+  /** Check to see if locked */
+  virtual bool is_locked() = 0;
 };
 
 /** @brief Abstraction of a serializer for Lifecycle
  */
-struct LCSerializer : Serializer {
+class LCSerializer : public Serializer {
+public:
   LCSerializer() {}
   virtual ~LCSerializer() = default;
 };
@@ -1355,45 +1281,73 @@ class Lifecycle {
 public:
   /** Head of a lifecycle run.  Used for tracking parallel lifecycle runs. */
   struct LCHead {
-    time_t start_date{0};
-    std::string marker;
-    time_t shard_rollover_date{0};
-
     LCHead() = default;
-    LCHead(time_t _date, std::string& _marker) : start_date(_date), marker(_marker) {}
+    virtual ~LCHead() = default;
+
+    virtual time_t& get_start_date() = 0;
+    virtual void set_start_date(time_t) = 0;
+    virtual std::string& get_marker() = 0;
+    virtual void set_marker(const std::string&) = 0;
+    virtual time_t& get_shard_rollover_date() = 0;
+    virtual void set_shard_rollover_date(time_t) = 0;
   };
 
   /** Single entry in a lifecycle run.  Multiple entries can exist processing different
    * buckets. */
   struct LCEntry {
-    std::string bucket;
-    std::string oid;
-    uint64_t start_time{0};
-    uint32_t status{0};
-
     LCEntry() = default;
-    LCEntry(std::string& _bucket, uint64_t _time, uint32_t _status) : bucket(_bucket), start_time(_time), status(_status) {}
-    LCEntry(std::string& _bucket, std::string _oid, uint64_t _time, uint32_t _status) : bucket(_bucket), oid(_oid), start_time(_time), status(_status) {}
+    virtual ~LCEntry() = default;
+
+    virtual std::string& get_bucket() = 0;
+    virtual void set_bucket(const std::string&) = 0;
+    virtual std::string& get_oid() = 0;
+    virtual void set_oid(const std::string&) = 0;
+    virtual uint64_t get_start_time() = 0;
+    virtual void set_start_time(uint64_t) = 0;
+    virtual uint32_t get_status() = 0;
+    virtual void set_status(uint32_t) = 0;
+
+    /** Print the entry to @a out */
+    virtual void print(std::ostream& out) const = 0;
+
+    friend inline std::ostream& operator<<(std::ostream& out, const LCEntry& e) {
+      e.print(out);
+      return out;
+    }
+    friend inline std::ostream& operator<<(std::ostream& out, const LCEntry* e) {
+      if (!e)
+       out << "<NULL>";
+      else
+       e->print(out);
+      return out;
+    }
+    friend inline std::ostream& operator<<(std::ostream& out, const std::unique_ptr<LCEntry>& p) {
+      out << p.get();
+      return out;
+      }
   };
 
   Lifecycle() = default;
   virtual ~Lifecycle() = default;
 
+  /** Get an empty entry */
+  virtual std::unique_ptr<LCEntry> get_entry() = 0;
   /** Get an entry matching the given marker */
-  virtual int get_entry(const std::string& oid, const std::string& marker, LCEntry& entry) = 0;
+  virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
   /** Get the entry following the given marker */
-  virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) = 0;
+  virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
   /** Store a modified entry in then backing store */
-  virtual int set_entry(const std::string& oid, const LCEntry& entry) = 0;
+  virtual int set_entry(const std::string& oid, LCEntry& entry) = 0;
   /** List all known entries */
   virtual int list_entries(const std::string& oid, const std::string& marker,
-                          uint32_t max_entries, std::vector<LCEntry>& entries) = 0;
+                          uint32_t max_entries,
+                          std::vector<std::unique_ptr<LCEntry>>& entries) = 0;
   /** Remove an entry from the backing store */
-  virtual int rm_entry(const std::string& oid, const LCEntry& entry) = 0;
+  virtual int rm_entry(const std::string& oid, LCEntry& entry) = 0;
   /** Get a head */
-  virtual int get_head(const std::string& oid, LCHead& head) = 0;
+  virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) = 0;
   /** Store a modified head to the backing store */
-  virtual int put_head(const std::string& oid, const LCHead& head) = 0;
+  virtual int put_head(const std::string& oid, LCHead& head) = 0;
 
   /** Get a serializer for lifecycle */
   virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
@@ -1407,14 +1361,8 @@ public:
  */
 class Notification {
 protected:
-  Object* obj;
-  Object* src_obj;
-  rgw::notify::EventType event_type;
-
   public:
-    Notification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
-      : obj(_obj), src_obj(_src_obj), event_type(_type)
-    {}
+    Notification() {}
 
     virtual ~Notification() = default;
 
@@ -1433,11 +1381,8 @@ protected:
  * those filters.
  */
 class Writer : public ObjectProcessor {
-protected:
-  const DoutPrefixProvider* dpp;
-
 public:
-  Writer(const DoutPrefixProvider *_dpp, optional_yield y) : dpp(_dpp) {}
+  Writer() {}
   virtual ~Writer() = default;
 
   /** prepare to start processing object data */
@@ -1461,6 +1406,13 @@ public:
                        optional_yield y) = 0;
 };
 
+
+/**
+ * @brief Abstraction of a placement tier
+ *
+ * This abstraction allows access to information about placement tiers,
+ * including storage class.
+ */
 class PlacementTier {
 public:
   virtual ~PlacementTier() = default;
@@ -1474,20 +1426,36 @@ public:
   /** Get the placement rule associated with this tier */
 };
 
+/**
+ * @brief Abstraction of a zone group
+ *
+ * This class allows access to information about a zonegroup.  It may be the
+ * group containing the current zone, or another group.
+ */
 class ZoneGroup {
 public:
   virtual ~ZoneGroup() = default;
+  /** Get the ID of this zonegroup */
   virtual const std::string& get_id() const = 0;
+  /** Get the name of this zonegroup */
   virtual const std::string& get_name() const = 0;
+  /** Determine if two zonegroups are the same */
   virtual int equals(const std::string& other_zonegroup) const = 0;
   /** Get the endpoint from zonegroup, or from master zone if not set */
   virtual const std::string& get_endpoint() const = 0;
+  /** Check if a placement target (by name) exists in this zonegroup */
   virtual bool placement_target_exists(std::string& target) const = 0;
+  /** Check if this is the master zonegroup */
   virtual bool is_master_zonegroup() const = 0;
+  /** Get the API name of this zonegroup */
   virtual const std::string& get_api_name() const = 0;
+  /** Get the list of placement target names for this zone */
   virtual int get_placement_target_names(std::set<std::string>& names) const = 0;
+  /** Get the name of the default placement target for this zone */
   virtual const std::string& get_default_placement_name() const = 0;
+  /** Get the list of hostnames from this zone */
   virtual int get_hostnames(std::list<std::string>& names) const = 0;
+  /** Get the list of hostnames that host s3 websites from this zone */
   virtual int get_s3website_hostnames(std::list<std::string>& names) const = 0;
   /** Get the number of zones in this zonegroup */
   virtual int get_zone_count() const = 0;
index 76adbaee3a627ea65de02f4e4b000a240baa837c..c06fc814d0c35299ed4d34879eedf9ed5a20db18 100644 (file)
@@ -1251,7 +1251,7 @@ namespace rgw::sal {
                    const rgw_user& _owner,
                    const rgw_placement_rule *_ptail_placement_rule,
                 uint64_t _part_num, const std::string& _part_num_str):
-                       Writer(dpp, y),
+                       StoreWriter(dpp, y),
                        store(_store),
                 owner(_owner),
                 ptail_placement_rule(_ptail_placement_rule),
@@ -1400,7 +1400,7 @@ namespace rgw::sal {
                    const rgw_placement_rule *_ptail_placement_rule,
                        uint64_t _olh_epoch,
                        const std::string& _unique_tag) :
-                       Writer(dpp, y),
+                       StoreWriter(dpp, y),
                        store(_store),
                 owner(_owner),
                 ptail_placement_rule(_ptail_placement_rule),
@@ -1766,39 +1766,39 @@ namespace rgw::sal {
   }
 
   int DBLifecycle::get_entry(const std::string& oid, const std::string& marker,
-                             LCEntry& entry)
+                             std::unique_ptr<LCEntry>* entry)
   {
     return store->getDB()->get_entry(oid, marker, entry);
   }
 
-  int DBLifecycle::get_next_entry(const std::string& oid, std::string& marker,
-                                  LCEntry& entry)
+  int DBLifecycle::get_next_entry(const std::string& oid, const std::string& marker,
+                                 std::unique_ptr<LCEntry>* entry)
   {
     return store->getDB()->get_next_entry(oid, marker, entry);
   }
 
-  int DBLifecycle::set_entry(const std::string& oid, const LCEntry& entry)
+  int DBLifecycle::set_entry(const std::string& oid, LCEntry& entry)
   {
     return store->getDB()->set_entry(oid, entry);
   }
 
   int DBLifecycle::list_entries(const std::string& oid, const std::string& marker,
-                                uint32_t max_entries, vector<LCEntry>& entries)
+                                uint32_t max_entries, vector<std::unique_ptr<LCEntry>>& entries)
   {
     return store->getDB()->list_entries(oid, marker, max_entries, entries);
   }
 
-  int DBLifecycle::rm_entry(const std::string& oid, const LCEntry& entry)
+  int DBLifecycle::rm_entry(const std::string& oid, LCEntry& entry)
   {
     return store->getDB()->rm_entry(oid, entry);
   }
 
-  int DBLifecycle::get_head(const std::string& oid, LCHead& head)
+  int DBLifecycle::get_head(const std::string& oid, std::unique_ptr<LCHead>* head)
   {
     return store->getDB()->get_head(oid, head);
   }
 
-  int DBLifecycle::put_head(const std::string& oid, const LCHead& head)
+  int DBLifecycle::put_head(const std::string& oid, LCHead& head)
   {
     return store->getDB()->put_head(oid, head);
   }
index c3d956cbdc3573eb4ec5b5b934f2c2c8bcb701f2..d076c4ce9c8a15cfca01ae33e5ca82c43a93e176 100644 (file)
@@ -15,7 +15,7 @@
 
 #pragma once
 
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
 #include "rgw_oidc_provider.h"
 #include "rgw_role.h"
 #include "rgw_lc.h"
@@ -28,8 +28,7 @@ namespace rgw { namespace sal {
 
   class DBStore;
 
-class LCDBSerializer : public LCSerializer {
-  const std::string oid;
+class LCDBSerializer : public StoreLCSerializer {
 
 public:
   LCDBSerializer(DBStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie) {}
@@ -40,28 +39,30 @@ public:
   }
 };
 
-class DBLifecycle : public Lifecycle {
+class DBLifecycle : public StoreLifecycle {
   DBStore* store;
 
 public:
   DBLifecycle(DBStore* _st) : store(_st) {}
 
-  virtual int get_entry(const std::string& oid, const std::string& marker, LCEntry& entry) override;
-  virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) override;
-  virtual int set_entry(const std::string& oid, const LCEntry& entry) override;
+  using StoreLifecycle::get_entry;
+  virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+  virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+  virtual int set_entry(const std::string& oid, LCEntry& entry) override;
   virtual int list_entries(const std::string& oid, const std::string& marker,
-                          uint32_t max_entries, std::vector<LCEntry>& entries) override;
-  virtual int rm_entry(const std::string& oid, const LCEntry& entry) override;
-  virtual int get_head(const std::string& oid, LCHead& head) override;
-  virtual int put_head(const std::string& oid, const LCHead& head) override;
+                          uint32_t max_entries,
+                          std::vector<std::unique_ptr<LCEntry>>& entries) override;
+  virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
+  virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
+  virtual int put_head(const std::string& oid, LCHead& head) override;
   virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
 };
 
-class DBNotification : public Notification {
+class DBNotification : public StoreNotification {
 protected:
   public:
   DBNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
-    : Notification(_obj, _src_obj, _type) {}
+    : StoreNotification(_obj, _src_obj, _type) {}
     ~DBNotification() = default;
 
     virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override { return 0;}
@@ -69,13 +70,13 @@ protected:
                               const ceph::real_time& mtime, const std::string& etag, const std::string& version) override { return 0; }
 };
 
-  class DBUser : public User {
+  class DBUser : public StoreUser {
     private:
       DBStore *store;
 
     public:
-      DBUser(DBStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
-      DBUser(DBStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+      DBUser(DBStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+      DBUser(DBStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
       DBUser(DBStore *_st) : store(_st) { }
       DBUser(DBUser& _o) = default;
       DBUser() {}
@@ -122,7 +123,7 @@ protected:
       friend class DBBucket;
   };
 
-  class DBBucket : public Bucket {
+  class DBBucket : public StoreBucket {
     private:
       DBStore *store;
       RGWAccessControlPolicy acls;
@@ -134,43 +135,43 @@ protected:
         }
 
       DBBucket(DBStore *_st, User* _u)
-        : Bucket(_u),
+        : StoreBucket(_u),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const rgw_bucket& _b)
-        : Bucket(_b),
+        : StoreBucket(_b),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const RGWBucketEnt& _e)
-        : Bucket(_e),
+        : StoreBucket(_e),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const RGWBucketInfo& _i)
-        : Bucket(_i),
+        : StoreBucket(_i),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const rgw_bucket& _b, User* _u)
-        : Bucket(_b, _u),
+        : StoreBucket(_b, _u),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const RGWBucketEnt& _e, User* _u)
-        : Bucket(_e, _u),
+        : StoreBucket(_e, _u),
         store(_st),
         acls() {
         }
 
       DBBucket(DBStore *_st, const RGWBucketInfo& _i, User* _u)
-        : Bucket(_i, _u),
+        : StoreBucket(_i, _u),
         store(_st),
         acls() {
         }
@@ -234,7 +235,7 @@ protected:
       friend class DBStore;
   };
 
-  class DBPlacementTier: public PlacementTier {
+  class DBPlacementTier: public StorePlacementTier {
     DBStore* store;
     RGWZoneGroupPlacementTier tier;
   public:
@@ -247,7 +248,7 @@ protected:
     RGWZoneGroupPlacementTier& get_rt() { return tier; }
   };
 
-  class DBZoneGroup : public ZoneGroup {
+  class DBZoneGroup : public StoreZoneGroup {
     DBStore* store;
     std::unique_ptr<RGWZoneGroup> group;
     std::string empty;
@@ -288,7 +289,7 @@ protected:
     }
   };
 
-  class DBZone : public Zone {
+  class DBZone : public StoreZone {
     protected:
       DBStore* store;
       RGWRealm *realm{nullptr};
@@ -336,7 +337,7 @@ protected:
       virtual const std::string& get_realm_id() override;
   };
 
-  class DBLuaScriptManager : public LuaScriptManager {
+  class DBLuaScriptManager : public StoreLuaScriptManager {
     DBStore* store;
 
     public:
@@ -382,7 +383,7 @@ protected:
    *                     rename all data/tail objects to orig object name and update
    *                     metadata of the orig object.
    */
-  class DBMultipartPart : public MultipartPart {
+  class DBMultipartPart : public StoreMultipartPart {
   protected:
     RGWUploadPartInfo info; /* XXX: info contains manifest also which is not needed */
 
@@ -451,7 +452,7 @@ protected:
     }
   };
 
-  class DBMultipartUpload : public MultipartUpload {
+  class DBMultipartUpload : public StoreMultipartUpload {
     DBStore* store;
     DBMPObj mp_obj;
     ACLOwner owner;
@@ -459,7 +460,7 @@ protected:
     rgw_placement_rule placement;
 
   public:
-    DBMultipartUpload(DBStore* _store, Bucket* _bucket, const std::string& oid, std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) : MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
+    DBMultipartUpload(DBStore* _store, Bucket* _bucket, const std::string& oid, std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) : StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
     virtual ~DBMultipartUpload() = default;
 
     virtual const std::string& get_meta() const { return mp_obj.get_meta(); }
@@ -493,7 +494,7 @@ protected:
                          const std::string& part_num_str) override;
   };
 
-  class DBObject : public Object {
+  class DBObject : public StoreObject {
     private:
       DBStore* store;
       RGWAccessControlPolicy acls;
@@ -530,12 +531,12 @@ protected:
       DBObject() = default;
 
       DBObject(DBStore *_st, const rgw_obj_key& _k)
-        : Object(_k),
+        : StoreObject(_k),
         store(_st),
         acls() {}
 
       DBObject(DBStore *_st, const rgw_obj_key& _k, Bucket* _b)
-        : Object(_k, _b),
+        : StoreObject(_k, _b),
         store(_st),
         acls() {}
 
@@ -617,7 +618,7 @@ protected:
       int read_attrs(const DoutPrefixProvider* dpp, DB::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr);
   };
 
-  class MPDBSerializer : public MPSerializer {
+  class MPDBSerializer : public StoreMPSerializer {
 
   public:
     MPDBSerializer(const DoutPrefixProvider *dpp, DBStore* store, DBObject* obj, const std::string& lock_name) {}
@@ -626,7 +627,7 @@ protected:
     virtual int unlock() override { return 0;}
   };
 
-  class DBAtomicWriter : public Writer {
+  class DBAtomicWriter : public StoreWriter {
     protected:
     rgw::sal::DBStore* store;
     const rgw_user& owner;
@@ -671,7 +672,7 @@ protected:
                          optional_yield y) override;
   };
 
-  class DBMultipartWriter : public Writer {
+  class DBMultipartWriter : public StoreWriter {
   protected:
     rgw::sal::DBStore* store;
     const rgw_user& owner;
@@ -719,7 +720,7 @@ public:
                        optional_yield y) override;
   };
 
-  class DBStore : public Store {
+  class DBStore : public StoreStore {
     private:
       /* DBStoreManager is used in case multiple
        * connections are needed one for each tenant.
diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h
new file mode 100644 (file)
index 0000000..53d333b
--- /dev/null
@@ -0,0 +1,622 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2022 Red Hat, Inc.
+ *
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include "rgw_sal.h"
+
+namespace rgw { namespace sal {
+
+class FilterStore : public Store {
+  public:
+    FilterStore() {}
+    virtual ~FilterStore() = default;
+
+    virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) = 0;
+    virtual const std::string get_name() const = 0;
+    virtual std::string get_cluster_id(const DoutPrefixProvider* dpp,  optional_yield y) = 0;
+    virtual std::unique_ptr<User> get_user(const rgw_user& u) = 0;
+    virtual int get_user_by_access_key(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y, std::unique_ptr<User>* user) = 0;
+    virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr<User>* user) = 0;
+    virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr<User>* user) = 0;
+    virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) = 0;
+    virtual int get_bucket(User* u, const RGWBucketInfo& i, std::unique_ptr<Bucket>* bucket) = 0;
+    virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const rgw_bucket& b, std::unique_ptr<Bucket>* bucket, optional_yield y) = 0;
+    virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const std::string& tenant, const std::string& name, std::unique_ptr<Bucket>* bucket, optional_yield y) = 0;
+    virtual bool is_meta_master() = 0;
+    virtual int forward_request_to_master(const DoutPrefixProvider *dpp, User* user, obj_version* objv,
+                                         bufferlist& in_data, JSONParser* jp, req_info& info,
+                                         optional_yield y) = 0;
+    virtual Zone* get_zone() = 0;
+    virtual std::string zone_unique_id(uint64_t unique_num) = 0;
+    virtual std::string zone_unique_trans_id(const uint64_t unique_num) = 0;
+    virtual int cluster_stat(RGWClusterStat& stats) = 0;
+    virtual std::unique_ptr<Lifecycle> get_lifecycle(void) = 0;
+    virtual std::unique_ptr<Completions> get_completions(void) = 0;
+
+    virtual std::unique_ptr<Notification> get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s,
+        rgw::notify::EventType event_type, const std::string* object_name=nullptr) = 0;
+    virtual std::unique_ptr<Notification> get_notification(
+    const DoutPrefixProvider* dpp, rgw::sal::Object* obj, rgw::sal::Object* src_obj, 
+    rgw::notify::EventType event_type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant,
+    std::string& _req_id, optional_yield y) = 0;
+
+    virtual RGWLC* get_rgwlc(void) = 0;
+    virtual RGWCoroutinesManagerRegistry* get_cr_registry() = 0;
+
+    virtual int log_usage(const DoutPrefixProvider *dpp, std::map<rgw_user_bucket, RGWUsageBatch>& usage_info) = 0;
+    virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) = 0;
+    virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
+                                       const std::map<std::string, std::string>& meta) = 0;
+    virtual void get_quota(RGWQuota& quota) = 0;
+    virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) = 0;
+    virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) = 0;
+    virtual uint64_t get_new_req_id() = 0;
+    virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp,
+                                       std::optional<rgw_zone_id> zone,
+                                       std::optional<rgw_bucket> bucket,
+                                       RGWBucketSyncPolicyHandlerRef* phandler,
+                                       optional_yield y) = 0;
+    virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) = 0;
+    virtual void wakeup_meta_sync_shards(std::set<int>& shard_ids) = 0;
+    virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, boost::container::flat_map<int, boost::container::flat_set<rgw_data_notify_entry>>& shard_ids) = 0;
+    virtual int clear_usage(const DoutPrefixProvider *dpp) = 0;
+    virtual int read_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch,
+                              uint32_t max_entries, bool* is_truncated,
+                              RGWUsageIter& usage_iter,
+                              std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+    virtual int trim_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+    virtual int get_config_key_val(std::string name, bufferlist* bl) = 0;
+    virtual int meta_list_keys_init(const DoutPrefixProvider *dpp, const std::string& section, const std::string& marker, void** phandle) = 0;
+    virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, std::list<std::string>& keys, bool* truncated) = 0;
+    virtual void meta_list_keys_complete(void* handle) = 0;
+    virtual std::string meta_get_marker(void* handle) = 0;
+    virtual int meta_remove(const DoutPrefixProvider* dpp, std::string& metadata_key, optional_yield y) = 0;
+    virtual const RGWSyncModuleInstanceRef& get_sync_module() = 0;
+    virtual std::string get_host_id() = 0;
+    virtual std::unique_ptr<LuaScriptManager> get_lua_script_manager() = 0;
+    virtual std::unique_ptr<RGWRole> get_role(std::string name,
+                                             std::string tenant,
+                                             std::string path="",
+                                             std::string trust_policy="",
+                                             std::string max_session_duration_str="",
+                std::multimap<std::string,std::string> tags={}) = 0;
+    virtual std::unique_ptr<RGWRole> get_role(std::string id) = 0;
+    virtual std::unique_ptr<RGWRole> get_role(const RGWRoleInfo& info) = 0;
+    virtual int get_roles(const DoutPrefixProvider *dpp,
+                         optional_yield y,
+                         const std::string& path_prefix,
+                         const std::string& tenant,
+                         std::vector<std::unique_ptr<RGWRole>>& roles) = 0;
+    virtual std::unique_ptr<RGWOIDCProvider> get_oidc_provider() = 0;
+    virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
+                                  const std::string& tenant,
+                                  std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) = 0;
+    virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
+                                 optional_yield y,
+                                 std::unique_ptr<rgw::sal::Object> _head_obj,
+                                 const rgw_user& owner,
+                                 const rgw_placement_rule *ptail_placement_rule,
+                                 const std::string& unique_tag,
+                                 uint64_t position,
+                                 uint64_t *cur_accounted_size) = 0;
+    virtual std::unique_ptr<Writer> get_atomic_writer(const DoutPrefixProvider *dpp,
+                                 optional_yield y,
+                                 std::unique_ptr<rgw::sal::Object> _head_obj,
+                                 const rgw_user& owner,
+                                 const rgw_placement_rule *ptail_placement_rule,
+                                 uint64_t olh_epoch,
+                                 const std::string& unique_tag) = 0;
+
+    virtual const std::string& get_compression_type(const rgw_placement_rule& rule) = 0;
+    virtual bool valid_placement(const rgw_placement_rule& rule) = 0;
+
+    virtual void finalize(void) = 0;
+
+    virtual CephContext* ctx(void) = 0;
+
+    virtual const std::string& get_luarocks_path() const = 0;
+    virtual void set_luarocks_path(const std::string& path) = 0;
+};
+
+class FilterUser : public User {
+  public:
+    FilterUser() {}
+    virtual ~FilterUser() = default;
+
+    virtual std::unique_ptr<User> clone() = 0;
+    virtual int list_buckets(const DoutPrefixProvider* dpp,
+                            const std::string& marker, const std::string& end_marker,
+                            uint64_t max, bool need_stats, BucketList& buckets,
+                            optional_yield y) = 0;
+    virtual int create_bucket(const DoutPrefixProvider* dpp,
+                            const rgw_bucket& b,
+                            const std::string& zonegroup_id,
+                            rgw_placement_rule& placement_rule,
+                            std::string& swift_ver_location,
+                            const RGWQuotaInfo* pquota_info,
+                            const RGWAccessControlPolicy& policy,
+                           Attrs& attrs,
+                            RGWBucketInfo& info,
+                            obj_version& ep_objv,
+                           bool exclusive,
+                           bool obj_lock_enabled,
+                           bool* existed,
+                           req_info& req_info,
+                           std::unique_ptr<Bucket>* bucket,
+                           optional_yield y) = 0;
+
+    virtual std::string& get_display_name() = 0;
+    virtual const std::string& get_tenant() = 0;
+    virtual void set_tenant(std::string& _t) = 0;
+    virtual const std::string& get_ns() = 0;
+    virtual void set_ns(std::string& _ns) = 0;
+    virtual void clear_ns() = 0;
+    virtual const rgw_user& get_id() const = 0;
+    virtual uint32_t get_type() const = 0;
+    virtual int32_t get_max_buckets() const = 0;
+    virtual const RGWUserCaps& get_caps() const = 0;
+    virtual RGWObjVersionTracker& get_version_tracker() = 0;
+    virtual Attrs& get_attrs() = 0;
+    virtual void set_attrs(Attrs& _attrs) = 0;
+    virtual bool empty() = 0;
+    virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+    virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) = 0;
+    virtual int read_stats(const DoutPrefixProvider *dpp,
+                          const bucket_index_layout_generation& idx_layout,
+                          int shard_id, std::string* bucket_ver, std::string* master_ver,
+                          std::map<RGWObjCategory, RGWStorageStats>& stats,
+                          std::string* max_marker = nullptr,
+                          bool* syncstopped = nullptr) = 0;
+    virtual int read_stats_async(const DoutPrefixProvider *dpp,
+                                const bucket_index_layout_generation& idx_layout,
+                                int shard_id, RGWGetBucketStats_CB* ctx) = 0;
+    virtual int complete_flush_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+    virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch,
+                          uint64_t end_epoch, uint32_t max_entries,
+                          bool* is_truncated, RGWUsageIter& usage_iter,
+                          std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+    virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+
+    virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+    virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) = 0;
+    virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+
+    RGWUserInfo& get_info() = 0;
+    virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterBucket : public Bucket {
+  public:
+
+    Bucket() = default;
+    virtual ~Bucket() = default;
+
+    virtual std::unique_ptr<Object> get_object(const rgw_obj_key& key) = 0;
+    virtual int list(const DoutPrefixProvider* dpp, ListParams&, int, ListResults&, optional_yield y) = 0;
+    virtual Attrs& get_attrs(void) = 0;
+    virtual int set_attrs(Attrs a) = 0;
+    virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children, bool forward_to_master, req_info* req_info, optional_yield y) = 0;
+    virtual int remove_bucket_bypass_gc(int concurrent_max, bool
+                                       keep_index_consistent,
+                                       optional_yield y, const
+                                       DoutPrefixProvider *dpp) = 0;
+    virtual RGWAccessControlPolicy& get_acl(void) = 0;
+    virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) = 0;
+
+    virtual void set_owner(rgw::sal::User* _owner) = 0;
+    virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats = false) = 0;
+    virtual int read_stats(const DoutPrefixProvider *dpp, int shard_id,
+                                std::string* bucket_ver, std::string* master_ver,
+                                std::map<RGWObjCategory, RGWStorageStats>& stats,
+                                std::string* max_marker = nullptr,
+                                bool* syncstopped = nullptr) = 0;
+    virtual int read_stats_async(const DoutPrefixProvider *dpp, int shard_id, RGWGetBucketStats_CB* ctx) = 0;
+    virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+    virtual int update_container_stats(const DoutPrefixProvider* dpp) = 0;
+    virtual int check_bucket_shards(const DoutPrefixProvider* dpp) = 0;
+    virtual int chown(const DoutPrefixProvider* dpp, User* new_user, User* old_user, optional_yield y, const std::string* marker = nullptr) = 0;
+    virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) = 0;
+    virtual bool is_owner(User* user) = 0;
+    virtual User* get_owner(void) = 0;
+    virtual ACLOwner get_acl_owner(void) = 0;
+    virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuota& quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0;
+    virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) = 0;
+    virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) = 0;
+    virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
+                          bool* is_truncated, RGWUsageIter& usage_iter,
+                          std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+    virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+    virtual int remove_objs_from_index(const DoutPrefixProvider *dpp, std::list<rgw_obj_index_key>& objs_to_unlink) = 0;
+    virtual int check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) = 0;
+    virtual int rebuild_index(const DoutPrefixProvider *dpp) = 0;
+    virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) = 0;
+    virtual int purge_instance(const DoutPrefixProvider* dpp) = 0;
+    virtual bool empty() const = 0;
+    virtual const std::string& get_name() const = 0;
+    virtual const std::string& get_tenant() const = 0;
+    virtual const std::string& get_marker() const = 0;
+    virtual const std::string& get_bucket_id() const = 0;
+    virtual size_t get_size() const = 0;
+    virtual size_t get_size_rounded() const = 0;
+    virtual uint64_t get_count() const = 0;
+    virtual rgw_placement_rule& get_placement_rule() = 0;
+    virtual ceph::real_time& get_creation_time() = 0;
+    virtual ceph::real_time& get_modification_time() = 0;
+    virtual obj_version& get_version() = 0;
+    virtual void set_version(obj_version &ver) = 0;
+    virtual bool versioned() = 0;
+    virtual bool versioning_enabled() = 0;
+
+    virtual std::unique_ptr<Bucket> clone() = 0;
+
+    virtual std::unique_ptr<MultipartUpload> get_multipart_upload(
+                               const std::string& oid,
+                               std::optional<std::string> upload_id=std::nullopt,
+                               ACLOwner owner={}, ceph::real_time mtime=real_clock::now()) = 0;
+    virtual int list_multiparts(const DoutPrefixProvider *dpp,
+                               const std::string& prefix,
+                               std::string& marker,
+                               const std::string& delim,
+                               const int& max_uploads,
+                               std::vector<std::unique_ptr<MultipartUpload>>& uploads,
+                               std::map<std::string, bool> *common_prefixes,
+                               bool *is_truncated) = 0;
+    virtual int abort_multiparts(const DoutPrefixProvider* dpp,
+                                CephContext* cct) = 0;
+
+    virtual rgw_bucket& get_key() = 0;
+    virtual RGWBucketInfo& get_info() = 0;
+
+    virtual void print(std::ostream& out) const = 0;
+
+    virtual bool operator==(const Bucket& b) const = 0;
+    virtual bool operator!=(const Bucket& b) const = 0;
+
+    friend class BucketList;
+};
+
+class FilterObject : public Object {
+  public:
+
+    struct FilterOp : ReadOp {
+      virtual ~FilterOp() = default;
+
+      virtual int prepare(optional_yield y, const DoutPrefixProvider* dpp) = 0;
+      virtual int read(int64_t ofs, int64_t end, bufferlist& bl, optional_yield y, const DoutPrefixProvider* dpp) = 0;
+      virtual int iterate(const DoutPrefixProvider* dpp, int64_t ofs, int64_t end, RGWGetDataCB* cb, optional_yield y) = 0;
+      virtual int get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) = 0;
+    };
+
+    struct FilterOp : DeleteOp {
+      virtual ~FilterOp() = default;
+
+      virtual int delete_obj(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+    };
+
+    FilterObject() {}
+    virtual ~FilterObject() = default;
+
+    virtual int delete_object(const DoutPrefixProvider* dpp,
+                             optional_yield y,
+                             bool prevent_versioning = false) = 0;
+    virtual int delete_obj_aio(const DoutPrefixProvider* dpp, RGWObjState* astate, Completions* aio,
+                              bool keep_index_consistent, optional_yield y) = 0;
+    virtual int copy_object(User* user,
+               req_info* info, const rgw_zone_id& source_zone,
+               rgw::sal::Object* dest_object, rgw::sal::Bucket* dest_bucket,
+               rgw::sal::Bucket* src_bucket,
+               const rgw_placement_rule& dest_placement,
+               ceph::real_time* src_mtime, ceph::real_time* mtime,
+               const ceph::real_time* mod_ptr, const ceph::real_time* unmod_ptr,
+               bool high_precision_time,
+               const char* if_match, const char* if_nomatch,
+               AttrsMod attrs_mod, bool copy_if_newer, Attrs& attrs,
+               RGWObjCategory category, uint64_t olh_epoch,
+              boost::optional<ceph::real_time> delete_at,
+               std::string* version_id, std::string* tag, std::string* etag,
+               void (*progress_cb)(off_t, void *), void* progress_data,
+               const DoutPrefixProvider* dpp, optional_yield y) = 0;
+    virtual RGWAccessControlPolicy& get_acl(void) = 0;
+    virtual int set_acl(const RGWAccessControlPolicy& acl) = 0;
+    virtual void set_atomic() = 0;
+    virtual bool is_atomic() = 0;
+    virtual void set_prefetch_data() = 0;
+    virtual bool is_prefetch_data() = 0;
+    virtual void set_compressed() = 0;
+    virtual bool is_compressed() = 0;
+    virtual void invalidate() = 0;
+    virtual bool empty() const = 0;
+    virtual const std::string &get_name() const = 0;
+
+    virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) = 0;
+    virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs, Attrs* delattrs, optional_yield y) = 0;
+    virtual int get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp, rgw_obj* target_obj = NULL) = 0;
+    virtual int modify_obj_attrs(const char* attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider* dpp) = 0;
+    virtual int delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr_name, optional_yield y) = 0;
+    virtual bool is_expired() = 0;
+    virtual void gen_rand_obj_instance_name() = 0;
+    virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) = 0;
+    virtual int transition(Bucket* bucket,
+                          const rgw_placement_rule& placement_rule,
+                          const real_time& mtime,
+                          uint64_t olh_epoch,
+                          const DoutPrefixProvider* dpp,
+                          optional_yield y) = 0;
+    virtual int transition_to_cloud(Bucket* bucket,
+                          rgw::sal::PlacementTier* tier,
+                          rgw_bucket_dir_entry& o,
+                          std::set<std::string>& cloud_targets,
+                          CephContext* cct,
+                          bool update_object,
+                          const DoutPrefixProvider* dpp,
+                          optional_yield y) = 0;
+    virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) = 0;
+    virtual int dump_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f) = 0;
+
+    virtual Attrs& get_attrs(void) = 0;
+    virtual const Attrs& get_attrs(void) const = 0;
+    virtual int set_attrs(Attrs a) = 0;
+    virtual bool has_attrs(void) = 0;
+    virtual ceph::real_time get_mtime(void) const = 0;
+    virtual uint64_t get_obj_size(void) const = 0;
+    virtual Bucket* get_bucket(void) const = 0;
+    virtual void set_bucket(Bucket* b) = 0;
+    virtual std::string get_hash_source(void) = 0;
+    virtual void set_hash_source(std::string s) = 0;
+    virtual std::string get_oid(void) const = 0;
+    virtual bool get_delete_marker(void) = 0;
+    virtual bool get_in_extra_data(void) = 0;
+    virtual void set_in_extra_data(bool i) = 0;
+    int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
+    virtual void set_obj_size(uint64_t s) = 0;
+    virtual void set_name(const std::string& n) = 0;
+    virtual void set_key(const rgw_obj_key& k) = 0;
+    virtual rgw_obj get_obj(void) const = 0;
+
+    virtual int swift_versioning_restore(bool& restored,   /* out */
+                                        const DoutPrefixProvider* dpp) = 0;
+    virtual int swift_versioning_copy(const DoutPrefixProvider* dpp,
+                                     optional_yield y) = 0;
+
+    virtual std::unique_ptr<ReadOp> get_read_op() = 0;
+    virtual std::unique_ptr<DeleteOp> get_delete_op() = 0;
+
+    virtual int omap_get_vals(const DoutPrefixProvider *dpp, const std::string& marker, uint64_t count,
+                             std::map<std::string, bufferlist>* m,
+                             bool* pmore, optional_yield y) = 0;
+    virtual int omap_get_all(const DoutPrefixProvider *dpp, std::map<std::string, bufferlist>* m,
+                            optional_yield y) = 0;
+    virtual int omap_get_vals_by_keys(const DoutPrefixProvider *dpp, const std::string& oid,
+                             const std::set<std::string>& keys,
+                             Attrs* vals) = 0;
+    virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val,
+                                   bool must_exist, optional_yield y) = 0;
+
+    virtual std::unique_ptr<Object> clone() = 0;
+
+    virtual rgw_obj_key& get_key() = 0;
+    virtual void set_instance(const std::string &i) = 0;
+    virtual const std::string &get_instance() const = 0;
+    virtual bool have_instance(void) = 0;
+    virtual void clear_instance() = 0;
+
+    virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterMultipartPart : public MultipartPart {
+public:
+  FilterMultipartPart() = default;
+  virtual ~FilterMultipartPart() = default;
+
+  virtual uint32_t get_num() = 0;
+  virtual uint64_t get_size() = 0;
+  virtual const std::string& get_etag() = 0;
+  virtual ceph::real_time& get_mtime() = 0;
+};
+
+class FilterMultipartUpload : public MultipartUpload {
+public:
+  FilterMultipartUpload() = default;
+  virtual ~FilterMultipartUpload() = default;
+
+  virtual const std::string& get_meta() const = 0;
+  virtual const std::string& get_key() const = 0;
+  virtual const std::string& get_upload_id() const = 0;
+  virtual const ACLOwner& get_owner() const = 0;
+  virtual ceph::real_time& get_mtime() = 0;
+
+  virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() = 0;
+
+  virtual const jspan_context& get_trace() = 0;
+
+  virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() = 0;
+
+  virtual int init(const DoutPrefixProvider* dpp, optional_yield y, ACLOwner& owner, rgw_placement_rule& dest_placement, rgw::sal::Attrs& attrs) = 0;
+  virtual int list_parts(const DoutPrefixProvider* dpp, CephContext* cct,
+                        int num_parts, int marker,
+                        int* next_marker, bool* truncated,
+                        bool assume_unsorted = false) = 0;
+  virtual int abort(const DoutPrefixProvider* dpp, CephContext* cct) = 0;
+  virtual int complete(const DoutPrefixProvider* dpp,
+                      optional_yield y, CephContext* cct,
+                      std::map<int, std::string>& part_etags,
+                      std::list<rgw_obj_index_key>& remove_objs,
+                      uint64_t& accounted_size, bool& compressed,
+                      RGWCompressionInfo& cs_info, off_t& ofs,
+                      std::string& tag, ACLOwner& owner,
+                      uint64_t olh_epoch,
+                      rgw::sal::Object* target_obj) = 0;
+
+  virtual int get_info(const DoutPrefixProvider *dpp, optional_yield y, rgw_placement_rule** rule, rgw::sal::Attrs* attrs = nullptr) = 0;
+
+  virtual std::unique_ptr<Writer> get_writer(const DoutPrefixProvider *dpp,
+                         optional_yield y,
+                         std::unique_ptr<rgw::sal::Object> _head_obj,
+                         const rgw_user& owner,
+                         const rgw_placement_rule *ptail_placement_rule,
+                         uint64_t part_num,
+                         const std::string& part_num_str) = 0;
+  virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterMPSerializer : public MPSerializer {
+public:
+  FilterMPSerializer() = default;
+  virtual ~FilterMPSerializer() = default;
+
+  virtual void clear_locked() = 0;
+};
+
+class FilterLCSerializer : public LCSerializer {
+public:
+  FilterLCSerializer() {}
+  virtual ~FilterLCSerializer() = default;
+};
+
+class FilterLifecycle : public Lifecycle {
+public:
+  struct FilterLCHead : LCHead {
+    FilterLCHead() = default;
+    virtual ~FilterLCHead() = default;
+
+    virtual time_t& get_start_date() = 0;
+    virtual void set_start_date(time_t) = 0;
+    virtual std::string& get_marker() = 0;
+    virtual void set_marker(const std::string&) = 0;
+    virtual time_t& get_shard_rollover_date() = 0;
+    virtual void set_shard_rollover_date(time_t) = 0;
+  };
+
+  struct FilterLCEntry : LCEntry {
+    FilterLCEntry() = default;
+    virtual ~FilterLCEntry() = default;
+
+    virtual std::string& get_bucket() = 0;
+    virtual void set_bucket(const std::string&) = 0;
+    virtual std::string& get_oid() = 0;
+    virtual void set_oid(const std::string&) = 0;
+    virtual uint64_t get_start_time() = 0;
+    virtual void set_start_time(uint64_t) = 0;
+    virtual uint32_t get_status() = 0;
+    virtual void set_status(uint32_t) = 0;
+  };
+
+  FilterLifecycle() = default;
+  virtual ~FilterLifecycle() = default;
+
+  virtual std::unique_ptr<LCEntry> get_entry() = 0;
+  virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
+  virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
+  virtual int set_entry(const std::string& oid, LCEntry& entry) = 0;
+  virtual int list_entries(const std::string& oid, const std::string& marker,
+                          uint32_t max_entries,
+                          std::vector<std::unique_ptr<LCEntry>>& entries) = 0;
+  virtual int rm_entry(const std::string& oid, LCEntry& entry) = 0;
+  virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) = 0;
+  virtual int put_head(const std::string& oid, LCHead& head) = 0;
+  virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
+};
+
+class FilterNotification : public Notification {
+protected:
+  Object* obj;
+  Object* src_obj;
+  rgw::notify::EventType event_type;
+
+  public:
+    FilterNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
+      : obj(_obj), src_obj(_src_obj), event_type(_type)
+    {}
+
+    virtual ~FilterNotification() = default;
+
+    virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) = 0;
+    virtual int publish_commit(const DoutPrefixProvider* dpp, uint64_t size,
+                              const ceph::real_time& mtime, const std::string& etag, const std::string& version) = 0;
+};
+
+class FilterWriter : public Writer {
+public:
+  FilterWriter() {}
+  virtual ~FilterWriter() = default;
+
+  virtual int prepare(optional_yield y) = 0;
+  virtual int process(bufferlist&& data, uint64_t offset) = 0;
+  virtual int complete(size_t accounted_size, const std::string& etag,
+                       ceph::real_time *mtime, ceph::real_time set_mtime,
+                       std::map<std::string, bufferlist>& attrs,
+                       ceph::real_time delete_at,
+                       const char *if_match, const char *if_nomatch,
+                       const std::string *user_data,
+                       rgw_zone_set *zones_trace, bool *canceled,
+                       optional_yield y) = 0;
+};
+
+class FilterPlacementTier : public PlacementTier {
+public:
+  virtual ~FilterPlacementTier() = default;
+
+  virtual const std::string& get_tier_type() = 0;
+  virtual const std::string& get_storage_class() = 0;
+  virtual bool retain_head_object() = 0;
+};
+
+class FilterZoneGroup : public ZoneGroup {
+public:
+  virtual ~FilterZoneGroup() = default;
+  virtual const std::string& get_id() const = 0;
+  virtual const std::string& get_name() const = 0;
+  virtual int equals(const std::string& other_zonegroup) const = 0;
+  virtual const std::string& get_endpoint() const = 0;
+  virtual bool placement_target_exists(std::string& target) const = 0;
+  virtual bool is_master_zonegroup() const = 0;
+  virtual const std::string& get_api_name() const = 0;
+  virtual int get_placement_target_names(std::set<std::string>& names) const = 0;
+  virtual const std::string& get_default_placement_name() const = 0;
+  virtual int get_hostnames(std::list<std::string>& names) const = 0;
+  virtual int get_s3website_hostnames(std::list<std::string>& names) const = 0;
+  virtual int get_zone_count() const = 0;
+  virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier) = 0;
+};
+
+class FilterZone : public Zone {
+  public:
+    virtual ~FilterZone() = default;
+
+    virtual ZoneGroup& get_zonegroup() = 0;
+    virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) = 0;
+    virtual const rgw_zone_id& get_id() = 0;
+    virtual const std::string& get_name() const = 0;
+    virtual bool is_writeable() = 0;
+    virtual bool get_redirect_endpoint(std::string* endpoint) = 0;
+    virtual bool has_zonegroup_api(const std::string& api) const = 0;
+    virtual const std::string& get_current_period_id() = 0;
+    virtual const RGWAccessKey& get_system_key() = 0;
+    virtual const std::string& get_realm_name() = 0;
+    virtual const std::string& get_realm_id() = 0;
+};
+
+class FilterLuaScriptManager : public LuaScriptManager {
+public:
+  virtual ~FilterLuaScriptManager() = default;
+
+  virtual int get(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) = 0;
+  virtual int put(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, const std::string& script) = 0;
+  virtual int del(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key) = 0;
+};
+
+} } // namespace rgw::sal
index deb129624fcded90678174301b96e2e77af215ba..85d61aa2b03a0699e9a647032437bd9ae48cf638 100644 (file)
@@ -1341,7 +1341,7 @@ MotrAtomicWriter::MotrAtomicWriter(const DoutPrefixProvider *dpp,
           const rgw_placement_rule *_ptail_placement_rule,
           uint64_t _olh_epoch,
           const std::string& _unique_tag) :
-        Writer(dpp, y),
+        StoreWriter(dpp, y),
         store(_store),
               owner(_owner),
               ptail_placement_rule(_ptail_placement_rule),
index c87053903339df38c1086f1041771299a8b37112..f90eb6d9890014fd24c2a16fb5a04e796f72c935 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #pragma clang diagnostic pop
 }
 
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
 #include "rgw_rados.h"
 #include "rgw_notify.h"
 #include "rgw_oidc_provider.h"
@@ -135,10 +135,10 @@ struct MotrUserInfo {
 };
 WRITE_CLASS_ENCODER(MotrUserInfo);
 
-class MotrNotification : public Notification {
+class MotrNotification : public StoreNotification {
   public:
     MotrNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type) :
-        Notification(_obj, _src_obj, _type) {}
+        StoreNotification(_obj, _src_obj, _type) {}
     ~MotrNotification() = default;
 
     virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override { return 0;}
@@ -146,15 +146,15 @@ class MotrNotification : public Notification {
                               const ceph::real_time& mtime, const std::string& etag, const std::string& version) override { return 0; }
 };
 
-class MotrUser : public User {
+class MotrUser : public StoreUser {
   private:
     MotrStore         *store;
     struct m0_uint128  idxID = {0xe5ecb53640d4ecce, 0x6a156cd5a74aa3b8}; // MD5 of â€œmotr.rgw.users“
     struct m0_idx      idx;
 
   public:
-    MotrUser(MotrStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
-    MotrUser(MotrStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+    MotrUser(MotrStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+    MotrUser(MotrStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
     MotrUser(MotrStore *_st) : store(_st) { }
     MotrUser(MotrUser& _o) = default;
     MotrUser() {}
@@ -202,7 +202,7 @@ class MotrUser : public User {
     friend class MotrBucket;
 };
 
-class MotrBucket : public Bucket {
+class MotrBucket : public StoreBucket {
   private:
     MotrStore *store;
     RGWAccessControlPolicy acls;
@@ -249,43 +249,43 @@ class MotrBucket : public Bucket {
       }
 
     MotrBucket(MotrStore *_st, User* _u)
-      : Bucket(_u),
+      : StoreBucket(_u),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const rgw_bucket& _b)
-      : Bucket(_b),
+      : StoreBucket(_b),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const RGWBucketEnt& _e)
-      : Bucket(_e),
+      : StoreBucket(_e),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const RGWBucketInfo& _i)
-      : Bucket(_i),
+      : StoreBucket(_i),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const rgw_bucket& _b, User* _u)
-      : Bucket(_b, _u),
+      : StoreBucket(_b, _u),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const RGWBucketEnt& _e, User* _u)
-      : Bucket(_e, _u),
+      : StoreBucket(_e, _u),
       store(_st),
       acls() {
       }
 
     MotrBucket(MotrStore *_st, const RGWBucketInfo& _i, User* _u)
-      : Bucket(_i, _u),
+      : StoreBucket(_i, _u),
       store(_st),
       acls() {
       }
@@ -353,7 +353,7 @@ class MotrBucket : public Bucket {
     friend class MotrStore;
 };
 
-class MotrPlacementTier: public PlacementTier {
+class MotrPlacementTier: public StorePlacementTier {
   MotrStore* store;
   RGWZoneGroupPlacementTier tier;
 public:
@@ -366,7 +366,7 @@ public:
   RGWZoneGroupPlacementTier& get_rt() { return tier; }
 };
 
-class MotrZoneGroup : public ZoneGroup {
+class MotrZoneGroup : public StoreZoneGroup {
   MotrStore* store;
   const RGWZoneGroup group;
   std::string empty;
@@ -405,7 +405,7 @@ public:
   const RGWZoneGroup& get_group() { return group; }
 };
 
-class MotrZone : public Zone {
+class MotrZone : public StoreZone {
   protected:
     MotrStore* store;
     RGWRealm *realm{nullptr};
@@ -461,7 +461,7 @@ class MotrZone : public Zone {
     friend class MotrStore;
 };
 
-class MotrLuaScriptManager : public LuaScriptManager {
+class MotrLuaScriptManager : public StoreLuaScriptManager {
   MotrStore* store;
 
   public:
@@ -493,7 +493,7 @@ class MotrOIDCProvider : public RGWOIDCProvider {
   }
 };
 
-class MotrObject : public Object {
+class MotrObject : public StoreObject {
   private:
     MotrStore *store;
     RGWAccessControlPolicy acls;
@@ -569,9 +569,9 @@ class MotrObject : public Object {
     MotrObject() = default;
 
     MotrObject(MotrStore *_st, const rgw_obj_key& _k)
-      : Object(_k), store(_st), acls() {}
+      : StoreObject(_k), store(_st), acls() {}
     MotrObject(MotrStore *_st, const rgw_obj_key& _k, Bucket* _b)
-      : Object(_k, _b), store(_st), acls() {}
+      : StoreObject(_k, _b), store(_st), acls() {}
 
     MotrObject(MotrObject& _o) = default;
 
@@ -676,7 +676,7 @@ class MotrObject : public Object {
 
 // A placeholder locking class for multipart upload.
 // TODO: implement it using Motr object locks.
-class MPMotrSerializer : public MPSerializer {
+class MPMotrSerializer : public StoreMPSerializer {
 
   public:
     MPMotrSerializer(const DoutPrefixProvider *dpp, MotrStore* store, MotrObject* obj, const std::string& lock_name) {}
@@ -685,7 +685,7 @@ class MPMotrSerializer : public MPSerializer {
     virtual int unlock() override { return 0;}
 };
 
-class MotrAtomicWriter : public Writer {
+class MotrAtomicWriter : public StoreWriter {
   protected:
   rgw::sal::MotrStore* store;
   const rgw_user& owner;
@@ -734,7 +734,7 @@ class MotrAtomicWriter : public Writer {
   void cleanup();
 };
 
-class MotrMultipartWriter : public Writer {
+class MotrMultipartWriter : public StoreWriter {
 protected:
   rgw::sal::MotrStore* store;
 
@@ -755,7 +755,7 @@ public:
                       const rgw_user& owner,
                       const rgw_placement_rule *ptail_placement_rule,
                       uint64_t _part_num, const std::string& part_num_str) :
-                                 Writer(dpp, y), store(_store), head_obj(std::move(_head_obj)),
+                                 StoreWriter(dpp, y), store(_store), head_obj(std::move(_head_obj)),
                                  part_num(_part_num), part_num_str(part_num_str)
   {
   }
@@ -804,7 +804,7 @@ public:
 //
 //
 
-class MotrMultipartPart : public MultipartPart {
+class MotrMultipartPart : public StoreMultipartPart {
 protected:
   RGWUploadPartInfo info;
 
@@ -825,7 +825,7 @@ public:
   friend class MotrMultipartUpload;
 };
 
-class MotrMultipartUpload : public MultipartUpload {
+class MotrMultipartUpload : public StoreMultipartUpload {
   MotrStore* store;
   RGWMPObj mp_obj;
   ACLOwner owner;
@@ -836,7 +836,7 @@ class MotrMultipartUpload : public MultipartUpload {
 public:
   MotrMultipartUpload(MotrStore* _store, Bucket* _bucket, const std::string& oid,
                       std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) :
-       MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
+       StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
   virtual ~MotrMultipartUpload() = default;
 
   virtual const std::string& get_meta() const { return mp_obj.get_meta(); }
@@ -871,7 +871,7 @@ public:
   int delete_parts(const DoutPrefixProvider *dpp);
 };
 
-class MotrStore : public Store {
+class MotrStore : public StoreStore {
   private:
     std::string luarocks_path;
     MotrZone zone;
index d20f538093fd23848fd16c335cc3b9c8aa9bec30..c09d5de458b4a652ed901dbf7550b021b9aa760d 100644 (file)
@@ -2686,7 +2686,8 @@ int MPRadosSerializer::try_lock(const DoutPrefixProvider *dpp, utime_t dur, opti
 }
 
 LCRadosSerializer::LCRadosSerializer(RadosStore* store, const std::string& _oid, const std::string& lock_name, const std::string& cookie) :
-  lock(lock_name), oid(_oid)
+  StoreLCSerializer(_oid),
+  lock(lock_name)
 {
   ioctx = &store->getRados()->lc_pool_ctx;
   lock.set_cookie(cookie);
@@ -2699,45 +2700,54 @@ int LCRadosSerializer::try_lock(const DoutPrefixProvider *dpp, utime_t dur, opti
 }
 
 int RadosLifecycle::get_entry(const std::string& oid, const std::string& marker,
-                             LCEntry& entry)
+                             std::unique_ptr<LCEntry>* entry)
 {
   cls_rgw_lc_entry cls_entry;
   int ret = cls_rgw_lc_get_entry(*store->getRados()->get_lc_pool_ctx(), oid, marker, cls_entry);
+  if (ret)
+    return ret;
 
-  entry.bucket = cls_entry.bucket;
-  entry.start_time = cls_entry.start_time;
-  entry.status = cls_entry.status;
+  LCEntry* e;
+  e = new StoreLCEntry(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+  if (!e)
+    return -ENOMEM;
 
-  return ret;
+  entry->reset(e);
+  return 0;
 }
 
-int RadosLifecycle::get_next_entry(const std::string& oid, std::string& marker,
-                                  LCEntry& entry)
+int RadosLifecycle::get_next_entry(const std::string& oid, const std::string& marker,
+                                  std::unique_ptr<LCEntry>* entry)
 {
   cls_rgw_lc_entry cls_entry;
   int ret = cls_rgw_lc_get_next_entry(*store->getRados()->get_lc_pool_ctx(), oid, marker,
                                      cls_entry);
 
-  entry.bucket = cls_entry.bucket;
-  entry.start_time = cls_entry.start_time;
-  entry.status = cls_entry.status;
+  if (ret)
+    return ret;
 
-  return ret;
+  LCEntry* e;
+  e = new StoreLCEntry(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+  if (!e)
+    return -ENOMEM;
+
+  entry->reset(e);
+  return 0;
 }
 
-int RadosLifecycle::set_entry(const std::string& oid, const LCEntry& entry)
+int RadosLifecycle::set_entry(const std::string& oid, LCEntry& entry)
 {
   cls_rgw_lc_entry cls_entry;
 
-  cls_entry.bucket = entry.bucket;
-  cls_entry.start_time = entry.start_time;
-  cls_entry.status = entry.status;
+  cls_entry.bucket = entry.get_bucket();
+  cls_entry.start_time = entry.get_start_time();
+  cls_entry.status = entry.get_status();
 
   return cls_rgw_lc_set_entry(*store->getRados()->get_lc_pool_ctx(), oid, cls_entry);
 }
 
 int RadosLifecycle::list_entries(const std::string& oid, const std::string& marker,
-                                uint32_t max_entries, vector<LCEntry>& entries)
+                                uint32_t max_entries, std::vector<std::unique_ptr<LCEntry>>& entries)
 {
   entries.clear();
 
@@ -2748,43 +2758,47 @@ int RadosLifecycle::list_entries(const std::string& oid, const std::string& mark
     return ret;
 
   for (auto& entry : cls_entries) {
-    entries.push_back(LCEntry(entry.bucket, oid, entry.start_time,
-                             entry.status));
+    entries.push_back(std::make_unique<StoreLCEntry>(entry.bucket, oid,
+                               entry.start_time, entry.status));
   }
 
   return ret;
 }
 
-int RadosLifecycle::rm_entry(const std::string& oid, const LCEntry& entry)
+int RadosLifecycle::rm_entry(const std::string& oid, LCEntry& entry)
 {
   cls_rgw_lc_entry cls_entry;
 
-  cls_entry.bucket = entry.bucket;
-  cls_entry.start_time = entry.start_time;
-  cls_entry.status = entry.status;
+  cls_entry.bucket = entry.get_bucket();
+  cls_entry.start_time = entry.get_start_time();
+  cls_entry.status = entry.get_status();
 
   return cls_rgw_lc_rm_entry(*store->getRados()->get_lc_pool_ctx(), oid, cls_entry);
 }
 
-int RadosLifecycle::get_head(const std::string& oid, LCHead& head)
+int RadosLifecycle::get_head(const std::string& oid, std::unique_ptr<LCHead>* head)
 {
   cls_rgw_lc_obj_head cls_head;
   int ret = cls_rgw_lc_get_head(*store->getRados()->get_lc_pool_ctx(), oid, cls_head);
+  if (ret)
+    return ret;
 
-  head.marker = cls_head.marker;
-  head.start_date = cls_head.start_date;
-  head.shard_rollover_date = cls_head.shard_rollover_date;
+  LCHead* h;
+  h = new StoreLCHead(cls_head.start_date, cls_head.shard_rollover_date, cls_head.marker);
+  if (!h)
+    return -ENOMEM;
 
-  return ret;
+  head->reset(h);
+  return 0;
 }
 
-int RadosLifecycle::put_head(const std::string& oid, const LCHead& head)
+int RadosLifecycle::put_head(const std::string& oid, LCHead& head)
 {
   cls_rgw_lc_obj_head cls_head;
 
-  cls_head.marker = head.marker;
-  cls_head.start_date = head.start_date;
-  cls_head.shard_rollover_date = head.shard_rollover_date;
+  cls_head.marker = head.get_marker();
+  cls_head.start_date = head.get_start_date();
+  cls_head.shard_rollover_date = head.get_shard_rollover_date();
 
   return cls_rgw_lc_put_head(*store->getRados()->get_lc_pool_ctx(), oid, cls_head);
 }
index 119e09e5dd7d8c055f5ce6ee55e2f8aca6dd5dc1..388145e3078dbfcedf61398d59f7abc8ed4498d9 100644 (file)
@@ -15,7 +15,7 @@
 
 #pragma once
 
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
 #include "rgw_rados.h"
 #include "rgw_notify.h"
 #include "rgw_oidc_provider.h"
@@ -37,7 +37,7 @@ class RadosCompletions : public Completions {
     virtual int drain() override;
 };
 
-class RadosPlacementTier: public PlacementTier {
+class RadosPlacementTier: public StorePlacementTier {
   RadosStore* store;
   RGWZoneGroupPlacementTier tier;
 public:
@@ -50,7 +50,7 @@ public:
   RGWZoneGroupPlacementTier& get_rt() { return tier; }
 };
 
-class RadosZoneGroup : public ZoneGroup {
+class RadosZoneGroup : public StoreZoneGroup {
   RadosStore* store;
   const RGWZoneGroup group;
   std::string empty;
@@ -88,7 +88,7 @@ public:
   const RGWZoneGroup& get_group() const { return group; }
 };
 
-class RadosZone : public Zone {
+class RadosZone : public StoreZone {
   protected:
     RadosStore* store;
     RadosZoneGroup group;
@@ -109,7 +109,7 @@ class RadosZone : public Zone {
     virtual const std::string& get_realm_id() override;
 };
 
-class RadosStore : public Store {
+class RadosStore : public StoreStore {
   private:
     RGWRados* rados;
     RGWUserCtl* user_ctl;
@@ -255,13 +255,13 @@ class RadosStore : public Store {
     void setUserCtl(RGWUserCtl *_ctl) { user_ctl = _ctl; }
 };
 
-class RadosUser : public User {
+class RadosUser : public StoreUser {
   private:
     RadosStore* store;
 
   public:
-    RadosUser(RadosStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
-    RadosUser(RadosStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+    RadosUser(RadosStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+    RadosUser(RadosStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
     RadosUser(RadosStore *_st) : store(_st) { }
     RadosUser(RadosUser& _o) = default;
     RadosUser() {}
@@ -308,7 +308,7 @@ class RadosUser : public User {
     friend class RadosBucket;
 };
 
-class RadosObject : public Object {
+class RadosObject : public StoreObject {
   private:
     RadosStore* store;
     RGWAccessControlPolicy acls;
@@ -349,20 +349,20 @@ class RadosObject : public Object {
     RadosObject() = default;
 
     RadosObject(RadosStore *_st, const rgw_obj_key& _k)
-      : Object(_k),
+      : StoreObject(_k),
        store(_st),
         acls(),
        rados_ctx(new RGWObjectCtx(dynamic_cast<Store*>(store))),
        rados_ctx_owned(true) {
     }
     RadosObject(RadosStore *_st, const rgw_obj_key& _k, Bucket* _b)
-      : Object(_k, _b),
+      : StoreObject(_k, _b),
        store(_st),
         acls(),
        rados_ctx(new RGWObjectCtx(dynamic_cast<Store*>(store))) ,
        rados_ctx_owned(true) {
     }
-    RadosObject(RadosObject& _o) : Object(_o) {
+    RadosObject(RadosObject& _o) : StoreObject(_o) {
       store = _o.store;
       acls = _o.acls;
       manifest = _o.manifest;
@@ -395,15 +395,15 @@ class RadosObject : public Object {
     virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; }
     virtual void set_atomic() override {
       rados_ctx->set_atomic(state.obj);
-      Object::set_atomic();
+      StoreObject::set_atomic();
     }
     virtual void set_prefetch_data() override {
       rados_ctx->set_prefetch_data(state.obj);
-      Object::set_prefetch_data();
+      StoreObject::set_prefetch_data();
     }
     virtual void set_compressed() override {
       rados_ctx->set_compressed(state.obj);
-      Object::set_compressed();
+      StoreObject::set_compressed();
     }
 
     virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) override;
@@ -478,7 +478,7 @@ class RadosObject : public Object {
     int read_attrs(const DoutPrefixProvider* dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr);
 };
 
-class RadosBucket : public Bucket {
+class RadosBucket : public StoreBucket {
   private:
     RadosStore* store;
     RGWAccessControlPolicy acls;
@@ -490,43 +490,43 @@ class RadosBucket : public Bucket {
     }
 
     RadosBucket(RadosStore *_st, User* _u)
-      : Bucket(_u),
+      : StoreBucket(_u),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const rgw_bucket& _b)
-      : Bucket(_b),
+      : StoreBucket(_b),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const RGWBucketEnt& _e)
-      : Bucket(_e),
+      : StoreBucket(_e),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const RGWBucketInfo& _i)
-      : Bucket(_i),
+      : StoreBucket(_i),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const rgw_bucket& _b, User* _u)
-      : Bucket(_b, _u),
+      : StoreBucket(_b, _u),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const RGWBucketEnt& _e, User* _u)
-      : Bucket(_e, _u),
+      : StoreBucket(_e, _u),
        store(_st),
         acls() {
     }
 
     RadosBucket(RadosStore *_st, const RGWBucketInfo& _i, User* _u)
-      : Bucket(_i, _u),
+      : StoreBucket(_i, _u),
        store(_st),
         acls() {
     }
@@ -594,7 +594,7 @@ class RadosBucket : public Bucket {
     friend class RadosUser;
 };
 
-class RadosMultipartPart : public MultipartPart {
+class RadosMultipartPart : public StoreMultipartPart {
 protected:
   RGWUploadPartInfo info;
 
@@ -613,7 +613,7 @@ public:
   friend class RadosMultipartUpload;
 };
 
-class RadosMultipartUpload : public MultipartUpload {
+class RadosMultipartUpload : public StoreMultipartUpload {
   RadosStore* store;
   RGWMPObj mp_obj;
   ACLOwner owner;
@@ -625,7 +625,7 @@ public:
   RadosMultipartUpload(RadosStore* _store, Bucket* _bucket, const std::string& oid,
                        std::optional<std::string> upload_id, ACLOwner owner,
                        ceph::real_time _mtime)
-      : MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id),
+      : StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id),
         owner(owner), mtime(_mtime) {}
   virtual ~RadosMultipartUpload() = default;
 
@@ -660,7 +660,7 @@ public:
                          const std::string& part_num_str) override;
 };
 
-class MPRadosSerializer : public MPSerializer {
+class MPRadosSerializer : public StoreMPSerializer {
   librados::IoCtx ioctx;
   rados::cls::lock::Lock lock;
   librados::ObjectWriteOperation op;
@@ -674,10 +674,9 @@ public:
   }
 };
 
-class LCRadosSerializer : public LCSerializer {
+class LCRadosSerializer : public StoreLCSerializer {
   librados::IoCtx* ioctx;
   rados::cls::lock::Lock lock;
-  const std::string oid;
 
 public:
   LCRadosSerializer(RadosStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie);
@@ -688,24 +687,26 @@ public:
   }
 };
 
-class RadosLifecycle : public Lifecycle {
+class RadosLifecycle : public StoreLifecycle {
   RadosStore* store;
 
 public:
   RadosLifecycle(RadosStore* _st) : store(_st) {}
 
-  virtual int get_entry(const std::string& oid, const std::string& marker, LCEntry& entry) override;
-  virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) override;
-  virtual int set_entry(const std::string& oid, const LCEntry& entry) override;
+  using StoreLifecycle::get_entry;
+  virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+  virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+  virtual int set_entry(const std::string& oid, LCEntry& entry) override;
   virtual int list_entries(const std::string& oid, const std::string& marker,
-                          uint32_t max_entries, std::vector<LCEntry>& entries) override;
-  virtual int rm_entry(const std::string& oid, const LCEntry& entry) override;
-  virtual int get_head(const std::string& oid, LCHead& head) override;
-  virtual int put_head(const std::string& oid, const LCHead& head) override;
+                          uint32_t max_entries,
+                          std::vector<std::unique_ptr<LCEntry>>& entries) override;
+  virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
+  virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
+  virtual int put_head(const std::string& oid, LCHead& head) override;
   virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
 };
 
-class RadosNotification : public Notification {
+class RadosNotification : public StoreNotification {
   RadosStore* store;
   /* XXX it feels incorrect to me that rgw::notify::reservation_t is
    * currently RADOS-specific; instead, I think notification types such as
@@ -716,10 +717,10 @@ class RadosNotification : public Notification {
 
   public:
     RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, req_state* _s, rgw::notify::EventType _type, const std::string* object_name=nullptr) :
-      Notification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _s, _obj, _src_obj, object_name) { }
+      StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _s, _obj, _src_obj, object_name) { }
 
     RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, rgw::notify::EventType _type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant, std::string& _req_id, optional_yield y) :
-      Notification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _obj, _src_obj, _bucket, _user_id, _user_tenant, _req_id, y) {}
+      StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _obj, _src_obj, _bucket, _user_id, _user_tenant, _req_id, y) {}
 
     ~RadosNotification() = default;
 
@@ -732,7 +733,7 @@ class RadosNotification : public Notification {
                               const ceph::real_time& mtime, const std::string& etag, const std::string& version) override;
 };
 
-class RadosAtomicWriter : public Writer {
+class RadosAtomicWriter : public StoreWriter {
 protected:
   rgw::sal::RadosStore* store;
   std::unique_ptr<Aio> aio;
@@ -748,7 +749,7 @@ public:
                    const rgw_placement_rule *ptail_placement_rule,
                    uint64_t olh_epoch,
                    const std::string& unique_tag) :
-                       Writer(dpp, y),
+                       StoreWriter(dpp, y),
                        store(_store),
                        aio(std::move(_aio)),
                        obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
@@ -777,7 +778,7 @@ public:
                        optional_yield y) override;
 };
 
-class RadosAppendWriter : public Writer {
+class RadosAppendWriter : public StoreWriter {
 protected:
   rgw::sal::RadosStore* store;
   std::unique_ptr<Aio> aio;
@@ -794,7 +795,7 @@ public:
                    const std::string& unique_tag,
                    uint64_t position,
                    uint64_t *cur_accounted_size) :
-                       Writer(dpp, y),
+                       StoreWriter(dpp, y),
                        store(_store),
                        aio(std::move(_aio)),
                        obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
@@ -823,7 +824,7 @@ public:
                        optional_yield y) override;
 };
 
-class RadosMultipartWriter : public Writer {
+class RadosMultipartWriter : public StoreWriter {
 protected:
   rgw::sal::RadosStore* store;
   std::unique_ptr<Aio> aio;
@@ -838,7 +839,7 @@ public:
                       const rgw_user& owner,
                       const rgw_placement_rule *ptail_placement_rule,
                       uint64_t part_num, const std::string& part_num_str) :
-                       Writer(dpp, y),
+                       StoreWriter(dpp, y),
                        store(_store),
                        aio(std::move(_aio)),
                        obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
@@ -867,7 +868,7 @@ public:
                        optional_yield y) override;
 };
 
-class RadosLuaScriptManager : public LuaScriptManager {
+class RadosLuaScriptManager : public StoreLuaScriptManager {
   RadosStore* store;
   rgw_pool pool;
 
diff --git a/src/rgw/rgw_sal_store.h b/src/rgw/rgw_sal_store.h
new file mode 100644 (file)
index 0000000..0390922
--- /dev/null
@@ -0,0 +1,412 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2022 Red Hat, Inc.
+ *
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include "rgw_sal.h"
+
+namespace rgw { namespace sal {
+
+class StoreStore : public Store {
+  public:
+    StoreStore() {}
+    virtual ~StoreStore() = default;
+
+    virtual uint64_t get_new_req_id() override {
+      return ceph::util::generate_random_number<uint64_t>();
+    }
+};
+
+class StoreUser : public User {
+  protected:
+    RGWUserInfo info;
+    RGWObjVersionTracker objv_tracker;
+    Attrs attrs;
+
+  public:
+    StoreUser() : info() {}
+    StoreUser(const rgw_user& _u) : info() { info.user_id = _u; }
+    StoreUser(const RGWUserInfo& _i) : info(_i) {}
+    StoreUser(StoreUser& _o) = default;
+    virtual ~StoreUser() = default;
+
+    virtual std::string& get_display_name() override { return info.display_name; }
+    virtual const std::string& get_tenant() override { return info.user_id.tenant; }
+    virtual void set_tenant(std::string& _t) override { info.user_id.tenant = _t; }
+    virtual const std::string& get_ns() override { return info.user_id.ns; }
+    virtual void set_ns(std::string& _ns) override { info.user_id.ns = _ns; }
+    virtual void clear_ns() override { info.user_id.ns.clear(); }
+    virtual const rgw_user& get_id() const override { return info.user_id; }
+    virtual uint32_t get_type() const override { return info.type; }
+    virtual int32_t get_max_buckets() const override { return info.max_buckets; }
+    virtual const RGWUserCaps& get_caps() const override { return info.caps; }
+    virtual RGWObjVersionTracker& get_version_tracker() override { return objv_tracker; }
+    virtual Attrs& get_attrs() override { return attrs; }
+    virtual void set_attrs(Attrs& _attrs) override { attrs = _attrs; }
+    virtual bool empty() override { return info.user_id.id.empty(); }
+    virtual RGWUserInfo& get_info() override { return info; }
+    virtual void print(std::ostream& out) const override { out << info.user_id; }
+
+    friend class StoreBucket;
+};
+
+class StoreBucket : public Bucket {
+  protected:
+    RGWBucketEnt ent;
+    RGWBucketInfo info;
+    User* owner = nullptr;
+    Attrs attrs;
+    obj_version bucket_version;
+    ceph::real_time mtime;
+
+  public:
+
+    StoreBucket() = default;
+    StoreBucket(User* _u) :
+      owner(_u) { }
+    StoreBucket(const rgw_bucket& _b) { ent.bucket = _b; info.bucket = _b; }
+    StoreBucket(const RGWBucketEnt& _e) : ent(_e) {
+      info.bucket = ent.bucket;
+      info.placement_rule = ent.placement_rule;
+      info.creation_time = ent.creation_time;
+    }
+    StoreBucket(const RGWBucketInfo& _i) : info(_i) {
+      ent.bucket = info.bucket;
+      ent.placement_rule = info.placement_rule;
+      ent.creation_time = info.creation_time;
+    }
+    StoreBucket(const rgw_bucket& _b, User* _u) :
+      owner(_u) { ent.bucket = _b; info.bucket = _b; }
+    StoreBucket(const RGWBucketEnt& _e, User* _u) : ent(_e), owner(_u) {
+      info.bucket = ent.bucket;
+      info.placement_rule = ent.placement_rule;
+      info.creation_time = ent.creation_time;
+    }
+    StoreBucket(const RGWBucketInfo& _i, User* _u) : info(_i), owner(_u) {
+      ent.bucket = info.bucket;
+      ent.placement_rule = info.placement_rule;
+      ent.creation_time = info.creation_time;
+    }
+    virtual ~StoreBucket() = default;
+
+    virtual Attrs& get_attrs(void) override { return attrs; }
+    virtual int set_attrs(Attrs a) override { attrs = a; return 0; }
+    virtual void set_owner(rgw::sal::User* _owner) override {
+      owner = _owner;
+    }
+    virtual User* get_owner(void) override { return owner; };
+    virtual ACLOwner get_acl_owner(void) override { return ACLOwner(info.owner); };
+    virtual bool empty() const override { return info.bucket.name.empty(); }
+    virtual const std::string& get_name() const override { return info.bucket.name; }
+    virtual const std::string& get_tenant() const override { return info.bucket.tenant; }
+    virtual const std::string& get_marker() const override { return info.bucket.marker; }
+    virtual const std::string& get_bucket_id() const override { return info.bucket.bucket_id; }
+    virtual size_t get_size() const override { return ent.size; }
+    virtual size_t get_size_rounded() const override { return ent.size_rounded; }
+    virtual uint64_t get_count() const override { return ent.count; }
+    virtual rgw_placement_rule& get_placement_rule() override { return info.placement_rule; }
+    virtual ceph::real_time& get_creation_time() override { return info.creation_time; }
+    virtual ceph::real_time& get_modification_time() override { return mtime; }
+    virtual obj_version& get_version() override { return bucket_version; }
+    virtual void set_version(obj_version &ver) override { bucket_version = ver; }
+    virtual bool versioned() override { return info.versioned(); }
+    virtual bool versioning_enabled() override { return info.versioning_enabled(); }
+    virtual rgw_bucket& get_key() override { return info.bucket; }
+    virtual RGWBucketInfo& get_info() override { return info; }
+    virtual void print(std::ostream& out) const override { out << info.bucket; }
+    virtual bool operator==(const Bucket& b) const override {
+      if (typeid(*this) != typeid(b)) {
+       return false;
+      }
+      const StoreBucket& sb = dynamic_cast<const StoreBucket&>(b);
+
+      return (info.bucket.tenant == sb.info.bucket.tenant) &&
+            (info.bucket.name == sb.info.bucket.name) &&
+            (info.bucket.bucket_id == sb.info.bucket.bucket_id);
+    }
+    virtual bool operator!=(const Bucket& b) const override {
+      if (typeid(*this) != typeid(b)) {
+       return false;
+      }
+      const StoreBucket& sb = dynamic_cast<const StoreBucket&>(b);
+
+      return (info.bucket.tenant != sb.info.bucket.tenant) ||
+            (info.bucket.name != sb.info.bucket.name) ||
+            (info.bucket.bucket_id != sb.info.bucket.bucket_id);
+    }
+
+    friend class BucketList;
+  protected:
+    virtual void set_ent(RGWBucketEnt& _ent) { ent = _ent; info.bucket = ent.bucket; info.placement_rule = ent.placement_rule; }
+};
+
+class StoreObject : public Object {
+  protected:
+    RGWObjState state;
+    Bucket* bucket;
+    Attrs attrs;
+    bool delete_marker{false};
+
+  public:
+
+    struct StoreReadOp : ReadOp {
+      virtual ~StoreReadOp() = default;
+    };
+
+    struct StoreDeleteOp : DeleteOp {
+      virtual ~StoreDeleteOp() = default;
+    };
+
+    StoreObject()
+      : state(),
+      bucket(nullptr),
+      attrs()
+      {}
+    StoreObject(const rgw_obj_key& _k)
+      : state(),
+      bucket(),
+      attrs()
+      { state.obj.key = _k; }
+    StoreObject(const rgw_obj_key& _k, Bucket* _b)
+      : state(),
+      bucket(_b),
+      attrs()
+      { state.obj.init(_b->get_key(), _k); }
+    StoreObject(StoreObject& _o) = default;
+
+    virtual ~StoreObject() = default;
+
+    virtual void set_atomic() override { state.is_atomic = true; }
+    virtual bool is_atomic() override { return state.is_atomic; }
+    virtual void set_prefetch_data() override { state.prefetch_data = true; }
+    virtual bool is_prefetch_data() override { return state.prefetch_data; }
+    virtual void set_compressed() override { state.compressed = true; }
+    virtual bool is_compressed() override { return state.compressed; }
+    virtual void invalidate() override {
+      rgw_obj obj = state.obj;
+      bool is_atomic = state.is_atomic;
+      bool prefetch_data = state.prefetch_data;
+      bool compressed = state.compressed;
+
+      state = RGWObjState();
+      state.obj = obj;
+      state.is_atomic = is_atomic;
+      state.prefetch_data = prefetch_data;
+      state.compressed = compressed;
+    }
+
+    virtual bool empty() const override { return state.obj.empty(); }
+    virtual const std::string &get_name() const override { return state.obj.key.name; }
+    virtual Attrs& get_attrs(void) override { return state.attrset; }
+    virtual const Attrs& get_attrs(void) const override { return state.attrset; }
+    virtual int set_attrs(Attrs a) override { state.attrset = a; state.has_attrs = true; return 0; }
+    virtual bool has_attrs(void) override { return state.has_attrs; }
+    virtual ceph::real_time get_mtime(void) const override { return state.mtime; }
+    virtual uint64_t get_obj_size(void) const override { return state.size; }
+    virtual Bucket* get_bucket(void) const override { return bucket; }
+    virtual void set_bucket(Bucket* b) override { bucket = b; state.obj.bucket = b->get_key(); }
+    virtual std::string get_hash_source(void) override { return state.obj.index_hash_source; }
+    virtual void set_hash_source(std::string s) override { state.obj.index_hash_source = s; }
+    virtual std::string get_oid(void) const override { return state.obj.key.get_oid(); }
+    virtual bool get_delete_marker(void) override { return delete_marker; }
+    virtual bool get_in_extra_data(void) override { return state.obj.is_in_extra_data(); }
+    virtual void set_in_extra_data(bool i) override { state.obj.set_in_extra_data(i); }
+    int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
+    virtual void set_obj_size(uint64_t s) override { state.size = s; }
+    virtual void set_name(const std::string& n) override { state.obj.key = n; }
+    virtual void set_key(const rgw_obj_key& k) override { state.obj.key = k; }
+    virtual rgw_obj get_obj(void) const override { return state.obj; }
+    virtual rgw_obj_key& get_key() override { return state.obj.key; }
+    virtual void set_instance(const std::string &i) override { state.obj.key.set_instance(i); }
+    virtual const std::string &get_instance() const override { return state.obj.key.instance; }
+    virtual bool have_instance(void) override { return state.obj.key.have_instance(); }
+    virtual void clear_instance() override { state.obj.key.instance.clear(); }
+
+    virtual void print(std::ostream& out) const override {
+      if (bucket)
+       out << bucket << ":";
+      out << state.obj.key;
+    }
+};
+
+class StoreMultipartPart : public MultipartPart {
+  protected:
+    std::string oid;
+public:
+  StoreMultipartPart() = default;
+  virtual ~StoreMultipartPart() = default;
+};
+
+class StoreMultipartUpload : public MultipartUpload {
+protected:
+  Bucket* bucket;
+  std::map<uint32_t, std::unique_ptr<MultipartPart>> parts;
+  jspan_context trace_ctx{false, false};
+public:
+  StoreMultipartUpload(Bucket* _bucket) : bucket(_bucket) {}
+  virtual ~StoreMultipartUpload() = default;
+
+  virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() override { return parts; }
+
+  virtual const jspan_context& get_trace() override { return trace_ctx; }
+
+  virtual void print(std::ostream& out) const override {
+    out << get_meta();
+    if (!get_upload_id().empty())
+      out << ":" << get_upload_id();
+  }
+};
+
+class StoreMPSerializer : public MPSerializer {
+protected:
+  bool locked;
+  std::string oid;
+public:
+  StoreMPSerializer() : locked(false) {}
+  StoreMPSerializer(std::string _oid) : locked(false), oid(_oid) {}
+  virtual ~StoreMPSerializer() = default;
+
+  virtual void clear_locked() override {
+    locked = false;
+  }
+  virtual bool is_locked() override { return locked; }
+
+  virtual void print(std::ostream& out) const override { out << oid; }
+};
+
+class StoreLCSerializer : public LCSerializer {
+protected:
+  std::string oid;
+public:
+  StoreLCSerializer() {}
+  StoreLCSerializer(std::string _oid) : oid(_oid) {}
+  virtual ~StoreLCSerializer() = default;
+
+  virtual void print(std::ostream& out) const override { out << oid; }
+};
+
+class StoreLifecycle : public Lifecycle {
+public:
+  struct StoreLCHead : LCHead {
+    time_t start_date{0};
+    time_t shard_rollover_date{0};
+    std::string marker;
+
+    StoreLCHead() = default;
+    StoreLCHead(time_t _start_date, time_t _rollover_date, std::string& _marker) : start_date(_start_date), shard_rollover_date(_rollover_date), marker(_marker) {}
+
+    StoreLCHead& operator=(LCHead& _h) {
+      start_date = _h.get_start_date();
+      shard_rollover_date = _h.get_shard_rollover_date();
+      marker = _h.get_marker();
+
+      return *this;
+    }
+
+    virtual time_t& get_start_date() override { return start_date; }
+    virtual void set_start_date(time_t _date) override { start_date = _date; }
+    virtual std::string& get_marker() override { return marker; }
+    virtual void set_marker(const std::string& _marker) override { marker = _marker; }
+    virtual time_t& get_shard_rollover_date() override { return shard_rollover_date; }
+    virtual void set_shard_rollover_date(time_t _date) override { shard_rollover_date = _date; }
+  };
+
+  struct StoreLCEntry : LCEntry {
+    std::string bucket;
+    std::string oid;
+    uint64_t start_time{0};
+    uint32_t status{0};
+
+    StoreLCEntry() = default;
+    StoreLCEntry(std::string& _bucket, uint64_t _time, uint32_t _status) : bucket(_bucket), start_time(_time), status(_status) {}
+    StoreLCEntry(std::string& _bucket, std::string _oid, uint64_t _time, uint32_t _status) : bucket(_bucket), oid(_oid), start_time(_time), status(_status) {}
+    StoreLCEntry(const StoreLCEntry& _e) = default;
+
+    StoreLCEntry& operator=(LCEntry& _e) {
+      bucket = _e.get_bucket();
+      oid = _e.get_oid();
+      start_time = _e.get_start_time();
+      status = _e.get_status();
+
+      return *this;
+    }
+
+    virtual std::string& get_bucket() override { return bucket; }
+    virtual void set_bucket(const std::string& _bucket) override { bucket = _bucket; }
+    virtual std::string& get_oid() override { return oid; }
+    virtual void set_oid(const std::string& _oid) override { oid = _oid; }
+    virtual uint64_t get_start_time() override { return start_time; }
+    virtual void set_start_time(uint64_t _time) override { start_time = _time; }
+    virtual uint32_t get_status() override { return status; }
+    virtual void set_status(uint32_t _status) override { status = _status; }
+    virtual void print(std::ostream& out) const override {
+      out << bucket << ":" << oid << ":" << start_time << ":" << status;
+    }
+  };
+
+  StoreLifecycle() = default;
+  virtual ~StoreLifecycle() = default;
+
+  virtual std::unique_ptr<LCEntry> get_entry() override {
+      return std::make_unique<StoreLCEntry>();
+  }
+  using Lifecycle::get_entry;
+};
+
+class StoreNotification : public Notification {
+protected:
+  Object* obj;
+  Object* src_obj;
+  rgw::notify::EventType event_type;
+
+  public:
+    StoreNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
+      : obj(_obj), src_obj(_src_obj), event_type(_type)
+    {}
+
+    virtual ~StoreNotification() = default;
+};
+
+class StoreWriter : public Writer {
+protected:
+  const DoutPrefixProvider* dpp;
+
+public:
+  StoreWriter(const DoutPrefixProvider *_dpp, optional_yield y) : dpp(_dpp) {}
+  virtual ~StoreWriter() = default;
+
+};
+
+class StorePlacementTier : public PlacementTier {
+public:
+  virtual ~StorePlacementTier() = default;
+};
+
+class StoreZoneGroup : public ZoneGroup {
+public:
+  virtual ~StoreZoneGroup() = default;
+};
+
+class StoreZone : public Zone {
+  public:
+    virtual ~StoreZone() = default;
+};
+
+class StoreLuaScriptManager : public LuaScriptManager {
+public:
+  virtual ~StoreLuaScriptManager() = default;
+};
+
+} } // namespace rgw::sal
index 2cd9709250841c42407d3f2e18eae907485df4aa..ecd8b5a9e874d1a33351376ab77e5be886b259d4 100644 (file)
@@ -1835,7 +1835,7 @@ int DB::Object::Delete::delete_obj(const DoutPrefixProvider *dpp) {
 }
 
 int DB::get_entry(const std::string& oid, const std::string& marker,
-                             rgw::sal::Lifecycle::LCEntry& entry)
+                             std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1844,7 +1844,7 @@ int DB::get_entry(const std::string& oid, const std::string& marker,
   InitializeParams(dpp, &params);
 
   params.op.lc_entry.index = oid;
-  params.op.lc_entry.entry.bucket = marker;
+  params.op.lc_entry.entry.set_bucket(marker);
 
   params.op.query_str = "get_entry";
   ret = ProcessOp(dpp, "GetLCEntry", &params);
@@ -1854,16 +1854,22 @@ int DB::get_entry(const std::string& oid, const std::string& marker,
     goto out;
   }
 
-  if (!params.op.lc_entry.entry.start_time == 0) { //ensure entry found
-    entry = params.op.lc_entry.entry;
+  if (!params.op.lc_entry.entry.get_start_time() == 0) { //ensure entry found
+    rgw::sal::Lifecycle::LCEntry* e;
+    e = new rgw::sal::StoreLifecycle::StoreLCEntry(params.op.lc_entry.entry);
+    if (!e) {
+      ret = -ENOMEM;
+      goto out;
+    }
+    entry->reset(e);
   }
 
 out:
   return ret;
 }
 
-int DB::get_next_entry(const std::string& oid, std::string& marker,
-                                  rgw::sal::Lifecycle::LCEntry& entry)
+int DB::get_next_entry(const std::string& oid, const std::string& marker,
+                             std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1872,7 +1878,7 @@ int DB::get_next_entry(const std::string& oid, std::string& marker,
   InitializeParams(dpp, &params);
 
   params.op.lc_entry.index = oid;
-  params.op.lc_entry.entry.bucket = marker;
+  params.op.lc_entry.entry.set_bucket(marker);
 
   params.op.query_str = "get_next_entry";
   ret = ProcessOp(dpp, "GetLCEntry", &params);
@@ -1882,15 +1888,21 @@ int DB::get_next_entry(const std::string& oid, std::string& marker,
     goto out;
   }
 
-  if (!params.op.lc_entry.entry.start_time == 0) { //ensure entry found
-    entry = params.op.lc_entry.entry;
+  if (!params.op.lc_entry.entry.get_start_time() == 0) { //ensure entry found
+    rgw::sal::Lifecycle::LCEntry* e;
+    e = new rgw::sal::StoreLifecycle::StoreLCEntry(params.op.lc_entry.entry);
+    if (!e) {
+      ret = -ENOMEM;
+      goto out;
+    }
+    entry->reset(e);
   }
 
 out:
   return ret;
 }
 
-int DB::set_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry)
+int DB::set_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1913,7 +1925,7 @@ out:
 }
 
 int DB::list_entries(const std::string& oid, const std::string& marker,
-                                uint32_t max_entries, vector<rgw::sal::Lifecycle::LCEntry>& entries)
+                                uint32_t max_entries, std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& entries)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1935,14 +1947,14 @@ int DB::list_entries(const std::string& oid, const std::string& marker,
   }
 
   for (auto& entry : params.op.lc_entry.list_entries) {
-    entries.push_back(std::move(entry));
+    entries.push_back(std::make_unique<rgw::sal::StoreLifecycle::StoreLCEntry>(std::move(entry)));
   }
 
 out:
   return ret;
 }
 
-int DB::rm_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry)
+int DB::rm_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1964,7 +1976,7 @@ out:
   return ret;
 }
 
-int DB::get_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
+int DB::get_head(const std::string& oid, std::unique_ptr<rgw::sal::Lifecycle::LCHead>* head)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
@@ -1981,13 +1993,13 @@ int DB::get_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
     goto out;
   }
 
-  head = params.op.lc_head.head;
+  *head = std::make_unique<rgw::sal::StoreLifecycle::StoreLCHead>(params.op.lc_head.head);
 
 out:
   return ret;
 }
 
-int DB::put_head(const std::string& oid, const rgw::sal::Lifecycle::LCHead& head)
+int DB::put_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
 {
   int ret = 0;
   const DoutPrefixProvider *dpp = get_def_dpp();
index d35b1bc0f3dbd26288eb17bf1f8fbebdf28b8471..d105dc2ac0814a82cf1c7ea3f5310e33832ad93d 100644 (file)
@@ -17,7 +17,7 @@
 #define FMT_HEADER_ONLY 1
 #include "fmt/format.h"
 #include <map>
-#include "rgw/rgw_sal.h"
+#include "rgw/rgw_sal_store.h"
 #include "rgw/rgw_common.h"
 #include "rgw/rgw_bucket.h"
 #include "global/global_context.h"
@@ -104,15 +104,15 @@ struct DBOpObjectDataInfo {
 
 struct DBOpLCHeadInfo {
   std::string index;
-  rgw::sal::Lifecycle::LCHead head;
+  rgw::sal::StoreLifecycle::StoreLCHead head;
 };
 
 struct DBOpLCEntryInfo {
   std::string index;
-  rgw::sal::Lifecycle::LCEntry entry;
+  rgw::sal::StoreLifecycle::StoreLCEntry entry;
   // used for list query
   std::string min_marker;
-  std::list<rgw::sal::Lifecycle::LCEntry> list_entries;
+  std::list<rgw::sal::StoreLifecycle::StoreLCEntry> list_entries;
 };
 
 struct DBOpInfo {
@@ -1933,15 +1933,15 @@ class DB {
         RGWObjState *astate, void *arg);
 
     int get_entry(const std::string& oid, const std::string& marker,
-                  rgw::sal::Lifecycle::LCEntry& entry);
-    int get_next_entry(const std::string& oid, std::string& marker,
-                  rgw::sal::Lifecycle::LCEntry& entry);
-    int set_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry);
+                 std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry);
+    int get_next_entry(const std::string& oid, const std::string& marker,
+                 std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry);
+    int set_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry);
     int list_entries(const std::string& oid, const std::string& marker,
-                          uint32_t max_entries, std::vector<rgw::sal::Lifecycle::LCEntry>& entries);
-    int rm_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry);
-    int get_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head);
-    int put_head(const std::string& oid, const rgw::sal::Lifecycle::LCHead& head);
+                          uint32_t max_entries, std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& entries);
+    int rm_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry);
+    int get_head(const std::string& oid, std::unique_ptr<rgw::sal::Lifecycle::LCHead>* head);
+    int put_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head);
     int delete_stale_objs(const DoutPrefixProvider *dpp, const std::string& bucket,
                           uint32_t min_wait);
     int createGC(const DoutPrefixProvider *_dpp);
index e89ff29a8a9a0688cd4d0ea8b29474e50540d784..649c644bebfa1f34db609fb0a3ae201311c5f10f 100644 (file)
@@ -567,9 +567,9 @@ static int list_lc_entry(const DoutPrefixProvider *dpp, DBOpInfo &op, sqlite3_st
     return -1;
 
   op.lc_entry.index = (const char*)sqlite3_column_text(stmt, LCEntryIndex);
-  op.lc_entry.entry.bucket = (const char*)sqlite3_column_text(stmt, LCEntryBucketName);
-  op.lc_entry.entry.start_time = sqlite3_column_int(stmt, LCEntryStartTime);
-  op.lc_entry.entry.status = sqlite3_column_int(stmt, LCEntryStatus);
+  op.lc_entry.entry.set_bucket((const char*)sqlite3_column_text(stmt, LCEntryBucketName));
+  op.lc_entry.entry.set_start_time(sqlite3_column_int(stmt, LCEntryStartTime));
+  op.lc_entry.entry.set_status(sqlite3_column_int(stmt, LCEntryStatus));
  
   op.lc_entry.list_entries.push_back(op.lc_entry.entry);
 
@@ -581,9 +581,9 @@ static int list_lc_head(const DoutPrefixProvider *dpp, DBOpInfo &op, sqlite3_stm
     return -1;
 
   op.lc_head.index = (const char*)sqlite3_column_text(stmt, LCHeadIndex);
-  op.lc_head.head.marker = (const char*)sqlite3_column_text(stmt, LCHeadMarker);
+  op.lc_head.head.set_marker((const char*)sqlite3_column_text(stmt, LCHeadMarker));
  
-  SQL_DECODE_BLOB_PARAM(dpp, stmt, LCHeadStartDate, op.lc_head.head.start_date, sdb);
+  SQL_DECODE_BLOB_PARAM(dpp, stmt, LCHeadStartDate, op.lc_head.head.get_start_date(), sdb);
 
   return 0;
 }
@@ -2600,13 +2600,13 @@ int SQLInsertLCEntry::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *par
   SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.index.c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.bucket_name, sdb);
-  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
+  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.status, sdb);
-  SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.status, sdb);
+  SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_status(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.start_time, sdb);
-  SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.start_time, sdb);
+  SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_start_time(), sdb);
 
 out:
   return rc;
@@ -2649,7 +2649,7 @@ int SQLRemoveLCEntry::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *par
   SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.index.c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.bucket_name, sdb);
-  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
+  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
 
 out:
   return rc;
@@ -2704,7 +2704,7 @@ int SQLGetLCEntry::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *params
   SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.index.c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, *pstmt, index, p_params.op.lc_entry.bucket_name, sdb);
-  SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
+  SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
 
 out:
   return rc;
@@ -2800,10 +2800,10 @@ int SQLInsertLCHead::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *para
   SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.index.c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_head.marker, sdb);
-  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.head.marker.c_str(), sdb);
+  SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.head.get_marker().c_str(), sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_head.start_date, sdb);
-  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.lc_head.head.start_date, sdb);
+  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.lc_head.head.get_start_date(), sdb);
 
 out:
   return rc;
index 22c6144b50b03ca46cb30fcd3d75114cce541c93..f99383b62186f25238b6af999e9a882c7112b5a2 100644 (file)
@@ -1068,31 +1068,31 @@ TEST_F(DBStoreTest, LCHead) {
   std::string index1 = "bucket1";
   std::string index2 = "bucket2";
   time_t lc_time = ceph_clock_now();
-  rgw::sal::Lifecycle::LCHead head;
+  std::unique_ptr<rgw::sal::Lifecycle::LCHead> head;
   std::string ents[] = {"entry1", "entry2", "entry3"};
-  rgw::sal::Lifecycle::LCHead head1 = {lc_time, ents[0]};
-  rgw::sal::Lifecycle::LCHead head2 = {lc_time, ents[1]};
-  rgw::sal::Lifecycle::LCHead head3 = {lc_time, ents[2]};
+  rgw::sal::StoreLifecycle::StoreLCHead head1(lc_time, 0, ents[0]);
+  rgw::sal::StoreLifecycle::StoreLCHead head2(lc_time, 0, ents[1]);
+  rgw::sal::StoreLifecycle::StoreLCHead head3(lc_time, 0, ents[2]);
 
   ret = db->put_head(index1, head1);
   ASSERT_EQ(ret, 0);
   ret = db->put_head(index2, head2);
   ASSERT_EQ(ret, 0);
 
-  ret = db->get_head(index1, head);
+  ret = db->get_head(index1, &head);
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(head.marker, "entry1");
+  ASSERT_EQ(head->get_marker(), "entry1");
 
-  ret = db->get_head(index2, head);
+  ret = db->get_head(index2, &head);
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(head.marker, "entry2");
+  ASSERT_EQ(head->get_marker(), "entry2");
 
   // update index1
   ret = db->put_head(index1, head3);
   ASSERT_EQ(ret, 0);
-  ret = db->get_head(index1, head);
+  ret = db->get_head(index1, &head);
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(head.marker, "entry3");
+  ASSERT_EQ(head->get_marker(), "entry3");
 
 }
 TEST_F(DBStoreTest, LCEntry) {
@@ -1103,13 +1103,13 @@ TEST_F(DBStoreTest, LCEntry) {
   std::string index2 = "lcindex2";
   typedef enum {lc_uninitial = 1, lc_complete} status;
   std::string ents[] = {"bucket1", "bucket2", "bucket3", "bucket4"};
-  rgw::sal::Lifecycle::LCEntry entry;
-  rgw::sal::Lifecycle::LCEntry entry1 = {ents[0], lc_time, lc_uninitial};
-  rgw::sal::Lifecycle::LCEntry entry2 = {ents[1], lc_time, lc_uninitial};
-  rgw::sal::Lifecycle::LCEntry entry3 = {ents[2], lc_time, lc_uninitial};
-  rgw::sal::Lifecycle::LCEntry entry4 = {ents[3], lc_time, lc_uninitial};
+  std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
+  rgw::sal::StoreLifecycle::StoreLCEntry entry1(ents[0], lc_time, lc_uninitial);
+  rgw::sal::StoreLifecycle::StoreLCEntry entry2(ents[1], lc_time, lc_uninitial);
+  rgw::sal::StoreLifecycle::StoreLCEntry entry3(ents[2], lc_time, lc_uninitial);
+  rgw::sal::StoreLifecycle::StoreLCEntry entry4(ents[3], lc_time, lc_uninitial);
 
-  vector<rgw::sal::Lifecycle::LCEntry> lc_entries;
+  vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> lc_entries;
 
   ret = db->set_entry(index1, entry1);
   ASSERT_EQ(ret, 0);
@@ -1121,33 +1121,33 @@ TEST_F(DBStoreTest, LCEntry) {
   ASSERT_EQ(ret, 0);
 
   // get entry index1, entry1
-  ret = db->get_entry(index1, ents[0], entry); 
+  ret = db->get_entry(index1, ents[0], &entry); 
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(entry.status, lc_uninitial);
-  ASSERT_EQ(entry.start_time, lc_time);
+  ASSERT_EQ(entry->get_status(), lc_uninitial);
+  ASSERT_EQ(entry->get_start_time(), lc_time);
 
   // get next entry index1, entry2
-  ret = db->get_next_entry(index1, ents[1], entry); 
+  ret = db->get_next_entry(index1, ents[1], &entry); 
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(entry.bucket, ents[2]);
-  ASSERT_EQ(entry.status, lc_uninitial);
-  ASSERT_EQ(entry.start_time, lc_time);
+  ASSERT_EQ(entry->get_bucket(), ents[2]);
+  ASSERT_EQ(entry->get_status(), lc_uninitial);
+  ASSERT_EQ(entry->get_start_time(), lc_time);
 
   // update entry4 to entry5
   entry4.status = lc_complete;
   ret = db->set_entry(index2, entry4);
   ASSERT_EQ(ret, 0);
-  ret = db->get_entry(index2, ents[3], entry); 
+  ret = db->get_entry(index2, ents[3], &entry); 
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(entry.status, lc_complete);
+  ASSERT_EQ(entry->get_status(), lc_complete);
 
   // list entries
   ret = db->list_entries(index1, "", 5, lc_entries);
   ASSERT_EQ(ret, 0);
   for (const auto& ent: lc_entries) {
     cout << "###################### \n";
-    cout << "lc entry.bucket : " << ent.bucket << "\n";
-    cout << "lc entry.status : " << ent.status << "\n";
+    cout << "lc entry.bucket : " << ent->get_bucket() << "\n";
+    cout << "lc entry.status : " << ent->get_status() << "\n";
   }
 
   // remove index1, entry3
@@ -1155,10 +1155,10 @@ TEST_F(DBStoreTest, LCEntry) {
   ASSERT_EQ(ret, 0);
 
   // get next entry index1, entry2.. should be null
-  entry = {};
-  ret = db->get_next_entry(index1, ents[1], entry); 
+  entry.release();
+  ret = db->get_next_entry(index1, ents[1], &entry); 
   ASSERT_EQ(ret, 0);
-  ASSERT_EQ(entry.start_time, 0);
+  ASSERT_EQ(entry.get(), nullptr);
 }
 
 TEST_F(DBStoreTest, RemoveBucket) {
index eeca2a09267a6ecc871ae7a365921453448d4ef6..0684f215bb1e9e0927449f134cc0c9d9f25dfc15 100644 (file)
@@ -67,7 +67,7 @@ public:
   }
 };
 
-class TestUser : public sal::User {
+class TestUser : public sal::StoreUser {
 public:
   virtual std::unique_ptr<User> clone() override {
     return std::unique_ptr<User>(new TestUser(*this));