On 2015-09-10 09:18, Piotr Pawłow wrote:
OK, what I'm about to say may be absolutely totally wrong, you have been warned. If I understand the code correctly, device remove is internally equivalent to shrinking the device to 0 size, and then running a balance, then deleting the device from the FS metadata. Based on this, I 'think' than you may be able to use btrfs balance cancel on the FS to stop the device remove, and then optionally do a resize to revert the remove. However, even it this does work, it probably isn't a particularly good idea. I would love to see some way in the tools to pause/cancel this just like a scrub or balance however.Hello,Is there some way to cancel a device remove operation? I have discovered that if I reboot that will cancel it, but that's not always possible. What I'm after is something the same as cancelling scrub. I keep running into situations where I want to pause a remove operation for speed reasons.Since removing a device involves shrinking it to 0 size first (http://lxr.free-electrons.com/source/fs/btrfs/volumes.c#L1743), I guess you could just run "btrfs filesystem resize" in a loop as a workaround, shrinking it incrementally, and then remove at the end.
It is worth noting that you should be able to limit the disk bandwidth/set the I/O priority of the operation by using either cgroups/ionice respectively on the userspace command (unlike a replace operation, a device removal is synchronous, and should inherit the I/O scheduler parameters from the command that invoked it).
smime.p7s
Description: S/MIME Cryptographic Signature