• Pavel Emelyanov's avatar
    fuse: Fix O_DIRECT operations vs cached writeback misorder · ea8cd333
    Pavel Emelyanov authored
    The problem is:
    1. write cached data to a file
    2. read directly from the same file (via another fd)
    The 2nd operation may read stale data, i.e. the one that was in a file
    before the 1st op. Problem is in how fuse manages writeback.
    When direct op occurs the core kernel code calls filemap_write_and_wait
    to flush all the cached ops in flight. But fuse acks the writeback right
    after the ->writepages callback exits w/o waiting for the real write to
    happen. Thus the subsequent direct op proceeds while the real writeback
    is still in flight. This is a problem for backends that reorder operation.
    Fix this by making the fuse direct IO callback explicitly wait on the
    in-flight writeback to finish.
    Signed-off-by: default avatarMaxim Patlasov <MPatlasov@parallels.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
fuse_i.h 21 KB