diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4ffb7fc50d15a6bdfd37a5ff07929b64d69eaf0c..4296c2b5d734ed30c93b3695f07c49c33e87c51e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3579,8 +3579,14 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, return ret; } + /* + * Writes that span EOF might trigger an I/O size update on completion, + * so consider them to be dirty for the purposes of O_DSYNC, even if + * there is no other metadata changes being made or are pending here. + */ iomap->flags = 0; - if (ext4_inode_datasync_dirty(inode)) + if (ext4_inode_datasync_dirty(inode) || + offset + length > i_size_read(inode)) iomap->flags |= IOMAP_F_DIRTY; iomap->bdev = inode->i_sb->s_bdev; iomap->dax_dev = sbi->s_daxdev;