From patchwork Thu Mar 27 00:38:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Min Chen X-Patchwork-Id: 3895961 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1FDD8BF549 for ; Thu, 27 Mar 2014 00:44:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4779A2014A for ; Thu, 27 Mar 2014 00:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BCDC2021F for ; Thu, 27 Mar 2014 00:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754697AbaC0Aow (ORCPT ); Wed, 26 Mar 2014 20:44:52 -0400 Received: from m59-178.qiye.163.com ([123.58.178.59]:55933 "EHLO m59-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755256AbaC0Aou (ORCPT ); Wed, 26 Mar 2014 20:44:50 -0400 Received: from localhost.localdomain (unknown [119.39.124.170]) by m59-178.qiye.163.com (HMail) with ESMTPA id 4772E1481A00; Thu, 27 Mar 2014 08:38:31 +0800 (CST) From: Min Chen To: ceph-devel@vger.kernel.org Cc: josh.durgin@inktank.com, Yunchuan Wen , Li Wang Subject: [PATCH 1/2] rbd: copy-on-read for clones, read entire object from parent Date: Thu, 27 Mar 2014 08:38:17 +0800 Message-Id: <1395880698-20479-2-git-send-email-minchen@ubuntukylin.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395880698-20479-1-git-send-email-minchen@ubuntukylin.com> References: <1395880698-20479-1-git-send-email-minchen@ubuntukylin.com> X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQU5VQ0hLS0tLT0tLTk9ISUpIV1kJDhceCFlBWS grPSQrOigoJDI1JDM#Oj8#KUFLVUtANiMkIj4oJDI1JDM#Oj8#KUFLVUtAKy8pJDU0JDI1JDM#Oj 8#KUFJVUtAODQuNS8pIiQ4NUFLVUtAKT48MjQ1JDooMjpBS1VLQCspNC0yNTg#JDMuNTo1QUtVS0 A*IjU6NjI4JDIrJDU0JDI1JDM#Oj8#KUFLVUtANi43LzIkKTgrLyQ*Mj09Pik#NS8kMjUkMz46Pz 4pQUlVS0AyKyQvND86IiQ4NS8kSyRKS0tBS1VLQDIrJE4kNjI1Li8#JDg1LyRLJEpLQUtVS0AyKy RKJDYyNS4vPiQ4NS8kSyRKS0FLVUtAMiskSiQzNC4pJDg1LyRLJEpLS0FLVUtAMiskSEskNjI1Li 8#JDg1LyRLJE5LQUtVS0AoLjkkPkFKVU5OQD01JCguOSQ#NSw0KT8oJDM3MSRKS0tJS0pBS1VJQ1 kG X-HM-Sender-Digest: e1kSHx4VD1lBWUc6ORA6Nyo*Pzo0LjpLKj8yOjQuOjQwChVVSlVKSEJO Q0NLTEpKT0xMVTMWGhIXVRYSFRgTHhU7DhkOFQ8OEAIXEhVVGBQWRVlXWQweGVlBHRoXCB5XWQgB WUFPSU5CN1dZEgtZQVlKSkJVSEJVSklPVUpMS1kG Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rbd copy-on-read is implmented in AioRequest. If object extent doesn't exist in clone, then read the entire range of object from parent. Bufferlist m_entire_data is added to AioRequest to save object instead of m_read_data which just keeps data read, and copy read range to m_read_data from m_entire_data Signed-off-by: Min Chen Signed-off-by: Yunchuan Wen Signed-off-by: Li Wang --- src/librbd/AioRequest.cc | 36 ++++++++++++++++++++++++++++++++++-- src/librbd/AioRequest.h | 2 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/librbd/AioRequest.cc b/src/librbd/AioRequest.cc index e8fb657..268999c 100644 --- a/src/librbd/AioRequest.cc +++ b/src/librbd/AioRequest.cc @@ -52,6 +52,19 @@ namespace librbd { m_parent_completion); } + //copy-on-read : read the entire object from parent, using bufferlist m_entire_object + void AioRequest::read_from_parent_COR(vector >& image_extents) + { + assert(!m_parent_completion); + m_parent_completion = aio_create_completion_internal(this, rbd_req_cb); + ldout(m_ictx->cct, 20) << "read_from_parent_COR this = " << this + << " parent completion " << m_parent_completion + << " extents " << image_extents + << dendl; + aio_read(m_ictx->parent, image_extents, NULL, &m_entire_object, + m_parent_completion); + } + /** read **/ bool AioRead::should_complete(int r) @@ -78,11 +91,30 @@ namespace librbd { uint64_t object_overlap = m_ictx->prune_parent_extents(image_extents, image_overlap); if (object_overlap) { m_tried_parent = true; - read_from_parent(image_extents); + if(COR)//copy-on-read option + { + vector > extend_image_extents; + //extend range to entire object + Striper::extent_to_file(m_ictx->cct, &m_ictx->layout, + m_object_no, 0, m_ictx->layout.fl_object_size, + extend_image_extents); + //read entire object from parent , and put it in m_entire_object + read_from_parent_COR(extend_image_extents); + } + else + read_from_parent(image_extents); return false; } } - + if(COR) //copy-on-read option + { + //if read entire object from parent success + if(m_tried_parent && r>0) + { + // copy the read range to m_read_data + m_read_data.substr_of(m_entire_object, m_object_off, m_object_len); + } + } return true; } diff --git a/src/librbd/AioRequest.h b/src/librbd/AioRequest.h index cf50ee2..4081c4c 100644 --- a/src/librbd/AioRequest.h +++ b/src/librbd/AioRequest.h @@ -47,6 +47,7 @@ namespace librbd { protected: void read_from_parent(vector >& image_extents); + void read_from_parent_COR(vector >& image_extents); ImageCtx *m_ictx; librados::IoCtx *m_ioctx; @@ -57,6 +58,7 @@ namespace librbd { AioCompletion *m_parent_completion; ceph::bufferlist m_read_data; bool m_hide_enoent; + ceph::bufferlist m_entire_object; }; class AioRead : public AioRequest {