From patchwork Sat Jun 29 05:04:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11023715 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 B9E3813B1 for ; Sat, 29 Jun 2019 05:05:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B371628842 for ; Sat, 29 Jun 2019 05:05:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7B7F2886B; Sat, 29 Jun 2019 05:05:17 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 4558328842 for ; Sat, 29 Jun 2019 05:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbfF2FFQ (ORCPT ); Sat, 29 Jun 2019 01:05:16 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:44385 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfF2FFQ (ORCPT ); Sat, 29 Jun 2019 01:05:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561784716; x=1593320716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8beiedFNEl66Grrik8fsXyOBB6jB+54HNF4jxVfcR8o=; b=f41KO5FpeebOqQ/UzWA4W53AESx/UqSk3afSi6gg2d6aGjrfjimQcsUs rv06JMomFSyYRKya/fgQofclUl07UhF8ltyR5lvPxiPfOZAO39Tel2AtJ MSc4PvAjskqx5NNlTTrcy4zl0bGIQ4Z+uXZI3fEj61mvPOO4lGunXJe1I 3FUHtQjQeu7aM/fEmh3nmwYrK/pgs6zDwV3NPSQn+qvoilYTGLHig6Kx5 GpQ1iutsSui4nPxqkaoIedHUktwPzv/QzqaSRU0ASPWR4ODbEEKWDpDB6 X9f1C74fr7r8GDbAPlQCdLSpZI0O9+Z+UwTa8W/3yD5S8ZC4KqqqWPezT w==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="113462922" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 13:05:16 +0800 IronPort-SDR: 4T2sc0xPQigzQij+9rP4BiCR/IX2FO6BwfhW+IyPcHko3GOVuCAeqXVVP4enzYnzXoI4Z42jKF 471ovHQX+xlUTdipWn6iR9ACEHBws706YJuNl7nckd9JT8Gei0U/N0jhYgDNQ25Z4GIYVV/aky gq3Esxrk6l5/ABLbUcGSEmSrQwt9Lg/PZPqXfrSkjEhPmVg+J9+Ha2N438Vr8h6ydT+wve1ree E3Tl3Mz3Ltrpn/O6J92S9m8LBoD7UEgFXsDEg/7qVktiUq2FKmpRr6mLBCOW+jsso3KWuuhU/h ZQ21eoFn/k/YG0uDmhHUAPEg Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 28 Jun 2019 22:04:26 -0700 IronPort-SDR: 7RHhqmj8iahaaEtvxRBSUSDL10h/BGd9hUqFnuCwOfmxQ7zUXedxKtZSA0ueFo0h/On/h4VgzQ OVXCYbjWl+eKatfXf/JRRS4TsfqwLoJrbAacE9YLl69z28HWlsb9khlKVKlvAYAnKca1fwlCMk Sz0R6GjEVFI8X7ijHBfS229YbwmNrNly1lFH5nPpvnfI/oFnsSCRyImbe+XaQc5mGzVQ/nH3uO NUKHo3QxQw9TUAx++BSEliRqL2pEi7gyUUIUTLsQrvccKS4BVKg1oaioOO1jVLdL45xp2OV0CK oVA= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Jun 2019 22:05:15 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 3/5] null_blk: create a helper for mem-backed ops Date: Fri, 28 Jun 2019 22:04:40 -0700 Message-Id: <20190629050442.8459-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190629050442.8459-1-chaitanya.kulkarni@wdc.com> References: <20190629050442.8459-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a helper for handling requests when null_blk is memory backed in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk_main.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 80c30bcf024f..e75d187c7393 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1194,10 +1194,29 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd) return sts; } +static inline int nullb_handle_memory_backed(struct nullb_cmd *cmd) +{ + struct nullb_device *dev = cmd->nq->dev; + + if (!dev->memory_backed) + return 0; + + if (dev->queue_mode == NULL_Q_BIO) { + if (bio_op(cmd->bio) == REQ_OP_FLUSH) + return null_handle_flush(dev->nullb); + + return null_handle_bio(cmd); + } + + if (req_op(cmd->rq) == REQ_OP_FLUSH) + return null_handle_flush(dev->nullb); + + return null_handle_rq(cmd); +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) { struct nullb_device *dev = cmd->nq->dev; - struct nullb *nullb = dev->nullb; blk_status_t sts; int err = 0; @@ -1209,19 +1228,7 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) if (sts != BLK_STS_OK) goto out; - if (dev->memory_backed) { - if (dev->queue_mode == NULL_Q_BIO) { - if (bio_op(cmd->bio) == REQ_OP_FLUSH) - err = null_handle_flush(nullb); - else - err = null_handle_bio(cmd); - } else { - if (req_op(cmd->rq) == REQ_OP_FLUSH) - err = null_handle_flush(nullb); - else - err = null_handle_rq(cmd); - } - } + err = nullb_handle_memory_backed(cmd); cmd->error = errno_to_blk_status(err); if (!cmd->error && dev->zoned) {