]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
blk: add upper bound of bluestore_deferred_batch_ops* options 38709/head
authorhzwuhongsong <hzwuhongsong@corp.netease.com>
Tue, 29 Dec 2020 06:24:01 +0000 (14:24 +0800)
committerhzwuhongsong <hzwuhongsong@corp.netease.com>
Tue, 29 Dec 2020 08:32:57 +0000 (16:32 +0800)
so the number of pending io does not overflow when being passed to submit_batch().

Signed-off-by: hzwuhongsong <hzwuhongsong@corp.netease.com>
src/blk/kernel/KernelDevice.cc
src/common/options.cc

index e3ef9f155d80af604142420ca5c217d6bb1d0b5f..d93279965970687dd3fbb22cfeedf3fe14238b47 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include <limits>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -813,6 +814,8 @@ void KernelDevice::aio_submit(IOContext *ioc)
 
   void *priv = static_cast<void*>(ioc);
   int r, retries = 0;
+  // num of pending aios should not overflow when passed to submit_batch()
+  assert(pending <= std::numeric_limits<uint16_t>::max());
   r = io_queue->submit_batch(ioc->running_aios.begin(), e,
                             pending, priv, &retries);
 
index 57901687e77f52cd3e2cf66a57fb7a2789cdc794..7590e0f8f13f849668e11d8e37e20f8e59004bec 100644 (file)
@@ -4617,17 +4617,20 @@ std::vector<Option> get_global_options() {
 
     Option("bluestore_deferred_batch_ops", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(0)
+    .set_min_max(0, 65535)
     .set_flag(Option::FLAG_RUNTIME)
     .set_description("Max number of deferred writes before we flush the deferred write queue"),
 
     Option("bluestore_deferred_batch_ops_hdd", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(64)
+    .set_min_max(0, 65535)
     .set_flag(Option::FLAG_RUNTIME)
     .set_description("Default bluestore_deferred_batch_ops for rotational media")
     .add_see_also("bluestore_deferred_batch_ops"),
 
     Option("bluestore_deferred_batch_ops_ssd", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(16)
+    .set_min_max(0, 65535)
     .set_flag(Option::FLAG_RUNTIME)
     .set_description("Default bluestore_deferred_batch_ops for non-rotational (solid state) media")
     .add_see_also("bluestore_deferred_batch_ops"),