Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3624001ybd; Tue, 25 Jun 2019 05:56:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9x264rYLJd5lgz5TCTSLikikMcbot67svq9DEQf7WCSbWmIe0RvY2Ne8cWJ7xK46bocnM X-Received: by 2002:a17:90a:214e:: with SMTP id a72mr32700743pje.0.1561467391652; Tue, 25 Jun 2019 05:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561467391; cv=none; d=google.com; s=arc-20160816; b=LUjveuNUSVHq4TqwWPzXH1Dhufa4/zTYAjIwxuEoOxRubJ9rYrKfQJKkBtvb89znr1 WY2vqcNaGcNBuXubrYeTRFQH9vcXVX5k/S8P4I+nC0/i4vmYm5UqQQ6TaHvSnognMnMJ nP5dxPMwTcl9/zaH/BY8Ix/LkD4DHdZF5bJE+oogGEKct16lyTrhGHq+axbpv4lie18h 4hcBk9LXCgWMBMxfOB2Ybf++J67QizFLyNSmgUpmpLdQd/UbZ06yyaEZM4bzvXuAMSAK N5cwViKLHJJCas2wB9Ise5CEj4JfqPGhWG00/ZLnEFpqV89j4Aka6tQ+0MIyQlAkTpz2 ctow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=hJ1vw1zo6Yo+NVBoQruROWjbHicMMrc+0Uq5a9tZI0E=; b=GRRVdgA2bLjNVTdUp7kIWMBQKNQY31tGOtTa2q5YEtRB7Ygh9UDRDfj/Kd48hwpIQb H1cxi3eS9jKMwOa+K6G+bkvYXhSJF3yV7EQFUw3XWBLI50pS9uYF39Rv08eSJUH8fRyf RNWwBhg2xBsl8gucVtdK6b2AdY9DCiP4yyPyd/dVsmb7aDeyiJOOJ+shf21rRElf2ZTF 5A4pFsafyDeoWnErbOCeVdnQ/i4cDCI2Qnzusd4VVaAhQbtCNX+oYueLIpRI3Ow+HknB qUTM2e2Ch6t2XXz4tRKf1gWUz7gORjDHgcq5If3JzLwJxP8fNkHqPlMqOAkMsacCoHh3 +D1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=AtCxVJwK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si304502ple.161.2019.06.25.05.56.14; Tue, 25 Jun 2019 05:56:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=AtCxVJwK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730203AbfFYLGi (ORCPT + 99 others); Tue, 25 Jun 2019 07:06:38 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:32844 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730028AbfFYLGh (ORCPT ); Tue, 25 Jun 2019 07:06:37 -0400 Received: by mail-lj1-f195.google.com with SMTP id h10so15839866ljg.0 for ; Tue, 25 Jun 2019 04:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hJ1vw1zo6Yo+NVBoQruROWjbHicMMrc+0Uq5a9tZI0E=; b=AtCxVJwKFF83GEQSiD5/UyKHSg1ExoYmFtw2Symdhw/wCQw8WfSqYsOwSLVDvVProW IA1d83IEb81JbfBdDvNgolRz4O+LVN1Tuw0/bfiu2tjVyk/Fm+r3ncH6VULwCoU/Cu+9 VO/DYwctluU9QQP/bca/HYt093rIWYRomNl/lekwrJE9unOWVRpkuIcDBKLn0kr6Vnc8 0S9nojlcDE+l3Q+K0UIe3UMEKlf8m1ndFqQq4BJEk18lmC2MRZgnZ/dpdL4pV4jMQHoY o258LxH0BHcR0hIAXDSxzwXYNXnCI3utaNv81DARxQqBKX1FmTWQZhDoWkJ3RZjIy+eB jMnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hJ1vw1zo6Yo+NVBoQruROWjbHicMMrc+0Uq5a9tZI0E=; b=Fj4FcM9xBumGro0KomoPYVPNi55hmfXn/49s7pOFH+wftG9YUVJlXTiixZONG/nqMj uOqmEBqaYBC+nSb2DdmJWVxKqHZ4cEgdIAEdJHQq4907oHBNUXmNOFmn+znjsdDB/RYj asuyS2YwiTHPSUffUknbJ8ePVMJkYx9SfZpPSm1xs3WZB9mLql6rVjQ3UClST5BTypAb sVNTyILqqog7oW83LAP5oE4EMLEYINxjKxdTUZxXHNnCh079r5lFYjmMHDc74TrOCGga to1tmeISc0JchbEyNVTEGWBcWZRvxzu+lW8jlov2xsOigPCmfJlPXUMRjR0ziS4UsW8/ JCKw== X-Gm-Message-State: APjAAAVpjGkdQ0ws9MU0YpRsJdQzo7s6FT++kA1PXJZnhU8r7slTvqgF g+G846v+lPy9eIh69fw3lMjkCQ== X-Received: by 2002:a2e:8345:: with SMTP id l5mr15081292ljh.18.1561460795234; Tue, 25 Jun 2019 04:06:35 -0700 (PDT) Received: from [192.168.0.36] (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.googlemail.com with ESMTPSA id h3sm2221123lja.93.2019.06.25.04.06.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 04:06:34 -0700 (PDT) Subject: Re: [PATCH 2/4] null_blk: add zone open, close, and finish support To: Damien Le Moal , "axboe@fb.com" , "hch@lst.de" , Chaitanya Kulkarni , Dmitry Fomichev , Ajay Joshi , Aravind Ramesh , "martin.petersen@oracle.com" , "James.Bottomley@HansenPartnership.com" , "agk@redhat.com" , "snitzer@redhat.com" Cc: "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "dm-devel@redhat.com" , Matias Bjorling References: <20190621130711.21986-1-mb@lightnvm.io> <20190621130711.21986-3-mb@lightnvm.io> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: <1aa6552c-ecf9-a168-df75-ec8c52ddbea6@lightnvm.io> Date: Tue, 25 Jun 2019 13:06:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/22/19 3:02 AM, Damien Le Moal wrote: > On 2019/06/21 22:07, Matias Bjørling wrote: >> 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; > > > With ZBC, open of a full zone is a "nop". No error. So I would rather have this as: > > if (zone->cond != BLK_ZONE_COND_FULL) > zone->cond = BLK_ZONE_COND_EXP_OPEN; > Is this only ZBC? I can't find a reference to it in ZAC. I think it should fail. One is trying to open a zone that is full, one can't open it again. It's done for this round. > >> + 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; > > Sam as for open. Closing a full zone on ZBC is a nop. I think this should cause error. And the code above would > also set an empty zone to closed. Finally, if the zone is open but nothing was > written to it, it must be returned to empty condition, not closed. Only on a reset event right? In general, if I do a expl. open, close it, it should not go to empty. So something > like this is needed. > > switch (zone->cond) { > case BLK_ZONE_COND_FULL: > case BLK_ZONE_COND_EMPTY: > break; > case BLK_ZONE_COND_EXP_OPEN: > if (zone->wp == zone->start) { > zone->cond = BLK_ZONE_COND_EMPTY; > break; > } > /* fallthrough */ > default: > 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; >> + } >> } >> > >