From patchwork Wed Aug 21 06:13:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1D15112C for ; Wed, 21 Aug 2019 06:13:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9FE722339F for ; Wed, 21 Aug 2019 06:13:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="gctFSIuB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbfHUGN1 (ORCPT ); Wed, 21 Aug 2019 02:13:27 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:37532 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGN1 (ORCPT ); Wed, 21 Aug 2019 02:13:27 -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=1566368006; x=1597904006; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=03o5Ng+xLElrc3iL8uEV730C8Y98WKwHciPKKrtiuA0=; b=gctFSIuBdMojo9Mt5/Rr+xi1Lu0r7NoBJANKHYDBsmomcaxztlPaXGYq 2AzWYiukl7fvT1C3VnGN/RskV4fn9fiLebhZpjLlNH63KdpSUWHQPmz2J yiqZLJR94Yx2QurlwqzC8ZdUWWAZiKntLyGmSxOjVKw12G37LsjL55ELA kUwblmZxKBAcCw3xldLC5/6ZM61UGlBW26Vp8f4Avu8ilgJ0FHzKR21RN A+n0r++06jMzqcjZtmHgX3BmkGpmI8NScnehXkj7st8sUwGbGqYQahp8j CFvr8yNbAIaNWr+hdSuw404je36iIHrV4RU00PMTYTC9jh5yg1SNLpJB0 g==; IronPort-SDR: Qdu6kWfD6AvkRlOLxLBpR8RCcSooKkLAXee0b00MbkGs9iAeWZN2/4EO7xHewFfjpizGLWz7Tz LH0cCmIv5SoO65m+P868HXDetbQo1eXA+3gC5H24e0sEZJHKkPIWPA6EpcDJnw8W2U+Tj56Pzq hNZRT+vakAgzE0jDMbQI2P9cQYKE6fdtljp6YL2NpgwbhB/gL3sgzbXOQ42NvNNFvw6zwsxNrf ki4ivD+gA0SxDZsOfy/tnQlZaG9k3RLgKxnfwQoU9fGLMt1FnuhTVEa34x6negkP7k0/UlMk1m Iik= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="117239008" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2019 14:13:26 +0800 IronPort-SDR: v1yGivytG2wosMqBNaCeYKwH+ldOEASbXnQyR5UD92a7CM3wsJYjkYlGeSHvqPAAZvk2RhGRmV pXAT77iNJPbJo6JnDkc+4l2R/cs5MMM7X5XrVp91GzwEIuQFG2IdGXmXHoT59D8q9mUaqw+LNn HfPz5262aJWw7FKkVd/jEmFl9cKsejSyry7f2pNVjNuFvBgD7BGCLOKus3XHheGiWC/JyGMcI6 4oONAKYvePXjdwQ8EOdXBH7GciWbTnbn6Acmp1wCg9W/6WCsJ+8nPCE0L7Efy/KRFZogbaaozj 2zL29smRKfc9p59kL2jaWCJl Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:10:47 -0700 IronPort-SDR: hgNCWtTKckibskIcPYYNxXQ3yaKCvMXNvW4Sj9aEGE+eyylBJUQTgZj2Omq1b6PFyXWTcXLVu0 AjFcwYprJFJjCDC8HltSdmiedeHFRYh8UOcC6UjwUziNO5G6c8pRKjsPpVH4K+Bx52Me7HD/hb US/Lnf/ahI9SSxiUkwVozYBoOzQn5EF820nHzYdds6Js9oIZJjYlTsCYf/9z9jjFq2zas6Pcww dNooWacDZz6zVD2mw8QZVRP6vNGKzPQhM0D/NAXkDu6Aot+eNvImDDN1y3JUVIflRv6v0J9oFt 5Io= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:25 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 1/6] null_blk: move duplicate code to callers Date: Tue, 20 Aug 2019 23:13:09 -0700 Message-Id: <20190821061314.3262-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This is a preparation patch which moves the duplicate code for sectors and nr_sectors calculations for bio vs request mode into their respective callers (null_queue_bio(), null_qeueue_req()). Now the core function only deals with the respective actions and commands instead of having to calculte the bio vs req operations and different sector related variables. We also move the flush command handling at the top which significantly simplifies the rest of the code. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 66 +++++++++++------------------------ 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 99c56d72ff78..7277f2db8ec9 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1133,7 +1133,8 @@ 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 blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, + sector_t nr_sectors, enum req_opf op) { struct nullb_device *dev = cmd->nq->dev; struct nullb *nullb = dev->nullb; @@ -1156,60 +1157,31 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) } } + if (op == REQ_OP_FLUSH) { + cmd->error = errno_to_blk_status(null_handle_flush(nullb)); + goto out; + } 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)) { + sector_t first_bad; + + if (badblocks_check(&nullb->dev->badblocks, sector, nr_sectors, + &first_bad, &bad_sectors)) { cmd->error = BLK_STS_IOERR; 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); - } + if (dev->queue_mode == NULL_Q_BIO) + err = null_handle_bio(cmd); + else + err = null_handle_rq(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) @@ -1282,6 +1254,8 @@ static struct nullb_queue *nullb_to_queue(struct nullb *nullb) static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio) { + sector_t sector = bio->bi_iter.bi_sector; + sector_t nr_sectors = bio_sectors(bio); struct nullb *nullb = q->queuedata; struct nullb_queue *nq = nullb_to_queue(nullb); struct nullb_cmd *cmd; @@ -1289,7 +1263,7 @@ static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio) cmd = alloc_cmd(nq, 1); cmd->bio = bio; - null_handle_cmd(cmd); + null_handle_cmd(cmd, sector, nr_sectors, bio_op(bio)); return BLK_QC_T_NONE; } @@ -1323,6 +1297,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, { struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq); struct nullb_queue *nq = hctx->driver_data; + sector_t nr_sectors = blk_rq_sectors(bd->rq); + sector_t sector = blk_rq_pos(bd->rq); might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING); @@ -1351,7 +1327,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, if (should_timeout_request(bd->rq)) return BLK_STS_OK; - return null_handle_cmd(cmd); + return null_handle_cmd(cmd, sector, nr_sectors, req_op(bd->rq)); } static const struct blk_mq_ops null_mq_ops = { From patchwork Wed Aug 21 06:13:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82B1E112C for ; Wed, 21 Aug 2019 06:13:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 619EB2339E for ; Wed, 21 Aug 2019 06:13:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="qEXCGhyz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727642AbfHUGNf (ORCPT ); Wed, 21 Aug 2019 02:13:35 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:49419 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGNe (ORCPT ); Wed, 21 Aug 2019 02:13:34 -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=1566368014; x=1597904014; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=TUb7VQETiYuhnpK2IfbU0g9qfGEQPnwxmGRJkLzjW50=; b=qEXCGhyzWWwOL/7yQwRpNbfNyAVrK0Ue2ijo9Lxgbp5c2tYCfV6L4T9m haaeXGgf5nY+y4gAbufKO9UmVSKS8HEnxxGv1Uxdtlo2RXl3fQLjNYUxN d/YHBKJXEUbKNjv4XsX9X9JGs14OxibCGXpIFu7EZFpauOtoh4ZizHgsk hXcBqgOg9X4BQ0L44yW6AeClZF76PTI9rvX/PtkZJXVlbFG9JvDhev578 ncokeoy4PxUlY0B4QH76yxc4zXMzLy2PjJZpcjh9dJ1PGX7sB1b5WT3MP PaMjmvTa44HRhmpQm0iqsxp7hJXiOU8GjOT/dKPYXD5eYPZ3Hk5VwHHIN g==; IronPort-SDR: PxjOdCWwVHl/9qYKP49FwMejSuMmRX2NSfNQEGZO1aaZ5jQ4svd2i31KLTVXm8xhQ0HpKnUpcK i//qBpR7akcFj36N5En/ZuiAqBlr87Ln8UadbVQbzEFLOgIsFFohv2TXhvmJnsVk3dcHVYWP8Q p2N38EKL77Z1R8MuPDOOUepryH49W5TAkBbQOGo0it2vZK+f0La1MhjFtCA8hXAvsOXMLNDRQ8 00eNajHD7tm4SythMonO4mHe8YcspgAYA0g/bv5ndBKf0MGPTagL2jQqA1UuJnCKK/+8G7O+5H l/w= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="116306211" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2019 14:13:34 +0800 IronPort-SDR: dL67fke1T2EHTeY2Vx2PDh4Z15NBTVL+wojnIcG6DYELiJcvlu21xcn4ndI8Lz3u4ppJ/dT3W0 E4tHhQnMZIyE04JtKOI4OZExZGNjXG6tgD9g2jKPWcIupxdWLA1U8WVLdL+Ej8+Y6gN1sgg0XY HS/evS1WKMQhEKGLz+XhmkZH2BLuzxMwwyQmoPNe7CTbdnZ0m5xUAHsikRj3XGmobiwp+/goQF OrX0XAY2fLXcDk0W+lnd1FLJdm8VzcAg1K/94WFHeUagxaWeso8jC2scpoQ0YvQjqMy+puup5P LAhfvpt01Xdeu4j6sTbIr+a+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:10:55 -0700 IronPort-SDR: k36J9yY30MlKBu+3U9vLiGmRUhBqX9KrLFRxiL2k+9bSVnGEepuEdzvru8Wpl9ZExk9SjMKPYG +3X6WmxDx0T8W+prokX1j4k1rEBnpi8ZVXB6dedxWCmKHbvaH4Ojhbt+ObFyfz0ulyQUINbAzX K0E2lxsYLR9P5JZGeGNg3EbzxhteM/5WPOYw0pKgGf9k/PZj0Qda1KWqoTfc3g2hlK+jrkAgp1 tbcz3nQDuB+vmLM+s2XJYXRDOyGWwpAT3xswmzky3uWhcksKIDhKKwdkNGhShzLWQe3rW+Odf5 3+o= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:34 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 2/6] null_blk: create a helper for throttling Date: Tue, 20 Aug 2019 23:13:10 -0700 Message-Id: <20190821061314.3262-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch creates a helper for handling throttling code in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 39 ++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 7277f2db8ec9..751679fadc9d 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1133,28 +1133,39 @@ static void null_restart_queue_async(struct nullb *nullb) blk_mq_start_stopped_hw_queues(q, true); } +static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd) +{ + struct nullb_device *dev = cmd->nq->dev; + struct nullb *nullb = dev->nullb; + blk_status_t sts = BLK_STS_OK; + struct request *rq = cmd->rq; + + 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 */ + sts = BLK_STS_DEV_RESOURCE; + } + return sts; +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, sector_t nr_sectors, enum req_opf op) { struct nullb_device *dev = cmd->nq->dev; struct nullb *nullb = dev->nullb; + blk_status_t sts; int err = 0; if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { - struct request *rq = cmd->rq; - - 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; - } + sts = null_handle_throttled(cmd); + if (sts != BLK_STS_OK) + return sts; } if (op == REQ_OP_FLUSH) { From patchwork Wed Aug 21 06:13:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 066CE112C for ; Wed, 21 Aug 2019 06:13:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9EE02339F for ; Wed, 21 Aug 2019 06:13:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="l18GxUaQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbfHUGNm (ORCPT ); Wed, 21 Aug 2019 02:13:42 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:45737 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGNm (ORCPT ); Wed, 21 Aug 2019 02:13:42 -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=1566368021; x=1597904021; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QKl1WwrouL89tniEOxclQ9nFN5eD/4jUwLTCVUmL8qw=; b=l18GxUaQhFJ0TNtmy1VKozmW+ePiwR6cq92kMnQRTPvkUUZ8hBqA7w2u +Vipsc6q1dDpZXu7OYvXOZSRlMfnoXxpNixAMNjmY0kp6xUst8diStQS3 OUAQY1lLZZs7hjxxgwSi74Tcrz302A7CGuDcHHumuhqjLbp7BskOKBSLZ 64D41S8MRQTTlrQtosY/uBbpvqKFQsHfSFdLZCgknFH2jh7Ct/hlTp0Xh akNxXNJFFpVxooHjpsMngsG2W3cSx4u0c/YZN+UHYHhzLHS5cj0MzrBN1 uzvd0+s9Q8vE+LqE56iqpucLSUDiqD79TN84bG+QbDr5yoPJp5XDA0HJc A==; IronPort-SDR: Mn+tZsm9Gq5wslXPvJ565bLXkbhS/B7LZ/dfKX1d5ClT1ZVFDcoVw8pPx8ue03QCaqhZzolKL5 NBrW0RLQgGdUp9nHrEZFmj4z8XX7/vVGer6jFUMak1pEE53Xej3vofGdJj1Y758Uto548BmMhX satGUi6nDxb9F8VnSJu6e9Rlg4hNQvRzx218s71XSuT0OQwQs5yc/St3llk5mhayZlJU1bbRUw FVc9zatGjyw1DbRAwEk/6FZvLi1CVnmDgsEzxjDXobUPMX2YhAJeHVpQr4seIjcDsGIyJIgkvg fMM= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="120898297" 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; 21 Aug 2019 14:13:41 +0800 IronPort-SDR: 8IAG1ql0clkBrPEKU2JlVmGaOAIR4nBfHu7USNN5AdFm+qzIIZyPSK0jYn2pAdAzgxNnClsIq0 33JKkbOyjEIdgAI5FViLyzpxfAvg7KrQWa1ul+SlvY1HwKHHfxejWoRtJzDVU3zgb1KGW7HruF x8bP+/74S68GA9PU+cYcUtTAkBbXEH+wyjcpjN4ej7aSq0cV+dR3pHOxWksE+wYck9FUazjPNn zV8qBBcvhF5h4tX2uzteZpGOB6iHXdp7Fa9NjYXJTrft6gwy5cdbdiNyJ2NZ0uOC3Qno8hJj0q aNLdvEmRc5Sry3OG4ZNlMQU4 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:11:02 -0700 IronPort-SDR: wdOTENdpg6bLasCT6hpMb/JCHR1J31DjyfgZJAPwSL6nxST5sNzHt/oncdZQIzHN14z4T3h++z 23A7rPC51/7eMmGjEc0YWEIBT17QQKY/swcptFxcBWM2bHZzi4WUsY/gMhkHyt3gfd3BjO63/7 UayGTjxZTJMu2a0y8fXMBJuVXriMj4BfSWNUV22fjlZ9o/nnzr4Zsv9ts1NEAkHh/H9Jt86Fqr Is5Db0g6T2/gkvqstbehzi6nCJwNCw81ZCrGR+gAlTcXPQ7NBnRu23WNCWfB5GyRD5tI6zjWLf 3iw= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:41 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 3/6] null_blk: create a helper for badblocks Date: Tue, 20 Aug 2019 23:13:11 -0700 Message-Id: <20190821061314.3262-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch creates a helper for handling badblocks code in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 751679fadc9d..eefaea1aaa45 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1154,6 +1154,20 @@ 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, + sector_t sector, + sector_t nr_sectors) +{ + struct badblocks *bb = &cmd->nq->dev->badblocks; + sector_t first_bad; + int bad_sectors; + + if (badblocks_check(bb, sector, nr_sectors, &first_bad, &bad_sectors)) + return BLK_STS_IOERR; + + return BLK_STS_OK; +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, sector_t nr_sectors, enum req_opf op) { @@ -1172,15 +1186,11 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, cmd->error = errno_to_blk_status(null_handle_flush(nullb)); goto out; } - if (nullb->dev->badblocks.shift != -1) { - int bad_sectors; - sector_t first_bad; - if (badblocks_check(&nullb->dev->badblocks, sector, nr_sectors, - &first_bad, &bad_sectors)) { - cmd->error = BLK_STS_IOERR; + if (nullb->dev->badblocks.shift != -1) { + cmd->error = null_handle_badblocks(cmd, sector, nr_sectors); + if (cmd->error != BLK_STS_OK) goto out; - } } if (dev->memory_backed) { From patchwork Wed Aug 21 06:13:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BE7214F7 for ; Wed, 21 Aug 2019 06:13:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 791BF2339E for ; Wed, 21 Aug 2019 06:13:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="cqCfIFZi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727716AbfHUGNs (ORCPT ); Wed, 21 Aug 2019 02:13:48 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34430 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGNr (ORCPT ); Wed, 21 Aug 2019 02:13:47 -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=1566368027; x=1597904027; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=DU4k6VI5I7oPvhvZ5H9K91YXdlSPmCDk4v0vyPEDUU4=; b=cqCfIFZi+1vycb9oOcXpRGz6oypilVzf8mORjHIMCExlHKYm91k0iLT3 VyzXYaCHZexMq+tW5+wIejQ9AuFDt9uy32g0jmwx3xXo9ccmIke3Apw86 kR3d68dK/qYj6l7XSncL0W2ZeIoI81paYiK1YlErqK5YZM+hN6p18UI29 vDimGR7RxBeO0TKO0wRVstKjeURohwmHvkfHIDC+sp7Y9TKuFW9NL7KkD BZFhcY+8l5saHW7PiUWzUYM/gLXrp/BhPtnDNurt1ExrfYK6Rfov18gFX GEm0aJU2EeGfc9a6muitfPGPH/5rlzdI/Tlh+hSVXh4GKe6TfQTzohaW8 w==; IronPort-SDR: 9g6UQxs/HZrSA2wGK2OBn4luSvvD4qHOodowsrcj1slpqZJjFxJJuMgrngGBnBC1MgqY9y8nsb qnAm2lAEfm3UM8PBisRBq3nezzx92rs2Xqu0+pLcqu3AQn34cP7lYV8nINTsLPnHB/5hEmzJxP H5WYefafev76kuB9FbUe3mMHSFTdGoLIXqGNrPvhA6EreUVAycrmkCXWONnkkcRivkOCQ2J0Tx gDt/dlNk1WlEs4V9bMxiddwxUbHHMYuR4HTBv+br3zYoS8JrXXBCXkZZy4aRM8tG0a8WJvDmgw HI4= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="117904606" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2019 14:13:47 +0800 IronPort-SDR: QO7bya6mDTBAjzzs2k2qafBTHWIWH62BJHwkwMaK4dG5dqzKKvxc12BnH1chL9J9cwAk9c6Yw2 ydY69R+tfSGgYuktnHTu8gNgumb/N3eV+vwJAhDHx9vuicHw0QIyWda1Fi81PYehu84htk5cYV XXOaMsfdzRT9L7lPCKVslRgMWgp+qvf7smLQWL6FKIoRserMJ21NNtrSFL5t54V2MEEd/NtTt4 wJ1+NCFPK2QkEc1S66emZIsWWVJG4zZ6LaDOeNDJYrCLSoKQdLGEkFTdkZOdKNOGjwqxWHf3w7 o6gvkKg4YwH7KpGMhlndOAXi Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:11:09 -0700 IronPort-SDR: 7jhNKrkiQ3mVz4a0eUmd+n40/8oKL40k7bvec9sEhI/gwFd5SLTyrHnWQJu/iEhuer0LwUH2Sg Lwu183LD9c2ycQBWKLzOHZ8co1+1PcuoPr/5y1klcc9ipYWfIIet1lSAde3myb/9TpaqzRie39 rctOc6zWmSS6xO4fOT+0siqLza08liEMaX9pU7na/nG6BIln9vFoGbQNjfOqdChosZOPdPCmjJ Be3IenkkgjkNvhu8wlk4GQ67NXmyQqHXwDoyCW5QHu3Jwzs+lhPMfhrEMzZJdaYnjz0KnJfHAl zrI= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:47 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 4/6] null_blk: create a helper for mem-backed ops Date: Tue, 20 Aug 2019 23:13:12 -0700 Message-Id: <20190821061314.3262-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch creates a helper for handling requests when null_blk is memory backed in the null_handle_cmd(). Although the helper is very simple right now, it makes the code flow consistent with the rest of code in the null_handle_cmd() and provides a uniform code structure for future code. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index eefaea1aaa45..4299274cccfb 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1168,13 +1168,26 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd, return BLK_STS_OK; } +static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, + enum req_opf op) +{ + struct nullb_device *dev = cmd->nq->dev; + int err; + + if (dev->queue_mode == NULL_Q_BIO) + err = null_handle_bio(cmd); + else + err = null_handle_rq(cmd); + + return errno_to_blk_status(err); +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, sector_t nr_sectors, enum req_opf op) { struct nullb_device *dev = cmd->nq->dev; struct nullb *nullb = dev->nullb; blk_status_t sts; - int err = 0; if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { sts = null_handle_throttled(cmd); @@ -1193,14 +1206,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, goto out; } - if (dev->memory_backed) { - if (dev->queue_mode == NULL_Q_BIO) - err = null_handle_bio(cmd); - else - err = null_handle_rq(cmd); - } - - cmd->error = errno_to_blk_status(err); + if (dev->memory_backed) + cmd->error = null_handle_memory_backed(cmd, op); if (!cmd->error && dev->zoned) { if (op == REQ_OP_WRITE) From patchwork Wed Aug 21 06:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4543B14F7 for ; Wed, 21 Aug 2019 06:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 179722339E for ; Wed, 21 Aug 2019 06:13:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="DHUBIShL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727750AbfHUGNx (ORCPT ); Wed, 21 Aug 2019 02:13:53 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:45763 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGNx (ORCPT ); Wed, 21 Aug 2019 02:13:53 -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=1566368033; x=1597904033; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=22LbrGmdfgSiYBlO20Pie1yzItTe2eIxl9QDNaARVf4=; b=DHUBIShLwYdadf4jBaAqipOG+re9qph975n6bLmnQtKCfO4c++FR3zZM wBg4HG/MLock7w495KxU4VciVEww099wXp51aSJ7GVRupIkA5d0yLNX7g 1PjGYv8/qCVkjirZB0awZlxsTtPtDeC/2ezL4s9YwzKKBc3a/ArQsJ9f7 tn2/tuviclprCbbsuQcLVX3/mhmaDeBZ0WwU2EmVaoVUjF1tMIFtU5gyh aIxHDIbVQ0AkkARfF3d1u3WffNwjHsYQj5546yCvT918p09o6QL1vh6BU zX3RS5gvrsm0wQg1RS/1cmSrei4epzyAkF1h4OOMnQ8QqlWSCeCaMlUqc Q==; IronPort-SDR: s8JJWeII689Wjf+3gzPj6BDdHrSPr2w3r22yISgcuDFfORultqQRiihSDZmap/R4DE9fHZdTW3 pZB+1x4MvkxNeRF7w8WWNMX6pfOnsj0Z9eScuDMgLdzaCXXw+baAZlXDuevxs15sFr9LTkY3kL lr3y7AEbdZxTZPZ/ym6MryJE7c4ioLN78jPRt5wm/J7IV2dZMZ3bcYeLAFovVqACHvJkBRP2d4 UxBn3K8zj9y9oHQ27I+WzInw3bonsWVyoMDbZv4y0m1qVf0R/gv/BaoT7rwKp17Gvf6KRwBggz 1Us= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="120898307" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2019 14:13:53 +0800 IronPort-SDR: ha3qAplBazpsuqLYmWiQudjXvMv40GaB72/T+ULE15rLpVfmeTTVc8lOPn6yIHvBA45/taxeBP PDSrbymIiaAXKzaYMjbIrYuanQuq0ENwSVqm0R5JGghRVCS2wDGvPls4LRU/jxmNQPHSVmkJcp BkI7mnP+8tuPTcU+iVZGf6TJM6HM+i1dOaOxU3mA2dwUnbrF5xN7N8GKRQsblkGxNzSWwoFA+g O7eJDwoUKC6bhvuAjHLUCGZvtXUd9TJndDUOSihRHrWqTvR8dHY17YxsPFlWMU5Sj8DF8N4sLy vFlQwOYJWwI1jCgy2Z4u4DUE Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:11:14 -0700 IronPort-SDR: vdms8fkYU7kFg+9rKjdFm5sRinTGU0Veh/veX0/V5K/+X6twGGnmmCxB6RlZhsZOoTT2ITLHOC LmjjhxHUqi0z5E0TJZA7Xsa9DwhvyxTPXEwUd2DziVtGWvMq91ARUS0g+cBACxJ2IAVSxhgtWe MCMQopB5yijhico8KQ0Lul1jPKXQDIsSh3tLqXGDZrWS31mUQVBU1vhP9QMMmG0AYR33DesRvO 63Je7B6YdJgQEYnWWRRk9ABgDXU9QHcRyBnXfEd+GPvZc19nHpI1vqQZfQ/dm8LDxznfsNWmW4 FB4= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:52 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 5/6] null_blk: create a helper for zoned devices Date: Tue, 20 Aug 2019 23:13:13 -0700 Message-Id: <20190821061314.3262-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch creates a helper function for handling zoned block device operations. This patch also restructured the code for null_blk_zoned.c and uses the pattern to return blk_status_t and catch the error in the function null_handle_cmd() into cmd->error variable instead of setting it up in the deeper layer just like the way it is done for flush, badblocks and memory backed case in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk.h | 19 +++++++++++++------ drivers/block/null_blk_main.c | 31 +++++++++++++++++++++++-------- drivers/block/null_blk_zoned.c | 23 ++++++++++------------- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h index a1b9929bd911..1a8d5a12461f 100644 --- a/drivers/block/null_blk.h +++ b/drivers/block/null_blk.h @@ -90,9 +90,9 @@ int null_zone_init(struct nullb_device *dev); void null_zone_exit(struct nullb_device *dev); int null_zone_report(struct gendisk *disk, sector_t sector, struct blk_zone *zones, unsigned int *nr_zones); -void null_zone_write(struct nullb_cmd *cmd, sector_t sector, - unsigned int nr_sectors); -void null_zone_reset(struct nullb_cmd *cmd, sector_t sector); +blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector, + unsigned int nr_sectors); +blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector); #else static inline int null_zone_init(struct nullb_device *dev) { @@ -106,10 +106,17 @@ static inline int null_zone_report(struct gendisk *disk, sector_t sector, { return -EOPNOTSUPP; } -static inline void null_zone_write(struct nullb_cmd *cmd, sector_t sector, - unsigned int nr_sectors) +static inline blk_status_t null_zone_write(struct nullb_cmd *cmd, + sector_t sector, + unsigned int nr_sectors) { + return BLK_STS_NOTSUPP; +} + +static inline blk_status_t null_zone_reset(struct nullb_cmd *cmd, + sector_t sector) +{ + return BLK_STS_NOTSUPP; } -static inline void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) {} #endif /* CONFIG_BLK_DEV_ZONED */ #endif /* __NULL_BLK_H */ diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 4299274cccfb..501af79bffb2 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1182,6 +1182,26 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, return errno_to_blk_status(err); } +static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd, + enum req_opf op, sector_t sector, + sector_t nr_sectors) +{ + blk_status_t sts = BLK_STS_OK; + + switch (op) { + case REQ_OP_WRITE: + sts = null_zone_write(cmd, sector, nr_sectors); + break; + case REQ_OP_ZONE_RESET: + sts = null_zone_reset(cmd, sector); + break; + default: + break; + } + + return sts; +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, sector_t nr_sectors, enum req_opf op) { @@ -1209,14 +1229,9 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, if (dev->memory_backed) cmd->error = null_handle_memory_backed(cmd, op); - if (!cmd->error && dev->zoned) { - if (op == REQ_OP_WRITE) - null_zone_write(cmd, sector, nr_sectors); - else if (op == REQ_OP_ZONE_RESET) - null_zone_reset(cmd, sector); - else if (op == REQ_OP_ZONE_RESET_ALL) - null_zone_reset(cmd, 0); - } + if (!cmd->error && dev->zoned) + cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors); + out: /* Complete IO by inline, softirq or timer */ switch (dev->irqmode) { diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index 8c7f5bf81975..4e48b4e088ae 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c @@ -84,7 +84,7 @@ int null_zone_report(struct gendisk *disk, sector_t sector, return 0; } -void null_zone_write(struct nullb_cmd *cmd, sector_t sector, +blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector, unsigned int nr_sectors) { struct nullb_device *dev = cmd->nq->dev; @@ -95,14 +95,12 @@ void null_zone_write(struct nullb_cmd *cmd, sector_t sector, case BLK_ZONE_COND_FULL: /* Cannot write to a full zone */ cmd->error = BLK_STS_IOERR; - break; + return BLK_STS_IOERR; case BLK_ZONE_COND_EMPTY: case BLK_ZONE_COND_IMP_OPEN: /* Writes must be at the write pointer position */ - if (sector != zone->wp) { - cmd->error = BLK_STS_IOERR; - break; - } + if (sector != zone->wp) + return BLK_STS_IOERR; if (zone->cond == BLK_ZONE_COND_EMPTY) zone->cond = BLK_ZONE_COND_IMP_OPEN; @@ -115,12 +113,12 @@ void null_zone_write(struct nullb_cmd *cmd, sector_t sector, break; default: /* Invalid zone condition */ - cmd->error = BLK_STS_IOERR; - break; + return BLK_STS_IOERR; } + return BLK_STS_OK; } -void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) +blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector) { struct nullb_device *dev = cmd->nq->dev; unsigned int zno = null_zone_no(dev, sector); @@ -137,10 +135,8 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) } break; case REQ_OP_ZONE_RESET: - if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { - cmd->error = BLK_STS_IOERR; - return; - } + if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) + return BLK_STS_IOERR; zone->cond = BLK_ZONE_COND_EMPTY; zone->wp = zone->start; @@ -149,4 +145,5 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) cmd->error = BLK_STS_NOTSUPP; break; } + return BLK_STS_OK; } From patchwork Wed Aug 21 06:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11105481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CB48112C for ; Wed, 21 Aug 2019 06:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AB012339E for ; Wed, 21 Aug 2019 06:13:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="DaD9OB1n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727752AbfHUGN6 (ORCPT ); Wed, 21 Aug 2019 02:13:58 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:45763 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfHUGN5 (ORCPT ); Wed, 21 Aug 2019 02:13:57 -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=1566368037; x=1597904037; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=azZDoPJ9i+Ak+dWcyy0BtIJhy96EbKkRr6W6u0sc/zQ=; b=DaD9OB1nyTTl6RVDMalXAnvzOB6sVQg9aj7+9gYktCHQerMx4XmSw48b gcOPvFcA4ywf+zrK/+YeCtEzecN3SjlndrRpxC6lhWQTX491zDV+BENK9 XUPkZ8QL4xW/8bCtN3BnRArqwLcLHwggiC66Nq5RwVxjlOfVRlSCd8jJr bN3ePnkb3CfkZSDguDBhYp/FlQN9j/TjeUh1UGRPPCZniksM288mHCT7L d3uJCmUxzzIoIBFNXEsawhSSgQepnkGWuT7IAmZGRgTtALEWyp7/hIlYN wf1KJ01htOaLggQWZkGPzVkm/yXR7nqpD5AQHCWP2rFEQc5UKa9yk6DVL w==; IronPort-SDR: L8px+SmLopy92/c8IFlhUQLsPiXbAxs1+yxHccGRNXdNlfhvX7QfyGqk7ABYJc7uauf/Kq1e96 XnXaNVguSsMDZXp4907njtjELMe59uBGyZyxIO7MUKuUCdAkrc8jZdR9liP3Hy8Qb8gAELcPue EdzBSAP2sOdzQ5DJnISJlpEwTQWVcU6YdCs09Eq5T/cfc4CmH+s87GwbSVspRfmTP9a284ClVD B8mgT29gi89/qcDXmNY9Nex+XbjDTXTJ9n4zRVFGYfHAKMsAx6oR/e7a97p6ADSEWT95dCsoLV I0c= X-IronPort-AV: E=Sophos;i="5.64,411,1559491200"; d="scan'208";a="120898312" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Aug 2019 14:13:57 +0800 IronPort-SDR: 0NFKxJ4nFiePXE/q3kNaXyzTIdF1NUKePzVYZ5Bd30ORNSLxKcklqK1C2ZwRQLAzn+madpdEiN 6YxKhH/6b73OiaDlymbKzXojJZnO2wtAFPO+i9XIL5Zpcf+DUTL3tfQy5/2SPnE94ue1Q/nAkP FaC7p8uC9K6sjUW8HTdQ/id2HebG+ELhRZ14jvyx3PqO8khDmeQC8e3abwkjz/8bd5fehZfrKa 9fVVhehk7XP2dMOLDkRw3m7vkXrcaSu0bHPvxFycDhpRdmEuKPzbUyXETPpxR2m6vvLyV1K6ib ALMKfl1J1schX6EvX8ZoAWbh Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 23:11:18 -0700 IronPort-SDR: ogp9yKyK0180MbK+Fl7+jMMdyTPBCn3oY7cDVJHT9j8n+YbP7k1CunSEZP8lStmAXViUdUYD37 +akx/s4EXmvhYRZoFUrVGjnZfP+QeMr42F5+YPGbWxXrlzXKjivmBIeNUrQRdbIQWIN0Tmfl4b nXwc3sHq/6tJylKWDROohYjKChMWdoGr3V0Is9JgIHTihlAlMoB74yR8CZUNnXY0lukNSaiXpK QaWh60DLcg5C6WOCBKoFz4iC5GYOsQZm3YGgHejJW2Ed77tggzP1QcFpGgr3cX/4GqmwTUktfg IBA= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 23:13:57 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V3 6/6] null_blk: create a helper for req completion Date: Tue, 20 Aug 2019 23:13:14 -0700 Message-Id: <20190821061314.3262-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> References: <20190821061314.3262-1-chaitanya.kulkarni@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This patch creates a helper function for handling the request completion in the null_handle_cmd(). Reviewed-by: Christoph Hellwig Signed-off-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 49 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 501af79bffb2..fe12ec59b3a6 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1202,6 +1202,32 @@ static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd, return sts; } +static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd) +{ + /* Complete IO by inline, softirq or timer */ + switch (cmd->nq->dev->irqmode) { + case NULL_IRQ_SOFTIRQ: + switch (cmd->nq->dev->queue_mode) { + case NULL_Q_MQ: + blk_mq_complete_request(cmd->rq); + break; + case NULL_Q_BIO: + /* + * XXX: no proper submitting cpu information available. + */ + end_cmd(cmd); + break; + } + break; + case NULL_IRQ_NONE: + end_cmd(cmd); + break; + case NULL_IRQ_TIMER: + null_cmd_end_timer(cmd); + break; + } +} + static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, sector_t nr_sectors, enum req_opf op) { @@ -1233,28 +1259,7 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector, cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors); out: - /* Complete IO by inline, softirq or timer */ - switch (dev->irqmode) { - case NULL_IRQ_SOFTIRQ: - switch (dev->queue_mode) { - case NULL_Q_MQ: - blk_mq_complete_request(cmd->rq); - break; - case NULL_Q_BIO: - /* - * XXX: no proper submitting cpu information available. - */ - end_cmd(cmd); - break; - } - break; - case NULL_IRQ_NONE: - end_cmd(cmd); - break; - case NULL_IRQ_TIMER: - null_cmd_end_timer(cmd); - break; - } + nullb_handle_cmd_completion(cmd); return BLK_STS_OK; }