From patchwork Thu May 21 09:19:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 6453601 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB7C3C0432 for ; Thu, 21 May 2015 09:28:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8B4620376 for ; Thu, 21 May 2015 09:28:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2226203B7 for ; Thu, 21 May 2015 09:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753776AbbEUJ2v (ORCPT ); Thu, 21 May 2015 05:28:51 -0400 Received: from m59-178.qiye.163.com ([123.58.178.59]:37309 "EHLO m59-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753162AbbEUJ2r (ORCPT ); Thu, 21 May 2015 05:28:47 -0400 Received: from localhost.localdomain (unknown [113.240.220.93]) by m59-178.qiye.163.com (HMail) with ESMTPA id EAF691480C6B; Thu, 21 May 2015 17:21:47 +0800 (CST) From: Li Wang To: Sage Weil , Ilya Dryomov , Alex Elder , Josh Durgin Cc: ceph-devel@vger.kernel.org, Min Chen , Yunchuan Wen , Li Wang Subject: [PATCH 2/4] Rbd: add a new request: rbd_copyup_request Date: Thu, 21 May 2015 17:19:53 +0800 Message-Id: <831f6e358c92970ea2eeb4d59bf974e2613cbc29.1432177493.git.liwang@ubuntukylin.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUpOVUNJQkJCQkJJSExLTUtOTldZCQ4XHghZQV koKz0kKDQ9Lz06MjckMjUkMz46Pz4pQUtVS0A2IyQiPigkMjUkMz46Pz4pQUtVS0ArLykkNTQkMj UkMz46Pz4pQUlVS0A*IjU6NjI4JDIrJDU0JDI1JDM#Oj8#KUFLVUtANi43LzIkKTgrLyQ*Mj09Pi k#NS8kMjUkMz46Pz4pQUlVS0AyKyQvND86IiQ4NS8kSyRKS0tBS1VLQDIrJEokMzQuKSQ4NS8kSy RKS0tBS1VLQDIrJEokNjI1Li8#JDg1LyRLJEpLQUtVS0AyKyRISyQ2MjUuLz4kODUvJEskTktBS1 VLQDIrJE4kNjI1Li8#JDg1LyRLJEpLQUtVS0AoLjkxPjgvJC80PzoiJDg1LyRLJEpLS0FLVUtAKC 45MT44LyROJDYyNS4vPiQ4NS8kSyRKS0FLVUtAKC45MT44LyRKJDM0LikkODUvJEskSktLQUtVS0 A1NC8kPTo2NC4oJD80NjoyNSQoKz0kPToyN0FKS1VLQCguOSQ#QUpVTk5APTUkKC45JD41LDQpPy gkMzcxJEpLS0lLSkFLVUlDWQY+ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6OCo6UQw5Hzo1TwEqLwtLFywMNEgwCUNVSlVKT0hJ SUtLSktCSEhPVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QU5NTEw3V1kSC1lBWUpKSFVJT0tVSUlLVUJIWQY+ X-HM-Tid: 0a4d75c75876649feaf691480c6b Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Min Chen Rbd_copyup_request is used only when copy_on_read enabled for RBD child images. It is independent of rbd_obj_request. Signed-off-by: Min Chen Signed-off-by: Li Wang Signed-off-by: Yunchuan Wen --- drivers/block/rbd.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 446204b..581cb7b 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -207,6 +207,9 @@ typedef void (*rbd_img_callback_t)(struct rbd_img_request *); struct rbd_obj_request; typedef void (*rbd_obj_callback_t)(struct rbd_obj_request *); +struct rbd_copyup_request; +typedef void (*rbd_copyup_callback_t)(struct rbd_copyup_request *); + enum obj_request_type { OBJ_REQUEST_NODATA, OBJ_REQUEST_BIO, OBJ_REQUEST_PAGES }; @@ -279,6 +282,27 @@ struct rbd_obj_request { struct kref kref; }; +struct rbd_copyup_request { + const char * object_name; + u64 object_no; + + struct page **copyup_pages; + u32 copyup_page_count; + + struct rbd_img_request *img_request; + /* links for img_request->copyup_requests list */ + struct list_head links; + + struct ceph_osd_request *osd_req; + + rbd_copyup_callback_t callback; + struct completion completion; + + int result; + + struct kref kref; +}; + enum img_req_flags { IMG_REQ_WRITE, /* I/O direction: read = 0, write = 1 */ IMG_REQ_CHILD, /* initiator: block = 0, child image = 1 */ @@ -310,6 +334,9 @@ struct rbd_img_request { u32 obj_request_count; struct list_head obj_requests; /* rbd_obj_request structs */ + struct list_head copyup_list; /* rbd_copyup_request list */ + spinlock_t copyup_list_lock; /* protects copyup list */ + struct kref kref; }; @@ -320,6 +347,9 @@ struct rbd_img_request { #define for_each_obj_request_safe(ireq, oreq, n) \ list_for_each_entry_safe_reverse(oreq, n, &(ireq)->obj_requests, links) +#define for_each_copyup_request(ireq, cpreq) \ + list_for_each_entry(cpreq, &(ireq)->copyup_list, links) + struct rbd_mapping { u64 size; u64 features; @@ -399,6 +429,7 @@ static DEFINE_SPINLOCK(rbd_client_list_lock); static struct kmem_cache *rbd_img_request_cache; static struct kmem_cache *rbd_obj_request_cache; +static struct kmem_cache *rbd_copyup_request_cache; static struct kmem_cache *rbd_segment_name_cache; static int rbd_major; @@ -2178,6 +2209,8 @@ static struct rbd_img_request *rbd_img_request_create( img_request->result = 0; img_request->obj_request_count = 0; INIT_LIST_HEAD(&img_request->obj_requests); + INIT_LIST_HEAD(&img_request->copyup_list); + spin_lock_init(&img_request->copyup_list_lock); kref_init(&img_request->kref); dout("%s: rbd_dev %p %s %llu/%llu -> img %p\n", __func__, rbd_dev, @@ -5666,6 +5699,14 @@ static int rbd_slab_init(void) if (!rbd_obj_request_cache) goto out_err; + rbd_assert(!rbd_copyup_request_cache); + rbd_copyup_request_cache = kmem_cache_create("rbd_copyup_request", + sizeof (struct rbd_copyup_request), + __alignof__(struct rbd_copyup_request), + 0, NULL); + if (!rbd_copyup_request_cache) + goto out_err; + rbd_assert(!rbd_segment_name_cache); rbd_segment_name_cache = kmem_cache_create("rbd_segment_name", CEPH_MAX_OID_NAME_LEN + 1, 1, 0, NULL); @@ -5677,6 +5718,11 @@ out_err: rbd_obj_request_cache = NULL; } + if (rbd_copyup_request_cache) { + kmem_cache_destroy(rbd_copyup_request_cache); + rbd_copyup_request_cache = NULL; + } + kmem_cache_destroy(rbd_img_request_cache); rbd_img_request_cache = NULL; @@ -5693,6 +5739,10 @@ static void rbd_slab_exit(void) kmem_cache_destroy(rbd_obj_request_cache); rbd_obj_request_cache = NULL; + rbd_assert(rbd_copyup_request_cache); + kmem_cache_destroy(rbd_copyup_request_cache); + rbd_copyup_request_cache = NULL; + rbd_assert(rbd_img_request_cache); kmem_cache_destroy(rbd_img_request_cache); rbd_img_request_cache = NULL;