All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>
Cc: Yu Kuai <yukuai1@huaweicloud.com>,
	dm-devel@redhat.com, linux-block@vger.kernel.org
Subject: [PATCH 2/7] dm: remove free_table_devices
Date: Sun, 30 Oct 2022 16:31:14 +0100	[thread overview]
Message-ID: <20221030153120.1045101-3-hch@lst.de> (raw)
In-Reply-To: <20221030153120.1045101-1-hch@lst.de>

free_table_devices just warns and frees all table_device structures when
the target removal did not remove them.  This should never happen, but
if it did, just freeing the structure without deleting them from the
list or cleaning up the resources would not help at all.  So just WARN on
a non-empty list instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 95a1ee3d314eb..19d25bf997be4 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -833,19 +833,6 @@ void dm_put_table_device(struct mapped_device *md, struct dm_dev *d)
 	mutex_unlock(&md->table_devices_lock);
 }
 
-static void free_table_devices(struct list_head *devices)
-{
-	struct list_head *tmp, *next;
-
-	list_for_each_safe(tmp, next, devices) {
-		struct table_device *td = list_entry(tmp, struct table_device, list);
-
-		DMWARN("dm_destroy: %s still exists with %d references",
-		       td->dm_dev.name, refcount_read(&td->count));
-		kfree(td);
-	}
-}
-
 /*
  * Get the geometry associated with a dm device
  */
@@ -2122,7 +2109,7 @@ static void free_dev(struct mapped_device *md)
 
 	cleanup_mapped_device(md);
 
-	free_table_devices(&md->table_devices);
+	WARN_ON_ONCE(!list_empty(&md->table_devices));
 	dm_stats_cleanup(&md->stats);
 	free_minor(minor);
 
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>
Cc: linux-block@vger.kernel.org, Yu Kuai <yukuai1@huaweicloud.com>,
	dm-devel@redhat.com
Subject: [dm-devel] [PATCH 2/7] dm: remove free_table_devices
Date: Sun, 30 Oct 2022 16:31:14 +0100	[thread overview]
Message-ID: <20221030153120.1045101-3-hch@lst.de> (raw)
In-Reply-To: <20221030153120.1045101-1-hch@lst.de>

free_table_devices just warns and frees all table_device structures when
the target removal did not remove them.  This should never happen, but
if it did, just freeing the structure without deleting them from the
list or cleaning up the resources would not help at all.  So just WARN on
a non-empty list instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 95a1ee3d314eb..19d25bf997be4 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -833,19 +833,6 @@ void dm_put_table_device(struct mapped_device *md, struct dm_dev *d)
 	mutex_unlock(&md->table_devices_lock);
 }
 
-static void free_table_devices(struct list_head *devices)
-{
-	struct list_head *tmp, *next;
-
-	list_for_each_safe(tmp, next, devices) {
-		struct table_device *td = list_entry(tmp, struct table_device, list);
-
-		DMWARN("dm_destroy: %s still exists with %d references",
-		       td->dm_dev.name, refcount_read(&td->count));
-		kfree(td);
-	}
-}
-
 /*
  * Get the geometry associated with a dm device
  */
@@ -2122,7 +2109,7 @@ static void free_dev(struct mapped_device *md)
 
 	cleanup_mapped_device(md);
 
-	free_table_devices(&md->table_devices);
+	WARN_ON_ONCE(!list_empty(&md->table_devices));
 	dm_stats_cleanup(&md->stats);
 	free_minor(minor);
 
-- 
2.30.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2022-10-30 15:31 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 15:31 fix delayed holder tracking v2 Christoph Hellwig
2022-10-30 15:31 ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 1/7] block: clear ->slave_dir when dropping the main slave_dir reference Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` Christoph Hellwig [this message]
2022-10-30 15:31   ` [dm-devel] [PATCH 2/7] dm: remove free_table_devices Christoph Hellwig
2022-10-30 15:31 ` [PATCH 3/7] dm: cleanup open_table_device Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 4/7] dm: cleanup close_table_device Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 5/7] dm: track per-add_disk holder relations in DM Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-11-09  2:08   ` Yu Kuai
2022-11-09  2:08     ` [dm-devel] " Yu Kuai
2022-11-09  8:26     ` Christoph Hellwig
2022-11-09  8:26       ` [dm-devel] " Christoph Hellwig
2022-11-10 18:09       ` Mike Snitzer
2022-11-10 18:09         ` [dm-devel] " Mike Snitzer
2022-11-10 19:48         ` Mike Snitzer
2022-11-10 19:48           ` Mike Snitzer
2022-11-12  6:23         ` Yu Kuai
2022-11-12  6:23           ` [dm-devel] " Yu Kuai
2022-10-30 15:31 ` [PATCH 6/7] block: remove delayed holder registration Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-30 15:31 ` [PATCH 7/7] block: store the holder kobject in bd_holder_disk Christoph Hellwig
2022-10-30 15:31   ` [dm-devel] " Christoph Hellwig
2022-10-31  1:52   ` Yu Kuai
2022-10-31  1:52     ` [dm-devel] " Yu Kuai
2022-11-01 10:49     ` Christoph Hellwig
2022-11-01 10:49       ` [dm-devel] " Christoph Hellwig
2022-11-01 11:12       ` Yu Kuai
2022-11-01 11:12         ` [dm-devel] " Yu Kuai
2022-11-01 11:21         ` Christoph Hellwig
2022-11-01 11:21           ` [dm-devel] " Christoph Hellwig
2022-11-01 11:28           ` Yu Kuai
2022-11-01 11:28             ` [dm-devel] " Yu Kuai
2022-11-01 13:18             ` Christoph Hellwig
2022-11-01 13:18               ` [dm-devel] " Christoph Hellwig
2022-11-01 13:29               ` Yu Kuai
2022-11-01 13:29                 ` [dm-devel] " Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221030153120.1045101-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=yukuai1@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.