From patchwork Mon Mar 18 09:15:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 10857013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 411CE6C2 for ; Mon, 18 Mar 2019 09:23:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29482292A2 for ; Mon, 18 Mar 2019 09:23:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BF3029249; Mon, 18 Mar 2019 09:23:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D890829249 for ; Mon, 18 Mar 2019 09:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727202AbfCRJW7 (ORCPT ); Mon, 18 Mar 2019 05:22:59 -0400 Received: from m97134.mail.qiye.163.com ([220.181.97.134]:50214 "EHLO m97134.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbfCRJW6 (ORCPT ); Mon, 18 Mar 2019 05:22:58 -0400 Received: from atest-guest.localdomain (unknown [218.94.118.90]) by smtp5 (Coremail) with SMTP id huCowABHr4m4YY9cO8zEAg--.331S14; Mon, 18 Mar 2019 17:15:42 +0800 (CST) From: Dongsheng Yang To: idryomov@gmail.com, jdillama@redhat.com, sage@redhat.com, elder@kernel.org Cc: ceph-devel@vger.kernel.org, Dongsheng Yang Subject: [PATCH v2 12/16] rbd: introduce completion for each img_request Date: Mon, 18 Mar 2019 05:15:30 -0400 Message-Id: <1552900534-29026-13-git-send-email-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1552900534-29026-1-git-send-email-dongsheng.yang@easystack.cn> References: <1552900534-29026-1-git-send-email-dongsheng.yang@easystack.cn> X-CM-TRANSID: huCowABHr4m4YY9cO8zEAg--.331S14 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUdsXrUUUUU X-Originating-IP: [218.94.118.90] X-CM-SenderInfo: 5grqw2pkhqwhp1dqwq5hdv52pwdfyhdfq/1tbihx57eltVf3Z3egAAsS Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we are going to do a sync IO, we need a way to wait a img_request to complete. Example, when we are going to do journal replay, we need to do a sync replaying, and return after img_request completed. Signed-off-by: Dongsheng Yang --- drivers/block/rbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a583c2e..cc0642c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -294,6 +294,8 @@ struct rbd_img_request { u32 obj_request_count; u32 pending_count; + struct completion completion; + struct kref kref; }; @@ -1654,6 +1656,7 @@ static struct rbd_img_request *rbd_img_request_create( if (rbd_dev_parent_get(rbd_dev)) img_request_layered_set(img_request); + init_completion(&img_request->completion); spin_lock_init(&img_request->completion_lock); INIT_LIST_HEAD(&img_request->object_extents); kref_init(&img_request->kref); @@ -2598,6 +2601,7 @@ static void rbd_img_end_request(struct rbd_img_request *img_req) blk_mq_end_request(img_req->rq, errno_to_blk_status(img_req->result)); + complete_all(&img_req->completion); rbd_img_request_put(img_req); }