2

I want to run thin_dump, and thin_check. They say they cannot be ran on live metadata. That's fine by me. The problem is I don't know how to make the metadata not live, while still being able to give thin_dump and thin_check an argument on what to be ran on.

I see there's an alternative way to use a metadata snapshot, for live metadata, but I don't want to do it that way. I don't want to change anything on the drive at this time.

# lvs -a
disk1thin           lvm    twi-aot---  <4.53t                     92.10  83.47
[disk1thin_tdata]   lvm    Twi-ao----  <4.53t
[disk1thin_tmeta]   lvm    ewi-ao---- 640.00m
# # Need to de-activate the metadata - this is the only way I know how, but must not be right
# lvchange -an lvm/disk1thin
# lvs -a
disk1thin           lvm    twi---t---  <4.53t
[disk1thin_tdata]   lvm    Twi-------  <4.53t
[disk1thin_tmeta]   lvm    ewi------- 640.00m
# thin_dump <uhh, what goes here?>
# thin_dump lvm/disk1thin
Couldn't stat path
# thin_dump lvm/disk1thin_tdata
Couldn't stat path
# thin_dump lvm/disk1thin_tmeta
Couldn't stat path
# thin_dump lvm/disk1thin-tpool
Couldn't stat path
# ls -la /dev/mapper
# crw-------  1 root root 10, 236 May 31 00:28 control
# # Not listed
# ls -la /dev/lvm/
ls: cannot access '/dev/lvm/': No such file or directory
# lvchange -ay lvm/disk1thin_tmeta
  Operation not permitted on hidden LV lvm/disk1thin_tmeta
# # Nope, that didn't work...

I also tried after having them active, running dmsetup suspend on them, but that does suspend all reads from them like its manpage says, so although they exist in /dev/lvm, thin_dump and thin_check can't be ran on them.

I also tried, once the thin pool is deactivated:

# thin_dump /dev/sdh3
bad checksum in superblock, wanted 3832019051

And it says bad checksum for any other device that has a thin volume on it. I know all disks haven't gone bad, so I'm pretty sure this isn't a proper option. Although the thin pool is on this device, the device starts with a smaller non-thin lv, so the option isn't really telling it to look in the right place for the thin volume.

user1902689
  • 131
  • 6

2 Answers2

1

@user1902689 the solution is (working on Ubuntu 18.04):

# Reserve the metadata snapshot
dmsetup message /dev/mapper/volg-volg--thinpool-tpool 0 reserve_metadata_snap

# Run the dump (the -m is the crtical part here)
thin_dump --format xml -m  /dev/mapper/volg-volg--thinpool_tmeta

# Release the metadata snapshot
dmsetup message /dev/mapper/volg-volg--thinpool-tpool 0 release_metadata_snap

I believe that the metadata snapshot is in memory, so you don't want to hold this for long.

FYI - volg is my volume group - thinpool is the volume of the thinpool - tpool is hidden.

# lvs -a
  LV                    VG   Attr       LSize  Pool          Origin      Data%  Meta%  Move Log Cpy%Sync Convert
  [lvol0_pmspare]       volg ewi------- 12.00m                                                                  
  thin_volume           volg Vwi-a-tz--  6.00g volg-thinpool             31.96                                  
  thin_volume_snap1     volg Vwi---tz-k  6.00g volg-thinpool thin_volume                                        
  thin_volume_snap2     volg Vwi---tz-k  6.00g volg-thinpool thin_volume                                        
  thin_volume_snap3     volg Vwi---tz-k  6.00g volg-thinpool thin_volume                                        
  volg-thinpool         volg twi-aotz--  9.80g                           20.51  9.41                            
  [volg-thinpool_tdata] volg Twi-ao----  9.80g                                                                  
  [volg-thinpool_tmeta] volg ewi-ao---- 12.00m                                                            
David B
  • 41
  • 2
0

I'm not going to mark this as the answer, because I think it's awful. And, I can't recommend it. It worked for me.

But, there must be a better way. Hope someone knows it.

Make sure ABSOLUTELY NOTHING is using the thin pool. You can't be booted on it. If it's your root volume, you have to be running off an ISO. umount any loopback devices you might be using, stop swap files, etc. lvchange -an all lv's in the thin pool to deactivate them. (But, don't deactivate the thin volume itself.)

# dmsetup info -c
Name                Maj Min Stat Open
lvm-disk1thin-tpool 253  10 L--w    1...
lvm-disk1thin_tdata 253   9 L--w    0...
lvm-disk1thin_tmeta 253   8 L--w    0...

Make sure open is 0 for _tdata and _tmeta. I don't know why open is 1 for -tpool. I couldn't figure out how to make that 0.

# dmsetup remove lvm-disk1thin-tpool
device-mapper: remove ioctl on lvm-disk1thin-tpool  failed: Device or resource busy

So, for safety sake, figure out how to make that 0. Or, if you're adventurous:

# dmsetup remove -f lvm-disk1thin-tpool
device-mapper: remove ioctl on lvm-disk1thin-tpool  failed: Device or resource busy
Command failed

But, did it?

# lvs -a
  disk1thin                       lvm    twi-XXt-X-  <4.53t
  [disk1thin_tdata]               lvm    Twi-------  <4.53t
  [disk1thin_tmeta]               lvm    ewi-a----- 640.00m

Those X's are for State unknown, Device Openness unknown, Volume Health unknown.

# thin_dump lvm-disk1thin_tmeta
(YAY, output!)

Then, to get the thin pool active again:

# lvchange -ay lvm/disk1thin

(You'll need to re-activate all the lv's you deactivated, re-mount and start anything you stopped, etc.)

user1902689
  • 131
  • 6