> 2023年2月3日 04:48,Eric Wheeler <bcache@xxxxxxxxxxxxxxxxxx> 写道: > > On Fri, 3 Feb 2023, Coly Li wrote: >>> 2023年1月27日 20:44,Andrea Tomassetti <andrea.tomassetti-opensource@xxxxxxxx> 写道: >>> From 83f490ec8e81c840bdaf69e66021d661751975f2 Mon Sep 17 00:00:00 2001 >>> From: Andrea Tomassetti <andrea.tomassetti-opensource@xxxxxxxx> >>> Date: Thu, 8 Sep 2022 09:47:55 +0200 >>> Subject: [PATCH v2] bcache: Add support for live resize of backing devices >>> >>> Signed-off-by: Andrea Tomassetti <andrea.tomassetti-opensource@xxxxxxxx> >>> --- >>> Hi Coly, >>> this is the second version of the patch. As you correctly pointed out, >>> I implemented roll-back functionalities in case of error. >>> I'm testing this funcionality using QEMU/KVM vm via libvirt. >>> Here the steps: >>> 1. make-bcache --writeback -B /dev/vdb -C /dev/vdc >>> 2. mkfs.xfs /dev/bcache0 >>> 3. mount /dev/bcache0 /mnt >>> 3. dd if=/dev/random of=/mnt/random0 bs=1M count=1000 >>> 4. md5sum /mnt/random0 | tee /mnt/random0.md5 >>> 5. [HOST] virsh blockresize <vm-name> --path <disk-path> --size <new-size> >>> 6. xfs_growfs /dev/bcache0 >>> 6. Repeat steps 3 and 4 with a different file name (e.g. random1.md5) >>> 7. umount/reboot/remount and check that the md5 hashes are correct with >>> md5sum -c /mnt/random?.md5 >> >> [snipped] >> >> Hi Andrea, >> >> For the above step 5, could you provide a specific command line for me to reproduce? >> >> I tried to resize the disk by virsh from 400G to 800G, the disk resize >> doesn’t happen online, I have to stop and restart the virtual machine >> and see the resized disk. > > Coly, > > The `virsh blockresize` command only informs the vm that the size has > changed. You will need to resize the disk itself using `lvresize` or > whatever your VM's backing device is. If you're backing device for the > virtual machine is a file, then you could use `truncate -s <size> > /file/path` before issuing `virsh blockresize`. > > Another possibility: are you using virtio-blk as shown in his example, or > a different virtual driver like virtio-scsi? > Yes, it was virtio-scsi drive. > If the VM doesn't detect it you might need to do this if its a > virtio-scsi disk on the inside: > > for i in /sys/class/scsi_host/*/scan; do echo - - - > $i; done > > If you're using virtio-blk (vda) then it should be immediate. I don't > think IDE will work at all, and not sure about nvme. Sure, now I switch to virtio-blk drive and I can see the backing device size extends immediately after blockresize command in virsh. Thanks. Coly Li