Re: [PATCH v2 6/6] smb/client: fix stale page cache in insert/collapse range
Namjae Jeon <[email protected]>
| Newsgroups | org.kernel.vger.linux-cifs |
|---|---|
| Message-ID | <CAKYAXd9Fe5EUYjmf9dp-aHw55YpaxuiKwZibcx8ePQYkJ+E0=Q@mail.gmail.com> |
> @@ -4107,11 +4117,20 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon, > goto out; > > filemap_invalidate_lock(inode->i_mapping); > - rc = filemap_write_and_wait_range(inode->i_mapping, off, new_eof - 1); > + rc = filemap_write_and_wait_range(inode->i_mapping, > + round_down(off, PAGE_SIZE), > + old_eof - 1); > if (rc < 0) > goto out_2; > - truncate_pagecache_range(inode, off, old_eof); > netfs_wait_for_outstanding_io(inode); > + /* > + * Invalidate cached folios from the page containing off to EOF before > + * moving data on the server, so subsequent reads do not see stale data. > + */ > + rc = invalidate_inode_pages2_range(inode->i_mapping, > + off >> PAGE_SHIFT, -1); > + if (rc < 0) > + goto out_2; Could we also invalidate the fscache ? If yes, we need to check collapse range, zero range and punch hole as well.