ext2_write_inode() copies the inode into its inode table block, marks the block dirty and sets I_METADATA_WRITEBACK so that a later fsync() writes the block out and waits for it. But the bit goes away with the inode. If the inode is evicted and read back in, fsync() finds a clean inode and returns while the block might still be dirty or under writeback. Right now that can't happen because inode_lru_isolate() never lets go of an inode with I_METADATA_WRITEBACK set. That is about to change. So call ext2_sync_inode_metadata() from ext2_evict_inode() for a linked inode that still has the bit set. It syncs the metadata buffers as well so it replaces the mmb_sync() there, and since the previous patch it doesn't read anything from disk. Suggested-by: Jan Kara Cc: stable@vger.kernel.org # v7.3 Signed-off-by: Christian Brauner (Amutable) --- fs/ext2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 9261b666d043..4ed727c3d26d 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -91,6 +91,14 @@ void ext2_evict_inode(struct inode * inode) if (inode->i_blocks) ext2_truncate_blocks(inode, 0); ext2_xattr_delete_inode(inode); + } else if (inode_state_read_once(inode) & I_METADATA_WRITEBACK) { + /* + * fsync() can't find what I_METADATA_WRITEBACK tracks once the + * inode is gone. This syncs the metadata buffers as well. + */ + ext2_sync_inode_metadata(inode, &(struct writeback_control) { + .sync_mode = WB_SYNC_ALL, + }); } else { mmb_sync(&EXT2_I(inode)->i_metadata_bhs); } -- 2.53.0