Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp25545iob; Wed, 27 Apr 2022 18:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhyThgBRXZCYLnnn13ar6HMeftmbflHNlQmLxoR/TqcEKzrNo4iTYAqaL5AqsAKjSZBsTx X-Received: by 2002:a05:6a00:1354:b0:50c:e672:edfc with SMTP id k20-20020a056a00135400b0050ce672edfcmr32148034pfu.50.1651107740261; Wed, 27 Apr 2022 18:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651107740; cv=none; d=google.com; s=arc-20160816; b=IAzbaJJKwGq6jpjZaH0XUDMh18Vtgr8+IK4EaclTppJqhRzqxYKN5uHOF9e/M0Z2Pd B4zez6pjcsOSlebUFfVpnR6jkjsU1rmtypc1BXhM7FV0LGY1GfP/swNbA8PD5y31y+VR MYhbkVIVqLPvoGRjLkZkDjKOr8Ptlu1NqvbZauVi9RnY2EqOS3SbIYjfdOh2dGfkxExf VvbPaxQnDSsyh5c7xOrVC4MS3je4l0owutYK4vkp+doZC/TjYlHS48PgcUMrbxpT5ifo gaVKE+E8XN9d2oguLnvNyF1O+4uFGIdaXNqxNk50T3oRF9AZ5IIYADX9iKwAymE1jw/N fZ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=3+shuYiOMOTbS7RmKTsh9Rcg33nlKjWDhWGRYehF4pY=; b=LHjRY461/AzlD4oYaT2at8LdkUr+SXEMHr8EAKFf9qgqIBe/vUS+yc0wMGpyS7hg4Z DlVrUwvQpZhcIvywuluS7hkbrw7+3X0gj0XElUqDamrozkiqeEdLOjSL8cU3vqtslWzL 1sI0SS31trwTQMCCy4WsMlF87aDY0AMth7/IC7BTU9dmYN1b7/qFuT1PEUY9Gn1U3SaC swZkEMph1Jv2uhTwRaqaIKTe798PVtnZi+nxLjyWNaxXI4NFiUMvJNyhzgq4fgOcS3eW fiEAbN8pS2TbCrHPvvpTYGjda57C5oVwJxOyttwjZgb6to1erYTxTxpm3JfNR5F7Yvjg CX6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=aa3edcSq; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=omMAaNcA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 126-20020a630384000000b003a94e627cc2si2996666pgd.360.2022.04.27.18.02.04; Wed, 27 Apr 2022 18:02:20 -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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=aa3edcSq; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=omMAaNcA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbiD0Xkz (ORCPT + 99 others); Wed, 27 Apr 2022 19:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiD0Xkw (ORCPT ); Wed, 27 Apr 2022 19:40:52 -0400 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D585710E for ; Wed, 27 Apr 2022 16:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1651102658; x=1682638658; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=yHKaW5zTI9WZN6XlbM6WV522YA4NJP0ufKH9fAehyOY=; b=aa3edcSqqCbqB/Jo77yKfnQ0PQg1i3+tiAujHUcR3XBbT8szvFmAYBmw KPLRUi0u3ecKmt74//GH/qX4aa9sPnvEEl5225FXrNwwlUPeAiY18uJf/ GA/wxKdheHHF+2rHYkllfARxT7LE6Rdakp45QrsboGiAalRaeVhS7LAFG iWHxfOpidB7QNkrdQPAlH0eRbSCqPgPkW9lQoYXGovduiV04C/tXtnTLy gu/ywCrAvhBvSj5GM4/9pqLyustGYQ92lOqT5LH8CVklNxvJ9iQR2CwKV iyJaTl+B53QZ9vO9BoHTBScqqzeu+rQjX+CZ9TSbb67Mp9s7jktMKNfIW g==; X-IronPort-AV: E=Sophos;i="5.90,294,1643644800"; d="scan'208";a="203872993" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Apr 2022 07:37:35 +0800 IronPort-SDR: 6Qa5AU5+QIauTlqhUot24gDYQxK88eWXeDXUotbB+Lk0Mgu73qddzQokDS9cW9OBaOPPsVdWno AaJOuQ/ikxiDkLlDSUVZNSSvICiF27AuQdREM9SqAWACOlIbwlOkecDshk51is5dL9IRytqeor UaR9wNICqaK8s/P/J3FM4tn1XJznaGGcmKQuWTCQxwF6yc0J+i5bJ9DBb1MgvvNRp+C3nDq/Oc iHoH3/Hb5ZpNTTp4mG8WZkoC5UCi64sYaIwhh2E1G4zqULiNh7WAi33UbA5j6MghwgjkY6OYFe t0b5A/NBlLmTro6D+n6axr56 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2022 16:07:45 -0700 IronPort-SDR: oBVrC8WURfayrQOjA/Xu8wcrG/O85ud0r4knicR020fgFJ8bUZt36ybMx0s2n2vmtJFJvgbeky HotcRYf2HzDYzXM9o9xx6+Yxo8s6d0FVIjMOPp9LW3HevaVo8tg9FwFHN0lrTF6Y94hydwpmVC pfb69e0v/lnRfbQ47VibD9ONebahuavVYeG0AvazjWH4ZW+qRnYCsdx3dldXjPlc8wZ27SOWeI yUBDuxBBKOl7vzPBKS119OIyacSuv588R+dZafEeSvAnqSyVeHfIbhCt0vGL6YomT/ipkWc54X vX0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2022 16:37:36 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KpZt70vJ6z1Rwrw for ; Wed, 27 Apr 2022 16:37:35 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1651102654; x=1653694655; bh=yHKaW5zTI9WZN6XlbM6WV522YA4NJP0ufKH 9fAehyOY=; b=omMAaNcAu4C2yHYQb1NClkSwg2xHp13YAJ2SJFHQcpzAm7KwKtr LoyEbaprBAqXCi8vJVE8STd2nWRh72RwP+tsxCLdjrW122FhlORiBAJ8dnK+srl9 3w1eKFOkpl1sQiG+Jw/wdu7z2ERwVaBSZVfkOkvF99qQqSEXxFfHnln0i40KAU/Z Rgsaekp7gheGMuCzGRy7neZeHEpBkYADsxKlKyaPXvPrCEfGYZfBs8AldO5KdA8A Widzt5gxXgMgTajwk3U2C0i7oJEtbBMNJ39YP0YWgmM6yf9XrjjBtapx0eQ1JfGG dk7Riq4IhGTM4HZ/ocUmEc8dhcniKD7mQgw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qL7Cq-8OnPUM for ; Wed, 27 Apr 2022 16:37:34 -0700 (PDT) Received: from [10.225.163.27] (unknown [10.225.163.27]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KpZt05KG9z1Rvlc; Wed, 27 Apr 2022 16:37:28 -0700 (PDT) Message-ID: Date: Thu, 28 Apr 2022 08:37:27 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 04/16] block: allow blk-zoned devices to have non-power-of-2 zone size Content-Language: en-US To: Pankaj Raghav , jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com, sagi@grimberg.me, dsterba@suse.com, johannes.thumshirn@wdc.com Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, clm@fb.com, gost.dev@samsung.com, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com, jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org, kch@nvidia.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, linux-block@vger.kernel.org References: <20220427160255.300418-1-p.raghav@samsung.com> <20220427160255.300418-5-p.raghav@samsung.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20220427160255.300418-5-p.raghav@samsung.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 On 4/28/22 01:02, Pankaj Raghav wrote: > 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. > > The only hot path affected by this change for power_of_2 zoned devices > is in blk_check_zone_append() but the effects should be negligible as the > helper blk_queue_zone_aligned() optimizes the calculation for those > devices. Note that the append path cannot be accessed by direct raw access > to the block device but only through a filesystem abstraction. > > Finally, remove the check for power_of_2 zone size requirement in > blk-zoned.c > > Reviewed-by: Luis Chamberlain > Signed-off-by: Pankaj Raghav > --- > block/blk-core.c | 3 +-- > block/blk-zoned.c | 12 ++++++------ > 2 files changed, 7 insertions(+), 8 deletions(-) > > diff --git a/block/blk-core.c b/block/blk-core.c > index 937bb6b86331..850caf311064 100644 > --- a/block/blk-core.c > +++ b/block/blk-core.c > @@ -634,8 +634,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q, > return BLK_STS_NOTSUPP; > > /* The bio sector must point to the start of a sequential zone */ > - if (pos & (blk_queue_zone_sectors(q) - 1) || > - !blk_queue_zone_is_seq(q, pos)) > + if (!blk_queue_zone_aligned(q, pos) || !blk_queue_zone_is_seq(q, pos)) blk_queue_zone_aligned() is a little confusing since "aligned" is also used for write-pointer aligned. I would rename this helper blk_queue_is_zone_start() or something like that. > return BLK_STS_IOERR; > > /* > diff --git a/block/blk-zoned.c b/block/blk-zoned.c > index 1dff4a8bd51d..f7c7c3bd148d 100644 > --- a/block/blk-zoned.c > +++ b/block/blk-zoned.c > @@ -288,10 +288,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, > return -EINVAL; > > /* Check alignment (handle eventual smaller last zone) */ > - if (sector & (zone_sectors - 1)) > + if (!blk_queue_zone_aligned(q, sector)) > return -EINVAL; > > - if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity) > + if (!blk_queue_zone_aligned(q, nr_sectors) && end_sector != capacity) > return -EINVAL; > > /* > @@ -489,14 +489,14 @@ 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 zoned device size", > + disk->disk_name); The message is weird now. Please change it to "Invalid zone size". Also, the entire premise of this patch series is that it is hard for people to support the unusable sectors between zone capacity and zone end for drives with a zone capacity smaller than the zone size. Yet, here you do not check that zone capacity == zone size for drives that do not have a zone size equal to a power of 2 number of sectors. This means that we can still have drives with ZC < ZS AND ZS not equal to a power of 2. So from the point of view of your arguments, no gains at all. Any thoughts on this ? > return -ENODEV; > } > > args->zone_sectors = zone->len; > - args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len); > + 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", -- Damien Le Moal Western Digital Research