cifs: revalidate mapping when doing direct writes

commit 7500a99281 upstream.

Kernel bugzilla: 216301

When doing direct writes we need to also invalidate the mapping in case
we have a cached copy of the affected page(s) in memory or else
subsequent reads of the data might return the old/stale content
before we wrote an update to the server.

Cc: stable@vger.kernel.org
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ronnie Sahlberg 2022-09-12 13:04:46 +10:00 коммит произвёл Greg Kroah-Hartman
Родитель b04e0208d0
Коммит e1aad8c560
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -3318,6 +3318,9 @@ static ssize_t __cifs_writev(
ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from) ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from)
{ {
struct file *file = iocb->ki_filp;
cifs_revalidate_mapping(file->f_inode);
return __cifs_writev(iocb, from, true); return __cifs_writev(iocb, from, true);
} }