pvmove --abort 之后无法移动范围

pvmove --abort 之后无法移动范围

我想将范围从一个磁盘移动到另一个磁盘,两个磁盘具有相同的大小:

# pvmove /dev/sdd1 /dev/sdc1

不幸的是,pvmove 在 99.99% 处挂了几个小时,我决定发出一个pvmove --abort。移动已停止,LV 仍可运行,但是无法再重新运行pvmove

# pvmove /dev/sdd1 /dev/sdc1
  Insufficient free space: 727303 extents needed, but only 0 available
  Unable to allocate mirror extents for kujira/pvmove0.
  Failed to convert pvmove LV to mirrored.

但是,目标设备正好有 727303 个可用区段。我甚至可以在 PV 上创建新的 LV,但pvmove不喜欢移动区段。问题是,我尝试移动的 LV 已调整大小一次,并被分成两个段:

# lvs --all -o lv_name,devices
  LV             Devices
  srv            srv_rimage_0(0),srv_rimage_1(0),srv_rimage_2(0)
  [srv_rimage_0] /dev/sda1(0)
  [srv_rimage_0] /dev/sda1(703489)
  [srv_rimage_1] /dev/sdc1(0)
  [srv_rimage_1] /dev/sdd1(703489)
  [srv_rimage_2] /dev/sdb1(0)
  [srv_rimage_2] /dev/sdb1(703489)
  [srv_rmeta_0]  /dev/sda1(703488)
  [srv_rmeta_1]  /dev/sdd1(703488)
  [srv_rmeta_2]  /dev/sdb1(703488)

srv_rimage_1现在位于sdc1并且sdd1

# pvdisplay --maps /dev/sdd1 /dev/sdc1
  --- Physical volume ---
  PV Name               /dev/sdd1
  VG Name               kujira
  PV Size               <5,46 TiB / not usable <1,57 MiB
  Allocatable           yes
  PE Size               4,00 MiB
  Total PE              1430791
  Free PE               703488
  Allocated PE          727303
  PV UUID               boRXi6-6fjo-Ga8Y-iVzJ-qdb4-g3Q7-TASCwx

  --- Physical Segments ---
  Physical extent 0 to 703487:
    FREE
  Physical extent 703488 to 703488:
    Logical volume      /dev/kujira/srv_rmeta_1
    Logical extents     0 to 0
  Physical extent 703489 to 1430790:
    Logical volume      /dev/kujira/srv_rimage_1
    Logical extents     703488 to 1430789

  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               kujira
  PV Size               <5,46 TiB / not usable <1,57 MiB
  Allocatable           yes
  PE Size               4,00 MiB
  Total PE              1430791
  Free PE               727303
  Allocated PE          703488
  PV UUID               ZikJzc-Au3G-O327-Rsw5-2AoY-Wwu3-NzBfBf

  --- Physical Segments ---
  Physical extent 0 to 703487:
    Logical volume      /dev/kujira/srv_rimage_1
    Logical extents     0 to 703487
  Physical extent 703488 to 1430790:
    FREE

我还能以某种方式将所有内容从 移动到sdd1sdc1

  LVM version:     2.03.02(2) (2018-12-18)
  Library version: 1.02.155 (2018-12-18)
  Driver version:  4.35.0
  Configuration:   ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --exec-prefix= --bindir=/bin --libdir=/lib/x86_64-linux-gnu --sbindir=/sbin --with-usrlibdir=/usr/lib/x86_64-linux-gnu --with-optimisation=-O2 --with-cache=internal --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --with-default-pid-dir=/run --with-default-run-dir=/run/lvm --with-default-locking-dir=/run/lock/lvm --with-thin=internal --with-thin-check=/usr/sbin/thin_check --with-thin-dump=/usr/sbin/thin_dump --with-thin-repair=/usr/sbin/thin_repair --enable-applib --enable-blkid_wiping --enable-cmdlib --enable-dmeventd --enable-dbus-service --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-readline --enable-udev_rules --enable-udev_sync

答案1

问题在于 LVM 的分配策略。我发现这篇博文解释了这个问题:https://tim.mattison.org/db01b8858c1748a7aed1649d57aefaa3

查看 pvmove 的手册页:

 --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit
              Determines the allocation policy when a command needs to allocate Physical Extents (PEs) from the VG. Each VG and LV has an allocation policy which can be changed with vgchange/lvchange, or overriden on the command line.  normal applies common sense rules
              such as not placing parallel stripes on the same PV.  inherit applies the VG policy to an LV.  contiguous requires new PEs be placed adjacent to existing PEs.  cling places new PEs on the same PV as existing PEs in the same stripe of the LV.  If there are
              sufficient PEs for an allocation, but normal does not use them, anywhere will use them even if it reduces performance, e.g. by placing two stripes on the same PV.  Optional positional PV args on the command line can also be used to limit which PVs the command
              will use for allocation.  See lvm(8) for more information about allocation.

我最好的猜测是,问题出在 PV 上的分割 LV,这里是其中一个未移动的磁盘:

--- Physical Segments ---
  Physical extent 0 to 703487:
    Logical volume      /dev/kujira/srv_rimage_2
    Logical extents     0 to 703487
  Physical extent 703488 to 703488:
    Logical volume      /dev/kujira/srv_rmeta_2
    Logical extents     0 to 0
  Physical extent 703489 to 1430790:
    Logical volume      /dev/kujira/srv_rimage_2
    Logical extents     703488 to 1430789

第二个扩展区来自 lvresize 进程。看起来,如果第一次请求,pvmove 将正确移动所有三个,但当其中一个rimage已经在另一个 PV 上时,它会拒绝移动它们。

正如博客文章中所写,pvmove --alloc anywhere [...]有效。

man 8 lvm,使用时应该看到分配调试代码-vvvv

相关内容