Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2063724ioo; Mon, 23 May 2022 09:17:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1KlCN3d2/tOrcmjEMeowcitVoQrRrMh6Os8+o6zW6vN8QJPe8+BIRr6bFTH78Q3vBK3OV X-Received: by 2002:a17:902:a50f:b0:162:28c6:bfac with SMTP id s15-20020a170902a50f00b0016228c6bfacmr4717711plq.99.1653322642789; Mon, 23 May 2022 09:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653322642; cv=none; d=google.com; s=arc-20160816; b=xhb3vbmWyoerkDolMjhcVW2fC70hMtTYQasXXm6SdqyJpIR1kL+nb5XmN4tW1wosCB xZHaAkJcH43j/iJAZopK8VFtFT1V99YHXIAZeN4tH7ApS4oSCcDb4jMjh4aME4r7vcMo z8mbKH2j6Ge0MZGNjOdsD0XFqeFeyhpdm0THF0OaBjq8mpvztY4qAOpSvI5XihX6btGT TK2mTUuBEnCaAQcpRrunY5b3Qj3OE6mVFfi6fmDm5ScuUSBbejinb/TZfgW24lFPRKD3 xX0l1XNtIm53cSwkxTCEUYsQDJ7aHdWV8mm8T20ie1WLnd/uZS/o7w/AFvs1BHpJuAHS wwfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=9W1pLbbKKEsanlon70WFxiL7DVRrcoEEPxlxXdEW3tc=; b=n+BGEsLLGqwQhB5FoHGzyltuaCAfr7dVjwZqHacoZOWUfLBAI+hp+DMl1xcJaRkFWR j3aI2eITpOTc6vRIio4e408HtGizcTTUJdIS3VL8+QMaSOva7GKuDfGnZeFTXIOclMV9 Cua5Sy7Hxp0qoh7GZzoliCv6J/9zWq+3ZuTJkmJGeg/RG0yq2bvUqlKX/Nz4qbmCkaM0 TfM5IqVgurJ+j0ZTEjupjtWx83k7cuAgDJACiWrvgCJBTxDXpZcy57Xww0i70Ydpzyav 7iU/4MI1lojzAqgiNmaFzLYYxDwg6NY24x7RE1alRzUnP9IJpWNmPbxAnGmWzAJjgkBn krqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="j+5dSK/d"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y17-20020a170902b49100b0015454f1f0dfsi9991081plr.28.2022.05.23.09.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 09:17:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="j+5dSK/d"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1C26663F9; Mon, 23 May 2022 09:16:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238390AbiEWQQr (ORCPT + 99 others); Mon, 23 May 2022 12:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238631AbiEWQQN (ORCPT ); Mon, 23 May 2022 12:16:13 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB9920F63 for ; Mon, 23 May 2022 09:16:12 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220523161611euoutp01dc7695105e7e75581ba5c6fa65388be6~xyB55ZxNv2128421284euoutp01O for ; Mon, 23 May 2022 16:16:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220523161611euoutp01dc7695105e7e75581ba5c6fa65388be6~xyB55ZxNv2128421284euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653322571; bh=9W1pLbbKKEsanlon70WFxiL7DVRrcoEEPxlxXdEW3tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+5dSK/d7b8Ph6xvXX8Q9EWPyzlu0EkiNlxa2nXL8c38PkTt5omi8GUyXEMibAPFe CISBDh+DsKGy6VMi0fkMfjFqZEnJtM6q56Sa5Ee4xSbg5j0mTGEluy+uZ6jHkS6DAO mCegylTPqTYKnGCQm12kKriPUdale5Hm4p3jmfLg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220523161609eucas1p27754a51739628374be85028f4954b683~xyB4VyB3q0957009570eucas1p2Z; Mon, 23 May 2022 16:16:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E4.A4.10009.943BB826; Mon, 23 May 2022 17:16:09 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220523161609eucas1p16c381cd9438240905bfdb0a739132e65~xyB3z4X131867318673eucas1p1E; Mon, 23 May 2022 16:16:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220523161609eusmtrp2b6776808758c9ecadcc8ec5d2a7ac2a3~xyB3zBIlt0219002190eusmtrp2N; Mon, 23 May 2022 16:16:09 +0000 (GMT) X-AuditID: cbfec7f2-e7fff70000002719-13-628bb3493b82 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 7D.19.09404.943BB826; Mon, 23 May 2022 17:16:09 +0100 (BST) Received: from localhost (unknown [106.210.248.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220523161608eusmtip23cd80bf73bf7fb5af10d44d04beb495e~xyB3eFHeK0812708127eusmtip2N; Mon, 23 May 2022 16:16:08 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, hare@suse.de, Johannes.Thumshirn@wdc.com Cc: linux-nvme@lists.infradead.org, dm-devel@redhat.com, dsterba@suse.com, jiangbo.365@bytedance.com, linux-kernel@vger.kernel.org, gost.dev@samsung.com, linux-block@vger.kernel.org, jaegeuk@kernel.org, Pankaj Raghav , Bart Van Assche , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v5 4/7] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Mon, 23 May 2022 18:15:58 +0200 Message-Id: <20220523161601.58078-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220523161601.58078-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7qem7uTDA73aVisvtvPZjHtw09m i99nzzNb7H03m9Xiwo9GJoubB3YyWexZNInJYuXqo0wWT9bPYrboOfCBxeJv1z0mi723tC0u 75rDZjF/2VN2ixsTnjJafF7awm7RtvEro4Ogx+Ur3h7/Tqxh87h8ttRj06pONo/NS+o9dt9s YP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K8fV2Ipzkg01GIuKk4EACpvuzJnAwAA X-CMS-MailID: 20220523161609eucas1p16c381cd9438240905bfdb0a739132e65 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220523161609eucas1p16c381cd9438240905bfdb0a739132e65 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220523161609eucas1p16c381cd9438240905bfdb0a739132e65 References: <20220523161601.58078-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A generic bdev_zone_no helper is added to calculate zone number for a given sector in a block device. This helper internally uses blk_queue_zone_no to find the zone number. Use the helper bdev_zone_no() to calculate nr of zones. This let's us make modifications to the math if needed in one place and adds now support for npo2 zone devices. Reviewed by: Adam Manzanares Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/nvme/target/zns.c | 2 +- include/linux/blkdev.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index e34718b09550..e41b6a6ef048 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -243,7 +243,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req) unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); return blkdev_nr_zones(req->ns->bdev->bd_disk) - - (sect >> ilog2(bdev_zone_sectors(req->ns->bdev))); + bdev_zone_no(req->ns->bdev, sect); } static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f5c7a41032ba..ed8742a72dcb 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1382,6 +1382,13 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev) return 0; } +static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec) +{ + struct request_queue *q = bdev_get_queue(bdev); + + return blk_queue_zone_no(q, sec); +} + static inline unsigned int bdev_max_open_zones(struct block_device *bdev) { struct request_queue *q = bdev_get_queue(bdev); -- 2.25.1