您好我正在使用Linux usb小工具工具来模拟USB闪存驱动器。它的工作正常,但性能非常低。
我使用由dd创建的4Gb文件,并在其上创建了一个ext2或vfat(尝试过两者)分区。比我使用以下命令序列安装它:
# modprobe dummy_hcd is_super_speed=1 # I tried is_high_speed=1, and no parameter too
# modprobe g_mass_storage file=/home/del/img/flash stall=0 # tried w/o stall=0 too
# mount /dev/sdc1 /mnt/tmp
之后我在dmesg中创建/ dev / sdc和/ dev / sdc1设备时没有任何错误:
[1256700.986581] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.022551] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.242481] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.278422] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.422339] gadget: high-speed config #1: Linux File-Backed Storage
[1256934.915697] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256934.951628] gadget: high-speed config #1: Linux File-Backed Storage
[1256935.915155] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256935.951090] gadget: high-speed config #1: Linux File-Backed Storage
[1256936.095018] gadget: high-speed config #1: Linux File-Backed Storage
[1317073.396892] usb-storage 3-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
[1317073.396995] scsi53 : usb-storage 3-1:1.0
[1317074.411883] scsi 53:0:0:0: Direct-Access Linux File-CD Gadget 0302 PQ: 0 ANSI: 2
[1317074.412669] sd 53:0:0:0: Attached scsi generic sg3 type 0
[1317074.431910] sd 53:0:0:0: [sdc] 8388608 512-byte logical blocks: (4.29 GB/4.00 GiB)
[1317074.443816] sd 53:0:0:0: [sdc] Write Protect is off
[1317074.443821] sd 53:0:0:0: [sdc] Mode Sense: 0f 00 00 00
[1317074.455839] sd 53:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1317074.551757] sdc: sdc1
[1317074.683704] sd 53:0:0:0: [sdc] Attached SCSI removable disk
问题是IO性能非常差。编写200Mb文件需要相当长的时间:
$ ls -lh file
-rw-rw-r-- 1 root del 206M Sep 4 09:34 file
$ time sudo cp file /mnt/tmp/
real 11m59.618s
user 0m0.000s
sys 0m0.260s
大约300K /秒。但是,同一系统上的同一文件会在不到一分钟的时间内复制到真正的USB闪存中。
Iotop显示的内容如下:
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
9986 be/4 root 0.00 B/s 262.05 K/s 0.00 % 99.86 % cp file /mnt/tmp/
20651 be/4 root 51.77 K/s 238.95 K/s 0.00 % 93.23 % [file-storage]
可以采取哪些措施来改善g_mass_storage仿真USB驱动器的性能?
PS:我正在使用内核
$ uname -rm
3.2.0-4-686-pae i686
答案 0 :(得分:2)
同样在这里。
在6点的一个晚上后,我找到了解决方案。
modprobe g_mass_storage file=/home/del/img/flash stall=0 buflen=65536
这最多可达5MByte / sec
modprobe g_mass_storage file=/home/del/img/flash stall=0 nofua=1
这最多可达11MByte / sec
" buflen"的组合和" nofua"没有真正的帮助。 关于" nufua"在这里阅读:http://lxr.free-electrons.com/source/drivers/usb/gadget/file_storage.c?v=3.5
Ultrasoft /