Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3317328iob; Mon, 16 May 2022 19:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIKLmp9McS2wsxJm4Ux8HSPiGOtAaHJasRVPrB84E+GKydyqcmfS9KXqxGl2coxL7WE+L/ X-Received: by 2002:a05:6a00:15d0:b0:50e:b15:cc43 with SMTP id o16-20020a056a0015d000b0050e0b15cc43mr20665185pfu.28.1652753488975; Mon, 16 May 2022 19:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652753488; cv=none; d=google.com; s=arc-20160816; b=iR8mSJQpEZMLSAFCTdAEBBr+1Nv0uOLf/CW0eSNCZ2ZDFT6fuusTjmEtEfsj+/aXQ7 npR3vnBHMAnz2P8JHF9Tan+IGUfst5A/o7tWROWjMJHzn7V/uJlk312KTBX05q9ibSE7 XqlztOa2KZgenNyImZVXgZ7j8f0dw0545KlG2VP2sKO3jGgiY1mpF7x8j/rGknObz3vM vvUChjJol4xRN9RYTixYQW+BDGCjWZceevgxTiGGJdLamiP2mCUGjSLh1r7GK3llcYkB 8V4lhrknfY4H76JXwdflCtB/pNtoi0Ou+89x7UwhgZUMGHBh3c/1kszrFiokOCBAw2h4 +EKg== 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=h7+/E7H/MRyrFasC/KFBpCGKVHCYzopaapRzkpChakE=; b=FKA/YpvOOU+uGJoaECMxcWtMbkhnl3U8Pf3gNw5w+cRuVwqLVvYOi/1mGY33/phl8w relzCxhEmDV9QdXA2IRxM814YVGtZC3rYu4e8OvKmGTu+qpx6qiN0x1IpYgT9HGmt7D/ ZWRO4hqil92m7Fh/o27RsguF9VrzF9XPZoBE/afbVZpVjI8iZGwQK7Q+iArtQ2wmk7C3 JYpXzZ1op/9WIfGrXGyZU+NDc4zTFMxuRLt2od0zpb+B6X7oIv6HktXddF04uTulWw5J sbXQsfvhtXLvCVKuDCedkzhd1l90SkjYpdpjsxbTOk9kqjRaIdltAehpsB2FfwMpd8dz rlzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=J3t8bIKw; 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 om17-20020a17090b3a9100b001d1ad44a667si1334342pjb.6.2022.05.16.19.11.16; Mon, 16 May 2022 19:11:28 -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=J3t8bIKw; 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 S235967AbiEPTFq (ORCPT + 99 others); Mon, 16 May 2022 15:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345195AbiEPTFp (ORCPT ); Mon, 16 May 2022 15:05:45 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C5C3273 for ; Mon, 16 May 2022 12:05:40 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220516190537euoutp0232f7fde909c3f026764ff78f5622889e~vq018bEzw1645916459euoutp02O for ; Mon, 16 May 2022 19:05:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220516190537euoutp0232f7fde909c3f026764ff78f5622889e~vq018bEzw1645916459euoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1652727937; bh=h7+/E7H/MRyrFasC/KFBpCGKVHCYzopaapRzkpChakE=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=J3t8bIKww9U91/aXllUx1XFJqoWz8qTBsMAIBINzB4M2tDEHcb+K6B6lI4mhfdYdv nmXw042wt9qwP8rLDH3WmzHnrEHxQT8ddWthxFJqP1JuiQMvWK9SF6apfRvdc+glKc UfLYZ0UWK1ScE07V9alm7bMZyRwAt0qHqwyjX2r0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220516190537eucas1p1827e4dc46edb0e9fd4eef7e9067f07a0~vq01ienVy2497024970eucas1p1I; Mon, 16 May 2022 19:05:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 07.CC.10260.080A2826; Mon, 16 May 2022 20:05:37 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220516190536eucas1p2ee3b60a2f6bc708919b76d35e69562a2~vq00_9hJ02269122691eucas1p28; Mon, 16 May 2022 19:05:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220516190536eusmtrp14da1d7baf4a6dcff2f764c9908a67164~vq00_HXpd1633216332eusmtrp1D; Mon, 16 May 2022 19:05:36 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-8b-6282a080c59a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D6.23.09404.080A2826; Mon, 16 May 2022 20:05:36 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220516190536eusmtip2c5868c94ebcb947cde3c0db117dc5408~vq00zV-qZ2254722547eusmtip23; Mon, 16 May 2022 19:05:36 +0000 (GMT) Received: from [192.168.8.130] (106.210.248.7) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 May 2022 20:05:34 +0100 Message-ID: Date: Mon, 16 May 2022 21:05:32 +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 v4 02/13] block: allow blk-zoned devices to have non-power-of-2 zone size Content-Language: en-US To: CC: , , , , , , , , Luis Chamberlain , , , , From: Pankaj Raghav In-Reply-To: <20220516165416.171196-3-p.raghav@samsung.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.210.248.7] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrEKsWRmVeSWpSXmKPExsWy7djP87qNC5qSDGa2MlmsvtvPZvH77Hlm i73vZrNaXPjRyGSxcvVRJoueAx9YLPbe0ra49HgFu8WevSdZLC7vmsNmMX/ZU3aLGxOeMlqs ufmUxYHX49+JNWweO2fdZfe4fLbUY9OqTjaPzUvqPXbfbAAKt95n9Xi/7yqbx/otV1k8Pm+S C+CK4rJJSc3JLEst0rdL4MrY/uA0Y8EfuYrDCzYxNjAuk+hi5OSQEDCReLf0HUsXIxeHkMAK RomN/X+YIJwvjBLvry1ih3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515446ac290987bdb9af24ffb835b287 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220516165421eucas1p2515446ac290987bdb9af24ffb835b287 References: <20220516165416.171196-1-p.raghav@samsung.com> <20220516165416.171196-3-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,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 Hi Damien, I copied your comments from the previous thread to avoid confusion. On 2022-05-16 16:00, Damien Le Moal wrote: > On 2022/05/16 15:39, Pankaj Raghav wrote: >> Checking if a given sector is aligned to a zone is a common >> operation that is performed for zoned devices. Add >> blk_queue_is_zone_start helper to check for this instead of opencoding it >> everywhere. >> >> Convert the calculations on zone size to be generic instead of relying on >> power_of_2 based logic in the block layer using the helpers wherever >> possible. >> >> @@ -490,14 +490,29 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx, >> * smaller last zone. >> */ >> if (zone->start == 0) { >> - if (zone->len == 0 || !is_power_of_2(zone->len)) { >> - pr_warn("%s: Invalid zoned device with non power of two zone size (%llu)\n", >> - disk->disk_name, zone->len); >> + if (zone->len == 0) { >> + pr_warn("%s: Invalid zone size", >> + disk->disk_name); > > This fits on one line, no ? > Yeah. I don't know why my formatter decided to do that. I will fix it. Thanks. >> + return -ENODEV; >> + } >> + >> + /* >> + * Don't allow zoned device with non power_of_2 zone size with >> + * zone capacity less than zone size. >> + */ >> + if (!is_power_of_2(zone->len) && >> + zone->capacity < zone->len) { >> + pr_warn("%s: Invalid zoned size with non power of 2 zone size and zone capacity < zone size", >> + disk->disk_name); > > Very long... What about: > > pr_warn("%s: Invalid zone capacity for non power of 2 zone size", > disk->disk_name); > This looks better. I will fix it up! >> return -ENODEV; >> } >> >> args->zone_sectors = zone->len; >> - args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len); >> + /* >> + * Division is used to calculate nr_zones for both power_of_2 >> + * and non power_of_2 zone sizes as it is not in the hot path. >> + */ > > This comment is not very useful. > I also saw you mentioning the comment was not useful in nvme code for a similar scenario. Hannes brought up a point about making it explicit when we are not using any special path for power of 2 zone sizes as in most cases we do branching if the zone size is power of 2 to avoid division. >> + args->nr_zones = div64_u64(capacity + zone->len - 1, zone->len); >> } else if (zone->start + args->zone_sectors < capacity) { >> if (zone->len != args->zone_sectors) { >> pr_warn("%s: Invalid zoned device with non constant zone size\n", >> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >> index 22fe512ee..32d7bd7b1 100644 >> --- a/include/linux/blkdev.h >> +++ b/include/linux/blkdev.h >> @@ -686,6 +686,22 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q, >> return div64_u64(sector, zone_sectors); >> } >> >> +static inline bool blk_queue_is_zone_start(struct request_queue *q, sector_t sec) >> +{ >> + sector_t zone_sectors = blk_queue_zone_sectors(q); >> + u64 remainder = 0; >> + >> + if (!blk_queue_is_zoned(q)) >> + return false; >> + >> + if (is_power_of_2(zone_sectors)) >> + return IS_ALIGNED(sec, zone_sectors); >> + >> + div64_u64_rem(sec, zone_sectors, &remainder); >> + /* if there is a remainder, then the sector is not aligned */ > > Hmmm... Fairly obvious. Not sure this comment is useful. > True. I will remove it. >> + return remainder == 0; >> +} >> + >> static inline bool blk_queue_zone_is_seq(struct request_queue *q, >> sector_t sector) >> { >> @@ -732,6 +748,12 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q, >> { >> return 0; >> } >> + >> +static inline bool blk_queue_is_zone_start(struct request_queue *q, sector_t sec) >> +{ >> + return false; >> +} >> + >> static inline unsigned int queue_max_open_zones(const struct request_queue *q) >> { >> return 0; > >