Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp517205iob; Wed, 4 May 2022 01:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU2b03fH6Ur9dNGmmSLy4S+QJ0wVyD/Jn5YAtp4cao2lvj20IOJmNOry3EzMtpq4ASkbbH X-Received: by 2002:a63:2b90:0:b0:3aa:b1df:df69 with SMTP id r138-20020a632b90000000b003aab1dfdf69mr17017411pgr.497.1651654297563; Wed, 04 May 2022 01:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651654297; cv=none; d=google.com; s=arc-20160816; b=P1D1H6qmTLUlPjNX+rc43uHt95t1nWG9h8gCCBUcZgtg4fWp9vTekU1Lc2xdilSX70 W/G3SJZxe8kL0lACRM/g9cAnyb58EjyaFZYe0kUViwEK6mMm+upuMTD9XX9IbRlVHAJ0 c40DVmWglEm86LFLmayKUevnEsCUKuPPcJ+ctwW6VkmIOlUQC2JEVV9TdEu2MKH9mUrf jbHFqQ+RIlHw+Z+ESPSx2Th+YCYQqbRJ46c9w9TkVEXevfizAUsQjhA1v3tX134MGQBo 1dEu6Eysq7RGZKeZZPus71gO2c7JCBlw9Pwe3rTOajM5phgg8UMIQoSYy8s+FnNRbTY8 7rsQ== 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 :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=dRT7i+B2Yov3mR9oGnGvAueqIkGXxxHVKRrgzcNI3cU=; b=GLMlrkY/saJA/n6+uzb+dNqj1a2DDS/8tMwlzNb4ZGSiLsRVkp8nOSMZ12sTZi12o6 w56wYtL+RBrsLOOMlTYdqnU16AwpyXcqkP2wBRIInUbQSh5+Vp6PoqJgT+2jppfP39so sbyvMHY8x92/AplozSxJ4KseHCx/KWED6NeUv5Px6GkHqmOEqJeiG7iMCiIkc1C4eHUf 0YFYpQt9afr6n0AySbtsm1h1vn1a40bYBb3R7i8CH9ekCZ0mEfjFFDFA308eNwsPMn4E IFbH6Laid4SWnnHkBEWpB53un1wrJ5PJl4eguM8DmHwC3Z0vaxklqD+HGPNasTbLoEju loUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dK2hgskR; 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 b3-20020a170902d50300b00153b2d164afsi2609788plg.183.2022.05.04.01.51.22; Wed, 04 May 2022 01:51:37 -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=dK2hgskR; 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 S1346514AbiEDIjI (ORCPT + 99 others); Wed, 4 May 2022 04:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346457AbiEDIiu (ORCPT ); Wed, 4 May 2022 04:38:50 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4922A2495F for ; Wed, 4 May 2022 01:35:11 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220504083509euoutp01d8228ecfb3b63360be766f2683ad92cd~r2e8uuqh13075630756euoutp01x for ; Wed, 4 May 2022 08:35:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220504083509euoutp01d8228ecfb3b63360be766f2683ad92cd~r2e8uuqh13075630756euoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651653309; bh=dRT7i+B2Yov3mR9oGnGvAueqIkGXxxHVKRrgzcNI3cU=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=dK2hgskREF92TYEpkqKsDjmkEjYwPK7wzzP1oiVva6bhCt79G74yWIFfuFfHSrERf fdgw42C1GDIKRj1T8l+6mqOTjxQ64hGvvb5aOLVawjptknwzmOiEqKcAN68byJrlMZ 1QYABbNq2ARnlq98jANcweeMCqJlFE72UlInrMxU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220504083509eucas1p1bf302755e2c37837eba93e0b599d169b~r2e8Q2IW10045900459eucas1p1g; Wed, 4 May 2022 08:35:09 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id A3.F1.10260.DBA32726; Wed, 4 May 2022 09:35:09 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220504083508eucas1p2b13cd91f8b71fcf1a929d098c710ed9e~r2e7a28PG0925109251eucas1p2Z; Wed, 4 May 2022 08:35:08 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220504083508eusmtrp1cf71a20db9e2f38cdbb8f13ea104ef26~r2e7ZXh5Y3254032540eusmtrp1W; Wed, 4 May 2022 08:35:08 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-a9-62723abdce8d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B3.74.09404.CBA32726; Wed, 4 May 2022 09:35:08 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220504083508eusmtip2e7e8bbafdd96bdd30b9c5ab3df5cab58~r2e7M-lMY2662026620eusmtip2R; Wed, 4 May 2022 08:35:08 +0000 (GMT) Received: from [192.168.8.130] (106.210.248.170) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 May 2022 09:35:05 +0100 Message-ID: Date: Wed, 4 May 2022 10:35:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 01/16] block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze Content-Language: en-US To: Bart Van Assche , , , , , , , , , , CC: , , , , , , , , , , , , , , , , From: Pankaj Raghav In-Reply-To: <3a178153-62c0-e298-ccb0-0edfd41b7ee2@acm.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [106.210.248.170] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA01Sf1CTdRzm+77v3r0swZch8Y15dAf5RxoYRd330kxOjff6ddbxR5d3wYA3 4IBJGwuVQ0b80CHKZE5lWDOxRKyWwLYAh7ZwDDYcASOaSnGCFsmAQwgaSIwXO/57Ps/nee77 PJ/7UrjQQIZRGZJcVioRZ0WQAsJonXdGmV+TJr/4s5pA+i4rjq7crSTR6cl5HNk13RiqqjzL R95uJ47Mnhoe6pkrwtDlKzcxNKLX4qjixiSBFsuHlrmS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zuceWLLL5 /2oplX9/3eM2Xd+QXdq3PZFf2ej6/aqfVTHX7tnzVJbsXa62TeWVZWu/+XuxArPfu5xefC2V 9bs/fY1R45vwVVHmJ5yvNLNOdQzvF3ETuqL26+XLit+sNxRiN/slCvx7WiMXmKBl/eLIq8Si KoGJ+rPn+5WveXx+Z5RxfphXsCDvB46aTMH+afozv4luUmJeq8RSnJFoqMVcVJwIAKUYqwP9 AwAA X-CMS-MailID: 20220504083508eucas1p2b13cd91f8b71fcf1a929d098c710ed9e X-Msg-Generator: CA X-RootMTR: 20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895 References: <20220427160255.300418-1-p.raghav@samsung.com> <20220427160255.300418-2-p.raghav@samsung.com> <3a178153-62c0-e298-ccb0-0edfd41b7ee2@acm.org> X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 On 2022-05-03 18:37, Bart Van Assche wrote: >>       sector_t zone_sectors = blk_queue_zone_sectors(disk->queue); >> +    sector_t capacity = get_capacity(disk); >>         if (!blk_queue_is_zoned(disk->queue)) >>           return 0; >> -    return (get_capacity(disk) + zone_sectors - 1) >> >> ilog2(zone_sectors); >> + >> +    if (is_power_of_2(zone_sectors)) >> +        return (capacity + zone_sectors - 1) >> >> +               ilog2(zone_sectors); >> + >> +    return div64_u64(capacity + zone_sectors - 1, zone_sectors); >>   } >>   EXPORT_SYMBOL_GPL(blkdev_nr_zones); > > Does anyone need support for more than 4 billion sectors per zone? If > not, do_div() should be sufficient. > You are absolutely right but blk_queue_zone_sectors explicitly changed the return type to uint32_t to sector_t in this commit: '113ab72 block: Fix potential overflow in blk_report_zones()'. I initially did have a do_div but later changed to div64_u64 to avoid any implicit down casting even though zone_sectors will be always limited to an unsigned int. >> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >> index 60d016138997..c4e4c7071b7b 100644 >> --- a/include/linux/blkdev.h >> +++ b/include/linux/blkdev.h >> @@ -665,9 +665,15 @@ static inline unsigned int >> blk_queue_nr_zones(struct request_queue *q) >>   static inline unsigned int blk_queue_zone_no(struct request_queue *q, >>                            sector_t sector) >>   { >> +    sector_t zone_sectors = blk_queue_zone_sectors(q); >> + >>       if (!blk_queue_is_zoned(q)) >>           return 0; >> -    return sector >> ilog2(q->limits.chunk_sectors); >> + >> +    if (is_power_of_2(zone_sectors)) >> +        return sector >> ilog2(zone_sectors); >> + >> +    return div64_u64(sector, zone_sectors); >>   } > > Same comment here. > > Thanks, > > Bart.