diff mbox series

[Q] dm: Can singleton rq-based target refer to a device?

Message ID d350c91e-8b67-d1db-6a59-94ee14f0b51c@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series [Q] dm: Can singleton rq-based target refer to a device? | expand

Commit Message

Kirill Tkhai Aug. 19, 2021, 12:26 p.m. UTC
Hi, Mike, Alasdair, all,

I have out-of-tree rq-based driver. It uses dm_get_device() to acquire underlining device.
My goal is to register it as just DM_TARGET_SINGLETON without DM_TARGET_IMMUTABLE flag,
since I need a possibility to reload it with another target.

There is a check in dm_table_determine_type(), which prevents that. It's not obvious,
what the reasons of this limitation are. Could you please explain, why this is required?
Can we make the check weaker like in the patch below?

Thanks,
Kirill

---

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

Patch

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 0543cdf89e92..81fd45142e42 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -936,30 +936,27 @@  static int dm_table_determine_type(struct dm_table *t)
 
 	if (list_empty(devices)) {
 		int srcu_idx;
 		struct dm_table *live_table = dm_get_live_table(t->md, &srcu_idx);
 
 		/* inherit live table's type */
 		if (live_table)
 			t->type = live_table->type;
 		dm_put_live_table(t->md, srcu_idx);
 		return 0;
 	}
 
-	tgt = dm_table_get_immutable_target(t);
-	if (!tgt) {
-		DMERR("table load rejected: immutable target is required");
-		return -EINVAL;
-	} else if (tgt->max_io_len) {
-		DMERR("table load rejected: immutable target that splits IO is not supported");
+	tgt = &t->targets[0];
+	if (tgt->max_io_len) {
+		DMERR("table load rejected: singleton target that splits IO is not supported");
 		return -EINVAL;
 	}
 
 	/* Non-request-stackable devices can't be used for request-based dm */
 	if (!tgt->type->iterate_devices ||
 	    !tgt->type->iterate_devices(tgt, device_is_rq_stackable, NULL)) {
 		DMERR("table load rejected: including non-request-stackable devices");
 		return -EINVAL;
 	}
 
 	return 0;
 }