Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4720551ioa; Wed, 27 Apr 2022 09:37:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVhVnNMTV+CzJpSbKmVSEpqnPyH/hf/qurFbw65wTSXLKHNSVg2VHSeDS1e8uU77LwnNYL X-Received: by 2002:a17:903:2406:b0:158:72dc:2d73 with SMTP id e6-20020a170903240600b0015872dc2d73mr30083446plo.46.1651077456320; Wed, 27 Apr 2022 09:37:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077456; cv=none; d=google.com; s=arc-20160816; b=eFUQaWqW5azGAF+Nky6jaEC7MmcJFGlFNBG2Pu+0lwfKnJhmB9lrQ5tPOeIRydfAzm itTl8eK3I8j+8icNRc2RMhZa4KCnZw5r0EmkY2ijYte7ZFk75wvvmMgBrMmcZGAD5hAD zRU4Dj56geVlCV68RkmRFADarq7OR9ssnW5B10GvqAN9XZiRPhXlOSYt/MGqkeQKJ8DS FKcX6wiNqniTx2quAP3Xf8jd8pUhNXF1Hxi1m4TIKLWVu3/FZPFdHcEz32gmzOOqPy69 k8gn6wRrYhhZ5Bzb/+Qkq98kMjHV4YQ/m2BP5+STAvXnEY5dzJ6yA//XumZ7j33lQnt4 0qtA== 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=hUBpZxkDXTvCbRzniY5oQe/mcS4maRVWN0mf8iYt6nk=; b=uJHnyTE9UdYZCs0qCDeaYxuOhUXyE5d23JSkopzWMK1UiZkOyUzISN5/mC0FgbuZI4 nuEVR0LEvKDnIVLRbyTOBRHikix6R9dXjPPK1P0cMg+vLskuPFQkfVYtlgZWpZ0TW8Ta +1xulihJF74NSWHAtJfvC0KcBr4gMp17Cstf2CIUx5WTpD84UV9qIyk1OARE6RtnllLl xu1lArjdiuXpoS3ACI6tMozWhjyQu1MlNYqGduGz9PvzwimHnGtnkytW7sOGrz9efQU2 isN68UfC0cy7OXv4cdCR8AbMHC/lKFVIrpbbJpTMm47QiMunvRvpHjmUM6SOztDwhuLk pKMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nUD3Zllj; 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 j6-20020a170902da8600b00153b2d16415si2461482plx.29.2022.04.27.09.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:37:36 -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=nUD3Zllj; 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 A571E4ABC53; Wed, 27 Apr 2022 09:07:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241903AbiD0QHf (ORCPT + 99 others); Wed, 27 Apr 2022 12:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241626AbiD0QGy (ORCPT ); Wed, 27 Apr 2022 12:06:54 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96833CE9B1 for ; Wed, 27 Apr 2022 09:03:07 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220427160303euoutp021adf0dfff62bc8f96d6dbb4e2b961af2~pzFAlqDbT1400814008euoutp02v for ; Wed, 27 Apr 2022 16:03:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220427160303euoutp021adf0dfff62bc8f96d6dbb4e2b961af2~pzFAlqDbT1400814008euoutp02v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651075383; bh=hUBpZxkDXTvCbRzniY5oQe/mcS4maRVWN0mf8iYt6nk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nUD3Zlljb1W0hKuro0V+VuS6AzNwVXo2IEBdL3HytZKp+pf4rjul8PwzEA8TIpSkW 7nJJ26TxElUXLp2CtpMD3NhzFJm4XRSCZtZ8SLFKMrDjwWSNHWQG3aYZcTV1wLjxje ypI6XKbLcp0CGsseTYr04mRkmN9XIp9n3ttp424c= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220427160300eucas1p2820b4ac90e9eb0636191f5d6b6009ac5~pzE_szwrg2336123361eucas1p2k; Wed, 27 Apr 2022 16:03:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D4.0A.10260.43969626; Wed, 27 Apr 2022 17:03:00 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a~pzE_QB5uM0602706027eucas1p1M; Wed, 27 Apr 2022 16:03:00 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220427160300eusmtrp11a05ef21462b132cd88f3aeacf09747f~pzE_N2fo72077420774eusmtrp1H; Wed, 27 Apr 2022 16:03:00 +0000 (GMT) X-AuditID: cbfec7f5-bf3ff70000002814-85-626969340c0e Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CC.97.09404.43969626; Wed, 27 Apr 2022 17:03:00 +0100 (BST) Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220427160300eusmtip201f34f7356e5fa50793f41df667dbd86~pzE93FBDa0262002620eusmtip2N; Wed, 27 Apr 2022 16:03:00 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com, sagi@grimberg.me, damien.lemoal@opensource.wdc.com, 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, Pankaj Raghav Subject: [PATCH 04/16] block: allow blk-zoned devices to have non-power-of-2 zone size Date: Wed, 27 Apr 2022 18:02:43 +0200 Message-Id: <20220427160255.300418-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxTVxjGOffc3lu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JDU7NbUgtQimj4mDU6qBKU0o8r2c c0vGDb+Q+80WSYcz9VMqFQJXmlr3rDjkvSuF6+j/Llk+9atRm7jPldSJbjlj8zXssc7Li6rc zI9Zfz2vemEqe/lL4M4V8y7O3sGeVlD3c1/SyWMh+6fv2iavcjNQTPpmROjh7Nq1T65JWh64 qcdQ77JNV/DM6hn3pzQs0lDmEHL2vX3280kOownb3x/vnDRjVva6xaqyTzdHfqy/s+6Ktk9T pO/R7x3+PVfOqG2Z+jdbbTLnprD3AQ1q7wXMvc9POl6rMJFZ+XCW2ffljOKruvI1Us5+Zn63 zvts5/bb59ledTZtEoxalqum/V0s+hVb8CG2swu3K/ZoXVwlVmcjEfzgz4t/O1c+P6zEUpyR aKjFXFScCAAgq28nsgMAAA== X-CMS-MailID: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a References: <20220427160255.300418-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.5 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 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 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)) 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); 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", -- 2.25.1