On Tue, Aug 13, 2024 at 2:22 PM Joanne Koong <joannelkoong@xxxxxxxxx> wrote: > > Add FOPEN_FETCH_ATTR flag to indicate that attributes should be > fetched from the server after an open. > > For fuse servers that are backed by network filesystems, this is > needed to ensure that file attributes are up to date between > consecutive open calls. > > For example, if there is a file that is opened on two fuse mounts, > in the following scenario: > > on mount A, open file.txt w/ O_APPEND, write "hi", close file > on mount B, open file.txt w/ O_APPEND, write "world", close file > on mount A, open file.txt w/ O_APPEND, write "123", close file > > when the file is reopened on mount A, the file inode contains the old > size and the last append will overwrite the data that was written when > the file was opened/written on mount B. > > (This corruption can be reproduced on the example libfuse passthrough_hp > server with writeback caching disabled and nopassthrough) > > Having this flag as an option enables parity with NFS's close-to-open > consistency. > This is the corresponding libfuse change: https://github.com/libfuse/libfuse/pull/1012/commits/a59f8e0f5ac9e09c0a54c5cd94e6bca7b635f57d This is for the same overwrite/corruption issue Sweet Tea brought up earlier this year in March in this thread: https://lore.kernel.org/linux-fsdevel/9d71a4fd1f1d8d4cfc28480f01e5fe3dc5a7e3f0.1709821568.git.sweettea-kernel@xxxxxxxxxx/#t In that thread, there was mention that Bernd's atomic open patchset may solve the issue. However, I don't think this works for cases where open is called without needing a fuse lookup. An alternative approach we considered is similar to Sweet Tea's approach, but gated behind an optional config flag that calls fuse_update_attributes() for statx_size at the beginning of every write and removes the FUSE_STATX_MODSIZE invalidation that every write does (in fuse_write_update_attr). The latter is needed or else every fuse_update_attributes() call in the beginning of the write will trigger a FUSE_GETATTR request to the server.