From patchwork Fri May 24 14:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13673222 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 63B5512C496 for ; Fri, 24 May 2024 14:29:38 +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=1716560980; cv=none; b=c3WZh2KSpHyD1aXXrT/OsOj1SItxvcpDjcCR2hNEmp6rhMZ5mbDpSbAF0af2s04cZmt6oGjqqr2fWWTTdcY7bP6tE9lX6Cz9I/Rv5xgAgrfEZdDxEDp5acx6QjsrQ5mm5a50TrLEj7DuCmnpWvsvBLAkiNOwZFt/sOWbAZ7xjqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716560980; c=relaxed/simple; bh=m/crkvdj6tgZu8Rjo/8pPIhVHQPC9wz6wLIU0Ouju64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SZSU9dkd8QouXOOs3Qyg5+RUdm/0PiEnZ8ubYQ0SaGnUS/KGysgspDE0a3Ol82PL629ViiISJ1sys32STxgXy7Tf0eWulfrAHBLAkt/q0QrK2k7q1rdl2NT/VSIIcnMDGKQoE8A2x5rpJ2xEqKEb6Eerb28lFA72d3QuZd01FHY= 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=wixcHswy; 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="wixcHswy" 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=w9fc44ZoadWtFqeM/SZvVFQF2HSr7fN/ty6EajFhxzs=; b=wixcHswyNvWd/e2kJW+1nRqz6D draxFNrk68PwsPqx72G+xX1rzvyO5W7xATKy1N02uP390laN3FDKC/GosJ0YUcOnJFisua89lMt7X b4It2O+0QiEKIxhVqx9Uj7anMBkqsy/WRUHl4ep7tTkuHAEF+xCj64x1bJH/IQ+4mbb2XkJPSFnM0 bP5a667QUWtsgBHyVMEDz+QgDY+zNIWXwei4YsoAXlvO0rRrpxpZ8wcbPxK3GMQE+0qty1+4VjXWc hwFk/NMD9eln8Cd4bD8xun6W1A5rGR1SNxhFrPk99ZOA8tO9N7Q5c2IZ65QomLr/D+gJLnt3rG/2Z XrBCPYdw==; Received: from [2001:4bb8:2dd:2931:3dd2:5393:218b:4dfd] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAVvN-000000097c9-1CGy; Fri, 24 May 2024 14:29:37 +0000 From: Christoph Hellwig To: Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev Subject: [PATCH 1/3] dm: move setting zoned_enabled to dm_table_set_restrictions Date: Fri, 24 May 2024 16:29:09 +0200 Message-ID: <20240524142929.817565-2-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240524142929.817565-1-hch@lst.de> References: <20240524142929.817565-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 --- 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..eb1165324ab047 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 0; + + if (!static_key_enabled(&zoned_enabled.key)) + static_branch_enable(&zoned_enabled); + return 0; } /* From patchwork Fri May 24 14:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13673223 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 0441312C483 for ; Fri, 24 May 2024 14:29:41 +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=1716560983; cv=none; b=o6wox3PvW7raOnHX/t9SvBd6nHj1hwUx+lzYK9Uj12z2xeQjnhAIolCTgHvN2ysbfSoX4m0t34wTt1qPV9qKVIMESP/+6ufbYRTKwc/GDXfaesHk1CaZFitiwGyGgD1X6Yzgtnn9ZyXRV+vaiEEhNBF3vmpteS/xanpQBTsNeM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716560983; c=relaxed/simple; bh=aYIybanKyqBH47FDinttBmlmSvJRWUTpQlgX7nP6zlg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dZTvjRXbb2akYhiwqf7jhije97FGNkyGdsLBu4p7dq63o0QT9Yokzt3JNZ89ESroXgrE9LExgiOnAP9Ys5BTXke8qT50p+lqKPIyIRSS8ehecvkNF/g9ofKzlC/DIUDRq3CVwr4kKzlXahZgPAyTXMB/2whEyGo3PKixkBNsna4= 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=fq6V1zOI; 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="fq6V1zOI" 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=Tk2ound9ipIJbf+jfeJ65KHCVqvIKlGFAaDHqk/3fZY=; b=fq6V1zOITYvQ5AtLkOlCaacpEX 3/U7uwPuKEb7BRtNMvy0idZoBRxq4GnYLz7Ocyn4kj15q2JydnlDqUBPNlbafTZRyJVaRWQZ2KM19 87PFedtiNJ58ERElM3aBbq8rlG1QTAwx7+iH0EiyPtYgoIrAOfger0kFf45FNBuZ3TBvdU/mf5D1W x1pHa26JWFHZNDMi6yQIT4EGnEhR78kmtjj7um4qQp4VQwoB7UfGEckMDZ2Tu8z94rTmA3JmY+YEm qMXDD5OqkprpCnXJ4t7/2jWhVAWaXCCHkuIO3h6a3JH0haWIHDGS6vnj1nni7QPXY/4Os3CmhuqJV S1UY5uBA==; Received: from [2001:4bb8:2dd:2931:3dd2:5393:218b:4dfd] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAVvQ-000000097ci-37rG; Fri, 24 May 2024 14:29:41 +0000 From: Christoph Hellwig To: Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev Subject: [PATCH 2/3] dm: remove dm_check_zoned Date: Fri, 24 May 2024 16:29:10 +0200 Message-ID: <20240524142929.817565-3-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240524142929.817565-1-hch@lst.de> References: <20240524142929.817565-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 --- 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 eb1165324ab047..13b4857d98fe5b 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 Fri May 24 14:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13673224 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 460AE86262 for ; Fri, 24 May 2024 14:29:47 +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=1716560988; cv=none; b=gRPS9PTN9l5WvW5MYPpTD6yrP9VOsCbR8d/MjTMJH2anDlBM7DaOu8QzwIr+3r4fhhWbCsRAMPusT1aX7ahaBT10VhdRBupYrjJAzlJZoTYuZVVnm9R6kOt1UVmHMXkMFkhc9ypTs6PvpXh/cgoxNasdLv01q5Mj3xXCKUhiYJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716560988; c=relaxed/simple; bh=f6b1oq2XR17tzZKT2KpSPO4AcWqaA3+exze5MLhdonk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rB85+VQeDzeUDrM7JrBchpiJ+qEcemgIE4iYX+kJGES59wrd2CA0cBrd9mJ9rWI9CFORzktV9q0LBG4oLSAWvM709fPeHopb4AdGewZQHnwjBFg/mBQVDZ7pmpr0bzU+NboaqaDOGmdZ4egtoUFGoZhRX/x5XZ7p8Ik+idEoEow= 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=ll8LHhxP; 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="ll8LHhxP" 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=EloC0hg3AK7jpk8XFiSg9G3Mz8fEBoZkLmqpwNpsZ+M=; b=ll8LHhxPxi+D9NfNwOi81G5x4h H+uB1cs1UEzYQJXWOiZu6uUPyyjzPbs3DSJ4SaEsdqHODHCuwK2vs9cL0GUGUtidoo7ZhIGjsxdEv hKscavOCVxsy+mzzN1TpVzfeKGNMGjPEUGiKUUuXf+3wBLRCdz4ZBRyihPogb/j+S2pQLpcx7ym/I yXk3w3jMXp2JQrSKTzvy1eFHSe7yBZMa5JGpWS2kBs+RyU9qnSbY2dKkX0yaE5UmfxiYpQd50zB6S JnXOi8mdoMM7VgeQLRi8XaKfc1BqX4vT8BQS5Us64pLuPiSzZjhWrX6LZMBd1zcgC7j+PETeewHCC Tz37Itcg==; Received: from [2001:4bb8:2dd:2931:3dd2:5393:218b:4dfd] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAVvU-000000097cq-2IXC; Fri, 24 May 2024 14:29:46 +0000 From: Christoph Hellwig To: Mike Snitzer , Mikulas Patocka Cc: Damien Le Moal , dm-devel@lists.linux.dev Subject: [PATCH 3/3] dm: make dm_set_zones_restrictions work on the queue limits Date: Fri, 24 May 2024 16:29:11 +0200 Message-ID: <20240524142929.817565-4-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240524142929.817565-1-hch@lst.de> References: <20240524142929.817565-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 --- drivers/md/dm-table.c | 16 +++++++++------- drivers/md/dm-zone.c | 11 ++++++----- drivers/md/dm.h | 3 ++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e291b78b307b13..6e4ee829005e92 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,18 @@ 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 (r) + if (limits->zoned) { + r = dm_set_zones_restrictions(t, q, limits); + if (r) { + queue_limits_cancel_update(q); 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 13b4857d98fe5b..719238aa3006ba 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,