On Wed, 26 Oct 2011, Yuping Luo wrote: > Hi, > I have one slow flash block device, which act as usb-mass storage > device, and during the data transfer with windows PC, it will get > ALLOW_MEDIUM_REMOVAL , and sync the file system cache, however, it > takes too much time (by log about 10s) and the usb reset occurs. > however, if the /proc/sys/vm_dirty_ratio changed from 20 to 0 or 4, > everything is ok. > I made some code change to defer the file cache flash for your > review, currently the do_verify() and do_synchronize_cache() not > touched. What happens if you simply remove the call to fsg_lun_fsync_sub() in do_prevent_allow()? In particular, what happens to the next command, which ought to be START STOP UNIT with the loej bit set? When do_start_stop() calls fsg_lun_close(), that should also sync the filesystem cache. (Otherwise, if the backing storage was on a flash card, the user might remove the card while there still some dirty buffers.) Doing the operation in the background is not a good idea. If flushing the dirty buffers out to the flash storage really is a slow operation, we _want_ the host to realize that it is slow. Most especially, we do not want the host to tell the user that it's okay to remove the medium before all the buffers have been written out. 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