From patchwork Wed Jun 15 10:19:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882042 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4DD4CCA473 for ; Wed, 15 Jun 2022 10:19:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-bTzr0hMoMu2ml3l8GVnvTA-1; Wed, 15 Jun 2022 06:19:35 -0400 X-MC-Unique: bTzr0hMoMu2ml3l8GVnvTA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4581A185A7A4; Wed, 15 Jun 2022 10:19:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33D3C111F5; Wed, 15 Jun 2022 10:19:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EBDCC194975A; Wed, 15 Jun 2022 10:19:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 35AFD194705C for ; Wed, 15 Jun 2022 10:19:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1C5FB1121315; Wed, 15 Jun 2022 10:19:33 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 182B51121314 for ; Wed, 15 Jun 2022 10:19:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F20A383397F for ; Wed, 15 Jun 2022 10:19:32 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-n1-eUfapPGu75m6osjHjdA-1; Wed, 15 Jun 2022 06:19:31 -0400 X-MC-Unique: n1-eUfapPGu75m6osjHjdA-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101930euoutp02347d17f28cfb6971517474920ff187c7~4xACoxryH2551125511euoutp02e for ; Wed, 15 Jun 2022 10:19:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101930euoutp02347d17f28cfb6971517474920ff187c7~4xACoxryH2551125511euoutp02e Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615101928eucas1p1b977b0e4c5103c43695d0073172d222d~4xAA3t8X30963309633eucas1p1n; Wed, 15 Jun 2022 10:19:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id D5.2B.09664.032B9A26; Wed, 15 Jun 2022 11:19:28 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615101927eucas1p17220c7a36f69f59ff8ddd560b42967ec~4xAAaJBok2789027890eucas1p1_; Wed, 15 Jun 2022 10:19:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101927eusmtrp21290cb4f6f1f11203710eaa6a045886f~4xAAZHNrb0349503495eusmtrp2H; Wed, 15 Jun 2022 10:19:27 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-b9-62a9b2307870 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 15.45.09095.F22B9A26; Wed, 15 Jun 2022 11:19:27 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220615101926eusmtip2a4d1534f6d9fb211105b6da848dd27ef~4w--OR_FM0785907859eusmtip2F; Wed, 15 Jun 2022 10:19:26 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:08 +0200 Message-Id: <20220615101920.329421-2-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7djP87oGm1YmGSz5wWOx+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0PgYpv aVtc3jWHzWL+sqfsFjcmPGW0+Ly0hd1izc2nLBZtG78yOgh7XL7i7fHvxBo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F38i96p+68d1k xyWbHCYwq9YLr50Sr+z6UHvGleqqK9vXzjv7L+GJLHdg5bvbwgtfzWlXYinOSDTUYi4qTgQA q9mqDXsDAAA= X-CMS-MailID: 20220615101927eucas1p17220c7a36f69f59ff8ddd560b42967ec X-Msg-Generator: CA X-RootMTR: 20220615101927eucas1p17220c7a36f69f59ff8ddd560b42967ec X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101927eucas1p17220c7a36f69f59ff8ddd560b42967ec References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v7 01/13] block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Adapt blkdev_nr_zones and blk_queue_zone_no function so that it can also work for non-power-of-2 zone sizes. As the existing deployments of zoned devices had power-of-2 assumption, power-of-2 optimized calculation is kept for those devices. There are no direct hot paths modified and the changes just introduce one new branch per call. Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav Reviewed-by: Bart Van Assche --- block/blk-zoned.c | 12 +++++++++--- include/linux/blkdev.h | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 38cd840d8..8b0615287 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -111,16 +111,22 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock); * blkdev_nr_zones - Get number of zones * @disk: Target gendisk * - * Return the total number of zones of a zoned block device. For a block - * device without zone capabilities, the number of zones is always 0. + * Return the total number of zones of a zoned block device, including the + * eventual small last zone if present. For a block device without zone + * capabilities, the number of zones is always 0. */ unsigned int blkdev_nr_zones(struct gendisk *disk) { 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 DIV_ROUND_UP_SECTOR_T(capacity, zone_sectors); } EXPORT_SYMBOL_GPL(blkdev_nr_zones); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 914c613d8..39017ae9d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -681,9 +681,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); } static inline bool blk_queue_zone_is_seq(struct request_queue *q, From patchwork Wed Jun 15 10:19:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882043 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B818C43334 for ; Wed, 15 Jun 2022 10:19:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-121-JO8bQc8NOLSeeKDflPWM-w-1; Wed, 15 Jun 2022 06:19:40 -0400 X-MC-Unique: JO8bQc8NOLSeeKDflPWM-w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63EE81C1CB89; Wed, 15 Jun 2022 10:19:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F3C340C1288; Wed, 15 Jun 2022 10:19:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EEFDC1947B84; Wed, 15 Jun 2022 10:19:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1C0AA1947B84 for ; Wed, 15 Jun 2022 10:19:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E409740CFD0A; Wed, 15 Jun 2022 10:19:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFA1B40CF8E7 for ; Wed, 15 Jun 2022 10:19:36 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4DC0101E985 for ; Wed, 15 Jun 2022 10:19:36 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-192-xSiW5XqGOCqDqcRk8u8Lbg-1; Wed, 15 Jun 2022 06:19:35 -0400 X-MC-Unique: xSiW5XqGOCqDqcRk8u8Lbg-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101933euoutp021bd97be9aa6b64d22407ac4ec5234d5b~4xAGJZ0ts2915629156euoutp02E for ; Wed, 15 Jun 2022 10:19:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101933euoutp021bd97be9aa6b64d22407ac4ec5234d5b~4xAGJZ0ts2915629156euoutp02E Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101932eucas1p2660b95125dabbb1744287f9d299c6460~4xAEayiPp0710307103eucas1p24; Wed, 15 Jun 2022 10:19:32 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1D.2B.09664.332B9A26; Wed, 15 Jun 2022 11:19:32 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615101931eucas1p15ed09ae433a2c378b599e9086130d8eb~4xAD9YEc10100501005eucas1p1N; Wed, 15 Jun 2022 10:19:31 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101931eusmtrp2b70e8cbdfb93fd8f578e936104ade6c6~4xAD8lqBD0308003080eusmtrp2f; Wed, 15 Jun 2022 10:19:31 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-cd-62a9b233f413 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5B.45.09095.332B9A26; Wed, 15 Jun 2022 11:19:31 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220615101930eusmtip20501ba33701d46b01bdb1087349cb48e~4xAC0W5x_0785907859eusmtip2G; Wed, 15 Jun 2022 10:19:30 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:09 +0200 Message-Id: <20220615101920.329421-3-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOKsWRmVeSWpSXmKPExsWy7djP87omm1YmGZxdxmix+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0Pg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r9HLEoXll07d/vVVw/61bKl4A9fPhwkxmvNkZzs+b5VTkjTp46qLON075V26 3d3vD1bNsrMNeirsfnGm5Cp9/xSGOa8Kc2ZcCFC/v7uklOHe6u0nXZVYijMSDbWYi4oTAXP6 75x6AwAA X-CMS-MailID: 20220615101931eucas1p15ed09ae433a2c378b599e9086130d8eb X-Msg-Generator: CA X-RootMTR: 20220615101931eucas1p15ed09ae433a2c378b599e9086130d8eb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101931eucas1p15ed09ae433a2c378b599e9086130d8eb References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v7 02/13] block: allow blk-zoned devices to have non-power-of-2 zone size X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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. The only hot path affected by this change for power_of_2 zoned devices is in blk_check_zone_append() but blk_queue_is_zone_start() helper is used to optimize the calculation for po2 zone sizes. Note that the append path cannot be accessed by direct raw access to the block device but only through a filesystem abstraction. Finally, allow non power of 2 zoned devices provided that their zone capacity and zone size are equal. The main motivation to allow non power_of_2 zoned device is to remove the unmapped LBA between zcap and zsze for devices that cannot have a power_of_2 zcap. Reviewed-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- block/blk-core.c | 3 +-- block/blk-zoned.c | 25 +++++++++++++++++++------ include/linux/blkdev.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 06ff5bbfe..248b947e5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -629,8 +629,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_is_zone_start(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 8b0615287..7957eec04 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_is_zone_start(q, sector)) return -EINVAL; - if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity) + if (!blk_queue_is_zone_start(q, nr_sectors) && end_sector != capacity) return -EINVAL; /* @@ -489,14 +489,27 @@ 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); + 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 zone capacity for non power of 2 zone size", + disk->disk_name); 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. + */ + 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 39017ae9d..3c106dba1 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -692,6 +692,27 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q, return div64_u64(sector, zone_sectors); } +static inline sector_t blk_queue_offset_from_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 sec & (zone_sectors - 1); + + div64_u64_rem(sec, zone_sectors, &remainder); + return remainder; +} + +static inline bool blk_queue_is_zone_start(struct request_queue *q, sector_t sec) +{ + return blk_queue_offset_from_zone_start(q, sec) == 0; +} + static inline bool blk_queue_zone_is_seq(struct request_queue *q, sector_t sector) { @@ -738,6 +759,18 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q, { return 0; } + +static inline sector_t blk_queue_offset_from_zone_start(struct request_queue *q, + sector_t sec) +{ + 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; From patchwork Wed Jun 15 10:19:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882044 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEEEAC43334 for ; Wed, 15 Jun 2022 10:19:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-QuAO9P0gPsaJVL9_1WMvpg-1; Wed, 15 Jun 2022 06:19:44 -0400 X-MC-Unique: QuAO9P0gPsaJVL9_1WMvpg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 894F6800971; Wed, 15 Jun 2022 10:19:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7683F4010E4D; Wed, 15 Jun 2022 10:19:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2AF5A1947B84; Wed, 15 Jun 2022 10:19:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC7F5194705C for ; Wed, 15 Jun 2022 10:19:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 71DE31121319; Wed, 15 Jun 2022 10:19:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D9181121315 for ; Wed, 15 Jun 2022 10:19:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50E0D802D1F for ; Wed, 15 Jun 2022 10:19:40 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-WjtbEnucOFKs6b_aThvZ7A-1; Wed, 15 Jun 2022 06:19:38 -0400 X-MC-Unique: WjtbEnucOFKs6b_aThvZ7A-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101937euoutp028ce7392b3dc4ff539b4bc5e4db64be03~4xAJoEgzG2870528705euoutp02S for ; Wed, 15 Jun 2022 10:19:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101937euoutp028ce7392b3dc4ff539b4bc5e4db64be03~4xAJoEgzG2870528705euoutp02S Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101935eucas1p28855fe6444bf0d736a79f31c7e260f2e~4xAH-GRyc1132211322eucas1p2x; Wed, 15 Jun 2022 10:19:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 28.67.10067.732B9A26; Wed, 15 Jun 2022 11:19:35 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101935eucas1p26a7bc245d88a89312158d7a265f64aef~4xAHQro9O1132211322eucas1p2w; Wed, 15 Jun 2022 10:19:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101935eusmtrp25b8235c373fbcc302cd299295374e82b~4xAHPZ7Ei0361403614eusmtrp2B; Wed, 15 Jun 2022 10:19:34 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-6a-62a9b23727ab Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0B.14.09038.632B9A26; Wed, 15 Jun 2022 11:19:34 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101934eusmtip1d8b298e6c644ba681b491ec040203480~4xAGNVgnE1144211442eusmtip1H; Wed, 15 Jun 2022 10:19:34 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:10 +0200 Message-Id: <20220615101920.329421-4-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7djPc7rmm1YmGcztNLJYfbefzWLah5/M Fr/Pnme22PtuNqvFhR+NTBY3D+xkstizaBKTxcrVR5ksnqyfxWzRc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xueqvjHb+fQ/gwdunYEm4eJslzm3cpjfUzJb9+Ji4CePq0JzVt/xWrNGe24X4yxTGZ/o fYJ70+ND13tEBJxmuCEVVOfQx+S1btWS/qXpb2V2BJkkXs9MuhlU6K7EUpyRaKjFXFScCACL +j2SeQMAAA== X-CMS-MailID: 20220615101935eucas1p26a7bc245d88a89312158d7a265f64aef X-Msg-Generator: CA X-RootMTR: 20220615101935eucas1p26a7bc245d88a89312158d7a265f64aef X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101935eucas1p26a7bc245d88a89312158d7a265f64aef References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v7 03/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Remove the condition which disallows non-power_of_2 zone size ZNS drive to be updated and use generic method to calculate number of zones instead of relying on log and shift based calculation on zone size. The power_of_2 calculation has been replaced directly with generic calculation without special handling. Both modified functions are not used in hot paths, they are only used during initialization & revalidation of the ZNS device. As rounddown macro from math.h does not work for 32 bit architectures, round down operation is open coded. Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/nvme/host/zns.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 9f81beb4d..d92f937d5 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) } ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze)); - if (!is_power_of_2(ns->zsze)) { - dev_warn(ns->ctrl->device, - "invalid zone size:%llu for namespace:%u\n", - ns->zsze, ns->head->ns_id); - status = -ENODEV; - goto free_data; - } blk_queue_set_zoned(ns->disk, BLK_ZONED_HM); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); @@ -128,8 +121,13 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns, const size_t min_bufsize = sizeof(struct nvme_zone_report) + sizeof(struct nvme_zone_descriptor); + /* + * Division is used to calculate nr_zones with no special handling + * for power of 2 zone sizes as this function is not invoked in a + * hot path + */ nr_zones = min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->zsze)); + div64_u64(get_capacity(ns->disk), ns->zsze)); bufsize = sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); @@ -182,6 +180,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, int ret, zone_idx = 0; unsigned int nz, i; size_t buflen; + u64 remainder = 0; if (ns->head->ids.csi != NVME_CSI_ZNS) return -EINVAL; @@ -197,7 +196,11 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL; c.zmr.pr = NVME_REPORT_ZONE_PARTIAL; - sector &= ~(ns->zsze - 1); + /* + * Round down the sector value to the nearest zone start + */ + div64_u64_rem(sector, ns->zsze, &remainder); + sector -= remainder; while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) { memset(report, 0, buflen); From patchwork Wed Jun 15 10:19:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882045 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29432C43334 for ; Wed, 15 Jun 2022 10:19:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-TmSAflJqPtiRr3SL3wMfDA-1; Wed, 15 Jun 2022 06:19:47 -0400 X-MC-Unique: TmSAflJqPtiRr3SL3wMfDA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B90A23804516; Wed, 15 Jun 2022 10:19:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A71492166B29; Wed, 15 Jun 2022 10:19:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 78FBA1947B84; Wed, 15 Jun 2022 10:19:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A66ED194705C for ; Wed, 15 Jun 2022 10:19:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 99A50492CA6; Wed, 15 Jun 2022 10:19:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9580E492CA5 for ; Wed, 15 Jun 2022 10:19:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CE193C025C9 for ; Wed, 15 Jun 2022 10:19:44 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-ZtvayhhFN_mrS3WiCjb7Fg-1; Wed, 15 Jun 2022 06:19:42 -0400 X-MC-Unique: ZtvayhhFN_mrS3WiCjb7Fg-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101941euoutp0185ecbc6df8f6ab4bd0188e833f023419~4xANHF8Y12585525855euoutp01E for ; Wed, 15 Jun 2022 10:19:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615101941euoutp0185ecbc6df8f6ab4bd0188e833f023419~4xANHF8Y12585525855euoutp01E Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101939eucas1p2eb2c5ef6e00ebaa4a2acbb8d2deb2eea~4xALZ4g0g1912519125eucas1p2g; Wed, 15 Jun 2022 10:19:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5C.69.09580.A32B9A26; Wed, 15 Jun 2022 11:19:38 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101938eucas1p26ab159a1ffd0fa5a16d7f202ba7206e7~4xAKNP28S2111721117eucas1p2V; Wed, 15 Jun 2022 10:19:38 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101938eusmtrp246a65538e1923130b814cf2be9b59611~4xAKMLDK-0361403614eusmtrp2H; Wed, 15 Jun 2022 10:19:38 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-19-62a9b23a0857 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BF.45.09095.A32B9A26; Wed, 15 Jun 2022 11:19:38 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101937eusmtip1e4794119142cb0d2fedd8d7073fa370c~4xAJR_qbe1151011510eusmtip1D; Wed, 15 Jun 2022 10:19:37 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:11 +0200 Message-Id: <20220615101920.329421-5-p.ra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C/UfWLa0aekdkzMP PTpKTsv/ncZfMHXJacuEIx3vPu7IUio98pxX/2PYnZBP02O/ikU1F5ml8RQY3HAX+/n5nZ5h 2DS2qeUBPw8vybNgSnwzzW7nrp1rLp3oaVO33CTtb5W//x2LDoO9ceIntu0lkim2bJ6btXfn KzLomQR2iLRZnG2at+C6n//8rzb5y6ZUWH4yXXFHNszZe0M2d3XyyzT5eZPCuSZPXX5j85JL T4Vi7n3Z/0f+cuolMU1tg2+bKtcsY1oabTjp30rh7DPaSdPUOO8+ehl78fTxjYe9JKJs9nZK F2/iPLAx73JEJFuuXOUm540N+RryT1a8+HDexPS8vofY5r2e59XLlViKMxINtZiLihMB1fs6 AXsDAAA= X-CMS-MailID: 20220615101938eucas1p26ab159a1ffd0fa5a16d7f202ba7206e7 X-Msg-Generator: CA X-RootMTR: 20220615101938eucas1p26ab159a1ffd0fa5a16d7f202ba7206e7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101938eucas1p26ab159a1ffd0fa5a16d7f202ba7206e7 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v7 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes Thumshirn , dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Reviewed-by: Johannes Thumshirn 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 3c106dba1..e09d73473 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1387,6 +1387,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); From patchwork Wed Jun 15 10:19:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882046 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5358DCCA47B for ; Wed, 15 Jun 2022 10:19:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-u68kyA9jPGi-GXL5WkdE7g-1; Wed, 15 Jun 2022 06:19:50 -0400 X-MC-Unique: u68kyA9jPGi-GXL5WkdE7g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A4C983397F; Wed, 15 Jun 2022 10:19:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6754C1121314; Wed, 15 Jun 2022 10:19:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3E6091947B84; Wed, 15 Jun 2022 10:19:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4DB2C194705C for ; Wed, 15 Jun 2022 10:19:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3D56C40C141F; Wed, 15 Jun 2022 10:19:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 390C34010E4D for ; Wed, 15 Jun 2022 10:19:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CEF52999B24 for ; Wed, 15 Jun 2022 10:19:47 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-yY0O1zidMyapvcWwSzrN3A-1; Wed, 15 Jun 2022 06:19:45 -0400 X-MC-Unique: yY0O1zidMyapvcWwSzrN3A-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101944euoutp0145d41347ae0a28eee071a776ebbea014~4xAP1wvI02495924959euoutp01X for ; Wed, 15 Jun 2022 10:19:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615101944euoutp0145d41347ae0a28eee071a776ebbea014~4xAP1wvI02495924959euoutp01X Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101942eucas1p2fd692c0d27a96cd40f5934749dd545cb~4xAN_mTaf1910819108eucas1p2k; Wed, 15 Jun 2022 10:19:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id DB.67.10067.E32B9A26; Wed, 15 Jun 2022 11:19:42 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101941eucas1p25e1c27b363e6b288b848521298e31705~4xANeL5hf2111721117eucas1p2a; Wed, 15 Jun 2022 10:19:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101941eusmtrp2ae19a360edb4529854235d5eddd10b32~4xANdYsXz0349503495eusmtrp2g; Wed, 15 Jun 2022 10:19:41 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-7c-62a9b23ea0ec Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 42.55.09095.D32B9A26; Wed, 15 Jun 2022 11:19:41 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101940eusmtip1c41b5b3584b730806ea14d0625152f0a~4xAMZrl_t0899908999eusmtip17; Wed, 15 Jun 2022 10:19:40 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:12 +0200 Message-Id: <20220615101920.329421-6-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKKsWRmVeSWpSXmKPExsWy7djPc7p2m1YmGTz7wW2x+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0PgY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Q/NFXZlP7A9w/l3/P1t564zkC+Ef+DwmHj9lzv/A8RbDBdHqGzwMnompSU5vw0wmRFcWbvo3 6VehSmbHHRb30x//rAl8ZWFvMzHTZ+bXvX9X2/vyvV7FGGC0NFGI/8FiDiWW4oxEQy3mouJE AENZ9i55AwAA X-CMS-MailID: 20220615101941eucas1p25e1c27b363e6b288b848521298e31705 X-Msg-Generator: CA X-RootMTR: 20220615101941eucas1p25e1c27b363e6b288b848521298e31705 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101941eucas1p25e1c27b363e6b288b848521298e31705 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Subject: [dm-devel] [PATCH v7 05/13] null_blk: allow non power of 2 zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Convert the power of 2 based calculation with zone size to be generic in null_zone_no with optimization for power of 2 based zone sizes. The nr_zones calculation in null_init_zoned_dev has been replaced with a division without special handling for power of 2 based zone sizes as this function is called only during the initialization and will not invoked in the hot path. Performance Measurement: Device: zone size = 128M, blocksize=4k FIO cmd: fio --name=zbc --filename=/dev/nullb0 --direct=1 --zonemode=zbd --size=23G --io_size= --ioengine=io_uring --iodepth= --rw= --bs=4k --loops=4 The following results are an average of 4 runs on AMD Ryzen 5 5600X with 32GB of RAM: Sequential Write: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 578 | 2257 | 12.80 | 576 | 2248 | 25.78 | x-----------------x---------------------------------x---------------------------------x | With patch | 581 | 2268 | 12.74 | 576 | 2248 | 25.85 | x-----------------x---------------------------------x---------------------------------x Sequential read: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 667 | 2605 | 11.79 | 675 | 2637 | 23.49 | x-----------------x---------------------------------x---------------------------------x | With patch | 667 | 2605 | 11.79 | 675 | 2638 | 23.48 | x-----------------x---------------------------------x---------------------------------x Random read: x-----------------x---------------------------------x---------------------------------x | IOdepth | 8 | 16 | x-----------------x---------------------------------x---------------------------------x | | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) | x-----------------x---------------------------------x---------------------------------x | Without patch | 522 | 2038 | 15.05 | 514 | 2006 | 30.87 | x-----------------x---------------------------------x---------------------------------x | With patch | 522 | 2039 | 15.04 | 523 | 2042 | 30.33 | x-----------------x---------------------------------x---------------------------------x Minor variations are noticed in Sequential write with io depth 8 and in random read with io depth 16. But overall no noticeable differences were noticed Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/main.c | 5 ++--- drivers/block/null_blk/zoned.c | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 6b67088f4..6c170927c 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1929,9 +1929,8 @@ static int null_validate_conf(struct nullb_device *dev) if (dev->queue_mode == NULL_Q_BIO) dev->mbps = 0; - if (dev->zoned && - (!dev->zone_size || !is_power_of_2(dev->zone_size))) { - pr_err("zone_size must be power-of-two\n"); + if (dev->zoned && !dev->zone_size) { + pr_err("Invalid zero zone size\n"); return -EINVAL; } diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index 2fdd7b20c..daf327015 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -16,7 +16,10 @@ static inline sector_t mb_to_sects(unsigned long mb) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) { - return sect >> ilog2(dev->zone_size_sects); + if (is_power_of_2(dev->zone_size_sects)) + return sect >> ilog2(dev->zone_size_sects); + + return div64_u64(sect, dev->zone_size_sects); } static inline void null_lock_zone_res(struct nullb_device *dev) @@ -65,10 +68,6 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) sector_t sector = 0; unsigned int i; - if (!is_power_of_2(dev->zone_size)) { - pr_err("zone_size must be power-of-two\n"); - return -EINVAL; - } if (dev->zone_size > dev->size) { pr_err("Zone size larger than device capacity\n"); return -EINVAL; @@ -86,8 +85,8 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) zone_capacity_sects = mb_to_sects(dev->zone_capacity); dev_capacity_sects = mb_to_sects(dev->size); dev->zone_size_sects = mb_to_sects(dev->zone_size); - dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects) - >> ilog2(dev->zone_size_sects); + dev->nr_zones = DIV_ROUND_UP_SECTOR_T(dev_capacity_sects, + dev->zone_size_sects); dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), GFP_KERNEL | __GFP_ZERO); From patchwork Wed Jun 15 10:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882048 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65739C433EF for ; Wed, 15 Jun 2022 10:20:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-XPoa-_CYPg2XDF2h1F38IA-1; Wed, 15 Jun 2022 06:20:00 -0400 X-MC-Unique: XPoa-_CYPg2XDF2h1F38IA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FD5D801E67; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4B91415106; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D65631947B84; Wed, 15 Jun 2022 10:19:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A7C01949759 for ; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D0293400DF1D; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBB7740CFD0A for ; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B42993804516 for ; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-94gJWWA1P0KVGJsrQ5nbjw-1; Wed, 15 Jun 2022 06:19:48 -0400 X-MC-Unique: 94gJWWA1P0KVGJsrQ5nbjw-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101947euoutp023669c17652f78ea718ddba73f6da33ec~4xAS1yZmz2930429304euoutp02G for ; Wed, 15 Jun 2022 10:19:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101947euoutp023669c17652f78ea718ddba73f6da33ec~4xAS1yZmz2930429304euoutp02G Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615101945eucas1p1d5342ae55cf549f7f52be0f3f500a61c~4xARRJUWa2260522605eucas1p1F; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 39.3B.09664.142B9A26; Wed, 15 Jun 2022 11:19:45 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2~4xAQvVa5T1177311773eucas1p1k; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101945eusmtrp22c89343c319808137c8290492d5eddfa~4xAQudBoS0361403614eusmtrp2X; Wed, 15 Jun 2022 10:19:45 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-f7-62a9b24146d1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B5.55.09095.142B9A26; Wed, 15 Jun 2022 11:19:45 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101943eusmtip1dcf863a2a0f7ec36b4725dadaac7a2c0~4xAPefbdk0536005360eusmtip1f; Wed, 15 Jun 2022 10:19:43 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:13 +0200 Message-Id: <20220615101920.329421-7-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7djPc7qOm1YmGVz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++VM9doju/su r9t8Mu7yomUTOIPESqbOdJUOPjz/RvSta7djshc49G34efXxjdQ1Vp497BWell4qXw9H21zL 6VwaafBh5bck4btl2e8vLzr66Elr1tXfs5/cufhv0tVb4rO/2VzpWRK0+kCQ9Q+ZGp3yv/b7 J/6YHV71Ju69/hGdsq6i5c73f5ltidkvHHtEUdwok1NYRuK2yJ7W7IOVmnyrUlwvMy1VYinO SDTUYi4qTgQABDAVGH8DAAA= X-CMS-MailID: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 X-Msg-Generator: CA X-RootMTR: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101945eucas1p16fa264e81d9b6027ff131dd311ed91e2 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v7 06/13] null_blk: use zone_size_sects_shift for power of 2 zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , Damien Le Moal , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of doing is_power_of_2 and ilog2 operation for every IO, cache the zone_size_sects_shift variable and use it for power of 2 zoned devices. This variable will be set to zero for non power of 2 zoned devices. Suggested-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/null_blk.h | 6 ++++++ drivers/block/null_blk/zoned.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 8359b4384..3bc7cbf25 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -83,6 +83,12 @@ struct nullb_device { unsigned int imp_close_zone_no; struct nullb_zone *zones; sector_t zone_size_sects; + /* + * zone_size_sects_shift is only useful when the zone size is + * power of 2. This variable is set to zero when zone size is non + * power of 2. + */ + unsigned int zone_size_sects_shift; bool need_zone_res_mgmt; spinlock_t zone_res_lock; diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index daf327015..5f929944b 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -16,8 +16,8 @@ static inline sector_t mb_to_sects(unsigned long mb) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) { - if (is_power_of_2(dev->zone_size_sects)) - return sect >> ilog2(dev->zone_size_sects); + if (dev->zone_size_sects_shift) + return sect >> dev->zone_size_sects_shift; return div64_u64(sect, dev->zone_size_sects); } @@ -85,9 +85,14 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) zone_capacity_sects = mb_to_sects(dev->zone_capacity); dev_capacity_sects = mb_to_sects(dev->size); dev->zone_size_sects = mb_to_sects(dev->zone_size); + + if (is_power_of_2(dev->zone_size_sects)) + dev->zone_size_sects_shift = ilog2(dev->zone_size_sects); + else + dev->zone_size_sects_shift = 0; + dev->nr_zones = DIV_ROUND_UP_SECTOR_T(dev_capacity_sects, dev->zone_size_sects); - dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), GFP_KERNEL | __GFP_ZERO); if (!dev->zones) From patchwork Wed Jun 15 10:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882047 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9928DC43334 for ; Wed, 15 Jun 2022 10:20:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-mwUOd_weN6aLHdSkFvpPAg-1; Wed, 15 Jun 2022 06:19:57 -0400 X-MC-Unique: mwUOd_weN6aLHdSkFvpPAg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE3A2800971; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD8B41121315; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8F12B1947B84; Wed, 15 Jun 2022 10:19:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 997EC194705C for ; Wed, 15 Jun 2022 10:19:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7C1CC1415107; Wed, 15 Jun 2022 10:19:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77F501415106 for ; Wed, 15 Jun 2022 10:19:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 611553804516 for ; Wed, 15 Jun 2022 10:19:53 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-8gDZB2cLMGGSZ1RenzTZGA-1; Wed, 15 Jun 2022 06:19:51 -0400 X-MC-Unique: 8gDZB2cLMGGSZ1RenzTZGA-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101950euoutp01c6e03c88b665d4e0514c96643cad31f9~4xAV2JlO52585525855euoutp01O for ; Wed, 15 Jun 2022 10:19:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615101950euoutp01c6e03c88b665d4e0514c96643cad31f9~4xAV2JlO52585525855euoutp01O Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101948eucas1p2db62e1a1d72812c89f83ad4da9df0d80~4xAUIacym1910819108eucas1p2s; Wed, 15 Jun 2022 10:19:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C4.77.10067.442B9A26; Wed, 15 Jun 2022 11:19:48 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101948eucas1p2d8d801735c39b25256a019134adb0c6f~4xATjX3Rj2114221142eucas1p2W; Wed, 15 Jun 2022 10:19:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101948eusmtrp2a7a7cca347d91d529dfe7e6734f73b3f~4xATiefYB0361403614eusmtrp2f; Wed, 15 Jun 2022 10:19:48 +0000 (GMT) X-AuditID: cbfec7f4-dd7ff70000002753-93-62a9b2444355 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 58.55.09095.442B9A26; Wed, 15 Jun 2022 11:19:48 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101947eusmtip13c89af2230fa641d50955a11bfcf71c9~4xASsSOCP1144211442eusmtip1M; Wed, 15 Jun 2022 10:19:47 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:14 +0200 Message-Id: <20220615101920.329421-8-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrO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EMwPxMx08q2bfkysXmpnOyPp5xn6r2756F4T3OrzcX894YL9o1IR+LxHhWK60wEf6 W2VE+2938U7JfqVitk989pqNSjFlrsnlTZ2hzfNmc829/fuaaHKYtZ/n8pqp1wKX81Wfuchh t9DT6vlm456WD4cqMw5U/Z48pULVoPGf9jFnthdrqr+v387JvXaBZ2POgh7B+bGTPj6pW6c7 6aStIbdkgjSPB3fbi949j9ncNTk0z+/7ud0oacb+Bwo7z9jN9cwxaFZiKc5INNRiLipOBAA/ +S8iegMAAA== X-CMS-MailID: 20220615101948eucas1p2d8d801735c39b25256a019134adb0c6f X-Msg-Generator: CA X-RootMTR: 20220615101948eucas1p2d8d801735c39b25256a019134adb0c6f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101948eucas1p2d8d801735c39b25256a019134adb0c6f References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v7 07/13] zonefs: allow non power of 2 zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The zone size shift variable is useful only if the zone sizes are known to be power of 2. Remove that variable and use generic helpers from block layer to calculate zone index in zonefs. Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- fs/zonefs/super.c | 6 ++---- fs/zonefs/zonefs.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index cc6d4cf58..0b737c2fb 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -485,10 +485,9 @@ static void __zonefs_io_error(struct inode *inode, bool write) { struct zonefs_inode_info *zi = ZONEFS_I(inode); struct super_block *sb = inode->i_sb; - struct zonefs_sb_info *sbi = ZONEFS_SB(sb); unsigned int noio_flag; unsigned int nr_zones = - zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT); + bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT); struct zonefs_ioerr_data err = { .inode = inode, .write = write, @@ -1410,7 +1409,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, struct zonefs_inode_info *zi = ZONEFS_I(inode); int ret = 0; - inode->i_ino = zone->start >> sbi->s_zone_sectors_shift; + inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start); inode->i_mode = S_IFREG | sbi->s_perm; zi->i_ztype = type; @@ -1787,7 +1786,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) * interface constraints. */ sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); - sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); sbi->s_uid = GLOBAL_ROOT_UID; sbi->s_gid = GLOBAL_ROOT_GID; sbi->s_perm = 0640; diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h index 4b3de66c3..39895195c 100644 --- a/fs/zonefs/zonefs.h +++ b/fs/zonefs/zonefs.h @@ -177,7 +177,6 @@ struct zonefs_sb_info { kgid_t s_gid; umode_t s_perm; uuid_t s_uuid; - unsigned int s_zone_sectors_shift; unsigned int s_nr_files[ZONEFS_ZTYPE_MAX]; From patchwork Wed Jun 15 10:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882049 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1E3FC433EF for ; Wed, 15 Jun 2022 10:20:04 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-xZoE4Sp3NNaEEI_NEMq-8w-1; Wed, 15 Jun 2022 06:20:01 -0400 X-MC-Unique: xZoE4Sp3NNaEEI_NEMq-8w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF9F0299E77E; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D450401E68; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 122BC195D4D1; Wed, 15 Jun 2022 10:19:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ABB75194705C for ; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9105D1415107; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CB5D1415106 for ; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 767E718A6524 for ; Wed, 15 Jun 2022 10:19:56 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-kNCPiRjDMUqHqDJKQ4T7_w-1; Wed, 15 Jun 2022 06:19:54 -0400 X-MC-Unique: kNCPiRjDMUqHqDJKQ4T7_w-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101953euoutp01ed50f2f4dff269e8ef66c51ef2328c0c~4xAYq4Cmc2526325263euoutp01k for ; Wed, 15 Jun 2022 10:19:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615101953euoutp01ed50f2f4dff269e8ef66c51ef2328c0c~4xAYq4Cmc2526325263euoutp01k Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615101951eucas1p18d84bd7b38d6657a6c512bd382ceedf6~4xAW0wNp51438314383eucas1p1I; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 39.77.10067.742B9A26; Wed, 15 Jun 2022 11:19:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec~4xAWbmb-F2114221142eucas1p2b; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101951eusmtrp2c759d4ee173fff60b6c81fb090bf1131~4xAWarPxE0361403614eusmtrp2l; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-9e-62a9b247678f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 07.24.09038.742B9A26; Wed, 15 Jun 2022 11:19:51 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101950eusmtip1b23a4a7a289c85a785fe400b913c2e54~4xAVmPX1i1152711527eusmtip1J; Wed, 15 Jun 2022 10:19:50 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:15 +0200 Message-Id: <20220615101920.329421-9-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAA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+l8w4sdJ5e n8f+4FAJx0PWK3Z8z3gZsgMfSAh8i/HQWWHlZP/n3IatOxkaljuevx8hevV6r6pM/7bYL4+f XWO0On3zzhMpv8Dj/J2lDRPLrV48XfZ+l131eaZHtncMtDR0BGf69/9MVEq8zXRhzi4HR9tl uvb8L/QX3PeQOxcX4TXpQFrRw5kHIhfUbVCLWre/p64y6xDPxAI92YwA9VqRVy9Vf7von9cL CGo44dS10dFQ0fvkjzXRh4KdJ2gE2554ryL78Ohj7jufGreXXkhtU2Ipzkg01GIuKk4EAHwS U/N7AwAA X-CMS-MailID: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec X-Msg-Generator: CA X-RootMTR: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v7 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Luis Chamberlain Today dm-zoned relies on the assumption that you have a zone size with a power of 2. Even though the block layer today enforces this requirement, these devices do exist and so provide a stop-gap measure to ensure these devices cannot be used by mistake Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/md/dm-zoned-target.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 0ec5d8b9b..ad4228db5 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -792,6 +792,10 @@ static int dmz_fixup_devices(struct dm_target *ti) return -EINVAL; } zone_nr_sectors = blk_queue_zone_sectors(q); + if (!is_power_of_2(zone_nr_sectors)) { + ti->error = "Zone size not power of 2"; + return -EINVAL; + } zoned_dev->zone_nr_sectors = zone_nr_sectors; zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk); @@ -806,6 +810,10 @@ static int dmz_fixup_devices(struct dm_target *ti) q = bdev_get_queue(zoned_dev->bdev); zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q); zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk); + if (!is_power_of_2(zoned_dev->zone_nr_sectors)) { + ti->error = "Zone size not power of 2"; + return -EINVAL; + } } if (reg_dev) { From patchwork Wed Jun 15 10:19:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882050 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA0C1C43334 for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-JNOy-C-XO3GZXFLGHJfByg-1; Wed, 15 Jun 2022 06:20:05 -0400 X-MC-Unique: JNOy-C-XO3GZXFLGHJfByg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EBDE3185A7A4; Wed, 15 Jun 2022 10:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA6682166B26; Wed, 15 Jun 2022 10:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5434F1949759; Wed, 15 Jun 2022 10:20:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 62AB5194705C for ; Wed, 15 Jun 2022 10:20:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3DD0D1415107; Wed, 15 Jun 2022 10:20:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 394C61415106 for ; Wed, 15 Jun 2022 10:20:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21E5F3C025C9 for ; Wed, 15 Jun 2022 10:20:01 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-567-Am2zJGCuMQu95r0rClKYoA-1; Wed, 15 Jun 2022 06:19:58 -0400 X-MC-Unique: Am2zJGCuMQu95r0rClKYoA-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101957euoutp01f9ec2788827cb3d62370cb1c5a8dd5a9~4xAb9HyQy2463124631euoutp01I for ; Wed, 15 Jun 2022 10:19:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615101957euoutp01f9ec2788827cb3d62370cb1c5a8dd5a9~4xAb9HyQy2463124631euoutp01I Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615101955eucas1p2eee10b45941965e4935abb0ebb017993~4xAaUbccm1132211322eucas1p2C; Wed, 15 Jun 2022 10:19:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1E.3B.09664.B42B9A26; Wed, 15 Jun 2022 11:19:55 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615101955eucas1p19b9d42ead7331f69f7dad1ec100312c2~4xAZ4G7zF1177311773eucas1p1q; Wed, 15 Jun 2022 10:19:55 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101955eusmtrp2c7777997ad5bfc414e0f88aef0add88c~4xAZ3Pb9R0349503495eusmtrp28; Wed, 15 Jun 2022 10:19:55 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-14-62a9b24bd01e Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E8.24.09038.A42B9A26; Wed, 15 Jun 2022 11:19:54 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220615101954eusmtip2aae9fd8bd11cf5ddb8d433d9ef34f41f~4xAZGNSD70755407554eusmtip2f; Wed, 15 Jun 2022 10:19:54 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:16 +0200 Message-Id: <20220615101920.329421-10-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCKsWRmVeSWpSXmKPExsWy7djP87rem1YmGcx9J2+x+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0PgYpv aVtc3jWHzWL+sqfsFjcmPGW0+Ly0hd1izc2nLBZtG78yOgh7XL7i7fHvxBo2j52z7rJ7XD5b 6rFpVSebx8KGqcwem5fUe+y+2QCUa73P6vF+31U2j74tqxg91m+5yuKx+XS1x+dNch7tB7qZ AvijuGxSUnMyy1KL9O0SuDIm7hMt2MtV8XvKbPYGxuMcXYycHBICJhK7f55g7WLk4hASWMEo 8Wr+R3YI5wujxI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OeMlp8XtrCbrHm5lMWi7aNXxkdhD0uX/H2+HdiDZvHzll32T0uny31 2LSqk81jYcNUZo/NS+o9dt9sAMq13mf1eL/vKptH35ZVjB7rt1xl8dh8utrj8yY5j/YD3UwB /FF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6GRP3 iRbs5ar4PWU2ewPjcY4uRg4OCQETieajyl2MXBxCAksZJc5/e8XcxcgJFJeQuL2wiRHCFpb4 c62LDaLoOaPEzTf32ECa2QS0JBo72UFqRASiJTpvvgerYRZYwCxx+s4EsISwQJTE3WUrWEHq WQRUJa4/rgEJ8wpYSyyfMJMFYr68xMxL38HKOYHiO2b3gJULCVhJ7HoXD1EuKHFy5hOwcmag 8uats5knMArMQpKahSS1gJFpFaNIamlxbnpusZFecWJucWleul5yfu4mRmB0bzv2c8sOxpWv PuodYmTiYDzEKMHBrCTCaxa8MkmINyWxsiq1KD++qDQntfgQoynQ1ROZpUST84HpJa8k3tDM wNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1OzW1ILUIpo+Jg1OqgWnm4qZLge3dfFP7Tk3bt8fM LK0keMM0Odc5fIvz3v5R+3Jqs51MavjaNQEls+SzPj98rauveXcL437umzLx+Z8+/v9x3Glb a+VN2QsbUxdPtTixq6Ptrc/yFYkpHbnMOsflL5xq5r1sl/bSpLS0rPpgy1Pj93cPh39f/uWe V6NOqE8c4y/P5ZtnNK5Y85b/tP7asJrsZ28OZAvdN7Q7Fem2bf3TBPd7euHP18Xcna2zunD+ yz8KTBd4Vq1r/Tcj+816t0kVSYn6sybLuf/6eCvfxGGfe5lE9seXNxfcuNEuN0Pjvv7mgk1T Pp6oVk3td7D6s/zepNo96xR3Z3S8uelw9OJj3vyNTFdzOq7N/qkXqMRSnJFoqMVcVJwIAGEU qwx3AwAA X-CMS-MailID: 20220615101955eucas1p19b9d42ead7331f69f7dad1ec100312c2 X-Msg-Generator: CA X-RootMTR: 20220615101955eucas1p19b9d42ead7331f69f7dad1ec100312c2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101955eucas1p19b9d42ead7331f69f7dad1ec100312c2 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v7 09/13] dm-zone: use generic helpers to calculate offset from zone start X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Use the blk_queue_offset_from_zone_start() helper function to calculate the offset from zone start instead of using power of 2 based calculation. Signed-off-by: Pankaj Raghav Reviewed-by: Luis Chamberlain --- drivers/md/dm-zone.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 3e7b1fe15..af36d33f9 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -395,7 +395,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md, case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE: /* Writes must be aligned to the zone write pointer */ - if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset) + if ((blk_queue_offset_from_zone_start(md->queue, + clone->bi_iter.bi_sector)) != zwp_offset) return false; break; case REQ_OP_ZONE_APPEND: @@ -608,10 +609,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone) */ if (clone->bi_status == BLK_STS_OK && bio_op(clone) == REQ_OP_ZONE_APPEND) { - sector_t mask = (sector_t)blk_queue_zone_sectors(q) - 1; - orig_bio->bi_iter.bi_sector += - clone->bi_iter.bi_sector & mask; + blk_queue_offset_from_zone_start(q, clone->bi_iter.bi_sector); } return; From patchwork Wed Jun 15 10:19:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882051 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED433CCA473 for ; Wed, 15 Jun 2022 10:20:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-jYOGEL22N56rn5ZDU3-o1Q-1; Wed, 15 Jun 2022 06:20:12 -0400 X-MC-Unique: jYOGEL22N56rn5ZDU3-o1Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8650A185A79C; Wed, 15 Jun 2022 10:20:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 707134010E4D; Wed, 15 Jun 2022 10:20:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 112D21956B85; Wed, 15 Jun 2022 10:20:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4ED00194705C for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3A30C4010E4D; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 347B240C141F for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BF872999B28 for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-Ty-n5-PyPZ2rPfxZd9vgtA-1; Wed, 15 Jun 2022 06:20:05 -0400 X-MC-Unique: Ty-n5-PyPZ2rPfxZd9vgtA-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615102003euoutp02bbfd98d225eb7123eacdf897276f4d95~4xAiFRZ3B2943429434euoutp02O for ; Wed, 15 Jun 2022 10:20:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615102003euoutp02bbfd98d225eb7123eacdf897276f4d95~4xAiFRZ3B2943429434euoutp02O Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615102001eucas1p14900ffba109adf1d6ad58fb31b6d3662~4xAgLQcWb1438314383eucas1p1Q; Wed, 15 Jun 2022 10:20:01 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 0F.77.10067.152B9A26; Wed, 15 Jun 2022 11:20:01 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615102000eucas1p27720aaa3c309327b2b9a33c5f840f498~4xAfSu7uw2162921629eucas1p2v; Wed, 15 Jun 2022 10:20:00 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615102000eusmtrp2756cf6a4b8bd2122ff7819f99032710c~4xAfRraCL0349503495eusmtrp2N; Wed, 15 Jun 2022 10:20:00 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-ba-62a9b251a009 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EF.24.09038.052B9A26; Wed, 15 Jun 2022 11:20:00 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101959eusmtip1f228020010ced5b70c8bfdd433177605~4xAd8XbKh1152711527eusmtip1L; Wed, 15 Jun 2022 10:19:59 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:17 +0200 Message-Id: <20220615101920.329421-11-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7djPc7qBm1YmGfzar2ux+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0PgYpv aVtc3jWHzWL+sqfsFjcmPGW0+Ly0hd1izc2nLBZtG78yOgh7XL7i7fHvxBo2j52z7rJ7XD5b 6rFpVSebx8KGqcwem5fUe+y+2QCUa73P6vF+31U2j74tqxg91m+5yuKx+XS1x+dNch7tB7qZ AvijuGxSUnMyy1KL9O0SuDLmNpxjL3jKVXGzbRlrA+Nlji5GTg4JAROJ6w/XsnUxcnEICaxg lFj+/BWU84VRYsXlDiYI5zOjxORZXcwwLV0vu5khEssZJXpvfoSqesko8ePfTqAMBwebgJZE Yyc7SIOIQLjE0T33mEBsZoE+ZoknL+tAbGGBeIlf61+CDWURUJX43XqfDcTmFbCWmHF0BjvE MnmJmZe+g9mcQPEds3tYIWoEJU7OfMICMVNeonnrbLCDJATOcUps3buGFaLZRWJz/xZGCFtY 4tXxLVBDZST+75zPBGFXSzy98RuquYVRon/nejaQBySAtvWdyQExmQU0Jdbv0ocod5Q42r+H BaKCT+LGW0GIE/gkJm2bzgwR5pXoaBOCqFaS2PnzCdRSCYnLTXNYIGwPie9bjrBMYFScheSZ WUiemYWwdwEj8ypG8dTS4tz01GKjvNRyveLE3OLSvHS95PzcTYzA1Hn63/EvOxiXv/qod4iR iYPxEKMEB7OSCK9Z8MokId6UxMqq1KL8+KLSnNTiQ4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duznlh2M K1991DvEyMTBeIhRgoNZSYTXLHhlkhBvSmJlVWpRfnxRaU5q8SFGU6CzJzJLiSbnA9NMXkm8 oZmBqaGJmaWBqaWZsZI4r2dBR6KQQHpiSWp2ampBahFMHxMHp1QDU8yDuaePFx5PLf7yYZ2m rdW2UIOnbKVf/nyvkHAXOcU652TvFIfAtkaD6HAPvw/c03zzdy+s077Dd+DMYtNSY9uZ5w3F V01plll91rF354KuK1bn2qL37Dtw4RNf1K7LptMVlGMDy4N5pGKEpJ5NX5PpclO1/vLlE3tt p3z/svZxveS6rw4Tm3RWHjPYUnntUFL/mS9OIjGTls5qMP/duEE3cWN4uOgJhh/JwiKJPIrH pN4JXOJc0CG05w774omn57zOjnrnsbzJbUIO+41ZNzqSmZ+eyMxizhJwll1rUVAg4mOxWzbw ZM2d1slW0X/3z0xfoiF1YF760Ygr0nJZkyTSHkzhVzVZJbz0lZ6HjxJLcUaioRZzUXEiAHgN WCd7AwAA X-CMS-MailID: 20220615102000eucas1p27720aaa3c309327b2b9a33c5f840f498 X-Msg-Generator: CA X-RootMTR: 20220615102000eucas1p27720aaa3c309327b2b9a33c5f840f498 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615102000eucas1p27720aaa3c309327b2b9a33c5f840f498 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Subject: [dm-devel] [PATCH v7 10/13] dm-table: use bdev_is_zone_start helper in device_area_is_invalid() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org, Luis Chamberlain Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Use bdev_is_zone_start() helper that uses generic calculation to check for zone alignment instead of using po2 based alignment check. Signed-off-by: Pankaj Raghav Reviewed-by: Luis Chamberlain --- drivers/md/dm-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index bd539afbf..b553cdb6d 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -251,7 +251,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, if (bdev_is_zoned(bdev)) { unsigned int zone_sectors = bdev_zone_sectors(bdev); - if (start & (zone_sectors - 1)) { + if (blk_queue_is_zone_start(bdev_get_queue(bdev), start)) { DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)start, @@ -268,7 +268,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, * devices do not end up with a smaller zone in the middle of * the sector range. */ - if (len & (zone_sectors - 1)) { + if (blk_queue_is_zone_start(bdev_get_queue(bdev), len)) { DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)len, From patchwork Wed Jun 15 10:19:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882052 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0F04CCA473 for ; Wed, 15 Jun 2022 10:20:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-9snFiOvtP3GEJIlsTFxCUQ-1; Wed, 15 Jun 2022 06:20:13 -0400 X-MC-Unique: 9snFiOvtP3GEJIlsTFxCUQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC8CA3C01D96; Wed, 15 Jun 2022 10:20:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 990862026D07; Wed, 15 Jun 2022 10:20:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B2A61949759; Wed, 15 Jun 2022 10:20:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EB970194705C for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DDFC01415107; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA2D51415106 for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C33DC101E986 for ; Wed, 15 Jun 2022 10:20:09 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-vu_7nrq0O0u2sgCgSxv8ww-1; Wed, 15 Jun 2022 06:20:08 -0400 X-MC-Unique: vu_7nrq0O0u2sgCgSxv8ww-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220615102006euoutp017a34bf14b11372fb3ec55b91646abdad~4xAk5KXLM2495924959euoutp01s for ; Wed, 15 Jun 2022 10:20:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220615102006euoutp017a34bf14b11372fb3ec55b91646abdad~4xAk5KXLM2495924959euoutp01s Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615102005eucas1p2e51799f03f95acf5c1f7703f8351de94~4xAjFUQzG2114721147eucas1p2r; Wed, 15 Jun 2022 10:20:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 6A.4B.09664.452B9A26; Wed, 15 Jun 2022 11:20:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615102004eucas1p1e458ea097d381058b16fc6daa3eec998~4xAipn0SG1175911759eucas1p1l; Wed, 15 Jun 2022 10:20:04 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615102004eusmtrp2ba89836fb0aa21ef02b3525c2b0f566c~4xAiouw-J0361403614eusmtrp2F; Wed, 15 Jun 2022 10:20:04 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-37-62a9b254e53c Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 63.34.09038.452B9A26; Wed, 15 Jun 2022 11:20:04 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615102003eusmtip1d5651274b4871f0239331522fba58745~4xAhxZ7w90653206532eusmtip1U; Wed, 15 Jun 2022 10:20:03 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:18 +0200 Message-Id: <20220615101920.329421-12-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCKsWRmVeSWpSXmKPExsWy7djP87ohm1YmGfT8trBYfbefzWLah5/M Fr/Pnme22PtuNqvFhR+NTBY3D+xkstizaBKTxcrVR5ksnqyfxWzRc+ADi8XfrntAsZaHQMW3 tC0u75rDZjF/2VN2i89LW9gt1tx8ymLRtvEro4OQx+Ur3h7/Tqxh89g56y67x+WzpR6bVnWy eSxsmMrssXlJvcfumw1Audb7rB7v911l8+jbsorRY/2Wqywem09Xe3zeJOfRfqC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 20220615102004eucas1p1e458ea097d381058b16fc6daa3eec998 X-Msg-Generator: CA X-RootMTR: 20220615102004eucas1p1e458ea097d381058b16fc6daa3eec998 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615102004eucas1p1e458ea097d381058b16fc6daa3eec998 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v7 11/13] dm-table: allow non po2 zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com As the block layer now supports non po2 zoned devices, allow dm to support non po2 zoned device. Signed-off-by: Pankaj Raghav --- drivers/md/dm-table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index b553cdb6d..ec77e7830 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -251,7 +251,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, if (bdev_is_zoned(bdev)) { unsigned int zone_sectors = bdev_zone_sectors(bdev); - if (blk_queue_is_zone_start(bdev_get_queue(bdev), start)) { + if (!blk_queue_is_zone_start(bdev_get_queue(bdev), start)) { DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)start, @@ -268,7 +268,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, * devices do not end up with a smaller zone in the middle of * the sector range. */ - if (blk_queue_is_zone_start(bdev_get_queue(bdev), len)) { + if (!blk_queue_is_zone_start(bdev_get_queue(bdev), len)) { DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)len, @@ -1648,7 +1648,7 @@ static int validate_hardware_zoned_model(struct dm_table *table, } /* Check zone size validity and compatibility */ - if (!zone_sectors || !is_power_of_2(zone_sectors)) + if (!zone_sectors) return -EINVAL; if (dm_table_any_dev_attr(table, device_not_matches_zone_sectors, &zone_sectors)) { From patchwork Wed Jun 15 10:19:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882053 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC4E0C433EF for ; Wed, 15 Jun 2022 10:20:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-413-YaHeieBFNEujWqK3MrYiEw-1; Wed, 15 Jun 2022 06:20:16 -0400 X-MC-Unique: YaHeieBFNEujWqK3MrYiEw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2714E1C1CB84; Wed, 15 Jun 2022 10:20:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161E140D2853; Wed, 15 Jun 2022 10:20:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CD6721947B84; Wed, 15 Jun 2022 10:20:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1050D194705C for ; Wed, 15 Jun 2022 10:20:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E2B2C2026D07; Wed, 15 Jun 2022 10:20:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE7352026D64 for ; Wed, 15 Jun 2022 10:20:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C431A802D1F for ; Wed, 15 Jun 2022 10:20:12 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-FckpJMhNNU27MGB1RVUsfQ-1; Wed, 15 Jun 2022 06:20:10 -0400 X-MC-Unique: FckpJMhNNU27MGB1RVUsfQ-1 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615102009euoutp0293bb7f49f9cc738229d7e98071bea759~4xAne4n5z2870528705euoutp02k for ; Wed, 15 Jun 2022 10:20:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615102009euoutp0293bb7f49f9cc738229d7e98071bea759~4xAne4n5z2870528705euoutp02k Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615102008eucas1p2e85d5e1cf2fc269992852614bac65244~4xAl5vWjX0710507105eucas1p2n; Wed, 15 Jun 2022 10:20:08 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id DD.4B.09664.752B9A26; Wed, 15 Jun 2022 11:20:07 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220615102007eucas1p1106f9520e2a86beb3792107dffd8071b~4xAlg-xfo0963309633eucas1p1M; Wed, 15 Jun 2022 10:20:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615102007eusmtrp2669d4daff88954051642382b44d5908f~4xAlgN9xL0361403614eusmtrp2O; Wed, 15 Jun 2022 10:20:07 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-42-62a9b2577ce6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 96.34.09038.752B9A26; Wed, 15 Jun 2022 11:20:07 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220615102006eusmtip2a812fe6e28f7649ef0489c27adfb5e9f~4xAkoisYR0472904729eusmtip2d; Wed, 15 Jun 2022 10:20:06 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:19 +0200 Message-Id: <20220615101920.329421-13-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCKsWRmVeSWpSXmKPExsWy7djP87rhm1YmGXTvMLdYfbefzWLah5/M Fr/Pnme22PtuNqvFhR+NTBY3D+xkstizaBKTxcrVR5ksnqyfxWzRc+ADi8XfrntAsZaHQMW3 tC0u75rDZjF/2VN2i89LW9gt1tx8ymLRtvEro4OQx+Ur3h7/Tqxh89g56y67x+WzpR6bVnWy eSxsmMrssXlJvcfumw1Audb7rB7v911l8+jbsorRY/2Wqywem09Xe3zeJOfRfqCbKYA/issm JTUnsyy1SN8ugStj0d925oK/vBWr2neyNTDu4O5i5OSQEDCR6J+/lLmLkYtDSGAFo8SpXcvY IJwvjBJzpi1kgXA+M0psObycHabl372/rBCJ5YwSM/5eh+p/CVT1fxFQPwcHm4CWRGMnWIOI QLjE0T33mEBqmAVeMEksvj2XFSQhLJAicXXhHyYQm0VAVaJjYgczSC+vgLXE/Wd1EMvkJWZe +g42hxMovGN2D1grr4CgxMmZT1hAbGagmuats8FukBA4xSmxtesBE0Szi8T3N9PYIGxhiVfH t0B9ICPxf+d8qJpqiac3fkM1tzBK9O9cD/aABNC2vjM5ICazgKbE+l36EOWOEgtP9jJDVPBJ 3HgrCHECn8SkbdOhwrwSHW1CENVKEjt/PoFaKiFxu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Ex sYMZpJdXwFri/rM6iPnyEjMvfQcr4QQK75jdwwpSIiRgJbHrXTxImFdAUOLkzCcsIDYzUHnz 1tnMExgFZiFJzUKSWsDItIpRJLW0ODc9t9hIrzgxt7g0L10vOT93EyMwsrcd+7llB+PKVx/1 DjEycTAeYpTgYFYS4TULXpkkxJuSWFmVWpQfX1Sak1p8iNEU6OqJzFKiyfnA1JJXEm9oZmBq aGJmaWBqaWasJM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cAk9VNiWqrwemXl45Prs6r3zCi/ u2pPkuiEiS/l9xbuuGrAxaya+vtrdPAH3ob8qxN6b8TV214164gM+cuaJal97Ozs6o2NHaZV e45+Ws6qEfztqm78dGVfj2OfDaepH5kjfauE836TGuPppa8uuLS0n5mxQ0+wZOWh3qjHnFf+ NEp5Lo1czx+6N0nA7N+Eh7eu7E/5bJFYrRL5/6AFm7b3weZ7OUuvFS7znqNdavDqyrM3ZZOa f/Cqfu5LrowynrF0zuKbkwN4FgbZuJx5d8Phdeb0nV17AwVWPl38/Puh2Upd5ZPNPBbVPc+V SKk7Et3+RVLaYMdTpvtMH6f0uJRNs/0XPmMrb7TuPMPfm7YHKrEUZyQaajEXFScCAJiYyIR1 AwAA X-CMS-MailID: 20220615102007eucas1p1106f9520e2a86beb3792107dffd8071b X-Msg-Generator: CA X-RootMTR: 20220615102007eucas1p1106f9520e2a86beb3792107dffd8071b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615102007eucas1p1106f9520e2a86beb3792107dffd8071b References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Subject: [dm-devel] [PATCH v7 12/13] dm: call dm_zone_endio after the target endio callback for zoned devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes.Thumshirn@wdc.com, dsterba@suse.com, jaegeuk@kernel.org Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com dm_zone_endio() updates the bi_sector of orig bio for zoned devices that uses either native append or append emulation and it is called before the endio of the target. But target endio can still update the clone bio after dm_zone_endio is called, thereby, the orig bio does not contain the updated information anymore. Call dm_zone_endio for zoned devices after calling the target's endio function Signed-off-by: Pankaj Raghav --- @Damien and @Hannes: I couldn't come up with a testcase that uses endio callback and zone append or append emulation for zoned devices to test for regression in this change. It would be great if you can suggest something. This change is required for the npo2 target as we update the clone bio sector in the endio callback function and the orig bio should be updated only after the endio callback for zone appends. drivers/md/dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 3f17fe1de..3a74e1038 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1025,10 +1025,6 @@ static void clone_endio(struct bio *bio) disable_write_zeroes(md); } - if (static_branch_unlikely(&zoned_enabled) && - unlikely(blk_queue_is_zoned(bdev_get_queue(bio->bi_bdev)))) - dm_zone_endio(io, bio); - if (endio) { int r = endio(ti, bio, &error); switch (r) { @@ -1057,6 +1053,10 @@ static void clone_endio(struct bio *bio) } } + if (static_branch_unlikely(&zoned_enabled) && + unlikely(blk_queue_is_zoned(bdev_get_queue(bio->bi_bdev)))) + dm_zone_endio(io, bio); + if (static_branch_unlikely(&swap_bios_enabled) && unlikely(swap_bios_limit(ti, bio))) up(&md->swap_bios_semaphore); From patchwork Wed Jun 15 10:19:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12882054 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59631C433EF for ; Wed, 15 Jun 2022 10:20:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-57-KQd7tO7K9Q40D6QH0hQ-1; Wed, 15 Jun 2022 06:20:19 -0400 X-MC-Unique: 57-KQd7tO7K9Q40D6QH0hQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8ABA3804519; Wed, 15 Jun 2022 10:20:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5564401E68; Wed, 15 Jun 2022 10:20:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 92EE81947B84; Wed, 15 Jun 2022 10:20:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 76C8D194705C for ; Wed, 15 Jun 2022 10:20:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 58A4E400DF1D; Wed, 15 Jun 2022 10:20:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 545CC40CF8E7 for ; Wed, 15 Jun 2022 10:20:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 350AC101AA52 for ; Wed, 15 Jun 2022 10:20:16 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-gec-nxqWOdasQ9iEmNs5RA-1; Wed, 15 Jun 2022 06:20:14 -0400 X-MC-Unique: gec-nxqWOdasQ9iEmNs5RA-1 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615102013euoutp02962e95fde311bc900a7139d39dc94850~4xAq-4c0m2870528705euoutp02o for ; Wed, 15 Jun 2022 10:20:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615102013euoutp02962e95fde311bc900a7139d39dc94850~4xAq-4c0m2870528705euoutp02o Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220615102011eucas1p27927ddf4d6c43741b27aa5073cb46fc2~4xApc1BVV1912519125eucas1p2M; Wed, 15 Jun 2022 10:20:11 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 10.5B.09664.B52B9A26; Wed, 15 Jun 2022 11:20:11 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4~4xAo7795N0710507105eucas1p2s; Wed, 15 Jun 2022 10:20:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615102011eusmtrp2227b720bc5fb53cd1c83b1d6c4bc4bce~4xAo6uDdB0361403614eusmtrp2W; Wed, 15 Jun 2022 10:20:11 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-4c-62a9b25bf383 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2A.65.09095.B52B9A26; Wed, 15 Jun 2022 11:20:11 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220615102010eusmtip2dbad86de53e6f9e7136701b3cc5cabba~4xAnvRvtz0472904729eusmtip2g; Wed, 15 Jun 2022 10:20:09 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Date: Wed, 15 Jun 2022 12:19:20 +0200 Message-Id: <20220615101920.329421-14-p.raghav@samsung.com> In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmV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+m3VbhHlS3xH2rsu5SvoWHQF9lzzkNzGVFk7gij+8Lt9S /UuK0GcNg9snWh4KJH9lP3Ne/ajFvl+JjUznE7+5z14jcS3pZYltaruhfeC21umzY2/29fba 7+9a/8R3bt6eEBsZl4k9O6vuq57dOPcnO6/uTjb7J5sa86sbul6XK1f9Loq+Y/ezKPKdn6/V xd6jfW/Ot+/Zrb7ewDXVMDF+7/TzAfGvLjk9/BHp8vTx7hX1lTkJ5dFKLMUZiYZazEXFiQDr 6t5jegMAAA== X-CMS-MailID: 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4 X-Msg-Generator: CA X-RootMTR: 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4 References: <20220615101920.329421-1-p.raghav@samsung.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v7 13/13] dm: add non power of 2 zoned target X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Raghav , Damien Le Moal , bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, jonathan.derrick@linux.dev, Johannes Thumshirn , dsterba@suse.com, jaegeuk@kernel.org Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Only power of 2(po2) zoned devices were supported in linux but now non power of 2(npo2) zoned device support has been added to the block layer. Filesystems such as F2FS and btrfs have support for zoned devices with po2 zone size assumption. Before adding native support for npo2 zoned devices, it was suggested to create a dm target for npo2 zoned device to appear as po2 device so that file systems can initially work without any explicit changes by using this target. The design of this target is very simple: introduce gaps between the zone capacity and the po2 zone size of the underlying device. All IOs will be remapped from target to the actual device location. For devices that use zone append, the bi_sector is remapped from device to target's layout. The read IOs that fall in the "emulated" gap area will return 0 and all the other IOs in that area will result in an error. If an read IO span across the zone capacity boundary, then the IOs are split between the boundary. All other IO operations that span across a zone capacity boundary will result in an error. The target can be easily updated as follows: dmsetup create