diff options
| author | Paulo Alcantara <pc@manguebit.org> | 2025-10-07 16:23:25 -0300 |
|---|---|---|
| committer | Steve French <stfrench@microsoft.com> | 2025-10-09 10:42:14 -0500 |
| commit | dba9f997c9d9a1cade05d006ed0429a63a4eed32 (patch) | |
| tree | 86d8f892d8cf78fd74cf262bf9dddcda6fe6280b /fs/smb/client/inode.c | |
| parent | b95cd1bdf5aa9221c98fc9259014b8bb8d1829d7 (diff) | |
smb: client: fix race with fallocate(2) and AIO+DIO
AIO+DIO may extend the file size, hence we need to make sure ->i_size
is stable across the entire fallocate(2) operation, otherwise it would
become a truncate and then inode size reduced back down when it
finishes.
Fix this by calling netfs_wait_for_outstanding_io() right after
acquiring ->i_rwsem exclusively in cifs_fallocate() and then guarantee
a stable ->i_size across fallocate(2).
Also call netfs_wait_for_outstanding_io() after truncating pagecache
to avoid any potential races with writeback.
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Fixes: 210627b0aca9 ("smb: client: fix missing timestamp updates with O_TRUNC")
Cc: Frank Sorenson <sorenson@redhat.com>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/client/inode.c')
| -rw-r--r-- | fs/smb/client/inode.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index fbfd5b556815..239dd84a336f 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -3012,6 +3012,7 @@ void cifs_setsize(struct inode *inode, loff_t offset) spin_unlock(&inode->i_lock); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); truncate_pagecache(inode, offset); + netfs_wait_for_outstanding_io(inode); } int cifs_file_set_size(const unsigned int xid, struct dentry *dentry, |