From patchwork Fri Aug 23 04:45: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: 11110541 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 8B8C81813 for ; Fri, 23 Aug 2019 04:45:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A55F23407 for ; Fri, 23 Aug 2019 04:45: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="I1VDUFv+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391752AbfHWEpc (ORCPT ); Fri, 23 Aug 2019 00:45:32 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:47588 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfHWEpc (ORCPT ); Fri, 23 Aug 2019 00:45:32 -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=1566535531; x=1598071531; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ueQItnJ2oij3/q1Mp5ESe1w0t5lYJZrEK8sitBs/q1A=; b=I1VDUFv+NpDe4rYG3M4X0lb5Jzo/v2mOCYkCmxSIRk2eIoFGoNAXwPji oRKVxhVmC7KaA+bDO06NfqyUOrugM7nIGygp+uvyE4ztbaJkWQeBysF1X lZe5s/mXx2TYZNXqWi0Cv6tnIXRD3/ZzDy8787cagyWzPZfLYXFmzalre 29UMhmCHktwZhEHyUapp2sjWntJdgyGac0wGP2udM4fvAF9iCHHOyrSeb sX2agbW+ylEEEkvafKALAOXJ/1JFkWswEnLsnGazPv98OP9lt74OmuniQ Yi4IAW3Q5Cy9NbUi/MKBazcm2J9LArpPgeNwjFbR3knoYglaj4geJptAv A==; IronPort-SDR: IVYCAo9lHwkYbykqLY9n+N7CNe/WExWlTfDUgpKyW2OoIOg8nNLWKyNxLt+KeLbQbXqMKabosG 83iLsPIaISUpu4P2NlxQJ6leTq+BMGe8Px4QmOwXwFOMPiUIjw7PuIxqroTKy8wRh6er5HHfEU YSG43Atvyfeh6UnwELSkV2VVKCuR9ngPUB2hLzv+MTWd9k+9TSGzeaTo9BFrGkJKsXm1yIV7jp +tMguVz5Hd/cDE9xzEEtyuBvKdhbl5Ci2WfQpgzdcoch11mvz+FdvbHQpwd0kJfsBw6s2HXYxu UAs= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="121078096" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 23 Aug 2019 12:45:31 +0800 IronPort-SDR: ooKwDupKhPPwVbGxgcao+oY5CgRxh8pXZF59Sa+w7Jt4xzIOUtiUHY5Xqou4hPZUkuI5DeFGI8 0bIMH9tOnkZJPhhgs2jF3m5bwcmFyLIf6DUn8NeRTJgB18qOhum0vSfB7kn3yF3pPHsdRupFKI 3qgvae9TNqvszmESXF1LtFweF3E/QbX0I4gAIi5u0t7sIhERB1/MNAyxUX3lmOkEUvlKFIgl8w bcQ1F9D7GwVJFDYJmCSg0ClSa5vEZ4R2nYsGzcrEgIxYGF1FrU49jRjPt1mVbHLoOH6P7/ZUV1 p0uDgot9e+0fK6ldY8FcXa/F Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:42:49 -0700 IronPort-SDR: iGptXJp9rpd1w9WpNAttO4BQtAAqoUmmex3Xl5UV0mUkNGKzuzDaMdynopeL8WTiocxjKvzetz q5g0tH8qFugwevFlMIgsiiqfDwrKqrAcbyi2w9j3VUz73CNxOiNb6PowlDOiFCsPj/MOYYYLFG xSVcP3hBr5NTmDnJvNzBhO99rDT/yQkOm004NX62OYjS/UGjNl6a3N0WrEYp58v8/qPjGvd7wX wIg8m/tRlLuN5xs+dUZrTyhIMF9CBY065c7soYnB+z0Srru3G+4nYthl3lB4WVC4wUGGobiwVv 6S8= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:45:30 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 1/6] null_blk: move duplicate code to callers Date: Thu, 22 Aug 2019 21:45:14 -0700 Message-Id: <20190823044519.3939-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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. Reviewed-by: Christoph Hellwig Signed-off-by: Chaitanya Kulkarni --- 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 Fri Aug 23 04:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11110545 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 7106014DB for ; Fri, 23 Aug 2019 04:45:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B746233FD for ; Fri, 23 Aug 2019 04:45: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="QPL1mIod" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391754AbfHWEpl (ORCPT ); Fri, 23 Aug 2019 00:45:41 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:3468 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfHWEpl (ORCPT ); Fri, 23 Aug 2019 00:45:41 -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=1566535541; x=1598071541; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=eTHJ36L8lpxjIW8iVH/66KmAi0WMFhcw2gBisuHAuYk=; b=QPL1mIod1PymsZFYyNEUieSCZJ45oxog1GUNx95a8CfTCmDsnV16xo3z 9s9FArD3kOHCecyxTlHAs+br+xiWVqpDCP9UbtvNr6UMO2xOI4DE7EsM/ 2Et14rCis/xM8V/w4NVqB5jbymrjoqK3x0smzlp5kmpqb5wfg+6sbjt99 eU73UE1GsqoXk1fkxBubEfCf4xhJbMfw5QEbB9dsHQc/7ad5Vk2948EMO whLxSbneZrBxSjsUmLQDd+3MR8AhrFbGz8m/yAPrZFWJTySMmpYp8ufj4 iwzDkbTvzOiZ3xNcxE/ecK8Chiqr04Xifm73OX67+n8T9q4sUCXWNzxZs g==; IronPort-SDR: AalEe0DolhGFf1Jqxfqk2TDiYekVr37xggJxC3VoWrirVdiZxgpH1CzUFUTIiouXA96cb3ZZf7 VTXwm2t3jHz1BoJodlclHuGh9jYR6INo406V1Z3ixscsRjOD5HnPjF5kaayZbpoxpdNR79rEAD vnJoIjpGQYoywn+oaJOdoj1X1CPjNVQkvK41Eggk8K0lYzIJtRqwYtNWAB2ilhTlkQgCac0J1s dgm6yz66V9LqD8U46qbAfXOCWOHASgwjZiYRPfcXy9ncoPSq6v7/mjyj8Yjdz+0man5Y3wNkm2 /+s= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="116493563" 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; 23 Aug 2019 12:45:41 +0800 IronPort-SDR: +ZgMdn02/RqbSyYl4H31u0+xCXxx0RJbr6jHvXY1SY3W53j+so4Tk2C46ATuoID/dixSw3Q7Qm wWnSKiLb4oU9kErq5CnJ94QIx9lTYsc+8UMlWyIkQASWnH6QCzrs8hvGbN2rEQnqa5h9edvOd8 ak411EYrWLj8AZUxiAOyUrdo6bBgQklDh2yBYRc+OEquv/uJwCAMsy/MTiZBDifHuthMd0eKEI 8RKDrdlgsjGi/Fklj6KrPL7NM/hAyxOetlo2xHLXLEFMJDxWnm03BVDTUKwnevG/K1a2GvxlWP IpHX2ZiBaldhP/9X6NeLrA7M Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:43:00 -0700 IronPort-SDR: q3qWJW5bjTQWiBSTJzXKKdE4f1an1JF0FU41ug8/xgvLsrqjyLYeZbF6oxdMU74+BMpFA7qFDc VQuh0nN37NNSbX2IN97ScULTF3t5b853TOkyQ9OF5M0fiCZuq7vSAqwjNHDP2l5edM7S8uwW+6 gfcLKeubS6JwoZsaPRLwGMx+xcjOK87PBsCNT9wxGbaMa0yxDmG5TWlhdcDTEMRuHoWnxsrw/J T/l+J+SFvsQ6e1mnjDAczL4jHKLFwlCIUAyw6MK+Y4nSQNn3XLXbxhyJHSv9d9FSopEdQ7scSj HEY= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:45:40 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 2/6] null_blk: create a helper for throttling Date: Thu, 22 Aug 2019 21:45:15 -0700 Message-Id: <20190823044519.3939-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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(). Reviewed-by: Christoph Hellwig Signed-off-by: Chaitanya Kulkarni --- 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 Fri Aug 23 04:45:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11110547 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 1314813B1 for ; Fri, 23 Aug 2019 04:45:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6C252341E for ; Fri, 23 Aug 2019 04:45:51 +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="RUJjWjT/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391761AbfHWEpv (ORCPT ); Fri, 23 Aug 2019 00:45:51 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45792 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391750AbfHWEpv (ORCPT ); Fri, 23 Aug 2019 00:45:51 -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=1566535550; x=1598071550; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=WrcGxDqywXDfY3arKaxOVoHAZYFwL8m4PFWA3SgNTeE=; b=RUJjWjT/sT/DtDA2B5J0JaX7QifyTU+6Orcq+jnIoZbCWwFarUa7Pfmn 1bewrT7JSb0FieiQWG6x8WdvysGmBRuVB/Sgdcac2Qgtrb1yjeMa63urh S7tzSfwmG87NQcTK93Iaij2bc0x4vh2NfwHnQvNKUlSLOpS/rCS3vLsXN 41udy/LrpJKEJWAY+QDWuQWIqXvfMKQCdeRoO1XPgMAnDTTM5+RaZ0AZF R9PqpxwgxnOJS/fcQ3l5Yp7Ii6/jXl0Z4+wC1u1wDQuLLf1z/1/Uad5a8 om/d9drXMmHmk8qDs3GcE5e8mEVqmA3a9H7qokKQsN5IZUD4dzoFSCsOZ g==; IronPort-SDR: K9lXyopte/8oEYOkXN0FopSSMwjyoJmWm+igYA5WScy6SYknk57zrnEus49cRn6F1DDG90etXl Cxlqy3kkvw4fwVMx06HP/P8R07BVJCZ1Ah8WgUXtbC7rya5DAtT0sLuxmClx9JfqKiy35+RcAZ C1xZpJjjMjRzQ5PHUYvehrjG9bcUUzW+KFHGG1jDk++CyQq3ZokugVvGTxNa9sGQwY40xFI2/d pkAxmGwdFD+xJL9JaWErebzXonXbr6+WNiYHBcvUTQa/Qhwb+y2Ftuvt68uPAKa8lQOQrQd2TK ktY= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="117414499" 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; 23 Aug 2019 12:45:50 +0800 IronPort-SDR: gsLMGj7HpUfUY3DVBNt1P2gigG2N/UZfsOMb9mqdHKRuQNQmUkj8IWn8peSj/lf2xWF7f99VQz sKKFP1SBA4mxt7acjgjEL3gIMX2SDuwv2flRLm0sOW3mHkdceX8kBdO22pTWzkHnEM5ro4Aqp8 OgcJLgLLxQNwNPW+3Nk3tvq4j19aBzY5nKJIJmXIq027Piz/VPtkChV3ZDlO4tkvlxLQ+gtjbD ky1UgQtD1q+0ieqfK6+nl9qYD4KbwmpiYYck35RukW76VNgazJgghX8wRWStfh1tcUv/RFr/OT fDkR08yE8XFDmsmAz6Ba3c2f Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:43:09 -0700 IronPort-SDR: 7lLyp+He1xxfJgwK11eR71bAGMxMjQmG82Fl5fwywLzzX+1f9BhwjaXvVE5w+MBDnJYbTY8Pl3 qz5hE7lsZoxFgrmkUuQDl+K0DkhkReVqdB1j6/312V+5+HAvlU1gRbBIFNzzjZJFxqMVZTkxsa HreRzTT8lJot4PnJfoujoKrLchVj1VI5UkyUh2VnzOk72zZEQzzUtKD1P2LjMeZXRnjFZhD4bl wjW8BrMO/6aCHqcGiYL0XY8vbGiLC6ZOLO6onoQz+CnRecjYzoEwHmKxgHYdLLKVU7YzFZy0UL O30= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:45:49 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 3/6] null_blk: create a helper for badblocks Date: Thu, 22 Aug 2019 21:45:16 -0700 Message-Id: <20190823044519.3939-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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(). Reviewed-by: Christoph Hellwig Signed-off-by: Chaitanya Kulkarni --- 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 Fri Aug 23 04:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11110549 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 9781313B1 for ; Fri, 23 Aug 2019 04:45:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 777BF2341E for ; Fri, 23 Aug 2019 04:45:59 +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="q85FeK5p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391750AbfHWEp7 (ORCPT ); Fri, 23 Aug 2019 00:45:59 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:42048 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfHWEp6 (ORCPT ); Fri, 23 Aug 2019 00:45:58 -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=1566535686; x=1598071686; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=zebTP9IMn+hrY1Oa6d1BDNvg/2muaBtnn4zOjwe7pkQ=; b=q85FeK5pcDnjoNtSyVGxPcTiG+MLmzFcTDONwdD9GpIiU53cTEXa20e3 K3rzvHNNqbSIgYPXH8lVyyzHZwvYZu9hxGRXcri04wtfh3XtMyYUJ9YL0 wMtTBG/PSB6zJEPHwYkB9GHDy2mcgXtGziwxy6Im/quyT6yGaJJ3oR4mr j5jAdpBLXQgMZulpB3v/aljQkoROoFPLYS8Bk1Vb4CeilCApdNtFFDF9l Nu/uh+73YCJ+WuxnkKvZyTmEmxj9gsc3ImeHZq6Z2c50ClFU5bTdXgstl 0DNXPv2IKOOUgruhg2GxUAkM4BhCS2dt8BfAxBYXIRtZ0n3HP7bhGYuUW Q==; IronPort-SDR: v44rH2l57GOSvB0AhHyins/lyzmD/bnf/pWkRzfKqpFDBLPSbv1ToUJAKxS9IO9LNd5O2Cd2ap HGPltWCn8QPv5sUlDFbKnpzrpTH2rdGeWyLHcYLeiuHOR+p/cDKKBb91lbQY734kiVxS71KWqE G97Dk6Bem67X74vIkLu4kmx4XhURocYC37HFF2OACbxYLj6Kds+6N9Mu90lR4Hhg+B01SWp2/9 AdN1C+NZaXie7eZV0Y0embuOWA5mB10t7xlD3qiNVOCV3/oXWCztpqkHSLR+YYWRNlixDFPdKW VAI= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="216934501" 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; 23 Aug 2019 12:48:05 +0800 IronPort-SDR: CKrsnjn23GxhDmn00PkBOuk9ERZrviik5fWRs0jedQiYdi82Csmnxq7YDOO00qlcOOmZSZ+2tg 9yWt/5I2MQqJyygPT47/PPpD1qet00uTtWEPTVs9wgdMBbRtQOSd0KWQIjuPl7mOUTRT86O/TS +xDTHmv0DqPSyf7gPoQi5wm69LN19zFlxxEWQ+ZAruptU0fpZJp6f14UU3uct6oVulLgL0qa9J qrM7Vk7TBmfn81ix9MFTYrz6DuYNnkYdp5lgBpugENOlJT/OdCQQgrGJV3hcKOWUABoeT+Zfsh Gr6dRuTaEAnbBIjZ3OJ+DAbZ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:43:17 -0700 IronPort-SDR: 9sHsjcvYTR2HGRKWNllsHvoqHxCU+77q4FabX4GRMiClesDsP9bj43KIW6aDzpzIUKmHe0PZaJ wTYP2aqKCiqGL73iaSwxI3DAuQmU8Y3gRycBaDzOUqEsr/W/o7RT8ckGGBX3Ij4NkBAB0Ax/+8 Dir0u8KaDabNt8QNY9DcK+HpD1auVz7D5O7vfISYfiefOCOSWreamctsJ5JDg8HGfIRr+EdLM7 cVHDXzuJH0ebKY62j98v9NeemeTtRa9Isfhuchf9xzzVpYQroMPheipbn+d4CrV+qF6MNVrOEs Mwc= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:45:58 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 4/6] null_blk: create a helper for mem-backed ops Date: Thu, 22 Aug 2019 21:45:17 -0700 Message-Id: <20190823044519.3939-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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. Reviewed-by: Christoph Hellwig Signed-off-by: Chaitanya Kulkarni --- 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 Fri Aug 23 04:45:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11110551 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 2C2E013B1 for ; Fri, 23 Aug 2019 04:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00BD42341E for ; Fri, 23 Aug 2019 04:46:08 +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="g16sZ7FM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391765AbfHWEqH (ORCPT ); Fri, 23 Aug 2019 00:46:07 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:3505 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfHWEqH (ORCPT ); Fri, 23 Aug 2019 00:46:07 -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=1566535566; x=1598071566; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Zyc6Q21AD+S60XUr9dTGz/44uiWt6W5q9gCT0tzG6ME=; b=g16sZ7FM4BnJR3hxDcwzcL9pgPr9zRhgGXc09iIbbC8aVDuq/2RVcvwi Cv2Z3ukq7fsBfq0fbX2tExOn4dc1nU1XRTlsVBgi4zIvuKoZlIFJhfE9A M/YyyzeyvZFcLMCkLPJEGxq6N3nWThvF0c9ZXPx/ikKDXm7X0GQI5ihkz L3hcAAAQrpTBNGeyNfvJu2X+1MSMnfl0Ht5ioHSZiSIIxFqmT8ytjlkqd ZLDslCvDtV1FR7HxZpQTzKvDE3NDKi3AanBD/+roTM1+CL2BOiO8Am7pL AhCg+EJyuDskX6iBd2/QOwSduDmyugSWVvVfD8jlkCIli0KGl/hULuXjN w==; IronPort-SDR: V5gPrUk1UpgEMhKtTw7nqSYd3J/lhgSkHns1HwHD8rpLvgQafV2YhWBeqLpZIy0j87Li5S9iJi Ydz2bUky79M/YAhR9nlPRKZ0yYt92njkdL0wjSuo6xPUVbBL1ROe0JlJm3WTitw3hdPCNYDYjo IbquZ1vptZ+5o61/v/NrAtRd1k3q0rWHrGZZ7ChVpk86vwlYoqcimmvt0iuBCvLnp0GjtytKVA 5Rg6CTK680rBWePaYqJmaXx1hxnGR/sMR4ZPmAcdn9dmrdxEJQfN9OTkaxrg+G0UtBa1wfLZ9x bjU= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="116493578" 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; 23 Aug 2019 12:46:06 +0800 IronPort-SDR: jWNCI7Z09+qMT8Ha3wHxbhZtVMYkZDVrnHslmyYwr7Gk6BTzrX40T+wlJqnszsFJoFCWWW0qPi zKGmIbcfHlb22yjajSMkORd8aAfLbJ05xqrQ/mBUETFkX4DxbIon0VunMu0tcEwKy9KHiwe3OJ FtsPKrjVjCGhMSA78Pi85CJ12g/JgxxOzku7NhUdBcWwl5dZueCMXKAgZWgsL+DCiusy8Axhu/ V7tYjnrKPr7ot2o5nWbH7EigH4Devtcun1koJOVax4G6Xz+6wZo6IK5/QLZbCM6rxDLshBd4Mv PIDOc7io20GpBDiJ7mHHLm6Z Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:43:24 -0700 IronPort-SDR: h5JVtagmr1DBWiv4PWLhpNGXGbaNxxyZUzMShFprlese9Nx07qwPc0OIopgIe1tVJbMWObQKV9 wKweP15H/ZtGEOSd3DGKTrRWPR5y7j8cgFJGmx/upXoJjjJPTiu+9PkJ/vuM/7wJr8upRdN3kD k6m/MFOly2oQ1WASOUOete5soKFFi8ZAlOIScSH1iugf6CG5qr3eyyzLGh0Yu0VjSeyfwPdMxn m7mKyiZnTui7dj6r4oQHKXegmJtPxZc7VP/j8IkWC7wViXxhsRiW/YsX7cfk8wwVnp6NLIq3Lk U30= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:46:06 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 5/6] null_blk: create a helper for zoned devices Date: Thu, 22 Aug 2019 21:45:18 -0700 Message-Id: <20190823044519.3939-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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(). We also move null_handle_zoned() to the null_blk_zoned.c to keep the zoned code separate. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk.h | 13 ++++++------ drivers/block/null_blk_main.c | 11 +++------- drivers/block/null_blk_zoned.c | 38 ++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h index a1b9929bd911..4895c02e0c65 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); +inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd, + enum req_opf op, sector_t sector, + sector_t nr_sectors); #else static inline int null_zone_init(struct nullb_device *dev) { @@ -106,10 +106,11 @@ 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_handle_zoned(struct nullb_cmd *cmd, + enum req_opf op, sector_t sector, + sector_t nr_sectors) { + 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..bf40c3115bb9 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1209,14 +1209,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..90092247e7eb 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, +static 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) +static 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,20 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) cmd->error = BLK_STS_NOTSUPP; break; } + return BLK_STS_OK; +} + +inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd, + enum req_opf op, sector_t sector, + sector_t nr_sectors) +{ + switch (op) { + case REQ_OP_WRITE: + return null_zone_write(cmd, sector, nr_sectors); + case REQ_OP_ZONE_RESET: + case REQ_OP_ZONE_RESET_ALL: + return null_zone_reset(cmd, sector); + default: + return BLK_STS_OK; + } } From patchwork Fri Aug 23 04:45:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11110553 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 E27E214DB for ; Fri, 23 Aug 2019 04:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C34EE2341E for ; Fri, 23 Aug 2019 04:46:15 +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="JXACSk8b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391767AbfHWEqP (ORCPT ); Fri, 23 Aug 2019 00:46:15 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:42062 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389942AbfHWEqP (ORCPT ); Fri, 23 Aug 2019 00:46:15 -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=1566535578; x=1598071578; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=228D0TMcq1JnDODJR+r8qowd7y4I2oLhKI5/sn4kpFA=; b=JXACSk8bVatEurOosxtX5AnQ0MKyeh30+mYJLu0VQKcblGOjvm6VT9YN oBurmD0ViVFdSNCJJ2VYh6xWzL3jZFBSICJXVs/nfOeo/N2j0D8NgVzPf 0x50A+5vn5pwwsXBaTim+Ymj1m2YesAklKRpikOG6vy5pglBUi9sDod6E Fr07pmQB9Zy6vgXu3yG09K8etOGyuaNo929skvAmLvuoIYYlkzaHcbFS2 rIcS7M4oQaMVXlzHGFRmW9bBSKYrBFNhnJGM1noEiucSUiCR9TWNHvUcW wR6zC+VaMMQG2PvE0UiRs7Yx09sYmd4ogFe1Sv4Kj50gvIPuPDRmCfCc2 A==; IronPort-SDR: WGrhMV5UXK9VrLEV9haSQTefhuy69/G3+rT+IZOs6vCdphQXHU4MnEhgj+NlYFaAw8ZtdCF3F8 KTKlL+s8ReJf/w+0S4xdVF9fgi87gTvAuoHtBMspV38yDe9HMmle4iFSYmya96iI6H5ocCwyJr sfQ2B4pyvRd7sjPInbnB7mtqrvxYdZMY7kkoPRBKY4Wo5b/aEa2Y154lJxmyYbaXSm5Q/HfUbl o99N0uKl97PimJ7uXfGJLpXsrx8fd6Xwc5YNu9krWuCFj/TK2LAnhgdupzRreXCYGtCFMCNlW7 lUQ= X-IronPort-AV: E=Sophos;i="5.64,420,1559491200"; d="scan'208";a="216934515" 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; 23 Aug 2019 12:46:18 +0800 IronPort-SDR: hfNfDnkUFVVCiD6ERIAbG2Oi8o9/ZxN3jsqe5b5SBlUyjPqar0ZxZLyr7yphdRjzyTxihmFvuy BpQcC3Rd4Uh9iuebj9Fvf326erp79wEB/Y7KacANs/71wz3RKqiS7tvvHRWWPzVGnQmVjf5t/W 03jjcBI4WAh+YN8A5vXLGJ8dKChZPg8AxgpwJbHLKA7cKOmDIg6J52IeFtc+UHmW4nePD6MKN/ y92uJdLcMt2eCa12UHHYFcI8UIPIAuU4TsLub3yP7Wx6EBSCD9UnKDCWTXWxUGWZu3XsmNo2vk pbpMGjxxQusUfTXTlN2cITh1 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 21:43:32 -0700 IronPort-SDR: s6MCs/14089iKFRVIUeLEjbSlxxjncfkPZ2XGP61vUwdTGJcI69T21i1eof879tPPGGTqxyFBX 5jPw2MP7osAEpgcdmmYqloHR5/tX69kHBjCM3Gtcid06KMoio7uMymCKC70JbL0ChM3wgfagML GdZ2JPRrSE/06BuD9mPP0WSWhFvtQ5OD+1Lki5Zn5KqEJlXNvgpOmCyc2W2TgmCuyv06NO7zC0 EBKhEd3RIpGP07HKQR9SaQxwAMCZWu8S1EwzTxdY+wjat0mk7fUgu0bDVTbL0r1+VR3s+704/N tww= WDCIronportException: Internal Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 22 Aug 2019 21:46:14 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH V4 6/6] null_blk: create a helper for req completion Date: Thu, 22 Aug 2019 21:45:19 -0700 Message-Id: <20190823044519.3939-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190823044519.3939-1-chaitanya.kulkarni@wdc.com> References: <20190823044519.3939-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 --- 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 bf40c3115bb9..b26a178d064d 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1182,6 +1182,32 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, return errno_to_blk_status(err); } +static inline void nullb_complete_cmd(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) { @@ -1213,28 +1239,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_complete_cmd(cmd); return BLK_STS_OK; }