Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4809804iob; Mon, 9 May 2022 02:04:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHCRU9qVCQ+cRctEqYNA8kVimje4xP/YwUcVKfJfsldPABg/4WNPYx0fRVdZQbN0+/ejJt X-Received: by 2002:a17:90a:ee84:b0:1d9:27f3:eeeb with SMTP id i4-20020a17090aee8400b001d927f3eeebmr25684856pjz.66.1652087090907; Mon, 09 May 2022 02:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652087090; cv=none; d=google.com; s=arc-20160816; b=vJBb+IH8ilCvpVfm8D1cKRzm29mrkcAFytu6wEptrfwvHXua3fFpoV419b/JHZ3jxa 22Eell9+pSIAYl8NOF5zkJg+XMxChYoiCguGvvFEMS+QxmExX7FHNVi8dGWIFyh0DU1R AS6PouSkw/zL4qTphtfigJ2rFcip0Im5UzSz9dgD/ajfXoRvV6oxs4FUDWU2iGeOjhXD k87D80h7ae7r2XYfBrzlnQbZ+/PkpLzjeKSIfLY0Ap7P8ylVOBerz8ZYEPR3UVa+MYtR u0QeQhqoRki9WgltSY4Aa4x8OUu0O7UYgkNghBRXzJFud3jEhiVfbHQBFrDgjdJWf0Mt N5Hw== 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=JoTkUzSf8cmjlB530ADCoO43bw10TWyzB3g7Zv2AHq76xY9lnCQJX7GtC4wQvfgN0L wq+v3idlsH/p+lErWUuiOIog4w96gz1atLqOv6dGNPt4hp8HYRNXMilO6h0IHQ68u0oJ VTyvDe15Shz0y76PLQtkopl6GWBg3+BC5KGShhK2fWOS6gyOh9K2sV65vaA0cyJq2Zae vil6+MdOCuWHIsZoFtB+y5fXgpNRaALtCm1EhwU/dB0hdBkgPtZ0evAPt4c2AiQmsYqo 8hIaDg707t1BJ9qiJRInqBytK/lnYvhe//egoMwQZGh8uaXoQVnd0rPbShheE3T+kuLP fGKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=b9vcZ7tQ; 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 b4-20020a63cf44000000b003c6db713095si792907pgj.680.2022.05.09.02.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:04:50 -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=b9vcZ7tQ; 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 7750A403DC; Mon, 9 May 2022 01:51:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376901AbiEENzF (ORCPT + 99 others); Thu, 5 May 2022 09:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380150AbiEENyr (ORCPT ); Thu, 5 May 2022 09:54:47 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C761357110 for ; Thu, 5 May 2022 06:51:06 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220505135105euoutp02240f53b68a05e844191e5550b7395df6~sOcFJ5MDd0043500435euoutp02f for ; Thu, 5 May 2022 13:51:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220505135105euoutp02240f53b68a05e844191e5550b7395df6~sOcFJ5MDd0043500435euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651758665; bh=vrYMM/cTOrW0/UYYWyRRUQC9LsDHx9p6dz/qEYyG7Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9vcZ7tQ94f3VdiXUlJw+T1XLGmoWXNflO074KduS8EF9ysX5kXm1rt2m1oyipPJF U50l3s5pkVpoTOl0YLZI8MqqXX9N6AQmW707OVASef5mBymqwItd13057wGOgNgTDD KO6hTkj5nwC4MhPJeWVTwHKOJIMsISUeYasAXfkU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220505135103eucas1p23cfe1abbea461339e96795ea1bacf823~sOcDQPzY83233532335eucas1p2q; Thu, 5 May 2022 13:51:03 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1C.AC.09887.746D3726; Thu, 5 May 2022 14:51:03 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220505135102eucas1p10efc01a623d97cbd6634943faa506353~sOcCcJ-_r2600826008eucas1p1D; Thu, 5 May 2022 13:51:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220505135102eusmtrp2d6c56ae84c8e8295e4cea35a306dff91~sOcCX3XLs2658826588eusmtrp2C; Thu, 5 May 2022 13:51:02 +0000 (GMT) X-AuditID: cbfec7f4-45bff7000000269f-e9-6273d6477c32 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5D.F2.09522.646D3726; Thu, 5 May 2022 14:51:02 +0100 (BST) Received: from localhost (unknown [106.210.248.170]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220505135102eusmtip1164954ce909a59d1b207a210c6e6fd14~sOcCAQS_N0093500935eusmtip1F; Thu, 5 May 2022 13:51:02 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, dsterba@suse.com, jaegeuk@kernel.org, bvanassche@acm.org, hare@suse.de Cc: jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, matias.bjorling@wdc.com, gost.dev@samsung.com, pankydev8@gmail.com, Pankaj Raghav , Luis Chamberlain , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH v2 04/11] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Thu, 5 May 2022 15:47:04 +0200 Message-Id: <20220505134710.132630-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220505134710.132630-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxTVxiHc+69vb1UW6/FyZkumjXKFBTFme1sGja3JZ5EDQvbH7rvonfI VhBbihuMCLTCCvId2doBwgSRD1cKlVHAjHUOJNBBVmXthG4aajal6ASGBaGjvZj53/Oe87zn 977JYUjpvGANE5+YzCkT5QoZLaLaeryDW/cOq2K3/1WyHjWOFtKo7L6XRHO2QRINPcwkkLPb Qq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vGa8+ a+X65yGxqetNzVd+7WoMnmD388vu4xdvONxZ+uxbjFPqgfqkucuXbI6VsFJ+J6fx/M09JZbi jERDLeai4kQAFrE/TYEDAAA= X-CMS-MailID: 20220505135102eucas1p10efc01a623d97cbd6634943faa506353 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220505135102eucas1p10efc01a623d97cbd6634943faa506353 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220505135102eucas1p10efc01a623d97cbd6634943faa506353 References: <20220505134710.132630-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