From: Min Chen Date: Fri, 25 Jul 2014 02:12:33 +0000 (+0800) Subject: librbd: copy-on-read for clones, add an option for copy-on-read X-Git-Tag: v0.93~197^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=541637d5c0477f5beafe42af7a656c97873d3934;p=ceph.git librbd: copy-on-read for clones, add an option for copy-on-read Signed-off-by: Min Chen Signed-off-by: Li Wang Signed-off-by: Yunchuan Wen --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 937aee6a75ec..622e9f4bd7c2 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -850,6 +850,7 @@ OPTION(rbd_localize_parent_reads, OPT_BOOL, true) OPTION(rbd_readahead_trigger_requests, OPT_INT, 10) // number of sequential requests necessary to trigger readahead OPTION(rbd_readahead_max_bytes, OPT_LONGLONG, 512 * 1024) // set to 0 to disable readahead OPTION(rbd_readahead_disable_after_bytes, OPT_LONGLONG, 50 * 1024 * 1024) // how many bytes are read in total before readahead is disabled +OPTION(rbd_clone_copy_on_read, OPT_BOOL, false)//copy-on-read option for rbd clones /* * The following options change the behavior for librbd's image creation methods that diff --git a/src/librbd/AioRequest.cc b/src/librbd/AioRequest.cc index ab54a65810ba..b42056e4fb1d 100644 --- a/src/librbd/AioRequest.cc +++ b/src/librbd/AioRequest.cc @@ -59,6 +59,10 @@ namespace librbd { ldout(m_ictx->cct, 20) << "should_complete " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len << " r = " << r << dendl; + //get copy-on-read option and check image if read_only + bool cor = (m_ictx->cct->_conf->rbd_clone_copy_on_read) && (!m_ictx->read_only); + ldout(m_ictx->cct, 20) << "should_complete cor = " << cor << " read_only = " << m_ictx->read_only << dendl; + if (!m_tried_parent && r == -ENOENT) { RWLock::RLocker l(m_ictx->snap_lock); RWLock::RLocker l2(m_ictx->parent_lock);