]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: allow force-check filter to pass through the SAL layer 43553/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 13 Oct 2021 21:58:55 +0000 (17:58 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Fri, 15 Oct 2021 05:44:42 +0000 (01:44 -0400)
The zipper updates did not pass a force-check filter from
RGWRados::Bucket::List through to
RGWRados::cls_bucket_list_ordered. This filter is necessary for the
"radosgw-admin bucket check --fix..." functionality.

Declares type RGWBucketListNameFilter to encapsualte the filter
type. Renames some fields so the two filters can be distinguished.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_lc.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_rados.cc
src/rgw/store/dbstore/common/dbstore.h

index edc7f8027311fd19cf7c01afa2d852cdb456818e..ac9656aea82563900edc65e99134f72074f24978 100644 (file)
@@ -295,12 +295,13 @@ void check_bad_user_bucket_mapping(rgw::sal::Store* store, rgw::sal::User* user,
   } while (user_buckets.is_truncated());
 }
 
-// note: function type conforms to RGWRados::check_filter_t
-bool rgw_bucket_object_check_filter(const string& oid)
+// returns true if entry is in the empty namespace. note: function
+// type conforms to type RGWBucketListNameFilter
+bool rgw_bucket_object_check_filter(const std::string& oid)
 {
-  rgw_obj_key key;
-  string ns;
-  return rgw_obj_key::oid_to_key_in_ns(oid, &key, ns);
+  const static std::string empty_ns;
+  rgw_obj_key key; // thrown away but needed for parsing
+  return rgw_obj_key::oid_to_key_in_ns(oid, &key, empty_ns);
 }
 
 int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::Store* store, rgw::sal::Bucket* bucket, rgw_obj_key& key)
@@ -604,6 +605,7 @@ int RGWBucket::check_object_index(const DoutPrefixProvider *dpp,
   while (results.is_truncated) {
     rgw::sal::Bucket::ListParams params;
     params.marker = results.next_marker;
+    params.force_check_filter = rgw_bucket_object_check_filter;
 
     int r = bucket->list(dpp, params, listing_max_entries, results, y);
 
index 6ec09b9f667e6785efb74bfcf8c6be9ad98c9745..0dbc4904f2acd55c2f12e29166ab6b25227fcf54 100644 (file)
@@ -50,7 +50,7 @@ extern void rgw_parse_url_bucket(const std::string& bucket,
                                  std::string &tenant_name, std::string &bucket_name);
 
 // this is used as a filter to RGWRados::cls_bucket_list_ordered; it
-// conforms to the type declaration of RGWRados::check_filter_t.
+// conforms to the type RGWBucketListNameFilter
 extern bool rgw_bucket_object_check_filter(const std::string& oid);
 
 void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
index 485848d22975a7cc21379f241c12e23a7ecf6371..8e19e36bc478106173694829d6b46be5b4812d56 100644 (file)
@@ -837,7 +837,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
    * operating on one shard at a time */
   params.allow_unordered = true;
   params.ns = RGW_OBJ_NS_MULTIPART;
-  params.filter = &mp_filter;
+  params.access_list_filter = &mp_filter;
 
   auto pf = [&](RGWLC::LCWorker* wk, WorkQ* wq, WorkItem& wi) {
     auto wt = boost::get<std::tuple<lc_op, rgw_bucket_dir_entry>>(wi);
index 9b4f77a8ca9a8fdeb5a4a861bf47b5fe61a19cb3..2c2b0a57ee529c427713ec8875d888ab26ce565f 100644 (file)
@@ -110,6 +110,7 @@ static RGWObjCategory main_category = RGWObjCategory::Main;
 #define RGW_USAGE_OBJ_PREFIX "usage."
 
 
+// returns true on success, false on failure
 static bool rgw_get_obj_data_pool(const RGWZoneGroup& zonegroup, const RGWZoneParams& zone_params,
                                   const rgw_placement_rule& head_placement_rule,
                                   const rgw_obj& obj, rgw_pool *pool)
@@ -1866,7 +1867,8 @@ int RGWRados::Bucket::List::list_objects_ordered(
                                           &truncated,
                                           &cls_filtered,
                                           &cur_marker,
-                                           y);
+                                           y,
+                                          params.force_check_filter);
     if (r < 0) {
       return r;
     }
@@ -1918,8 +1920,8 @@ int RGWRados::Bucket::List::list_objects_ordered(
        next_marker = index_key;
       }
 
-      if (params.filter &&
-         ! params.filter->filter(obj.name, index_key.name)) {
+      if (params.access_list_filter &&
+         ! params.access_list_filter->filter(obj.name, index_key.name)) {
         continue;
       }
 
@@ -2168,12 +2170,15 @@ int RGWRados::Bucket::List::list_objects_unordered(const DoutPrefixProvider *dpp
        continue;
       }
 
-      if (params.filter && !params.filter->filter(obj.name, index_key.name))
+      if (params.access_list_filter &&
+         !params.access_list_filter->filter(obj.name, index_key.name)) {
         continue;
+      }
 
       if (params.prefix.size() &&
-         (0 != obj.name.compare(0, params.prefix.size(), params.prefix)))
+         (0 != obj.name.compare(0, params.prefix.size(), params.prefix))) {
         continue;
+      }
 
       if (count >= max) {
         truncated = true;
@@ -2329,6 +2334,7 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket,
   return -ENOENT;
 }
 
+// returns true on success, false on failure
 bool RGWRados::get_obj_data_pool(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_pool *pool)
 {
   return rgw_get_obj_data_pool(svc.zone->get_zonegroup(), svc.zone->get_zone_params(), placement_rule, obj, pool);
@@ -8377,7 +8383,7 @@ int RGWRados::cls_bucket_list_ordered(const DoutPrefixProvider *dpp,
                                      bool* cls_filtered,
                                      rgw_obj_index_key *last_entry,
                                       optional_yield y,
-                                     check_filter_t force_check_filter)
+                                     RGWBucketListNameFilter force_check_filter)
 {
   /* expansion_factor allows the number of entries to read to grow
    * exponentially; this is used when earlier reads are producing too
@@ -8670,7 +8676,7 @@ int RGWRados::cls_bucket_list_unordered(const DoutPrefixProvider *dpp,
                                        bool *is_truncated,
                                        rgw_obj_index_key *last_entry,
                                         optional_yield y,
-                                       check_filter_t force_check_filter) {
+                                       RGWBucketListNameFilter force_check_filter) {
   ldpp_dout(dpp, 10) << __func__ << " " << bucket_info.bucket <<
     " start_after=\"" << start_after <<
     "\", prefix=\"" << prefix <<
@@ -9049,12 +9055,16 @@ int RGWRados::check_disk_state(const DoutPrefixProvider *dpp,
   list_state.meta.category = main_category;
   list_state.meta.etag = etag;
   list_state.meta.content_type = content_type;
-  if (astate->obj_tag.length() > 0)
+
+  if (astate->obj_tag.length() > 0) {
     list_state.tag = astate->obj_tag.c_str();
+  }
+
   list_state.meta.owner = owner.get_id().to_str();
   list_state.meta.owner_display_name = owner.get_display_name();
 
   list_state.exists = true;
+
   cls_rgw_encode_suggestion(CEPH_RGW_UPDATE | suggest_flag, list_state, suggested_updates);
   return 0;
 }
index 26b603b128b0120835700976862d1c6aa72412a5..f335ecc00babfa5a4d87db98f85b9679f90ff79c 100644 (file)
@@ -986,13 +986,14 @@ public:
         rgw_obj_key end_marker;
         std::string ns;
         bool enforce_ns;
-        RGWAccessListFilter *filter;
+        RGWAccessListFilter* access_list_filter;
+       RGWBucketListNameFilter force_check_filter;
         bool list_versions;
        bool allow_unordered;
 
         Params() :
          enforce_ns(true),
-         filter(NULL),
+         access_list_filter(nullptr),
          list_versions(false),
          allow_unordered(false)
        {}
@@ -1361,8 +1362,6 @@ public:
   using ent_map_t =
     boost::container::flat_map<std::string, rgw_bucket_dir_entry>;
 
-  using check_filter_t = bool (*)(const std::string&);
-
   int cls_bucket_list_ordered(const DoutPrefixProvider *dpp,
                               RGWBucketInfo& bucket_info,
                              const int shard_id,
@@ -1377,7 +1376,7 @@ public:
                              bool* cls_filtered,
                              rgw_obj_index_key *last_entry,
                               optional_yield y,
-                             check_filter_t force_check_filter = nullptr);
+                             RGWBucketListNameFilter force_check_filter = {});
   int cls_bucket_list_unordered(const DoutPrefixProvider *dpp,
                                 RGWBucketInfo& bucket_info,
                                int shard_id,
@@ -1389,7 +1388,7 @@ public:
                                bool *is_truncated,
                                rgw_obj_index_key *last_entry,
                                 optional_yield y,
-                               check_filter_t = nullptr);
+                               RGWBucketListNameFilter force_check_filter = {});
   int cls_bucket_head(const DoutPrefixProvider *dpp,
                      const RGWBucketInfo& bucket_info,
                      int shard_id,
index 68120239214bf47b88389a5d2481b5cad7b908a3..7bd96a7bc4100497420201b75ca4561b20699f78 100644 (file)
@@ -38,6 +38,10 @@ class RGWSyncModuleInstance;
 typedef std::shared_ptr<RGWSyncModuleInstance> RGWSyncModuleInstanceRef;
 class RGWCompressionInfo;
 
+
+using RGWBucketListNameFilter = std::function<bool (const std::string&)>;
+
+
 namespace rgw {
   class Aio;
   namespace IAM { struct Policy; }
@@ -378,7 +382,8 @@ class Bucket {
       rgw_obj_key end_marker;
       std::string ns;
       bool enforce_ns{true};
-      RGWAccessListFilter* filter{nullptr};
+      RGWAccessListFilter* access_list_filter{nullptr};
+      RGWBucketListNameFilter force_check_filter;
       bool list_versions{false};
       bool allow_unordered{false};
       int shard_id{RGW_NO_SHARD};
index 67cbdad666d3739c9da1bbcd3d7568982b87d6d7..cd0484939828f9661601e34ef12b20263baa3a1b 100644 (file)
@@ -349,7 +349,8 @@ namespace rgw::sal {
     list_op.params.end_marker = params.end_marker;
     list_op.params.ns = params.ns;
     list_op.params.enforce_ns = params.enforce_ns;
-    list_op.params.filter = params.filter;
+    list_op.params.access_list_filter = params.access_list_filter;
+    list_op.params.force_check_filter = params.force_check_filter;
     list_op.params.list_versions = params.list_versions;
     list_op.params.allow_unordered = params.allow_unordered;
 
index 5ce3b2f00093938280536ff7e49bfc2513d7f7fa..e36c901a4fa91eaa984ea09119f63926c7276783 100644 (file)
@@ -736,7 +736,8 @@ int RadosBucket::list(const DoutPrefixProvider* dpp, ListParams& params, int max
   list_op.params.end_marker = params.end_marker;
   list_op.params.ns = params.ns;
   list_op.params.enforce_ns = params.enforce_ns;
-  list_op.params.filter = params.filter;
+  list_op.params.access_list_filter = params.access_list_filter;
+  list_op.params.force_check_filter = params.force_check_filter;
   list_op.params.list_versions = params.list_versions;
   list_op.params.allow_unordered = params.allow_unordered;
 
@@ -766,7 +767,7 @@ int RadosBucket::list_multiparts(const DoutPrefixProvider *dpp,
   params.delim = delim;
   params.marker = marker;
   params.ns = RGW_OBJ_NS_MULTIPART;
-  params.filter = &mp_filter;
+  params.access_list_filter = &mp_filter;
 
   int ret = list(dpp, params, max_uploads, results, null_yield);
 
index 3515fbe718bc06cbf15ee4f4db858a9e9a6dc9f0..4619ff55d2a9739ee7f69ca59177a6eea1af7907 100644 (file)
@@ -1378,13 +1378,14 @@ class DB {
           rgw_obj_key end_marker;
           string ns;
           bool enforce_ns;
-          RGWAccessListFilter *filter;
+          RGWAccessListFilter* access_list_filter;
+          RGWBucketListNameFilter force_check_filter;
           bool list_versions;
-             bool allow_unordered;
+         bool allow_unordered;
 
           Params() :
                enforce_ns(true),
-               filter(NULL),
+               access_list_filter(nullptr),
                list_versions(false),
                allow_unordered(false)
                {}