Re: [PATCH] USB: g_mass_storage: Hide caching mode page to improve write speed for Windows

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

 



On Fri, 21 Sep 2012, Leo Song wrote:

> If connect an UMS device (for example, an Android phone) to Linux PC and
> Windows PC, then copy a big file (~500MB) to the device, you will find that
> Linux PC's write speed is much faster than Windows PC. This issue can be fixed
> by hiding the "caching mode page" on UMS device.
> 
> Previously in f_mass_storage.c: do_mode_sense(), caching mode page was the
> only mode page, and it was configured as:
> 	Write cache enabled (WCE=1)
> 	Read cache not disabled
> 	No cache retention priorities
> 
> The "Write cache enable"(WCE) bit has different influence for Linux PC and
> Windows PC.
> 
> For Linux PC, whether WCE is 0 or 1, the write speed from Linux PC to UMS
> device has no difference. Linux PC just ignores this flag.

That isn't true at all.  The flag doesn't affect write speed but it 
does affect other things.

> For Windows PC, if
> 	1. the UMS devices has a valid "caching mode page"
> 	2. the WCE bit in "caching mode page" is set to 1
> 	3. the "write-cache buffer flushing" on Windows PC is not turned off
> 
> With these three conditions together, Windows PC will send SCSI WRITE COMMAND
> with FUA=1 (FUA, force unit access), and FUA=1 will cause UMS device to wait
> until the blocks have been written onto the medium, which will drag down write
> speed a lot. Unluckily, this is Windows PC's default behavior.
> 
> On Windows, the FUA=1 flag can be changed by turning off "write-cache buffer
> flushing" under UMS device's properties, but if we do so, Windows will pop up
> error message as following:
> 
> 	Windows could not change the write-caching setting for the device.
> 	Your device might not support this feature or changing the setting.
> 								[ OK ]
> 
> Windows need to change UMS device's caching mode page, but this page is hard
> coded and can't be changed, so there will be error pop up.

Right; the mass-storage gadget doesn't support the MODE SELECT command.  
Even if it did, we really don't want the gadget to bypass the page 
cache.

> To fix this issue, we can just hide the "caching mode page". With this patch,
> there will be no influence for Linux PC, because Linux PC does not handle UMS
> device's caching mode page; for Windows PC, if it does see the "caching mode
> page", it will not send SCSI WRITE COMMAND with FUA=1, and write speed will
> become as fast as Linux PC.

Your assumptions about Linux are wrong.  I don't think hiding this page 
is a good idea.

Can't you get the result you want by loading the driver with the nofua 
parameter, as Michal suggested?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux