I have a 160 GB USB 2.0 drive which I plug into my two identical
laptops for purposes of doing file system backups (runs overnight).
The laptops unfortunately only have USB 1.1 interfaces, but it has
been fast enough for doing the backups when running linux-2.4.
I now have one laptop running linux-2.6.0-test9, and have found that
the write speed is more than 5 times slower than it is under 2.4
kernels (linux-2.4.21-rc1 in particular, but earlier 2.4 kernels as
well). This is no longer fast enough. My full backup (using dump)
which could complete in about 5 hours under linux-2.4 now would take
more than 25 hours under linux-2.6, so I now have to reboot into
linux-2.4 to do an overnight full backup.
But reads are a little bit faster under linux-2.6. Reads from the
USB drive (of a big file that has not been read since rebooting) are
about 1.33 times faster under linux-2.6.0-test9 than under
linux-2.4.
uhci_hcd and usb_storage are the relevant modules in linux-2.6.0-test9.
usb-uhci and usb-storage are the relevant modules in linux-2.4.21-rc1.
I'm seeing 147,000 bytes/sec write speed under linux-2.6.0-test9.
I'm seeing 774,000 bytes/sec write speed under linux-2.4.21-rc1.
The write speeds which I measured are to a new file in an ext3 file
system (which spans the entire 160 GB usb drive), and I included the
time to do a sync (since it takes almost no time to write a file that
fits in memory), e.g.:
$ mkdir /usb_drive/tmp
$ sync
$ time dd if=/dev/zero bs=4k count=8192 of=/usb_drive/tmp/tmp && time sync
8192+0 records in
8192+0 records out
33554432 bytes transferred in 0.730587 seconds (45928043 bytes/sec)
real 0m1.155s
user 0m0.013s
sys 0m0.580s
real 3m46.462s
user 0m0.001s
sys 0m0.004s
$ dc
4096 8192 * p
33554432
1.155 3 60 * 46.462 + + p
227.617
/ p
147416
(that is 147,000 bytes/sec)
The relevant output from lspci -v is:
00:05.0 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ISA (rev 02)
Flags: bus master, medium devsel, latency 0
00:05.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01) (prog-if 80 [Master])
Flags: bus master, medium devsel, latency 64
I/O ports at 1000 [size=16]
00:05.2 USB Controller: Intel Corp. 82371AB/EB/MB PIIX4 USB (rev 01) (prog-if 00 [UHCI])
Flags: bus master, medium devsel, latency 64, IRQ 11
I/O ports at ffe0 [size=32]
00:05.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02)
Flags: medium devsel, IRQ 9
Has anyone else noticed that their writes to usb_storage over USB 1.1
are much slower since upgrading to a linux-2.6.0-test* kernel?
Anyone have any ideas how I might be able to recover the (somewhat)
faster write speed while running a linux-2.6.0-test* kernel?
-Tim Shepard
Someone sent me a private e-mail message suggesting that I apply this
patch that Matthew Dharm posted to the linux-usb-devel list yesterday
and see if that would restore the write throughput to linux-2.4
levels.
The patch limits the size of the transfers, and can be found at
http://sourceforge.net/mailarchive/message.php?msg_id=6429200
or right here:
--- drivers/usb/storage/scsiglue.c.orig 2003-08-09 00:36:46.000000000 -0400
+++ drivers/usb/storage/scsiglue.c 2003-11-03 16:49:42.000000000 -0500
@@ -315,6 +315,9 @@
/* lots of sg segments can be handled */
.sg_tablesize = SG_ALL,
+ /* limit the total size of a transfer to 120 KB */
+ .max_sectors = 240,
+
/* merge commands... this seems to help performance, but
* periodically someone should test to see which setting is more
* optimal.
I am happy to report that this patch has restored the write throughput
to the same speed that it was on linux-2.4.
Problem solved. Thanks much.
-Tim Shepard