From patchwork Fri Jun 21 13:07:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 11012547 X-Patchwork-Delegate: snitzer@redhat.com 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 4C0E2112C for ; Mon, 24 Jun 2019 07:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B2062884B for ; Mon, 24 Jun 2019 07:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EF3C28974; Mon, 24 Jun 2019 07:43:57 +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 mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B5BB62884B for ; Mon, 24 Jun 2019 07:43:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB7BD31628F4; Mon, 24 Jun 2019 07:43:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEED65D9C5; Mon, 24 Jun 2019 07:43:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9DCCB1806B1D; Mon, 24 Jun 2019 07:43:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5LD7sHV014244 for ; Fri, 21 Jun 2019 09:07:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C6065B68A; Fri, 21 Jun 2019 13:07:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2732D5B689 for ; Fri, 21 Jun 2019 13:07:51 +0000 (UTC) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDC1D3086203 for ; Fri, 21 Jun 2019 13:07:32 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id m23so5856223lje.12 for ; Fri, 21 Jun 2019 06:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yP4hCZ6yL3D/UZqgqC/Ov+Z6vjll5loZko6056/cetY=; b=WiMV9WZtz6n4ISyy7pUtYCnGw26um/pfnCPW0IUhTrj5WLELiUwQzTzG1Ps+Fm34sU niM84VraxJjxEYv4lANQu3cYxfRtxumRLPBQhauTyA3CnBL4peWd+iHPQtOun7Vq50zL HNHQiBxrBvNYVwNdhOGm90h2gZQDczlnARy2Q53GRYk/CeAka+BWLGtHypDgvFyVfhri lTPNVcm6BwJSShquC+A8X9br/R1xmVZkUNVve76ifd960/mo4rMXML0R/zeJGhy+vvhd T1yWVku6ySVz5E63YpGfCMcCgCDAfB92y09Sw+3UECBT3fmJSiSVa5pI9at0YCp0c5rI Zzlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yP4hCZ6yL3D/UZqgqC/Ov+Z6vjll5loZko6056/cetY=; b=q6dnzMIfLUnO3/D7Qd4LX/HcWeQ9DLun2lvbB7ecPYNb7Klk8GhXHDK0kplB4JA/Jj m3iivwi1ZIevr8E/Hk/aIR1fbxX/4ypd0TSQ3vn8uRqeZ7PwdL9+F/mVBkaCi7paMdId 0CxeDr9C2su+2XAM6DxHkyDn0Qhgs0DpCo7xnMvey/hetufyMZlpsSQnNPflWlgOc6dN yx8DLO7JLNYujMfMVlglvJ85NsiS6/k8t5T3DUMzNmTk3ez67NBKncQvOuWSxZ7hm30c noBrcoEa2GypE3B4czm1NEHBCzs2d/OocfJx6VEAttX5rXcTU3D4McFwshBC06BimoxJ XHOA== X-Gm-Message-State: APjAAAX421qJUvyqayNLduehuMLz7HDvRnDHtP43g5GCequhbZwrcyEl /gwyEd/W+J14JwOBV0BV3Ino7g== X-Google-Smtp-Source: APXvYqz0iDNEIsEABaU1xi7aYwfBGvl2BdjDcs2x8HZgfccJp7p8AirvIqLaeTE1wbjQW06IpIgp+g== X-Received: by 2002:a2e:900c:: with SMTP id h12mr3609956ljg.197.1561122451127; Fri, 21 Jun 2019 06:07:31 -0700 (PDT) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id r2sm387100lfi.51.2019.06.21.06.07.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 06:07:30 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com, hch@lst.de, damien.lemoal@wdc.com, chaitanya.kulkarni@wdc.com, dmitry.fomichev@wdc.com, ajay.joshi@wdc.com, aravind.ramesh@wdc.com, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, agk@redhat.com, snitzer@redhat.com Date: Fri, 21 Jun 2019 15:07:09 +0200 Message-Id: <20190621130711.21986-3-mb@lightnvm.io> In-Reply-To: <20190621130711.21986-1-mb@lightnvm.io> References: <20190621130711.21986-1-mb@lightnvm.io> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 21 Jun 2019 13:07:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 21 Jun 2019 13:07:33 +0000 (UTC) for IP:'209.85.208.194' DOMAIN:'mail-lj1-f194.google.com' HELO:'mail-lj1-f194.google.com' FROM:'mb@lightnvm.io' RCPT:'' X-RedHat-Spam-Score: -0.009 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE) 209.85.208.194 mail-lj1-f194.google.com 209.85.208.194 mail-lj1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 24 Jun 2019 03:43:21 -0400 Cc: linux-block@vger.kernel.org, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, =?utf-8?q?Matias_?= =?utf-8?q?Bj=C3=B8rling?= Subject: [dm-devel] [PATCH 2/4] null_blk: add zone open, close, and finish support X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 24 Jun 2019 07:43:56 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Ajay Joshi Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH support to allow explicit control of zone states. Signed-off-by: Ajay Joshi Signed-off-by: Matias Bjørling --- drivers/block/null_blk.h | 4 ++-- drivers/block/null_blk_main.c | 13 ++++++++++--- drivers/block/null_blk_zoned.c | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h index 34b22d6523ba..62ef65cb0f3e 100644 --- a/drivers/block/null_blk.h +++ b/drivers/block/null_blk.h @@ -93,7 +93,7 @@ int null_zone_report(struct gendisk *disk, sector_t sector, gfp_t gfp_mask); 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); +void null_zone_mgmt_op(struct nullb_cmd *cmd, sector_t sector); #else static inline int null_zone_init(struct nullb_device *dev) { @@ -111,6 +111,6 @@ static inline void null_zone_write(struct nullb_cmd *cmd, sector_t sector, unsigned int nr_sectors) { } -static inline void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) {} +static inline void null_zone_mgmt_op(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 447d635c79a2..5058fb980c9c 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1209,10 +1209,17 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) nr_sectors = blk_rq_sectors(cmd->rq); } - if (op == REQ_OP_WRITE) + switch (op) { + case REQ_OP_WRITE: null_zone_write(cmd, sector, nr_sectors); - else if (op == REQ_OP_ZONE_RESET) - null_zone_reset(cmd, sector); + break; + case REQ_OP_ZONE_RESET: + case REQ_OP_ZONE_OPEN: + case REQ_OP_ZONE_CLOSE: + case REQ_OP_ZONE_FINISH: + null_zone_mgmt_op(cmd, sector); + break; + } } out: /* Complete IO by inline, softirq or timer */ diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index fca0c97ff1aa..47d956b2e148 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c @@ -121,17 +121,44 @@ void null_zone_write(struct nullb_cmd *cmd, sector_t sector, } } -void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) +void null_zone_mgmt_op(struct nullb_cmd *cmd, sector_t sector) { struct nullb_device *dev = cmd->nq->dev; unsigned int zno = null_zone_no(dev, sector); struct blk_zone *zone = &dev->zones[zno]; + enum req_opf op = req_op(cmd->rq); if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { cmd->error = BLK_STS_IOERR; return; } - zone->cond = BLK_ZONE_COND_EMPTY; - zone->wp = zone->start; + switch (op) { + case REQ_OP_ZONE_RESET: + zone->cond = BLK_ZONE_COND_EMPTY; + zone->wp = zone->start; + return; + case REQ_OP_ZONE_OPEN: + if (zone->cond == BLK_ZONE_COND_FULL) { + cmd->error = BLK_STS_IOERR; + return; + } + zone->cond = BLK_ZONE_COND_EXP_OPEN; + return; + case REQ_OP_ZONE_CLOSE: + if (zone->cond == BLK_ZONE_COND_FULL) { + cmd->error = BLK_STS_IOERR; + return; + } + zone->cond = BLK_ZONE_COND_CLOSED; + return; + case REQ_OP_ZONE_FINISH: + zone->cond = BLK_ZONE_COND_FULL; + zone->wp = zone->start + zone->len; + return; + default: + /* Invalid zone condition */ + cmd->error = BLK_STS_IOERR; + return; + } }