Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4631688iob; Sun, 8 May 2022 19:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykRP/jeq1tjzrbzmeKCEnLMBbjJ3ZXFtGE+0rjEvy6/5+729Wdld2NtIWpyFGhpVqyt5Y4 X-Received: by 2002:a63:c015:0:b0:385:fe06:eb86 with SMTP id h21-20020a63c015000000b00385fe06eb86mr11357703pgg.132.1652064985292; Sun, 08 May 2022 19:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652064985; cv=none; d=google.com; s=arc-20160816; b=LsgWIm91c7vjIN04jdYCJLY7LngM6VBhaAPTOMdcYc7wRQilHakgV1616Rtg/1T2UF U6DsFSLtjqvnQjfvbz6xTJH/vBb4kZDfZjyIw+VerLUk290cRH93stlub6hIjPE5WdlT izyKM5mS6106X38fQEkRtRtKOczAHuNm/vfRV107cPG37spGecxB+bbLYQzY3deCJJes GCnao9N/GwRTKVbkpR2w6yS7NxqAec+mz01gAhHYQdVsi009/L/Wavw8G7YsZ0ZlGjsG imqMC9f2Q9izxn7+6HhuYml62ZBX5maXat+2G0tNkhNStKyOo8GcT9gqAMCB++l+WcuY vjAA== 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=vrYMM/cTOrW0/UYYWyRRUQC9LsDHx9p6dz/qEYyG7Ug=; b=A45NXm53r0pHdZi9+BJJJsNoL5HBXTGIM3lZfQE8ueQBIfNevRa5heT0sqyf73hCyp RZlpTlyByyje7MPVsRjBvs59YzuX+2AS92LQuyN36AVuLE3V2+MMyvwiIlO8NzBzVpMX McMCyDh3WgGkSQZ17hV7H+tj+MiL9UajL+R7KkG9MhFEZEqe01P1H3x+dNHRNJ9ftxy8 BLRJMDUT+vVMkllKK/HBG0fmMtwX9vj46HB/6vqFH0O8ws3be5hdg+1HBIgtVikVhgmH t5zMjqqBTqEPbVip5L7dZZ1+NYS3Q3HIOexpySO+Xd30EHZdHsVsT1DYNO0FN896V8xq G5UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mmTePLGw; 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 k186-20020a6384c3000000b003c642b43d4fsi9863110pgd.520.2022.05.08.19.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:56:25 -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=mmTePLGw; 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 D8C8C81FDF; Sun, 8 May 2022 19:55:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376303AbiEFIPf (ORCPT + 99 others); Fri, 6 May 2022 04:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389859AbiEFIPH (ORCPT ); Fri, 6 May 2022 04:15:07 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9797A67D31 for ; Fri, 6 May 2022 01:11:18 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220506081112euoutp014a085c0176c6f102b6fc3df183912d18~sdcnQh75j2290722907euoutp018 for ; Fri, 6 May 2022 08:11:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220506081112euoutp014a085c0176c6f102b6fc3df183912d18~sdcnQh75j2290722907euoutp018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651824673; bh=vrYMM/cTOrW0/UYYWyRRUQC9LsDHx9p6dz/qEYyG7Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mmTePLGw4WStsyva52M2FKpil6omiccqCPYZ4GIQEsZ//VNJXoXEYLaOqeWV10nuU H1KB/2RLGV3AAL91mXIlKUu1yvrmAsSoKUK3i9resOCgmy5mYJoxFff3E0dVac7DiF zuJl0kHbOaDAUn2cOtbKeKzSTj1SPHrWhq/K78Zk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220506081110eucas1p29f4ec4b6163302f91ffd1654e9132bc4~sdclV3MUy0616806168eucas1p2n; Fri, 6 May 2022 08:11:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C8.05.09887.E18D4726; Fri, 6 May 2022 09:11:10 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220506081110eucas1p1b6c624ddca1c41b9838bb5b85f8ca5ff~sdck9wLVm1797017970eucas1p1B; Fri, 6 May 2022 08:11:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220506081110eusmtrp222f0eafc663deb2c7f6b2252e5b9e61c~sdck8jKjJ2593625936eusmtrp2X; Fri, 6 May 2022 08:11:10 +0000 (GMT) X-AuditID: cbfec7f4-471ff7000000269f-31-6274d81ece15 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 82.F2.09522.E18D4726; Fri, 6 May 2022 09:11:10 +0100 (BST) Received: from localhost (unknown [106.210.248.174]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220506081110eusmtip15b4e6a476e2eada8a56f7f54296837f1~sdckpd6-70578205782eusmtip1b; Fri, 6 May 2022 08:11:10 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org Cc: Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v3 04/11] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Fri, 6 May 2022 10:10:58 +0200 Message-Id: <20220506081105.29134-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220506081105.29134-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxTZxTGee+9vf2IhUsx8I6KbE38A9AqCyHv3MJcYrYbF3XZ5sY+xBW5 KwQorB8ONZlFEAU2Cjj5KCwwMq1Q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GJpry7BRmdi8/2sussnObANj3jmKR27dyYo2FW9nPe Kxg+83my3yj2QBCP6vKKh/cPLL50uD5ApnPz26VMv4IETk7lqhDRuXPzke68vn29jqsDmpyX h81emz/DqGrSjdu5T7rnaPXUmPuGLyjV1A4VPz1N5db6V1LpYV9yHRZWCLOtu17/10nBr97g zLnosx/e+bTL+LsdVXaNt01oaj/Z+D76WL6GhLrhPDf2V4H5jmKV99gNAydtWZhsdnHJoh5h 7dYHL263X50gX3L35OwdMS6Cyfe+rkl3es9nxT01UfnC57jEt9zbeqQicg7bPU+w2b0oSoml OCPRUIu5qDgRABxkWpSzAwAA X-CMS-MailID: 20220506081110eucas1p1b6c624ddca1c41b9838bb5b85f8ca5ff X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220506081110eucas1p1b6c624ddca1c41b9838bb5b85f8ca5ff X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220506081110eucas1p1b6c624ddca1c41b9838bb5b85f8ca5ff References: <20220506081105.29134-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 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 82b61acf7..5516dd6cc 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -242,7 +242,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 32d7bd7b1..967790f51 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1370,6 +1370,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