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 4/7] dm: cleanup close_table_device Date: Sun, 30 Oct 2022 16:31:16 +0100 [thread overview] Message-ID: <20221030153120.1045101-5-hch@lst.de> (raw) In-Reply-To: <20221030153120.1045101-1-hch@lst.de> Take the list unlink and free into close_table_device so that no half torn down table_devices exist. Also remove the check for a NULL bdev as that can't happen - open_table_device never adds a table_device to the list that does not have a valid block_device. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/dm.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 28d7581b6a826..2917700b1e15c 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -774,14 +774,11 @@ static struct table_device *open_table_device(struct mapped_device *md, */ static void close_table_device(struct table_device *td, struct mapped_device *md) { - if (!td->dm_dev.bdev) - return; - bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); put_dax(td->dm_dev.dax_dev); - td->dm_dev.bdev = NULL; - td->dm_dev.dax_dev = NULL; + list_del(&td->list); + kfree(td); } static struct table_device *find_table_device(struct list_head *l, dev_t dev, @@ -823,11 +820,8 @@ void dm_put_table_device(struct mapped_device *md, struct dm_dev *d) struct table_device *td = container_of(d, struct table_device, dm_dev); mutex_lock(&md->table_devices_lock); - if (refcount_dec_and_test(&td->count)) { + if (refcount_dec_and_test(&td->count)) close_table_device(td, md); - list_del(&td->list); - kfree(td); - } mutex_unlock(&md->table_devices_lock); } -- 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 4/7] dm: cleanup close_table_device Date: Sun, 30 Oct 2022 16:31:16 +0100 [thread overview] Message-ID: <20221030153120.1045101-5-hch@lst.de> (raw) In-Reply-To: <20221030153120.1045101-1-hch@lst.de> Take the list unlink and free into close_table_device so that no half torn down table_devices exist. Also remove the check for a NULL bdev as that can't happen - open_table_device never adds a table_device to the list that does not have a valid block_device. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/dm.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 28d7581b6a826..2917700b1e15c 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -774,14 +774,11 @@ static struct table_device *open_table_device(struct mapped_device *md, */ static void close_table_device(struct table_device *td, struct mapped_device *md) { - if (!td->dm_dev.bdev) - return; - bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); put_dax(td->dm_dev.dax_dev); - td->dm_dev.bdev = NULL; - td->dm_dev.dax_dev = NULL; + list_del(&td->list); + kfree(td); } static struct table_device *find_table_device(struct list_head *l, dev_t dev, @@ -823,11 +820,8 @@ void dm_put_table_device(struct mapped_device *md, struct dm_dev *d) struct table_device *td = container_of(d, struct table_device, dm_dev); mutex_lock(&md->table_devices_lock); - if (refcount_dec_and_test(&td->count)) { + if (refcount_dec_and_test(&td->count)) close_table_device(td, md); - list_del(&td->list); - kfree(td); - } mutex_unlock(&md->table_devices_lock); } -- 2.30.2 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
next prev 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 ` [PATCH 2/7] dm: remove free_table_devices Christoph Hellwig 2022-10-30 15:31 ` [dm-devel] " 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 ` Christoph Hellwig [this message] 2022-10-30 15:31 ` [dm-devel] [PATCH 4/7] dm: cleanup close_table_device 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-5-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: linkBe 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.