Linux-NFS Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2] NFS: Don't use page_file_mapping after removing the page
@ 2019-02-06 11:09 Benjamin Coddington
  2019-02-12 18:52 ` Benjamin Coddington
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Coddington @ 2019-02-06 11:09 UTC (permalink / raw)
  To: trond.myklebust, anna.schumaker; +Cc: linux-nfs

If nfs_page_async_flush() removes the page from the mapping, then we can't
use page_file_mapping() on it as nfs_updatepate() is wont to do when
receiving an error.  Instead, push the mapping to the stack before the page
is possibly truncated.

Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in nfs_page_async_flush()")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/write.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index f12cb31a41e5..d09c9f878141 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -238,9 +238,9 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
 }
 
 /* A writeback failed: mark the page as bad, and invalidate the page cache */
-static void nfs_set_pageerror(struct page *page)
+static void nfs_set_pageerror(struct address_space *mapping)
 {
-	nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page));
+	nfs_zap_mapping(mapping->host, mapping);
 }
 
 /*
@@ -994,7 +994,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
 		nfs_list_remove_request(req);
 		if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) &&
 		    (hdr->good_bytes < bytes)) {
-			nfs_set_pageerror(req->wb_page);
+			nfs_set_pageerror(page_file_mapping(req->wb_page));
 			nfs_context_set_write_error(req->wb_context, hdr->error);
 			goto remove_req;
 		}
@@ -1348,7 +1348,8 @@ int nfs_updatepage(struct file *file, struct page *page,
 		unsigned int offset, unsigned int count)
 {
 	struct nfs_open_context *ctx = nfs_file_open_context(file);
-	struct inode	*inode = page_file_mapping(page)->host;
+	struct address_space *mapping = page_file_mapping(page);
+	struct inode	*inode = mapping->host;
 	int		status = 0;
 
 	nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
@@ -1366,7 +1367,7 @@ int nfs_updatepage(struct file *file, struct page *page,
 
 	status = nfs_writepage_setup(ctx, page, offset, count);
 	if (status < 0)
-		nfs_set_pageerror(page);
+		nfs_set_pageerror(mapping);
 	else
 		__set_page_dirty_nobuffers(page);
 out:
-- 
2.14.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] NFS: Don't use page_file_mapping after removing the page
  2019-02-06 11:09 [PATCH v2] NFS: Don't use page_file_mapping after removing the page Benjamin Coddington
@ 2019-02-12 18:52 ` Benjamin Coddington
  2019-02-12 21:28   ` Schumaker, Anna
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Coddington @ 2019-02-12 18:52 UTC (permalink / raw)
  To: trond.myklebust, anna.schumaker; +Cc: linux-nfs

Hi Trond and Anna,

I want to bump this.  The problem we created is easier to hit now than 
the problem we were fixing, so something should be done for 5.0 if 
possible.

Ben

On 6 Feb 2019, at 6:09, Benjamin Coddington wrote:

> If nfs_page_async_flush() removes the page from the mapping, then we 
> can't
> use page_file_mapping() on it as nfs_updatepate() is wont to do when
> receiving an error.  Instead, push the mapping to the stack before the 
> page
> is possibly truncated.
>
> Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in 
> nfs_page_async_flush()")
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  fs/nfs/write.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index f12cb31a41e5..d09c9f878141 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -238,9 +238,9 @@ static void nfs_grow_file(struct page *page, 
> unsigned int offset, unsigned int c
>  }
>
>  /* A writeback failed: mark the page as bad, and invalidate the page 
> cache */
> -static void nfs_set_pageerror(struct page *page)
> +static void nfs_set_pageerror(struct address_space *mapping)
>  {
> -	nfs_zap_mapping(page_file_mapping(page)->host, 
> page_file_mapping(page));
> +	nfs_zap_mapping(mapping->host, mapping);
>  }
>
>  /*
> @@ -994,7 +994,7 @@ static void nfs_write_completion(struct 
> nfs_pgio_header *hdr)
>  		nfs_list_remove_request(req);
>  		if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) &&
>  		    (hdr->good_bytes < bytes)) {
> -			nfs_set_pageerror(req->wb_page);
> +			nfs_set_pageerror(page_file_mapping(req->wb_page));
>  			nfs_context_set_write_error(req->wb_context, hdr->error);
>  			goto remove_req;
>  		}
> @@ -1348,7 +1348,8 @@ int nfs_updatepage(struct file *file, struct 
> page *page,
>  		unsigned int offset, unsigned int count)
>  {
>  	struct nfs_open_context *ctx = nfs_file_open_context(file);
> -	struct inode	*inode = page_file_mapping(page)->host;
> +	struct address_space *mapping = page_file_mapping(page);
> +	struct inode	*inode = mapping->host;
>  	int		status = 0;
>
>  	nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
> @@ -1366,7 +1367,7 @@ int nfs_updatepage(struct file *file, struct 
> page *page,
>
>  	status = nfs_writepage_setup(ctx, page, offset, count);
>  	if (status < 0)
> -		nfs_set_pageerror(page);
> +		nfs_set_pageerror(mapping);
>  	else
>  		__set_page_dirty_nobuffers(page);
>  out:
> -- 
> 2.14.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] NFS: Don't use page_file_mapping after removing the page
  2019-02-12 18:52 ` Benjamin Coddington
@ 2019-02-12 21:28   ` Schumaker, Anna
  0 siblings, 0 replies; 3+ messages in thread
From: Schumaker, Anna @ 2019-02-12 21:28 UTC (permalink / raw)
  To: bcodding, trond.myklebust; +Cc: linux-nfs

On Tue, 2019-02-12 at 13:52 -0500, Benjamin Coddington wrote:
> Hi Trond and Anna,
> 
> I want to bump this.  The problem we created is easier to hit now than
> the problem we were fixing, so something should be done for 5.0 if
> possible.

Sounds good.  I'll send it in a pull request this week.

Thanks,
Anna

> 
> Ben
> 
> On 6 Feb 2019, at 6:09, Benjamin Coddington wrote:
> 
> > If nfs_page_async_flush() removes the page from the mapping, then we
> > can't
> > use page_file_mapping() on it as nfs_updatepate() is wont to do when
> > receiving an error.  Instead, push the mapping to the stack before the
> > page
> > is possibly truncated.
> > 
> > Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in
> > nfs_page_async_flush()")
> > Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> > ---
> >  fs/nfs/write.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> > index f12cb31a41e5..d09c9f878141 100644
> > --- a/fs/nfs/write.c
> > +++ b/fs/nfs/write.c
> > @@ -238,9 +238,9 @@ static void nfs_grow_file(struct page *page,
> > unsigned int offset, unsigned int c
> >  }
> > 
> >  /* A writeback failed: mark the page as bad, and invalidate the page
> > cache */
> > -static void nfs_set_pageerror(struct page *page)
> > +static void nfs_set_pageerror(struct address_space *mapping)
> >  {
> > -     nfs_zap_mapping(page_file_mapping(page)->host,
> > page_file_mapping(page));
> > +     nfs_zap_mapping(mapping->host, mapping);
> >  }
> > 
> >  /*
> > @@ -994,7 +994,7 @@ static void nfs_write_completion(struct
> > nfs_pgio_header *hdr)
> >               nfs_list_remove_request(req);
> >               if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) &&
> >                   (hdr->good_bytes < bytes)) {
> > -                     nfs_set_pageerror(req->wb_page);
> > +                     nfs_set_pageerror(page_file_mapping(req->wb_page));
> >                       nfs_context_set_write_error(req->wb_context, hdr-
> > >error);
> >                       goto remove_req;
> >               }
> > @@ -1348,7 +1348,8 @@ int nfs_updatepage(struct file *file, struct
> > page *page,
> >               unsigned int offset, unsigned int count)
> >  {
> >       struct nfs_open_context *ctx = nfs_file_open_context(file);
> > -     struct inode    *inode = page_file_mapping(page)->host;
> > +     struct address_space *mapping = page_file_mapping(page);
> > +     struct inode    *inode = mapping->host;
> >       int             status = 0;
> > 
> >       nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
> > @@ -1366,7 +1367,7 @@ int nfs_updatepage(struct file *file, struct
> > page *page,
> > 
> >       status = nfs_writepage_setup(ctx, page, offset, count);
> >       if (status < 0)
> > -             nfs_set_pageerror(page);
> > +             nfs_set_pageerror(mapping);
> >       else
> >               __set_page_dirty_nobuffers(page);
> >  out:
> > --
> > 2.14.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 11:09 [PATCH v2] NFS: Don't use page_file_mapping after removing the page Benjamin Coddington
2019-02-12 18:52 ` Benjamin Coddington
2019-02-12 21:28   ` Schumaker, Anna

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org linux-nfs@archiver.kernel.org
	public-inbox-index linux-nfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox