> -----Original Message----- > From: linux-btrfs-owner@xxxxxxxxxxxxxxx <linux-btrfs- > owner@xxxxxxxxxxxxxxx> On Behalf Of Zygo Blaxell > Sent: Saturday, 2 May 2020 1:35 PM > To: Phil Karn <karn@xxxxxxxx> > Cc: Jean-Denis Girard <jd.girard@xxxxxxxxx>; linux-btrfs@xxxxxxxxxxxxxxx > Subject: Re: Extremely slow device removals > > On Fri, May 01, 2020 at 01:05:20AM -0700, Phil Karn wrote: > > On 4/30/20 11:13, Jean-Denis Girard wrote: > > > > > > Hi Phil, > > > > > > I did something similar one month ago. It took less than 4 hours for > > > 1.71 TiB of data: > > > > > > [xxx@taina ~]$ sudo btrfs replace status /home/SysNux Started on > > > 21.Mar 11:13:20, finished on 21.Mar 15:06:33, 0 write errs, 0 > > > uncorr. read errs > > > > I just realized you did a *replace* rather than a *remove*. When I did > > a replace on another drive, it also went much faster. It must copy the > > data from the old drive to the new one in larger and/or more > > contiguous chunks. It's only the remove operation that's painfully slow. > > "Replace" is a modified form of scrub which assumes that you want to > reconstruct an entire drive instead of verifying an existing one. > It reads and writes all the blocks roughly in physical disk order, and doesn't > need to update any metadata since it's not changing any of the data as it > passes through. > > "Delete" is resize to 0 followed by remove the empty device. Resize requires > relocating all data onto other disks--or other locations on the same disk--one > extent at a time, and updating all of the reference pointers in the filesystem. > > The difference in speed can be several orders of magnitude. Delete seems to work like a balance. I've had a totally unbalanced raid 1 array and after removing a single almost full drive all the remaining drives are magically 50% full, down from 90% and up from 10%. It's a bit stressful when there is a missing disk as you can only delete a missing disk, not replace it. It would be nice if BTRFS had some more smarts so it knows when to "balance" data, and when to simply "move/copy" a single copy of data. Paul.
