[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#722898: partman-crypto: blockdev-wipe is too slow



Package: partman-crypto
Severity: normal
Tags: d-i, patch

Hello,

I'm currently in the process of installing wheezy and after 15 hours of
blockdev-wipe, the progress indicator is at 11%.  This means that the expected
time for the wipe to complete would be 5.5 days when extrapolating linearly
(which is optimistic due to decreasing disk performance towards higher block
numbers).  The device that is being wiped is a md raid 1 of two 3TB disks.
This means that I'm averaging 6 MB/s on two brand new disks and an Athlon II
X4 640 processor.  This is at least a factor 10 too slow.

As far as I can see, several things conspire to achieve this extraordinary
slowdown:
* blockdev-wipe is writing with a block size of 64k
* blockdev-wipe opens the device with O_SYNC (cf. bug #381135)
* md is running a resync in the background

Changing the block size to 4M increases throughput to 48 MB/s and disabling md
resync brings throughput up to 60 MB/s.

I still have to benchmark different block sizes, but before I get to that, I
suggest to disable md resync.  More specifically, I suggest to set to zero
/proc/sys/dev/raid/speed_limit_min, which controls the minimum resync rate.
That way, resync will yield unconditionally to any other I/O.

I'm attaching a patch (untested!) to set speed_limit_min to zero only for the
duration of wiping, however I wonder whether it might be more desireable to do
this in a different place and to keep speed_limit_min at zero during all of
the installation.  That would certainly speed up package installation on md
raid installs.

What do you think?

Cheers,
Thiemo
diff --git a/lib/crypto-base.sh b/lib/crypto-base.sh
index ba90169..c95fbab 100644
--- a/lib/crypto-base.sh
+++ b/lib/crypto-base.sh
@@ -281,10 +281,13 @@ setup_cryptdev () {
 }
 
 crypto_do_wipe () {
-	local template dev fifo pid x
+	local template dev fifo pid x speedlimit speedlimitfile
 	template=$1
 	dev=$2
 	fifo=/var/run/wipe_progress
+        speedlimitfile=/proc/sys/dev/raid/speed_limit_min
+        speedlimit=$(cat $speedlimitfile)
+        echo 0 > $speedlimitfile
 
 	mknod $fifo p
 	/bin/blockdev-wipe -s 65536 $dev > $fifo &
@@ -309,6 +312,7 @@ crypto_do_wipe () {
 	ret=$?
 
 	[ $cancelled -eq 1 ] && ret=0
+        echo $speedlimit > $speedlimitfile
 	return $ret
 }
 

Reply to: