]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: check the data extra pool supports omap 18978/head
authorYao Zongyou <yaozongyou@vip.qq.com>
Fri, 17 Nov 2017 05:47:23 +0000 (13:47 +0800)
committerYao Zongyou <yaozongyou@vip.qq.com>
Fri, 17 Nov 2017 05:47:23 +0000 (13:47 +0800)
If the data extra pool is ec and does not support omap, multi-part
uploading will fail, so adding this check when adding or changing
zone placement.

Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
src/rgw/rgw_admin.cc

index 22fb0f0ce74edf63ca4581dec0f657dc36155b5c..abde1b832cae61767fda62e367b69fc29e091187 100644 (file)
@@ -2253,6 +2253,24 @@ static void parse_tier_config_param(const string& s, map<string, string, ltstr_n
   }
 }
 
+static int check_pool_support_omap(rgw_pool pool) 
+{
+  librados::IoCtx io_ctx;
+  int ret = store->get_rados_handle()->ioctx_create(pool.to_str().c_str(), io_ctx);
+  if (ret < 0) {
+     // the pool may not exist at this moment, we have no way to check if it supports omap.
+     return 0;
+  }
+
+  ret = io_ctx.omap_clear("__omap_test_not_exist_oid__");
+  if (ret == -EOPNOTSUPP) {
+    io_ctx.close();
+    return ret;
+  }
+  io_ctx.close();
+  return 0;
+}
+
 int check_reshard_bucket_params(RGWRados *store,
                                const string& bucket_name,
                                const string& tenant,
@@ -4294,6 +4312,13 @@ int main(int argc, const char **argv)
           if (compression_type) {
             info.compression_type = *compression_type;
           }
+
+          ret = check_pool_support_omap(info.get_data_extra_pool());
+          if (ret < 0) {
+             cerr << "ERROR: the data extra (non-ec) pool '" << info.get_data_extra_pool() 
+                 << "' does not support omap" << std::endl;
+             return ret;
+          }
         } else if (opt_cmd == OPT_ZONE_PLACEMENT_MODIFY) {
           auto p = zone.placement_pools.find(placement_id);
           if (p == zone.placement_pools.end()) {
@@ -4317,6 +4342,13 @@ int main(int argc, const char **argv)
           if (compression_type) {
             info.compression_type = *compression_type;
           }
+          
+          ret = check_pool_support_omap(info.get_data_extra_pool());
+          if (ret < 0) {
+             cerr << "ERROR: the data extra (non-ec) pool '" << info.get_data_extra_pool() 
+                 << "' does not support omap" << std::endl;
+             return ret;
+          }
         } else if (opt_cmd == OPT_ZONE_PLACEMENT_RM) {
           zone.placement_pools.erase(placement_id);
         }