>-----Original Message----- >From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-owner@xxxxxxxxxxxxxxx] On >Behalf Of Alan Stern >Sent: 2012年9月22日 2:08 >To: Leo Song >Cc: Michal Nazarewicz; Felipe Balbi; linux-usb@xxxxxxxxxxxxxxx >Subject: RE: [PATCH] USB: g_mass_storage: Hide caching mode page to improve >write speed for Windows > >On Fri, 21 Sep 2012, Leo Song wrote: > >> Actually this patch does not interact with the nofua attribute >> directly. The original code will let Windows PC go into a confused > >What's confused about it? The "confused state" I mean is: 1. end-user can see yellow "!" on Windows PC in the UMS device's properties, which is not perfect; 2. by default the UMS device works under "Better performance" mode on Windows, but "Better performance" mode's write speed is much slower than it should be (compared with USB-TF card adapter), which is a violation of common sense; 3. if end-user tries to switch from "Better performance" to "Quick removal", Windows will cry, which is not friendly to end-user. Previously I wrote a doc to describe this issue, and proposed several ways to solve it, there are also some test data for different mode/solution, you can view the doc at: https://docs.google.com/open?id=0B_axg5vW_1lgRVJTSDJwU0xETVk > >> state, and Windows will always send WRITE COMMAND with FUA=1. If >> manually "echo 1 > ./f_mass_storage/lun/nofua" to let the UMS device >> ignore the FUA bit from host PC, it can improve write speed. >> >> But with original code, if you check the properties of the UMS device >> in Windows Device Manger, there is an unpleasant yellow "!" under the >> "Policies" item, and the "Removal policy" is fixed to "Better >> performance". If you try to change to "Quick removal", Windows will >> cry. This is very different with a normal USB flash disk, and >> unfriendly to end user. > >It is more friendly than slowing down all the accesses by forcing each >write out to permanent storage immediately. > >> This patch's solution is to hide the "caching mode page", if Windows >> does not see this page, it will not be confused, and will not send >> WRITE COMMAND with FUA=1, so that write speed will be fast. >> >> With this patch, the unpleasant yellow "!" will disappear, and >> "Removal policy" will be "Quick removal" by default, and you can >> change to "Better performance" if you want. It will be the same as a >> normal USB flash disk. > >Normal USB flash disks don't have an internal cache. Linux systems do. >It's appropriate for the gadget to be different from a flash disk. > >You should compare the mass-storage gadget to a real USB-based disk >drive (i.e., one with rotating media) instead of to a flash drive. >Many disk drives have an internal cache and they inform Windows about >it. How does Windows react to them? I checked two USB-Hard disks, they look the same as a normal USB-flask disk, Windows can't see their "caching mode page", and I can switch between "Better performance" and "Quick removal" at will. USB-hard disks have cache inside, but they choose not to expose the cache to Windows/Linux PC, they will manage the cache by themselves, which will save a lot of cache syncing/flushing job between host and device. What this patch doing is just make the UMS device looks more like a normal USB hard/flash disk, and it does improve the write speed a lot. Again, you can see the test data in my doc: https://docs.google.com/open?id=0B_axg5vW_1lgRVJTSDJwU0xETVk Leo -- 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