diff mbox

Emulate BLKRRPART on device-mapper

Message ID 200907081414.50698.knikanth@suse.de (mailing list archive)
State Changes Requested, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Nikanth Karthikesan July 8, 2009, 8:44 a.m. UTC
From: Hannes Reinecke <hare@suse.de>
Subject: Emulate BLKRRPART on device-mapper

Partitions on device-mapper devices are managed by kpartx (if at
all). So if we were just to send out a 'change' event if someone
called BLKRRPART on these devices, kpartx will be triggered via udev
and can manage the partitions accordingly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---


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

Comments

Alasdair G Kergon July 20, 2009, 6:23 p.m. UTC | #1
On Wed, Jul 08, 2009 at 02:14:50PM +0530, Nikanth Karthikesan wrote:
> From: Hannes Reinecke <hare@suse.de>
> Subject: Emulate BLKRRPART on device-mapper
> 
> Partitions on device-mapper devices are managed by kpartx (if at
> all). So if we were just to send out a 'change' event if someone
> called BLKRRPART on these devices, kpartx will be triggered via udev
> and can manage the partitions accordingly.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
 
Please could I have a 'Tested-by' for this one?

I agree with the idea, but I need some evidence that this specific patch
works correctly.  (The block layer is supposed to handle that class
of ioctls itself and I didn't think dm saw them.)

Alasdair

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

Patch

Index: linux-2.6-dm/drivers/md/dm.c
===================================================================
--- linux-2.6-dm.orig/drivers/md/dm.c
+++ linux-2.6-dm/drivers/md/dm.c
@@ -394,19 +394,25 @@  static int dm_blk_ioctl(struct block_dev
 	if (!map || !dm_table_get_size(map))
 		goto out;
 
-	/* We only support devices that have a single target */
-	if (dm_table_get_num_targets(map) != 1)
-		goto out;
-
-	tgt = dm_table_get_target(map, 0);
-
 	if (dm_suspended(md)) {
 		r = -EAGAIN;
 		goto out;
 	}
 
-	if (tgt->type->ioctl)
-		r = tgt->type->ioctl(tgt, cmd, arg);
+	if (cmd == BLKRRPART) {
+		/* Emulate Re-read partitions table */
+		kobject_uevent(&disk_to_dev(md->disk)->kobj, KOBJ_CHANGE);
+		r = 0;
+	} else {
+		/* We only support devices that have a single target */
+		if (dm_table_get_num_targets(map) != 1)
+			goto out;
+
+		tgt = dm_table_get_target(map, 0);
+
+		if (tgt->type->ioctl)
+			r = tgt->type->ioctl(tgt, cmd, arg);
+	}
 
 out:
 	dm_table_put(map);