Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: still a problem with gpt(8) reading from LVM volumes? (was: problems with GPT (and maybe dkctl wedges) on LVM volumes)



woods%planix.ca@localhost ("Greg A. Woods") writes:

>At Fri, 12 Mar 2021 14:02:06 -0800, I wrote:
>Subject: problems with GPT (and maybe dkctl wedges) on LVM volumes
>>
>> # gpt -vvv show -a /dev/mapper/rvg0-nbtest.0
>> /dev/mapper/rvg0-nbtest.0: mediasize=41943040; sectorsize=512; blocks=81920
>> /dev/mapper/rvg0-nbtest.0: PMBR at sector 0
>> /dev/mapper/rvg0-nbtest.0: Pri GPT at sector 1
>> /dev/mapper/rvg0-nbtest.0: GPT partition: type=ffs, start=64, size=41942943
>> gpt: /dev/mapper/rvg0-nbtest.0: map entry doesn't fit media: new start + new size < start + size
>> (22 + 13fde < 40 + 27fff9f)

>I'm still not quite sure why gpt(8) can't show me the full partition
>table when reading from a raw LVM volume (dm) device as above in exactly
>the same way it does when reading from the raw (xbd emulated) disk in
>the domU.


gpt sees that the medium has only 41MByte and the partition exceeds that
and bails out.

That's a bug in the dm driver:

                dm_table_disksize(&dmv->table_head, &numsec, NULL);
                *valp = numsec;

It reports the number of blocks (sectors) and should report the
number of bytes.

An untested patch would be:

Index: device-mapper.c
===================================================================
RCS file: /cvsroot/src/sys/dev/dm/device-mapper.c,v
retrieving revision 1.61
diff -p -u -r1.61 device-mapper.c
--- device-mapper.c	8 Jul 2020 15:07:13 -0000	1.61
+++ device-mapper.c	19 Mar 2021 06:00:03 -0000
@@ -515,14 +515,15 @@ disk_ioctl_switch(dev_t dev, unsigned lo
 	{
 		off_t *valp = data;
 		uint64_t numsec;
+		unsigned secsize;
 
 		if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
 			return ENODEV;
 
 		aprint_debug("DIOCGMEDIASIZE ioctl called\n");
 
-		dm_table_disksize(&dmv->table_head, &numsec, NULL);
-		*valp = numsec;
+		dm_table_disksize(&dmv->table_head, &numsec, &secsize);
+		*valp = numsec * secsize;
 
 		dm_dev_unbusy(dmv);
 		break;


-- 
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."


Home | Main Index | Thread Index | Old Index