On Thu, 27 Oct 2011, Yuping Luo wrote: > > I'd like to think doing fsync in gadget driver is wrong. It is not the duty of gadget driver but the duty of pdflush and users. > > I think the storage gadget just act as one glue layer, or proxy, which > handle one file (just like one normal linux file) or block device, and > need explicitly be told what to do by the user from host. > > > This gadget is only one of many users of fs through standard vfs interface. There are many users who might access the related storage. We can't stop them actually. > > if the backing file exported to PC, it should not be used by the > system , right ? > > > I would think the fsync should be done by user explicitly before he unplugs a card. Otherwise, let the data bad. > > > Yeah, that's the role of SYNCHRONIZE_CACHE, however, not sure why > ALLOW_MEDIUM_REMOVAL sent. Yuping has the right idea here. The sync should be done by the user -- the _host's_ user, not the _gadget_'s user. (In general, the gadget doesn't have a user -- and in particular, the file-storage code runs as an autonomous kernel thread.) Clicking an "Eject" button on the host should be sufficient to sync the cache. We have to make sure that it does. 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