From patchwork Mon May 27 08:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13674770 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A06C22064; Mon, 27 May 2024 08:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797084; cv=none; b=n0eTnYQoUxp2kCKexKD1Pg77pWXYlcxcAgeT1iLrkIX4cDUXEMrIWvwzJWkPTGMZjxp1aTHo/5W2ZZRX4nwM06L8Uo+ts4f6OPlaIGMwEEmaCkwH6LCNO71dTo1Euwc3rzDI7sGLmCQZXiaIiWr198kFE01KeS8hcAq2SjB4g1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797084; c=relaxed/simple; bh=jJb0qV+yVo0T50ZIbb1/KCaU079vCvkA/B8vzd4PZEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M6RyKWpdYX3IBPPgxWDLQRA9nnju7IkarwLboUY8fvLKoztuJFmq14BauI+xcnDsyUq5t7sInYoJD9CoVOVBE3ahH/npErpg6D2kk7fOM/s36EM3PVxUfoTpS/qj0WkEkPz2rG7qXuzpn3ZYDEfq+7FEcj97FqH1TX5GXws9rig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=LUPhVlxZ; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LUPhVlxZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mgE9BnxU8T58RflXXWmwBrZKZXCTN0gf1+ADme25Lc0=; b=LUPhVlxZIgQxnwlOonV+t84Ekd xwZLYZ4Hy/xUQJcq/DePNzkYJNXqYsoJyNvuDt0Ub0cKtwLEBpgCBofDaO/GLq48xX8OWfFahKZci ty1DjFA2uS1u2RSgGgQRvA/Cc4a8TFfDBVz/timMis/QHBQPWpEPi5zYrRJXFB76XqegU+RGB3Hip rhXTod7WJgYNZGymjk88K+gXwEkIGXHf6ilNiRRTFa2m+QdLVotHvDnKCmIGHijAotN1LZJnh9HiO XAhzgrBixMAEb8pX+Vkqawvy4Jj1ckIxtQYIt5Yos4qD7jzLcH/4Z+my5apg9qZiyyQS/kku0Qfg9 3i7MSv1A==; Received: from 2a02-8389-2341-5b80-3177-e4c1-2108-f294.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:3177:e4c1:2108:f294] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBVLV-0000000EAhj-2LCo; Mon, 27 May 2024 08:04:42 +0000 From: Christoph Hellwig To: Jens Axboe , Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev, linux-block@vger.kernel.org Subject: [PATCH 1/3] dm: move setting zoned_enabled to dm_table_set_restrictions Date: Mon, 27 May 2024 10:04:24 +0200 Message-ID: <20240527080435.1029612-2-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527080435.1029612-1-hch@lst.de> References: <20240527080435.1029612-1-hch@lst.de> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Keep it together with the rest of the zoned code. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/md/dm-table.c | 3 --- drivers/md/dm-zone.c | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index cc66a27c363a65..e291b78b307b13 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -2040,9 +2040,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, r = dm_set_zones_restrictions(t, q); if (r) return r; - if (blk_queue_is_zoned(q) && - !static_key_enabled(&zoned_enabled.key)) - static_branch_enable(&zoned_enabled); } dm_update_crypto_profile(q, t); diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 8e6bcb0d786a1a..3103360ce7f040 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -287,7 +287,13 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) queue_emulates_zone_append(q) ? "emulated" : "native"); } - return dm_revalidate_zones(md, t); + ret = dm_revalidate_zones(md, t); + if (ret < 0) + return ret; + + if (!static_key_enabled(&zoned_enabled.key)) + static_branch_enable(&zoned_enabled); + return 0; } /* From patchwork Mon May 27 08:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13674771 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8700622064; Mon, 27 May 2024 08:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797087; cv=none; b=IFEeq00CcdXjvhCW3YPguSkrpFSSag4LXL9S8TgtjpkSGpbN2kmmlaCvqmxcYgZl26OARfoifsLzF8l8idimu8MnIEoSt+TrycsJOcTM1t86nxhGCHOQVcBlfROaLdUuvZO4vUbCFR30iewjQm2fqFhHvFNQhQUu3q2T4ZoIKfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797087; c=relaxed/simple; bh=J3Sg4YwTVp/79+lhFzCb8z/RnEN7h9efuinMRpk7Vqg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=apTa8a+AoeazqoacTl27aNsLIpLubl4H+e8fCg0ygTpQc42DE/xIX7aESuaKAFEw1Jm8Sh9emTWG0+NNIk1QH3QYAyjsrINBEkJqUlZDOdcSI+PrbYb7VZrhMWyPLdLkaKOTMiC9REkUuL5Tc1dxyPhHqikw4+A2l77aWCZ6nxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=i0tvWjGW; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="i0tvWjGW" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6DkYMyOULdedhk/4nMLsECp+rsvb5FND6u2c2SP/QTA=; b=i0tvWjGWFbbA+DELwkk5tpzf7Q h5xeoeDvZ/TrpL5MXsQ1Eny26mJKJjUK2JLJPN47q8M5ZnbktCxpzLFgJOg8MS677y7jMhbIizWrH ktQlp13I8MmRsDqTJ7xDQsw9jZ8nKG9nmigq+PG97cPdSLXjpiZDnalB1WDLtR3rdfLX4Hf0UEDJA xSVrp57v0bGnhJerydGkMxHqO51CyaA2DTgyWVpWW6SHlY7IbunZUdOtVCEedKodXdusu4I7cy/4e mEJT6oRMv62hJ0Qin7pf8i4VZtxkWXvkmnjULXyyzA1JF6UPABSPPinH5KvFmvrb6JErK2pB/klXm UbQVFjdg==; Received: from 2a02-8389-2341-5b80-3177-e4c1-2108-f294.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:3177:e4c1:2108:f294] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBVLY-0000000EAj3-1cQr; Mon, 27 May 2024 08:04:44 +0000 From: Christoph Hellwig To: Jens Axboe , Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev, linux-block@vger.kernel.org Subject: [PATCH 2/3] dm: remove dm_check_zoned Date: Mon, 27 May 2024 10:04:25 +0200 Message-ID: <20240527080435.1029612-3-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527080435.1029612-1-hch@lst.de> References: <20240527080435.1029612-1-hch@lst.de> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Fold it into the only caller in preparation to changes in the queue limits setup. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Snitzer Reviewed-by: Johannes Thumshirn --- drivers/md/dm-zone.c | 59 +++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 3103360ce7f040..0ee22494857d07 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -160,37 +160,6 @@ static int dm_check_zoned_cb(struct blk_zone *zone, unsigned int idx, return 0; } -static int dm_check_zoned(struct mapped_device *md, struct dm_table *t) -{ - struct gendisk *disk = md->disk; - unsigned int nr_conv_zones = 0; - int ret; - - /* Count conventional zones */ - md->zone_revalidate_map = t; - ret = dm_blk_report_zones(disk, 0, UINT_MAX, - dm_check_zoned_cb, &nr_conv_zones); - md->zone_revalidate_map = NULL; - if (ret < 0) { - DMERR("Check zoned failed %d", ret); - return ret; - } - - /* - * If we only have conventional zones, expose the mapped device as - * a regular device. - */ - if (nr_conv_zones >= ret) { - disk->queue->limits.max_open_zones = 0; - disk->queue->limits.max_active_zones = 0; - disk->queue->limits.zoned = false; - clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); - disk->nr_zones = 0; - } - - return 0; -} - /* * Revalidate the zones of a mapped device to initialize resource necessary * for zone append emulation. Note that we cannot simply use the block layer @@ -254,6 +223,8 @@ static bool dm_table_supports_zone_append(struct dm_table *t) int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) { struct mapped_device *md = t->md; + struct gendisk *disk = md->disk; + unsigned int nr_conv_zones = 0; int ret; /* @@ -272,14 +243,30 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) return 0; /* - * Check that the mapped device will indeed be zoned, that is, that it - * has sequential write required zones. + * Count conventional zones to check that the mapped device will indeed + * have sequential write required zones. */ - ret = dm_check_zoned(md, t); - if (ret) + md->zone_revalidate_map = t; + ret = dm_blk_report_zones(disk, 0, UINT_MAX, + dm_check_zoned_cb, &nr_conv_zones); + md->zone_revalidate_map = NULL; + if (ret < 0) { + DMERR("Check zoned failed %d", ret); return ret; - if (!blk_queue_is_zoned(q)) + } + + /* + * If we only have conventional zones, expose the mapped device as + * a regular device. + */ + if (nr_conv_zones >= ret) { + disk->queue->limits.max_open_zones = 0; + disk->queue->limits.max_active_zones = 0; + disk->queue->limits.zoned = false; + clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); + disk->nr_zones = 0; return 0; + } if (!md->disk->nr_zones) { DMINFO("%s using %s zone append", From patchwork Mon May 27 08:04:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13674772 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1384C3D0D0; Mon, 27 May 2024 08:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797089; cv=none; b=rRfeMlgabvRG2F1ByubUUnKauktNvgIO00IZd/vL29um6jTc51EjAKZsCByPZlRLLiFZJUJUtRAI3A83jRg636ye15pZObeAhZzAIzXLRhWRt8jvQQWuo+YDv9kjb5ziBsJTlqhRTA6XBobgvdxIacue1yXk7Jh9eBZtyZQKQac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716797089; c=relaxed/simple; bh=K6QW4Ee4lGnLIoRVxiBydldanURp7hDujs18V3mvsSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eoc0/3pi2ah4rpFxKbFReWODVTlwKcn4EYN5RcDslhSNvYTUEDC/vs+wv219/92CdWFJrf7Lpl1YAH0TyS1Y2HBrcDUWsWkG05BZUZNxd7sRLI4kTIc6xZnXgV4iG5pVzeLA46AjQtQ87Y9dZEb30oMAVx115af6NGlR/tftYQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=gRPVzS2J; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gRPVzS2J" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=lbwSzTm0VhAXubnmYNdJiciwo9vwE6hDWfs2OC3v0UU=; b=gRPVzS2JUvCwPzoos1we10eAH+ waT9BIh1tV7RfYiYlgQBNoDYu5Nez26VO8KvZx+yK0xTvLMHwcSmqZdPaT/wIr/jS+qNtzXsnDG0c oBtvVDmEFj2RsROWgRZuaxnbbUEf1DNan/df386qT8dmRoywBn9YcYtp3xUzpAlLOZNJoIHzeUDAu MgRLhEbIJIVUn9n8LmyXRtq7QQdZwnK/wn+8zoH3tyBxwKvN6EoP1jtG2rKGUoiUcFrYF3KQOqnz8 S2dvj7X4hOlN5ry5v4oZbmfTRx6/Bnt7Tk8x7mt/juWMeMy+4zOTnVGLTeydC/7P1lSvx72kDxu2F fb0rRKlQ==; Received: from 2a02-8389-2341-5b80-3177-e4c1-2108-f294.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:3177:e4c1:2108:f294] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBVLb-0000000EAkP-1iBI; Mon, 27 May 2024 08:04:47 +0000 From: Christoph Hellwig To: Jens Axboe , Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev, linux-block@vger.kernel.org Subject: [PATCH 3/3] dm: make dm_set_zones_restrictions work on the queue limits Date: Mon, 27 May 2024 10:04:26 +0200 Message-ID: <20240527080435.1029612-4-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527080435.1029612-1-hch@lst.de> References: <20240527080435.1029612-1-hch@lst.de> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Don't stuff the values directly into the queue without any synchronization, but instead delay applying the queue limits in the caller and let dm_set_zones_restrictions work on the limit structure. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/md/dm-table.c | 12 ++++++------ drivers/md/dm-zone.c | 11 ++++++----- drivers/md/dm.h | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e291b78b307b13..a027a6c0928d1a 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1981,10 +1981,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, if (!dm_table_supports_secure_erase(t)) limits->max_secure_erase_sectors = 0; - r = queue_limits_set(q, limits); - if (r) - return r; - if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) { wc = true; if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_FUA))) @@ -2036,12 +2032,16 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, * For a zoned target, setup the zones related queue attributes * and resources necessary for zone append emulation if necessary. */ - if (blk_queue_is_zoned(q)) { - r = dm_set_zones_restrictions(t, q); + if (limits->zoned) { + r = dm_set_zones_restrictions(t, q, limits); if (r) return r; } + r = queue_limits_set(q, limits); + if (r) + return r; + dm_update_crypto_profile(q, t); /* diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 0ee22494857d07..5d66d916730efa 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -220,7 +220,8 @@ static bool dm_table_supports_zone_append(struct dm_table *t) return true; } -int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) +int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q, + struct queue_limits *lim) { struct mapped_device *md = t->md; struct gendisk *disk = md->disk; @@ -236,7 +237,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); } else { set_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); - blk_queue_max_zone_append_sectors(q, 0); + lim->max_zone_append_sectors = 0; } if (!get_capacity(md->disk)) @@ -260,9 +261,9 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) * a regular device. */ if (nr_conv_zones >= ret) { - disk->queue->limits.max_open_zones = 0; - disk->queue->limits.max_active_zones = 0; - disk->queue->limits.zoned = false; + lim->max_open_zones = 0; + lim->max_active_zones = 0; + lim->zoned = false; clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); disk->nr_zones = 0; return 0; diff --git a/drivers/md/dm.h b/drivers/md/dm.h index e0c57f19839b29..53ef8207fe2c15 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -101,7 +101,8 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t); /* * Zoned targets related functions. */ -int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q); +int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q, + struct queue_limits *lim); void dm_zone_endio(struct dm_io *io, struct bio *clone); #ifdef CONFIG_BLK_DEV_ZONED int dm_blk_report_zones(struct gendisk *disk, sector_t sector,