]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Add option to allow disabling issuing alloc hint 4983/head
authorHaomai Wang <haomaiwang@gmail.com>
Wed, 17 Jun 2015 14:04:52 +0000 (22:04 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Wed, 17 Jun 2015 14:04:52 +0000 (22:04 +0800)
For HDD osd backend, a alloc hint is good for local filesystem to ensure
extent continuous. But for SSD, the available capacity is useful and
precious, user may not expect lots of capacity is used by reserving.
Then ssd is good for random rw.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/common/config_opts.h
src/librbd/AioRequest.cc
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h

index d762a2c9de3667b63dd1d0a1cb27718c0eeb53be..e59560ec9d55b8e75a7dd7cc2f9054f41d03edc5 100644 (file)
@@ -897,6 +897,7 @@ OPTION(rbd_blacklist_on_break_lock, OPT_BOOL, true) // whether to blacklist clie
 OPTION(rbd_blacklist_expire_seconds, OPT_INT, 0) // number of seconds to blacklist - set to 0 for OSD default
 OPTION(rbd_request_timed_out_seconds, OPT_INT, 30) // number of seconds before maint request times out
 OPTION(rbd_skip_partial_discard, OPT_BOOL, false) // when trying to discard a range inside an object, set to true to skip zeroing the range.
+OPTION(rbd_enable_alloc_hint, OPT_BOOL, true) // when writing a object, it will issue a hint to osd backend to indicate the expected size object need
 
 /*
  * The following options change the behavior for librbd's image creation methods that
index 77ead571a4b4e1273c6e1b2568afd4f7a62a4198..558fa0131a4f657efb711daa8459130c2cbe8fd3 100644 (file)
@@ -497,7 +497,8 @@ namespace librbd {
   }
 
   void AioWrite::add_write_ops(librados::ObjectWriteOperation *wr) {
-    wr->set_alloc_hint(m_ictx->get_object_size(), m_ictx->get_object_size());
+    if (m_ictx->enable_alloc_hint)
+      wr->set_alloc_hint(m_ictx->get_object_size(), m_ictx->get_object_size());
     wr->write(m_object_off, m_write_data);
     wr->set_op_flags2(m_op_flags);
   }
index 7f74ec01869364ed8dcb7e5057f83044b9af908c..7637c852ca2ff20c93529fdb5683bf07c3c21152 100644 (file)
@@ -931,5 +931,6 @@ public:
     ASSIGN_OPTION(blacklist_on_break_lock);
     ASSIGN_OPTION(blacklist_expire_seconds);
     ASSIGN_OPTION(request_timed_out_seconds);
+    ASSIGN_OPTION(enable_alloc_hint);
   }
 }
index 3d8d1f943a13a7e42aed3fb2802bc7baad94747a..053ff61408e9e8353d99cd380ff022cf48521231 100644 (file)
@@ -157,6 +157,7 @@ namespace librbd {
     bool blacklist_on_break_lock;
     uint32_t blacklist_expire_seconds;
     uint32_t request_timed_out_seconds;
+    bool enable_alloc_hint;
     static bool _filter_metadata_confs(const string &prefix, std::map<string, bool> &configs,
                                        map<string, bufferlist> &pairs, map<string, bufferlist> *res);