> syncfs seems to enforce the semantics laid out by VFS[1]. Specifically the > statement: > When there is an error during writeback, they expect that error to be reported > when a file sync request is made. After an error has been reported on one > request, subsequent requests on the same file descriptor should return 0, unless > further writeback errors have occurred since the previous file syncronization. > > This is enforced by the errseq_check_and_advance logic. We can hack around this > logic by resetting the errset (setting the error on it) every time we get the > sync_fs callback, but that to me seems wrong. FWIW, implementing this behaviour > for fdatasync, and fsync is easier, because the error is bubbled up from the > filesystem to the VFS. I don't actually think this is a good idea because > it seems like this sync_fs behaviour is a bit...not neccessarily what all > filesystems expect. For example, btrfs_sync_fs returns an error if it > is unable to finish the current transaction. Nowhere in the btrfs code > does it set the errseq on the superblock if this fails. > > I think we have a couple paths forward: > 1. Change the semantic of sync_fs so the error is always bubbled up if > it returns a non-zero value. If we do this, we have to decide whether > or not we would _also_ call errseq_check_and_advance on the SB, > or leave that to a subsequent call. > 2. Have overlayfs forcefully set an error on the superblock on every > callback to sync_fs. This seems ugly, but I wrote a little patch, > and it seems to solve the problem for all the fsync / fdatasync / > sync / syncfs variants without having to do plumbing in VFS. > 3. Choose a different set of semantics for how we want to handle > errors in volatile mounts. > IMO it is best if you post your patch to fix volatile overlayfs, because it seems to me that the volatile overlayfs issue is worse than generic sync_fs issues and it's good if we had a small backportable patch even if a bit ugly. Later you can pursue the sync_fs semantic fixes if you wish they do not contradict the fix in overlayfs, just are just a way to remove a hack. Thanks, Amir.