On 26/08/2019 22:32, Al Viro wrote: <> > D'oh... OK, that settles it; exclusion with st_write() would've been > painful, but playing with the next st_write() on the same struct file > rewinding the damn thing to overwrite what st_flush() had spewed is > an obvious no-go. > So what are the kind of errors current ->release implementation is trying to return? Is it actual access the HW errors or its more of a resource allocations errors? If the later then maybe the allocations can be done before hand, say at ->flush but are not redone on redundant flushes? If the former then yes looks like troubles. That said I believe the ->last_close_with_error() is a very common needed pattern which few use exactly because it does not work. But which I wanted/needed many times before. So I would break some eggs which ever is the most elegant way, and perhaps add a new parameter to ->flush(bool last) or some other easy API. [Which is BTW the worst name ever, while at it lets rename it to ->close() which is what it is. "flush" is used elsewhere to mean sync. ] So yes please lets fix VFS API with drivers so to have an easy and safe way to execute very last close, all the while still being able to report errors to close(2). My $0.017 Thanks Boaz