【问题标题】:Can't reclaim lvm "thin pool" space无法回收 lvm \"thin pool\" 空间
【发布时间】:2022-11-24 09:14:33
【问题描述】:

pool usage相对于lvm volume是非常大的,但是好像并没有实际使用。

以前,元数据区域已满,元数据被扩展。从那时起,我遇到了“lvm transaction id mismatch”问题,我通过 vgcfgbackup -> change transaction id -> vgcfgrestore 解决了这个问题。

vgcfgrestore后出现unreclaimed lvm thin pool space问题。删除快照,fstrim for mounted lvm volumes 也没有解决。

解决这个问题的任何想法?

# lvs -a vg0 -o +discards
LV                 VG      Attr       LSize   Pool       Origin    Data%  Meta%  Move Log Cpy%Sync Convert Discards
  20221101.120002    vg0 Vwi-aotz-k  15.00t tpool0 tvol0 29.13                                               passdown
  20221101.180001    vg0 Vwi-aotz-k  15.00t tpool0 tvol0 29.13                                               passdown
  20221102.000001    vg0 Vwi-aotz-k  15.00t tpool0 tvol0 29.13                                               passdown
  20221102.060001    vg0 Vwi-aotz-k  15.00t tpool0 tvol0 29.13                                               passdown
  20221102.120001    vg0 Vwi-aotz-k  15.00t tpool0 tvol0 29.13                                               passdown
  tpool0             vg0 twi-aotz--  16.00t                          90.86  0.59                             passdown
  [tpool0_tdata]     vg0 Twi-ao----  16.00t                                                                      
  [tpool0_tmeta]     vg0 ewi-ao---- <15.01g                                                                      
  [tpool0_tmeta]     vg0 ewi-ao---- <15.01g                                                                      
  tvol0              vg0 Vwi-aotz--  15.00t tpool0                   29.13                                   passdown
  [lvol0_pmspare]    vg0 ewi------- <15.01g                                                                      
  [lvol0_pmspare]    vg0 ewi------- <15.01g                                                                      
  [lvol0_pmspare]    vg0 ewi------- <15.01g 

# dmsetup ls | grep vg0 | sort -k2 -V
vg0-tpool0_tmeta    (253:4)
vg0-tpool0_tdata    (253:5)
vg0-tpool0-tpool    (253:6)
vg0-tpool0          (253:7)
vg0-tvol0           (253:8)
vg0-20221102.000001 (253:16)
vg0-20221102.060001 (253:17)
vg0-20221102.120001 (253:18)
vg0-20221101.120002 (253:19)
vg0-20221101.180001 (253:20)

# grep . /sys/block/dm-{4..8}/queue/discard_max_bytes 
/sys/block/dm-4/queue/discard_max_bytes:0
/sys/block/dm-5/queue/discard_max_bytes:0
/sys/block/dm-6/queue/discard_max_bytes:0
/sys/block/dm-7/queue/discard_max_bytes:0
/sys/block/dm-8/queue/discard_max_bytes:17179869184

【问题讨论】:

    标签: lvm


    【解决方案1】:

    在我的 linux 机器上,这个问题已经解决了。希望这对某人有帮助。

    !!警告!!

    在以下情况下,这些命令可以覆盖 LVM 和 dm-device 中的重要信息。情况可能会变得更糟,也可能无法解决。在应用该方案之前,请充分考虑风险,并在另一台设备(如虚拟机)上进行充分测试。 还要考虑到您的情况可能与我的不同。 我不承担任何责任。


    [瘦转储]

    $ dmsetup message vg0-tpool0-tpool 0 reserve_metadata_snap
    $ thin_dump -m /dev/mapper/vg0-tpool0_tmeta > meta.backup.xml ; grep transaction meta.backup.xml
    <superblock uuid="" time="86" transaction="169" flags="0" version="2" data_block_size="16384" nr_data_blocks="0">
      <device dev_id="1" mapped_blocks="574203" transaction="0" creation_time="0" snap_time="86">
      <device dev_id="56" mapped_blocks="1865793" transaction="108" creation_time="55" snap_time="55">
      <device dev_id="77" mapped_blocks="572719" transaction="154" creation_time="80" snap_time="80">
      <device dev_id="80" mapped_blocks="573481" transaction="162" creation_time="83" snap_time="83">
      <device dev_id="81" mapped_blocks="573838" transaction="164" creation_time="84" snap_time="84">
      <device dev_id="82" mapped_blocks="573845" transaction="166" creation_time="85" snap_time="85">
      <device dev_id="83" mapped_blocks="574074" transaction="168" creation_time="86" snap_time="86">
    $ dmsetup message vg0-tpool0-tpool 0 release_metadata_snap
    

    [vg 配置]:未找到 transaction_id 108

    $ vgcfgbackup vg0 -f vg0.backup.cfg ; grep transaction vg0.backup.cfg
                    transaction_id = 169
                    transaction_id = 0
                    transaction_id = 154
                    transaction_id = 162
                    transaction_id = 164
                    transaction_id = 166
                    transaction_id = 168
    

    [修理]

    1. 在 /etc/lvm/archive 中找到包含“事务 ID 108”的 vgcfg 备份。
      $ grep "transaction.*108" /etc/lvm/archive/* | cut -d: -f1
      $ vi ${vgcfg_filename}
        ### contents of vgcfg with transaction_id = 108 ###
        #### Copy this block and paste it to "vg0.backup.cfg" created in the previous process.
              20221101.000005 {
              ...
              transaction_id = 108
              ...
              }
              }
      
      1. 修改vg0.backup.cfg
      $ vi vg0.backup.cfg
      vg0 {    
              ...
              tvol0 {
              ...
          ### ADD "transaction_id = 108" block
              20221101.000005 {
              ...
                      transaction_id = 108
              ...
              }
          ###
              ...
      }
      
      1. 从修改后的 vg0.backup.cfg 恢复 vg
      $ yes | vgcfgrestore vg0 -f vg0.221115.cfg --force
      ...
      Volume group vg0 has active volume: 20221101.000005.
      ...
      
      
      $ lvremove /dev/vg0/20221101.000005 ## transaction_id 108
        Logical volume "20221101.000005" successfully removed
      
      $ lvs -a vg0
        LV                 VG      Attr       LSize   Pool       Origin    Data%  Meta%  Move Log Cpy%Sync Convert
        ...
        tpool0             vg0     twi-aotz--  16.00t                      27.82  0.29                            
        ...
      

    【讨论】:

      猜你喜欢
      • 2021-09-17
      • 2018-09-06
      • 2013-01-22
      • 2011-05-02
      • 2013-01-14
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多