diff mbox series

cifs: revalidate mapping when doing direct writes

Message ID 20220912030446.173296-2-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: revalidate mapping when doing direct writes | expand

Commit Message

Ronnie Sahlberg Sept. 12, 2022, 3:04 a.m. UTC
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.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/file.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Steve French Sept. 12, 2022, 5:32 a.m. UTC | #1
---------- Forwarded message ---------
From: Steve French <smfrench@gmail.com>
Date: Mon, Sep 12, 2022 at 12:30 AM
Subject: Re: [PATCH] cifs: revalidate mapping when doing direct writes
To: Ronnie Sahlberg <lsahlber@redhat.com>
Cc: linux-cifs <linux-cifs@vger.kernel.org>, Ronnie Sahlberg
<lsahlber@redhat.com>


added cc:stable and tentatively merged into cifs-2.6.git for-next
pending testing

Also let me know if you think this could address any long standing
xfstest failures

On Sun, Sep 11, 2022 at 10:05 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/file.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index fa738adc031f..6f38b134a346 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -3575,6 +3575,9 @@ static ssize_t __cifs_writev(
>
>  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);
>  }
>
> --
> 2.35.3
>
Paulo Alcantara Sept. 12, 2022, 3:57 p.m. UTC | #2
Ronnie Sahlberg <lsahlber@redhat.com> writes:

> 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.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/file.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
diff mbox series

Patch

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index fa738adc031f..6f38b134a346 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3575,6 +3575,9 @@  static ssize_t __cifs_writev(
 
 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);
 }