Why is converting from RAID1 to single in Btrfs an I/O-intensive operation?
Hallöchen!
I want to replace a device in a RAID1 and converted it temporarily to “single”:
btrfs balance start -f -mconvert=single,soft -dconvert=single,soft /
This takes very long. I don’t see why, and wonder whether this is the right approach in the first place. After all, no (significant) amount of data should be needed to be transferred in the process, should it?
A side question: Is -sconvert also necessary?
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 5 lines · Torsten Bronger
Hallöchen!
I want to replace a device in a RAID1 and converted it temporarily to “single”:
Quoted 7 lines
btrfs balance start -f -mconvert=single,soft -dconvert=single,soft /
This takes very long. I don’t see why, and wonder whether this is the right approach in the first place. After all, no (significant) amount of data should be needed to be transferred in the process, should it?
Converting between RAID profiles copies data from chunks with the old profile to the chunks with the new profile. Old chunk is not modified in place, they are removed after all data is moved to the new chunk.
Quoted 5 lines
A side question: Is -sconvert also necessary?
Regards,
Torsten.
Hallöchen!
Quoted 10 lines · Andrei Borzenkov
Quoted 3 lines · Torsten Bronger
I want to replace a device in a RAID1 and converted it temporarily to “single”: [...] This takes very long. I don’t see why, [...]
Converting between RAID profiles copies data from chunks with the old profile to the chunks with the new profile. Old chunk is not modified in place, they are removed after all data is moved to the new chunk.
Thank you! I see the reason now (while it is unfortunate nevertheless that this means that the bulk data has to be moved as well).
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 4 lines · Torsten Bronger
Hallöchen!
I want to replace a device in a RAID1 and converted it temporarily to “single”:
I suggest you to evaluate
- remove a disk when the FS is offline
- mount the FS in 'degraded' mode
- attach a new disk
This would minimize the cost of the reshaping. But wait for some other feedback because I am not sure how robust is working in a 'degraded' mode for "I/O-intensive operation".
BR
Quoted 12 lines
btrfs balance start -f -mconvert=single,soft -dconvert=single,soft /
This takes very long. I don’t see why, and wonder whether this is the right approach in the first place. After all, no (significant) amount of data should be needed to be transferred in the process, should it?
A side question: Is -sconvert also necessary?
Regards,
Torsten.
Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5
Hallöchen!
Quoted 10 lines · Goffredo Baroncelli
Quoted 2 lines · Torsten Bronger
I want to replace a device in a RAID1 and converted it temporarily to “single”:
I suggest you to evaluate
- remove a disk when the FS is offline
- mount the FS in 'degraded' mode
- attach a new disk
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
Mileage may vary in a more professional environment.
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 16 lines · Torsten Bronger
Hallöchen!
Quoted 10 lines · Goffredo Baroncelli
Quoted 2 lines · Torsten Bronger
I want to replace a device in a RAID1 and converted it temporarily to “single”:
I suggest you to evaluate
- remove a disk when the FS is offline
- mount the FS in 'degraded' mode
- attach a new disk
Quoted 5 lines
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
I just want to make clear, this bug was fixed long ago. You would need to update your bootloader conf to use degraded at boot time in this case, but in theory, it should work identical to have a raid1 degraded as converting it all back to single.
I agree though, it would be a great feature addition to reduce IO load to replicating single chunks to RAID1, or converting them back to single but not rewriting them out. On SSDs it would reduce wear, and on HDDs would reduce seeking/head thrashing.
Quoted 9 lines
Mileage may vary in a more professional environment.
Regards,
Torsten.--
Torsten Bronger
Hallöchen!
Quoted 12 lines · [email protected] writes:
Quoted 9 lines · Torsten Bronger
[...]
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
Quoted 4 lines
I just want to make clear, this bug was fixed long ago. You would need to update your bootloader conf to use degraded at boot time in this case, but in theory, it should work identical to have a raid1 degraded as converting it all back to single.
What was fixed? Can you now mount in in degraded mode read-write as often as you wish?
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 17 lines · Torsten Bronger
Hallöchen!
Quoted 12 lines · [email protected] writes:
Quoted 9 lines · Torsten Bronger
[...]
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
Quoted 7 lines
Quoted 4 lines
I just want to make clear, this bug was fixed long ago. You would need to update your bootloader conf to use degraded at boot time in this case, but in theory, it should work identical to have a raid1 degraded as converting it all back to single.
What was fixed? Can you now mount in in degraded mode read-write as often as you wish?
Yes, and has been for some time. Since kernel 4.14 iirc.
Quoted 5 lines
Regards,
Torsten.
--
Torsten Bronger
Quoted 15 lines · Torsten Bronger
Hallöchen!
Quoted 10 lines · Goffredo Baroncelli
Quoted 2 lines · Torsten Bronger
I want to replace a device in a RAID1 and converted it temporarily to “single”:
I suggest you to evaluate
- remove a disk when the FS is offline
- mount the FS in 'degraded' mode
- attach a new disk
Quoted 6 lines
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
Just for curiosity, I know that the BTRFS RAID1 is not the fastest implementation, but how slower is in your "I/O-intensive operation".
In theory the differences should not be so huge
Quoted 5 lines
Mileage may vary in a more professional environment.
Regards,
Torsten.
Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5
Hallöchen!
Quoted 5 lines · Goffredo Baroncelli
[...]
Just for curiosity, I know that the BTRFS RAID1 is not the fastest implementation, but how slower is in your "I/O-intensive operation".
What exactly do you want to compare? Be that as it may, I have no benchmarks. Originally, I was just wondering why RAID1 --> single may take hours, given that all data is on both disks anyway.
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 10 lines
Hallöchen!
Quoted 5 lines · Goffredo Baroncelli
[...]
Just for curiosity, I know that the BTRFS RAID1 is not the fastest implementation, but how slower is in your "I/O-intensive operation".
Quoted 7 lines
What exactly do you want to compare? Be that as it may, I have no benchmarks. Originally, I was just wondering why RAID1 --> single may take hours, given that all data is on both disks anyway.
Regards,
Torsten.
So what I think you would like to have answered is : Since RAID1 has two duplicate chunks (A1 and A2) why could not BTRFS simply change the chunk type of A1 to single and discard chunk A2.
Personally I don't have the slightest idea why , but I imagine that this perhaps might be possible with the extent tree V2 changes sometime in the future. Meanwhile perhaps someone else would like to explain why...
Hallöchen!
Quoted 5 lines · waxhead
[...]
So what I think you would like to have answered is : Since RAID1 has two duplicate chunks (A1 and A2) why could not BTRFS simply change the chunk type of A1 to single and discard chunk A2.
Exactly.
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Replace the disk offline, mount degraded, use btrfs replace with the devid of the missing disk.
Quoted 14 lines · waxhead
Quoted 14 lines
Hallöchen!
Quoted 5 lines · Goffredo Baroncelli
[...]
Just for curiosity, I know that the BTRFS RAID1 is not the fastest implementation, but how slower is in your "I/O-intensive operation".
What exactly do you want to compare? Be that as it may, I have no benchmarks. Originally, I was just wondering why RAID1 --> single may take hours, given that all data is on both disks anyway.
Quoted 6 lines
Quoted 3 lines
Regards,
Torsten.So what I think you would like to have answered is : Since RAID1 has two duplicate chunks (A1 and A2) why could not BTRFS simply change the chunk type of A1 to single and discard chunk A2.
Quoted 1 line
Personally I don't have the slightest idea why , but I imagine that this
perhaps might be possible with the extent tree V2 changes sometime in the future. Meanwhile perhaps someone else would like to explain why...
I believe this would violate the "CoW" nature of Btrfs. In other words, it would introduce a change in-place, which is not possible with current current way of working.
There probably are ways to make it safe and atomic, but maybe not a high priority from the current devs?
Hallöchen!
Quoted 8 lines · Forza
[...]
I believe this would violate the "CoW" nature of Btrfs. In other words, it would introduce a change in-place, which is not possible with current current way of working.
There probably are ways to make it safe and atomic, but maybe not a high priority from the current devs?
My naive assumption was: There is the bulk data, and there is metadata that also contains the profile of the data. If the profile is changed, only the metadata has to be re-written atomically (in particular, the CoW way).
But apparently, the profile is part of the bulk data chunk itself. This may well be necessary, but I was surprised by that.
Regards,
Torsten.
Signature · 1 line
Torsten Bronger
Quoted 14 lines · Torsten Bronger
Hallöchen!
Quoted 8 lines · Forza
[...]
I believe this would violate the "CoW" nature of Btrfs. In other words, it would introduce a change in-place, which is not possible with current current way of working.
There probably are ways to make it safe and atomic, but maybe not a high priority from the current devs?
Quoted 7 lines
My naive assumption was: There is the bulk data, and there is metadata that also contains the profile of the data. If the profile is changed, only the metadata has to be re-written atomically (in particular, the CoW way).
But apparently, the profile is part of the bulk data chunk itself. This may well be necessary, but I was surprised by that.
If you want to go back to single on a 2 device RAID1, and avoid the wear, especially if you plan to return to RAID1 at a later date, why not just use it degraded? A degraded RAID1 chunk is basically just single anyway. You can convert the metadata to dup to reduce write amp without making the fs itself less resilient. New chunks will become single while degraded anyway. You can convert those back later as well.
When you do want to return using the old disk, use btrfs replace instead. It will simply copy the existing data rather than balance it to replicate it.
Quoted 7 lines
Regards,
Torsten.--
Torsten Bronger
Hallöchen!
Quoted 5 lines · [email protected] writes:
[...]
If you want to go back to single on a 2 device RAID1, and avoid the wear, especially if you plan to return to RAID1 at a later date, why not just use it degraded?
Now that I know that the mount-degraded-rw-only-once thing has long been fixed, I will do that of course.
Bye,
Torsten.
Signature · 1 line
Torsten Bronger
Op 18-02-2023 om 12:38 schreef Torsten Bronger:
Quoted 14 lines
Hallöchen!
Quoted 10 lines · Goffredo Baroncelli
Quoted 2 lines · Torsten Bronger
I want to replace a device in a RAID1 and converted it temporarily to “single”:
I suggest you to evaluate
- remove a disk when the FS is offline
- mount the FS in 'degraded' mode
- attach a new disk
Better (if you have the hardware for it, i.e. sufficient connectors) add the extra disk to the pool. Then remove the old disk from the pool. Then physically remove the (now unused) disk.
Quoted 11 lines
I agree that converting to single is not the fastest way to replace a disk, but the safest AFAICS. It is the boot partition in a simple home server without monitor or keyboard, which makes mounting as degraded difficult. Besides, you can only mount in degraded mode once. If anything goes wrong, I have to rebuild from scratch.
Mileage may vary in a more professional environment.
Regards,
Torsten.