udf_write_inode() copies the inode into the block that holds it, 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 udf_sync_inode_metadata() from udf_evict_inode() for an inode that isn't deleted and 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 allocate anything. Suggested-by: Jan Kara Cc: stable@vger.kernel.org # v7.3 Signed-off-by: Christian Brauner (Amutable) --- fs/udf/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index b3e7c07cb9e7..8f45133ce75a 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -152,8 +152,18 @@ void udf_evict_inode(struct inode *inode) } } truncate_inode_pages_final(&inode->i_data); - if (!want_delete) - mmb_sync(&iinfo->i_metadata_bhs); + if (!want_delete) { + /* + * fsync() can't find what I_METADATA_WRITEBACK tracks once the + * inode is gone. This syncs the metadata buffers as well. + */ + if (inode_state_read_once(inode) & I_METADATA_WRITEBACK) + udf_sync_inode_metadata(inode, &(struct writeback_control) { + .sync_mode = WB_SYNC_ALL, + }); + else + mmb_sync(&iinfo->i_metadata_bhs); + } mmb_invalidate(&iinfo->i_metadata_bhs); clear_inode(inode); kfree(iinfo->i_data); -- 2.53.0