All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: dm-devel@redhat.com
Cc: Mike Snitzer <snitzer@kernel.org>
Subject: [dm-devel] [PATCH 5/6] dm ioctl: assert _hash_lock is held in __hash_remove
Date: Fri, 17 Feb 2023 15:07:36 -0500	[thread overview]
Message-ID: <20230217200737.12481-6-snitzer@kernel.org> (raw)
In-Reply-To: <20230217200737.12481-1-snitzer@kernel.org>

Also update dm_early_create() to take _hash_lock when calling both
__get_name_cell and __hash_remove -- given dm_early_create()'s early
boot usecase this locking isn't about correctness but it allows
lockdep_assert_held() to be added to __hash_remove.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
 drivers/md/dm-ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index f34d36a4b4a1..067dfc08d4c3 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -310,6 +310,8 @@ static struct dm_table *__hash_remove(struct hash_cell *hc)
 	struct dm_table *table;
 	int srcu_idx;
 
+	lockdep_assert_held(&_hash_lock);
+
 	/* remove from the dev trees */
 	__unlink_name(hc);
 	__unlink_uuid(hc);
@@ -2263,7 +2265,9 @@ int __init dm_early_create(struct dm_ioctl *dmi,
 err_destroy_table:
 	dm_table_destroy(t);
 err_hash_remove:
+	down_write(&_hash_lock);
 	(void) __hash_remove(__get_name_cell(dmi->name));
+	up_write(&_hash_lock);
 	/* release reference from __get_name_cell */
 	dm_put(md);
 err_destroy_dm:
-- 
2.37.0 (Apple Git-136)

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


  parent reply	other threads:[~2023-02-17 20:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 20:07 [dm-devel] [PATCH 0/6] dm: some changes just staged for 6.3 Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 1/6] dm: add cond_resched() to dm_wq_work() Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 2/6] dm: add cond_resched() to dm_wq_requeue_work() Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 3/6] dm thin: add cond_resched() to various workqueue loops Mike Snitzer
2023-02-17 20:07 ` [dm-devel] [PATCH 4/6] dm cache: " Mike Snitzer
2023-02-17 20:07 ` Mike Snitzer [this message]
2023-02-17 20:07 ` [dm-devel] [PATCH 6/6] dm ioctl: remove unnecessary check when using dm_get_mdptr() Mike Snitzer

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=20230217200737.12481-6-snitzer@kernel.org \
    --to=snitzer@kernel.org \
    --cc=dm-devel@redhat.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.