Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4169139ioo; Wed, 25 May 2022 17:12:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5yV6uSLjuL+PKDtH+FfT+//Uvl2vLlwsx17MVOtlN+AKW+j01NsEQAVmNeEVQ5jmmbwZs X-Received: by 2002:a05:6402:b36:b0:42b:cd47:8d7 with SMTP id bo22-20020a0564020b3600b0042bcd4708d7mr4825346edb.337.1653523951965; Wed, 25 May 2022 17:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653523951; cv=none; d=google.com; s=arc-20160816; b=lV8B/62vHV7ykfkGjNG/7+i8rwRJU3u9jgD+QB7dgNHHX3UtbPMO/I80Fq9opCgT+2 JnEP/NhPooEqajfuPH65xQqoHI073BfvfuLGVeubDaDUVGRvIXi+OOriY7iK+Kpu4epn 0HaWzxFlDGvMyURMsQ0ghKvyYPPeMFkRHwkeN/G4PUeUh0nhbh3XLvMtc14mBFybLb+T Ji5BLyYsXy35EVOF52FevCvT1Jt3qDeBilcOL2v2/plP6kXHGs980DEPa3MczjUhihF/ jaZtGzR99sVZt+VPB8fP6v96taxxypq00iF4rd8wfcrZfvpFnlA+pBsRr8Hy4AwgcSMA 7nRQ== 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=BCFV2LBUNqEf+dV2Fq86i+j2NBtT0y3Z5BLK9XhReQf73MwrNTXf7LeHiJBPPpgP+V xUH0ju0zbbWFG0zH1eUhMwof5tk+UHve7It9ByZigpHhEHO3bIFvoTueHO7cWgoPikaU 6jeLk2mwayrQNG89vAN0KLTxIx24rckkWkAtK6jh1xoMfO9qy+VT1io6nb5J1WMLC89Z RhtvXjP1y9VFvRbe3pPAccIq2jKwEWIsFNFWAZptl9IThF+CPW1+4UxSqigfy4mqqEwn JprliJdZ1m/t4pR767Quar1heKATpTD4XCeS5JTjKUvsLf+fRYTr8xPa0lyC2RiDqu3P lj3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=EUtqN6Uo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd9-20020a1709069b8900b006fec955c743si99196ejc.375.2022.05.25.17.12.01; Wed, 25 May 2022 17:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=EUtqN6Uo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245371AbiEYPuk (ORCPT + 99 others); Wed, 25 May 2022 11:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245368AbiEYPuI (ORCPT ); Wed, 25 May 2022 11:50:08 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D81B0A42 for ; Wed, 25 May 2022 08:50:07 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220525155006euoutp02f839f9c1fa5728d668d501a4787a785f~yY9ssHz5E0354103541euoutp02G for ; Wed, 25 May 2022 15:50:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220525155006euoutp02f839f9c1fa5728d668d501a4787a785f~yY9ssHz5E0354103541euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653493806; bh=9W1pLbbKKEsanlon70WFxiL7DVRrcoEEPxlxXdEW3tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EUtqN6UoLdNj6uWhYdhS76kwjBfchXAD6tXcjKypXGQ5Zor9Uv0/pySK48uRJXz2Q Mxjpz9wLtPAQAt3vBJyqK5aFYKN+YiBxC47cgh17iOxGWX9J+/YAmUi3SuV0Tl01RD OEM7kEUVkpnnfgszDWcWjmmLA/FzWiceeimxHmRk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220525155004eucas1p2dfa1a7a6b945f9b09d92979e69409947~yY9rKj9GH0574305743eucas1p2V; Wed, 25 May 2022 15:50:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D8.43.09887.C205E826; Wed, 25 May 2022 16:50:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220525155004eucas1p162c6f43536424f93800ba788ed045363~yY9qwmLNY1064710647eucas1p1p; Wed, 25 May 2022 15:50:04 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220525155004eusmtrp26fd7b673c6e99ce337989ba209192d6f~yY9qvwSZQ0177001770eusmtrp2Z; Wed, 25 May 2022 15:50:04 +0000 (GMT) X-AuditID: cbfec7f4-45bff7000000269f-6c-628e502c8c17 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.9E.09404.B205E826; Wed, 25 May 2022 16:50:03 +0100 (BST) Received: from localhost (unknown [106.210.248.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220525155003eusmtip11ab0a9c1aac41be6c73f997f027f7090~yY9qdZ3lV1835018350eusmtip1C; Wed, 25 May 2022 15:50:03 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, damien.lemoal@opensource.wdc.com, snitzer@redhat.com, Johannes.Thumshirn@wdc.com, hch@lst.de, hare@suse.de Cc: dsterba@suse.com, dm-devel@redhat.com, jiangbo.365@bytedance.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, gost.dev@samsung.com, Pankaj Raghav , Bart Van Assche , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v6 4/8] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Wed, 25 May 2022 17:49:53 +0200 Message-Id: <20220525154957.393656-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525154957.393656-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87o6AX1JBgcOy1isvtvPZjHtw09m i99nzzNb7H03m9Xiwo9GJoubB3YyWexZNInJYuXqo0wWT9bPYrboOfCBxeJv1z0mi723tC0u 75rDZjF/2VN2ixsTnjJafF7awm7RtvEro4Ogx+Ur3h7/Tqxh87h8ttRj06pONo/NS+o9dt9s YPPY2Xqf1eP9vqtsHn1bVjF6rN9ylcVj8+lqj8+b5DzaD3QzBfBGcdmkpOZklqUW6dslcGWc XGNZcJK/Yte5x+wNjPN4uxg5OSQETCS+7VjN3sXIxSEksIJRYu+u86wQzhdGiWNrGpkhnM+M EksvdrHDtOxeepcNIrGc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7/Tqxh87h8ttRj06pONo/NS+o9dt9s YPPY2Xqf1eP9vqtsHn1bVjF6rN9ylcVj8+lqj8+b5DzaD3QzBfBG6dkU5ZeWpCpk5BeX2CpF G1oY6RlaWugZmVjqGRqbx1oZmSrp29mkpOZklqUW6dsl6GWcXGNZcJK/Yte5x+wNjPN4uxg5 OSQETCR2L73LBmILCSxllFh6IwciLiFxe2ETI4QtLPHnWhdQDRdQzTNGiYYnF4ESHBxsAloS jZ3sIHERgU5GiTn7WsEcZoEmZolzC9czgxQJC4RIvG3jABnEIqAqcfTiR3aQMK+AlcT8OVEQ 8+UlZl76zg5icwpYS8zf/5kZ4h4ria93vrKC2LwCghInZz5hAbGZgeqbt85mnsAoMAtJahaS 1AJGplWMIqmlxbnpucVGesWJucWleel6yfm5mxiBkbvt2M8tOxhXvvqod4iRiYPxEKMEB7OS CO+Fp71JQrwpiZVVqUX58UWlOanFhxhNgc6eyCwlmpwPTB15JfGGZgamhiZmlgamlmbGSuK8 ngUdiUIC6YklqdmpqQWpRTB9TBycUg1M3JOrAro0JyveN36aE7Q8uXR/7N4vigU7mxfWMifo 8r8PZFLqeBS8VmmefMwJM80HkkbLtigt8uQvyD/9bWuLKO9mLzHpxq2MnKeFXEv2CKjb/wj+ tmT2nLDoRxceKlWVXJn7ZL/vZGOf7gp/EVH5lksN/cqPXXZOritM1HjEU2j+o0Y1S3JvfuT5 qDef77y+M3vmry1lphNNfhcsc9n2/yXfrNPP4rMChefc/CeSLKMwY/muZ1xHzoa+msRTtcVl a/n/vXWGGdPaJPQ0hbWu1l5YaLn99L27CgI+LTXf2Gc7nNhfs32S0Vu5ZxXvO57FZczdvv8u Y25qV/wLmwdX/z33LPv+azO3g5aRdliMEktxRqKhFnNRcSIANKoc7WUDAAA= X-CMS-MailID: 20220525155004eucas1p162c6f43536424f93800ba788ed045363 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220525155004eucas1p162c6f43536424f93800ba788ed045363 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220525155004eucas1p162c6f43536424f93800ba788ed045363 References: <20220525154957.393656-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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