dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dm ioctl: increase granularity of type_lock when loading table
@ 2013-08-29  3:21 Mike Snitzer
  2013-08-29  3:21 ` [PATCH 2/3] dm ioctl: cleanup error handling in table_load Mike Snitzer
  2013-08-29  3:21 ` [PATCH 3/3] dm: allow error target to replace immutable target Mike Snitzer
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Snitzer @ 2013-08-29  3:21 UTC (permalink / raw)
  To: dm-devel

Hold the mapped device's type_lock before calling populate_table() since
it is where the table's type is determined based on the specified
targets.  There is no need to allow concurrent table loads to race to
establish the table's targets or type.

This eliminates the need to grab the lock in dm_table_set_type().

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-ioctl.c | 6 ++++--
 drivers/md/dm-table.c | 2 --
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 40e6dce..ec69f23 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1264,9 +1264,12 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
 	if (r)
 		goto out;
 
+	/* Protect md->type and md->queue against concurrent table loads. */
+	dm_lock_md_type(md);
 	r = populate_table(t, param, param_size);
 	if (r) {
 		dm_table_destroy(t);
+		dm_unlock_md_type(md);
 		goto out;
 	}
 
@@ -1276,12 +1279,11 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
 		DMWARN("can't replace immutable target type %s",
 		       immutable_target_type->name);
 		dm_table_destroy(t);
+		dm_unlock_md_type(md);
 		r = -EINVAL;
 		goto out;
 	}
 
-	/* Protect md->type and md->queue against concurrent table loads. */
-	dm_lock_md_type(md);
 	if (dm_get_md_type(md) == DM_TYPE_NONE)
 		/* Initial table load: acquire type of table. */
 		dm_set_md_type(md, dm_table_get_type(t));
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index f309477..8f87835 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -888,9 +888,7 @@ static int dm_table_set_type(struct dm_table *t)
 		 * Determine the type from the live device.
 		 * Default to bio-based if device is new.
 		 */
-		dm_lock_md_type(t->md);
 		live_md_type = dm_get_md_type(t->md);
-		dm_unlock_md_type(t->md);
 		if (live_md_type == DM_TYPE_REQUEST_BASED)
 			request_based = 1;
 		else
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-08-29 19:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29  3:21 [PATCH 1/3] dm ioctl: increase granularity of type_lock when loading table Mike Snitzer
2013-08-29  3:21 ` [PATCH 2/3] dm ioctl: cleanup error handling in table_load Mike Snitzer
2013-08-29  3:21 ` [PATCH 3/3] dm: allow error target to replace immutable target Mike Snitzer
2013-08-29 14:37   ` Mikulas Patocka
2013-08-29 14:44     ` Mike Snitzer
2013-08-29 17:07       ` Mikulas Patocka
2013-08-29 18:04         ` Mike Snitzer
2013-08-29 19:09           ` Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).