]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add bucket to resharding queue if needs resharding
authorOrit Wasserman <owasserm@redhat.com>
Fri, 19 May 2017 11:02:17 +0000 (14:02 +0300)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:51 +0000 (13:17 -0700)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index cc9f290ecad9baa6ece020c464eb5eee886ff033..4114cf0caa0a8bfc118bcccef3bc9d904c1d9da7 100644 (file)
@@ -3118,15 +3118,10 @@ void RGWPutObj::execute()
       ldout(s->cct, 20) << "check_quota() returned ret=" << op_ret << dendl;
       goto done;
     }
-    bool need_resharding = false;
-    op_ret = store->check_bucket_shards(s->bucket_owner.get_id(), s->bucket,
-                                       bucket_quota, s->bucket_info.num_shards, need_resharding);
+    op_ret = store->check_bucket_shards(s->bucket_info, s->bucket, bucket_quota);
     if (op_ret < 0) {
       ldout(s->cct, 20) << "check_bucket_shards() returned ret=" << op_ret << dendl;
       goto done;
-    } else if (need_resharding) {
-      /* Add to resharding queue */
-      ldout(s->cct, 20) << s->bucket << " needs resharding " << dendl;
     }
   }
 
index 10e2cc49d3ee8260f6f64088400598d0048b1c31..51a21a89350c06d47a0ecf65fa85ec9e02e67fed 100644 (file)
@@ -13080,15 +13080,28 @@ int RGWRados::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bu
   return 0;
 }
 
-int RGWRados::check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket,
-                                 RGWQuotaInfo& bucket_quota, uint64_t num_shards,  bool& need_resharding)
+int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket,
+                                 RGWQuotaInfo& bucket_quota)
 {
   if (!cct->_conf->rgw_dynamic_resharding) {
       return 0;
   }
 
-  return quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard, num_shards,
-                                           bucket_owner, bucket, bucket_quota, 1, need_resharding);
+  bool need_resharding = false;
+  int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+
+  int ret =  quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard,
+                                               num_source_shards,  bucket_info.owner, bucket, bucket_quota,
+                                               1, need_resharding);
+  if (ret < 0) {
+    return ret;
+  }
+
+  if (need_resharding) {
+    return add_bucket_to_reshard(bucket_info);
+  }
+
+  return ret;
 }
 
 int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info)
index 7a856b42f5a46e2b1a736f8707abea18146ed73e..88594eba0266e1850946afddf7380e9dda052d8f 100644 (file)
@@ -3479,9 +3479,8 @@ public:
   int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
                   RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size);
 
-  int check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket,
-                         RGWQuotaInfo& bucket_quota, uint64_t num_shards,
-                         bool& need_resharding);
+  int check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket,
+                         RGWQuotaInfo& bucket_quota);
 
   int add_bucket_to_reshard(const RGWBucketInfo& bucket_info);