On Mon, 27 Aug 2012, Felipe Balbi wrote: > On Sat, Aug 25, 2012 at 07:44:09PM +0200, Sebastian Andrzej Siewior wrote: > > On Sat, Aug 25, 2012 at 10:35:34AM -0400, Alan Stern wrote: > > > For safety's sake, it would be a good idea to flush the dirty pages > > > when a disconnect occurs. > > > > It does not look like there is an API for this (yet). > > Does it really make sense to flush dirty pages on disconnect ? Shouldn't > we delay it to close() ? I mean, this will be running on a device with a > battery anyway, so there's very little risk of loosing any data. The way I see it is: If the disconnect was done on purpose and carefully then the host will have issued a SYNCHRONIZE CACHE command, so there will be no dirty pages and hence nothing to flush. But if the disconnect wasn't on purpose or was done without thinking (i.e., no unmount beforehand) then we can assume the host _should_ have issued that command but didn't get a chance. Therefore we should flush the dirty pages ourselves. If the gadget isn't connected then most likely there won't be a close() until the driver is unloaded or the system is shut down. Neither of those is a very good time to start flushing dirty pages. 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