From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B186EC433EF for ; Mon, 9 May 2022 18:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240422AbiEITCo (ORCPT ); Mon, 9 May 2022 15:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240412AbiEITCn (ORCPT ); Mon, 9 May 2022 15:02:43 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0DC42854BE; Mon, 9 May 2022 11:58:48 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7AF061F96C; Mon, 9 May 2022 18:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1652122727; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w16vchMYkyFzvUDJDkFpExZGWWDGv88fe0vQkjsLWNM=; b=mlwTaZePSYYE+AM6xPPGqmoaln0IagFvo9KKgNNA4Uz66qywNk6uF9/skqurvX0+4SQsTk UJoUGdTg3x8JIPYFK35e6+W609tsTHvyuFkLN8zUuM5Y6yjYFjh4XdOfahdlwnluavSp7v s3SJEovsDRoQEco1xf6AO+Dr6kV3n2Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1652122727; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w16vchMYkyFzvUDJDkFpExZGWWDGv88fe0vQkjsLWNM=; b=XoAgV38ZQFsVXsLl2q0Y/LuyEaHZ7SnRRkLm8/ZoXITtGX7+VWngPcr6IpaTqKZE5vbtWk ZaBqkBsEIZSIRUCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DE59313AA5; Mon, 9 May 2022 18:58:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id C0pQNWZkeWIhcgAAMHmgww (envelope-from ); Mon, 09 May 2022 18:58:46 +0000 Date: Mon, 9 May 2022 20:54:32 +0200 From: David Sterba To: Pankaj Raghav Cc: jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org, Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Luis Chamberlain Subject: Re: [PATCH v3 11/11] dm-zoned: ensure only power of 2 zone sizes are allowed Message-ID: <20220509185432.GB18596@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Pankaj Raghav , jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org, Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Luis Chamberlain References: <20220506081105.29134-1-p.raghav@samsung.com> <20220506081105.29134-12-p.raghav@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220506081105.29134-12-p.raghav@samsung.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Fri, May 06, 2022 at 10:11:05AM +0200, Pankaj Raghav wrote: > 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-zone.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c > index 3e7b1fe15..27dc4ddf2 100644 > --- a/drivers/md/dm-zone.c > +++ b/drivers/md/dm-zone.c > @@ -231,6 +231,18 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t) > struct request_queue *q = md->queue; > unsigned int noio_flag; > int ret; > + struct block_device *bdev = md->disk->part0; > + sector_t zone_sectors; > + char bname[BDEVNAME_SIZE]; > + > + zone_sectors = bdev_zone_sectors(bdev); > + > + if (!is_power_of_2(zone_sectors)) { is_power_of_2 takes 'unsigned long' and sector_t is u64, so this is not 32bit clean and we had an actual bug where value 1<<48 was not recognized as power of 2. > + DMWARN("%s: %s only power of two zone size supported\n", > + dm_device_name(md), > + bdevname(bdev, bname)); > + return 1; > + } > > /* > * Check if something changed. If yes, cleanup the current resources > -- > 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 E3C24C433F5 for ; Mon, 9 May 2022 18:58:59 +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-660-ObxEdthYPzqp5BLmst82wQ-1; Mon, 09 May 2022 14:58:57 -0400 X-MC-Unique: ObxEdthYPzqp5BLmst82wQ-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 B4090811E81; Mon, 9 May 2022 18:58: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 9D3C82166B2F; Mon, 9 May 2022 18:58:53 +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 468E11947052; Mon, 9 May 2022 18:58:53 +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 E463D1947051 for ; Mon, 9 May 2022 18:58:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D0EC2401012D; Mon, 9 May 2022 18:58:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBA9F40CF91B for ; Mon, 9 May 2022 18:58:52 +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 B30AB811E7A for ; Mon, 9 May 2022 18:58:52 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-5b1HH2KcMoq2-Oiu2ftOWA-1; Mon, 09 May 2022 14:58:48 -0400 X-MC-Unique: 5b1HH2KcMoq2-Oiu2ftOWA-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7AF061F96C; Mon, 9 May 2022 18:58:47 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DE59313AA5; Mon, 9 May 2022 18:58:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id C0pQNWZkeWIhcgAAMHmgww (envelope-from ); Mon, 09 May 2022 18:58:46 +0000 Date: Mon, 9 May 2022 20:54:32 +0200 From: David Sterba To: Pankaj Raghav Message-ID: <20220509185432.GB18596@twin.jikos.cz> Mail-Followup-To: dsterba@suse.cz, Pankaj Raghav , jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org, Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Luis Chamberlain References: <20220506081105.29134-1-p.raghav@samsung.com> <20220506081105.29134-12-p.raghav@samsung.com> MIME-Version: 1.0 In-Reply-To: <20220506081105.29134-12-p.raghav@samsung.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) 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: Re: [dm-devel] [PATCH v3 11/11] 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: , Reply-To: dsterba@suse.cz Cc: jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, Chris Mason , dm-devel@redhat.com, hch@lst.de, Alasdair Kergon , Naohiro Aota , bvanassche@acm.org, gost.dev@samsung.com, damien.lemoal@opensource.wdc.com, jonathan.derrick@linux.dev, Chaitanya Kulkarni , snitzer@kernel.org, Josef Bacik , Jens Axboe , dsterba@suse.com, jaegeuk@kernel.org, matias.bjorling@wdc.com, Sagi Grimberg , axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Keith Busch , Luis Chamberlain , linux-fsdevel@vger.kernel.org, Johannes Thumshirn , linux-btrfs@vger.kernel.org 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 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Fri, May 06, 2022 at 10:11:05AM +0200, Pankaj Raghav wrote: > 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-zone.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c > index 3e7b1fe15..27dc4ddf2 100644 > --- a/drivers/md/dm-zone.c > +++ b/drivers/md/dm-zone.c > @@ -231,6 +231,18 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t) > struct request_queue *q = md->queue; > unsigned int noio_flag; > int ret; > + struct block_device *bdev = md->disk->part0; > + sector_t zone_sectors; > + char bname[BDEVNAME_SIZE]; > + > + zone_sectors = bdev_zone_sectors(bdev); > + > + if (!is_power_of_2(zone_sectors)) { is_power_of_2 takes 'unsigned long' and sector_t is u64, so this is not 32bit clean and we had an actual bug where value 1<<48 was not recognized as power of 2. > + DMWARN("%s: %s only power of two zone size supported\n", > + dm_device_name(md), > + bdevname(bdev, bname)); > + return 1; > + } > > /* > * Check if something changed. If yes, cleanup the current resources > -- > 2.25.1 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel