From patchwork Sat Jun 29 05:04:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11023711 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 AD1F013B1 for ; Sat, 29 Jun 2019 05:05:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6AB728852 for ; Sat, 29 Jun 2019 05:05:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AB0B28842; Sat, 29 Jun 2019 05:05:01 +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 406CD28842 for ; Sat, 29 Jun 2019 05:05:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbfF2FFA (ORCPT ); Sat, 29 Jun 2019 01:05:00 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:31713 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfF2FE7 (ORCPT ); Sat, 29 Jun 2019 01:04:59 -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=1561784710; x=1593320710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lkN9lEpspnIIS0j0TPEkwsMc1UYH09NPUvmC70jV3WQ=; b=gdpejC4P7LYM+UI+AcdJXjYnltVvb2ZCu79CMnj+wy8zS5UIJiQLtgPe F+iQUSEwNKxZrqWSNEVnVnYcLsLi5A05/tHmd/71zbtRN+T/ETgQFzEVf ujoG77zIQR7J181z7A5q0bvhfDhC0njaYkqkXwHtzmVjWvsPC6/7c8/sc iQ811wMz1MZ6bZBqNyChSGxqke6j/MNhTym02PSUEH1hnsuOzQhn+RLCH Jl6jLtbKXxDbIoro0EZgMl5M96pI9DNm11sWIrcNnaufv1NsJMuk4oOfL 4NAAvFBnG+Jg8L0+SOT6qK2x2RGaVnkwsqOSz43plGB+sA7XhSvE+g8Qb A==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="211658292" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 13:05:09 +0800 IronPort-SDR: U1YYRsja2kDK0pxYQ8IivJ5B+UPj93Q62YHhRx1RmT5gNnVqv8IJd8zMdL+U5fOXrhlGye3016 9DnSyMn5VhJu6wFWDFGbLrzAvCygk/ANMP6fsaVX5qY40QYyXKsQGFOZU7pVQ8FzNCLvhD/wVJ 5BVNsTFUI2OSpMTU0fOSB8M8Ox6ToGgXen785WNPPtxzFdL72RKtTISptx3/WPy8AC882EZKTD Edd+NYupO7CWQuw5AQ47J5uRR0a+NJkuEXjimTXdOFvIlnPzRf2lswe9PWg+gJDnWTjai2ANRe YDwHW3Q7pvvCgmoRkNmS5USp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 28 Jun 2019 22:04:03 -0700 IronPort-SDR: zBSfKx6IBq7BipP4+OS/GFDPfLlS5kLtWol3iSqGf8NuLRjOUd2uy7pm+hNKhLPuAMNWRxeMTR UuvxlI6+aLsDuiJZNd+dAGrgY4tv5hRBcvCGaSEePc4lRAK5qyn52sqWVjpIBVB9GDUx6/So73 8n9v6NIpPKUDfz7pr+KW2mMCMgQ2PXEqG+67N30OMlhlEhiXLhN8Wn4LnzHzfgmxEzfMoyP/GT TZZgWla8TZ6bp5wA78zORcnWDvQS8TR0W6b9sPLWDzyfnEKVqLUlb23rz/z76VcDiv4O7ic0Xw c0M= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Jun 2019 22:04:59 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 1/5] null_blk: create a helper for throttling Date: Fri, 28 Jun 2019 22:04:38 -0700 Message-Id: <20190629050442.8459-2-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 throttling code in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk_main.c | 43 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 99328ded60d1..98e2985f57fc 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1133,28 +1133,41 @@ static void null_restart_queue_async(struct nullb *nullb) blk_mq_start_stopped_hw_queues(q, true); } -static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) +static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd) { struct nullb_device *dev = cmd->nq->dev; struct nullb *nullb = dev->nullb; - int err = 0; + blk_status_t sts = BLK_STS_OK; + struct request *rq = cmd->rq; - if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { - struct request *rq = cmd->rq; + if (!test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) + goto out; - if (!hrtimer_active(&nullb->bw_timer)) - hrtimer_restart(&nullb->bw_timer); + if (!hrtimer_active(&nullb->bw_timer)) + hrtimer_restart(&nullb->bw_timer); - if (atomic_long_sub_return(blk_rq_bytes(rq), - &nullb->cur_bytes) < 0) { - null_stop_queue(nullb); - /* race with timer */ - if (atomic_long_read(&nullb->cur_bytes) > 0) - null_restart_queue_async(nullb); - /* requeue request */ - return BLK_STS_DEV_RESOURCE; - } + if (atomic_long_sub_return(blk_rq_bytes(rq), &nullb->cur_bytes) < 0) { + null_stop_queue(nullb); + /* race with timer */ + if (atomic_long_read(&nullb->cur_bytes) > 0) + null_restart_queue_async(nullb); + /* requeue request */ + sts = BLK_STS_DEV_RESOURCE; } +out: + return sts; +} + +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; + + sts = null_handle_throttled(cmd); + if (sts != BLK_STS_OK) + return sts; if (nullb->dev->badblocks.shift != -1) { int bad_sectors; From patchwork Sat Jun 29 05:04:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11023713 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 64F0613B1 for ; Sat, 29 Jun 2019 05:05:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6172128842 for ; Sat, 29 Jun 2019 05:05:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54CEA2886B; Sat, 29 Jun 2019 05:05:08 +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 EECE428842 for ; Sat, 29 Jun 2019 05:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbfF2FFG (ORCPT ); Sat, 29 Jun 2019 01:05:06 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:28723 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfF2FFG (ORCPT ); Sat, 29 Jun 2019 01:05:06 -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=1561784707; x=1593320707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dKnrLUk0qlsHPa3dAslqUoy6mwhm2PBa8f+jbng9EZ8=; b=Jw1L3wZjuhS6wQ/kmczYxwOP5kku+x9TsuJ7De6XbRrENp4OOvDmYZsr HOMVvI4KGyLivjQ0wjAvMqac/f6Gu24ogC4qBoL29eFvHV2tQCiyn7q39 3hQR7QjibU40HhfMOCiNpvziA/c9/votCEoWawSqDl5QiJefWa6O7L+94 QE4aH9uv6K4/jYTSlWgOmq6S8noWrtiherqv7w2TYfpZMitALyVzX5mjR YgO+g1XeUKnst5dBHzojj+QTnJ5LD8WnEZkTDrgmcQA8nYHr5JRULRbWC 6tUuZCyhjin2o7ftCKT4Mcv6rUKEeS3EShqyOVBwlD90iRzAcQ6BE4Osf g==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="116692880" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 13:05:07 +0800 IronPort-SDR: OYJvJPZqEJfaVbA4lHcnucsQ5WuQANUE8Chc4goztG7PYj4OFmSOq8qTPKA5G1x7yrC7qmhETN q6akFCMBUM4nR2JTdYdpCzxxbD1bZjDLOVUCu0g4j9JyRK+1RW4yG6fnsSIXlaN0HC57tF34u6 4OIVj1ORz/56hzeIN0G+Bfg6ccMQlLD9KNXS34fOEhmyGzn6RjJxx5Ku7hJRKUHeFxPwCCt85R +B9zGZ8qk1FXzfaBoXTdeBjkN+tlXJaufnUH5ptVKg/G5dAMg5wLPlk2rsola8hN2nqp16waCz YYF8++/Peu8R5huOXLzr3xEY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 28 Jun 2019 22:04:17 -0700 IronPort-SDR: /eyZmEKjs/LAwwA9mZMK02+BwAiAMp0qJvCVdStdoyPRVsSL4/5uMccK34llRm1wJGTSLw99kd 5yQgmoY3k+ZeIjsDbGtFqB308lH9eUXNYQb4u18DyrUFRMxJPKeAfjjcXE2EZAQV6qq2tFMGVI y0PuhDBduv1yMjVxkfKclJTwmmSLCKlyjunN3XDHXjxrQfFyY3HVfZOxon8IgqGqlbd26nlWpV Kcw/OTUFBaafYVRkJr2GOjxeLsiwtubAexprQJVK4ECjiwV5AbxerD5Y8VlYQ/pCYbl8jyBG+X qm8= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Jun 2019 22:05:05 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 2/5] null_blk: create a helper for badblocks Date: Fri, 28 Jun 2019 22:04:39 -0700 Message-Id: <20190629050442.8459-3-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 badblocks code in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk_main.c | 62 ++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 98e2985f57fc..80c30bcf024f 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1158,6 +1158,42 @@ static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd) return sts; } +static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd) +{ + struct nullb_device *dev = cmd->nq->dev; + struct badblocks *bb = &dev->badblocks; + sector_t sector, size, first_bad; + blk_status_t sts = BLK_STS_OK; + bool is_flush = true; + int bad_sectors; + + if (dev->nullb->dev->badblocks.shift == -1) + goto out; + + if (dev->queue_mode == NULL_Q_BIO && + bio_op(cmd->bio) != REQ_OP_FLUSH) { + is_flush = false; + sector = cmd->bio->bi_iter.bi_sector; + size = bio_sectors(cmd->bio); + } + if (dev->queue_mode != NULL_Q_BIO && + req_op(cmd->rq) != REQ_OP_FLUSH) { + is_flush = false; + sector = blk_rq_pos(cmd->rq); + size = blk_rq_sectors(cmd->rq); + } + + if (is_flush) + goto out; + + if (badblocks_check(bb, sector, size, &first_bad, &bad_sectors)) { + cmd->error = BLK_STS_IOERR; + sts = BLK_STS_IOERR; + } +out: + return sts; +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) { struct nullb_device *dev = cmd->nq->dev; @@ -1169,29 +1205,9 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) if (sts != BLK_STS_OK) return sts; - if (nullb->dev->badblocks.shift != -1) { - int bad_sectors; - sector_t sector, size, first_bad; - bool is_flush = true; - - if (dev->queue_mode == NULL_Q_BIO && - bio_op(cmd->bio) != REQ_OP_FLUSH) { - is_flush = false; - sector = cmd->bio->bi_iter.bi_sector; - size = bio_sectors(cmd->bio); - } - if (dev->queue_mode != NULL_Q_BIO && - req_op(cmd->rq) != REQ_OP_FLUSH) { - is_flush = false; - sector = blk_rq_pos(cmd->rq); - size = blk_rq_sectors(cmd->rq); - } - if (!is_flush && badblocks_check(&nullb->dev->badblocks, sector, - size, &first_bad, &bad_sectors)) { - cmd->error = BLK_STS_IOERR; - goto out; - } - } + sts = null_handle_badblocks(cmd); + if (sts != BLK_STS_OK) + goto out; if (dev->memory_backed) { if (dev->queue_mode == NULL_Q_BIO) { 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) { From patchwork Sat Jun 29 05:04:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11023717 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 8F57C14C0 for ; Sat, 29 Jun 2019 05:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ADA028821 for ; Sat, 29 Jun 2019 05:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C6BE2886B; Sat, 29 Jun 2019 05:05:25 +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 E9E1E28842 for ; Sat, 29 Jun 2019 05:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbfF2FFY (ORCPT ); Sat, 29 Jun 2019 01:05:24 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:27331 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfF2FFY (ORCPT ); Sat, 29 Jun 2019 01:05:24 -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=1561784723; x=1593320723; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tlBpfcAVxnlFlUQlVXVVs5RLfQ4mFtw2mZWOifeqQlA=; b=cMR/AXa3mn9Vx6jYRPFO50CQPvd80Iq0xKvFnFhZuGixm/+30mYyv9TZ 4ZKkRpeQE/w4dbTPMPLXvmPZe66xE9h1KFbyKuY6uPN70+bl37J3frYZN rLZ4+psnMuJtKZXu0yHhWskH7a7vW6nkRESsRA9BKepxJuuKquzGTgaxy NDC+N64gy7f5YynqZ+9ccXsdloVsHoD4PeQQSPJOI/PRrNWwiWZ6o8RU0 IS35rm1daGgSUbl8PtKfaSUv5Y+GCgqc+VE4/Fzwxkx5OgDx6wVObfl8n PtFJAOdoiYbn+OJcSb+hN/O2HZyf91xazSdMELpzqBHwMb4trGC1V9g8u A==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="111829943" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 13:05:23 +0800 IronPort-SDR: AM0tCepizJMI97F5LqtVaQHOrJMvOftxoZxrxmh97/BELkwZRSQP9TjQZeAzZfLnyul5KlEy2+ wp6eVA+/+13FVitul6qetpdonyfHpKuUBkjRRaM8ATRdF9bT5nqeZshqVIRgJXFgT2fXHrxTwg qM3UOAm8pdCf/6hCelg7FzjRriN5KiF9xo+uQd3j2pTPrhGeTsAS9dtprRMzniA5uDtgsP70lP mOEVe4EzyIwT41lZ13UVab51eIc4ljnz47zbPwSTin89P81+pixVK+pCBqOXFpqXD5ylvwWi6c 3VHiYED9lFxGX2FaGxIY83lg Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 28 Jun 2019 22:04:27 -0700 IronPort-SDR: R7ahFVZ5knu/3A8Xwx0p7B1Wq9O4XRwNGCrhN7tL8RVkzh32v+rz9HExKtZwsVTROZzQOfh3Jw f1zWk4xhAJtvm4XSXKXd8w5VW+9a+sHe1kacqNjRO6YUpUx/166YmMc2B59fLGVVeuPP/xllRz JYOlJVofZe8etTZGURfeuXCGIGZHKh+12FtNQGnNeC9RnaWKEBX3rB4cvjFx9+10pgOBem3pud U4gd32Gc04EyTxmwCRIaPNpVBn0FwrnQT+wPmBmKks8SMiD8DO4ObVYy9P9yhgVzPg6p2ldQo6 Yq4= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Jun 2019 22:05:22 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 4/5] null_blk: create a helper for zoned devices Date: Fri, 28 Jun 2019 22:04:41 -0700 Message-Id: <20190629050442.8459-5-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 function for handling zoned block device operations. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk_main.c | 50 +++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index e75d187c7393..824392681a28 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1214,6 +1214,34 @@ static inline int nullb_handle_memory_backed(struct nullb_cmd *cmd) return null_handle_rq(cmd); } +static inline void nullb_handle_zoned(struct nullb_cmd *cmd) +{ + unsigned int nr_sectors; + sector_t sector; + req_opf op; + + if (cmd->nq->dev->queue_mode == NULL_Q_BIO) { + op = bio_op(cmd->bio); + sector = cmd->bio->bi_iter.bi_sector; + nr_sectors = cmd->bio->bi_iter.bi_size >> 9; + } else { + op = req_op(cmd->rq); + sector = blk_rq_pos(cmd->rq); + nr_sectors = blk_rq_sectors(cmd->rq); + } + + switch ((op)) { + case REQ_OP_WRITE: + null_zone_write(cmd, sector, nr_sectors); + break; + case REQ_OP_ZONE_RESET: + null_zone_reset(cmd, sector); + break; + default: + break; + } +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) { struct nullb_device *dev = cmd->nq->dev; @@ -1231,26 +1259,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) err = nullb_handle_memory_backed(cmd); cmd->error = errno_to_blk_status(err); - if (!cmd->error && dev->zoned) { - sector_t sector; - unsigned int nr_sectors; - enum req_opf op; - - if (dev->queue_mode == NULL_Q_BIO) { - op = bio_op(cmd->bio); - sector = cmd->bio->bi_iter.bi_sector; - nr_sectors = cmd->bio->bi_iter.bi_size >> 9; - } else { - op = req_op(cmd->rq); - sector = blk_rq_pos(cmd->rq); - nr_sectors = blk_rq_sectors(cmd->rq); - } - - if (op == REQ_OP_WRITE) - null_zone_write(cmd, sector, nr_sectors); - else if (op == REQ_OP_ZONE_RESET) - null_zone_reset(cmd, sector); - } + if (!cmd->error && dev->zoned) + nullb_handle_zoned(cmd); out: /* Complete IO by inline, softirq or timer */ switch (dev->irqmode) { From patchwork Sat Jun 29 05:04:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11023719 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 45F7614C0 for ; Sat, 29 Jun 2019 05:05:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3588928685 for ; Sat, 29 Jun 2019 05:05:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26F00286B3; Sat, 29 Jun 2019 05:05:44 +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 BC74528685 for ; Sat, 29 Jun 2019 05:05:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbfF2FFn (ORCPT ); Sat, 29 Jun 2019 01:05:43 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:18799 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfF2FFn (ORCPT ); Sat, 29 Jun 2019 01:05:43 -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=1561784742; x=1593320742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rPijYuJVtPOfdrCqQnG8pzfi1badlCEPEZ8dbgwaWGY=; b=PP5+ykFAKxKT/tKH5M7G0k89Yxa5vAxrENRAgRZ3AM0TM1SYU+E6SNwE L2ESh+06G4qkWhb/GbKShIqLpC6V/hDHOqZbFKDs7OSMk9w7jE4SH0DDH fuMrKv+5iGijX2QNtabc1FviiD4wc05vK6O3M3duTj/NGah5PWdCBAE4+ c8EL7JPk1KQVzQmu9MFMgwQpuNV/cXpBLagEjEhQ5TjD/Ijqz7YBsOkqp F4UkXVsquZDqk4Ff7u8Xqwx2YVzup0TQq1zi1H90/H6Fm/vb1wU8bzv9P qDJodH1vxqiof817mFfT9z/NjuJKftkIF9WkIHTmsX8rO6SZKDhEnVLvp Q==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="218207938" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 13:05:30 +0800 IronPort-SDR: t0/mitBA9aNwbjO6QRVMlXIjiie1AkRJY+QTzOT3fSznm/L/oHkWOz2cAZJa4YtHAxfS/uXIuJ OhMvwu31l+Sk1Q11IAgoVq1FM+cCaqqcX9hfDP9wQldU9wSjhNS1ctz83Q1uBy4D2a6iqiJy91 IZThpg13woxRyxLO++vZNEYh0CsTH3RkUpWYEHdplvgAjyVz+0ZbwIEcScFvRRwLgdtM5s9Z5X 4/76RdFeMDwE+1tklhq5USHiwhVegk4bs9TvrFJJgSf59D0GjnfjzHnHXCsOpi9NlaiEQGAEw0 8eornvr9CJne0lEDldzEmHbp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 28 Jun 2019 22:04:35 -0700 IronPort-SDR: vFT+fLEoUW25vnBwiKXucvlwq9vBc7fpfoMI5KvTUDBNv0y5Pq0xWs8I7SHoyWsZUGpN5J27Xa KAN0HNjNQurHEVX8bUXR86rwMelj7zEVX8eRAOStk7WWP1DpIC2zdh9FTSGoKFz1VXFZ/7ftQC AfmdGcup/ljsXakt9/sBa3PKX7TIwO7oaK985+/iOc64lMvj8824ofnVc0z6KIWsUfLo85GRXt ewgKmJPv/h80FsU91VefrI8jtazqrLtheSGO+qZa8ckCgp7mZ4EINa8KYJNtrdM11NweO+s6Ac cik= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Jun 2019 22:05:30 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 5/5] null_blk: create a helper for req completion Date: Fri, 28 Jun 2019 22:04:42 -0700 Message-Id: <20190629050442.8459-6-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 function for handling the request completion in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 824392681a28..c5343d514c66 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1242,30 +1242,12 @@ static inline void nullb_handle_zoned(struct nullb_cmd *cmd) } } -static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) +static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd) { - struct nullb_device *dev = cmd->nq->dev; - blk_status_t sts; - int err = 0; - - sts = null_handle_throttled(cmd); - if (sts != BLK_STS_OK) - return sts; - - sts = null_handle_badblocks(cmd); - if (sts != BLK_STS_OK) - goto out; - - err = nullb_handle_memory_backed(cmd); - cmd->error = errno_to_blk_status(err); - - if (!cmd->error && dev->zoned) - nullb_handle_zoned(cmd); -out: /* Complete IO by inline, softirq or timer */ - switch (dev->irqmode) { + switch (cmd->nq->dev->irqmode) { case NULL_IRQ_SOFTIRQ: - switch (dev->queue_mode) { + switch (cmd->nq->dev->queue_mode) { case NULL_Q_MQ: blk_mq_complete_request(cmd->rq); break; @@ -1284,6 +1266,29 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) null_cmd_end_timer(cmd); break; } +} + +static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) +{ + struct nullb_device *dev = cmd->nq->dev; + blk_status_t sts; + int err = 0; + + sts = null_handle_throttled(cmd); + if (sts != BLK_STS_OK) + return sts; + + sts = null_handle_badblocks(cmd); + if (sts != BLK_STS_OK) + goto out; + + err = nullb_handle_memory_backed(cmd); + cmd->error = errno_to_blk_status(err); + + if (!cmd->error && dev->zoned) + nullb_handle_zoned(cmd); +out: + nullb_handle_cmd_completion(cmd); return BLK_STS_OK; }