xfs
[Top] [All Lists]

Re: [PATCH 1/6] xfs: mmap write/read leaves bad state on pages

To: Brian Foster <bfoster@xxxxxxxxxx>
Subject: Re: [PATCH 1/6] xfs: mmap write/read leaves bad state on pages
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 22 Aug 2014 08:38:45 +1000
Cc: xfs@xxxxxxxxxxx, clm@xxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20140821124823.GB64112@xxxxxxxxxxxxxxx>
References: <1408597754-13526-1-git-send-email-david@xxxxxxxxxxxxx> <1408597754-13526-2-git-send-email-david@xxxxxxxxxxxxx> <20140821124823.GB64112@xxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, Aug 21, 2014 at 08:48:24AM -0400, Brian Foster wrote:
> On Thu, Aug 21, 2014 at 03:09:09PM +1000, Dave Chinner wrote:
> > +++ b/fs/xfs/xfs_aops.c
> > @@ -1753,11 +1753,69 @@ xfs_vm_readpages(
> >     return mpage_readpages(mapping, pages, nr_pages, xfs_get_blocks);
> >  }
> >  
> > +/*
> > + * This is basically a copy of __set_page_dirty_buffers() with one
> > + * small tweak: buffers beyond EOF do not get marked dirty. If we mark them
> > + * dirty, we'll never be able to clean them because we don't write buffers
> > + * beyond EOF, and that means we can't invalidate pages that span EOF
> > + * that have been marked dirty. Further, the dirty state can leak into
> > + * the file interior if the file is extended, resulting in all sorts of
> > + * bad things happening as the state does not match the unerlying data.
> > + */
> > +STATIC int
> > +xfs_vm_set_page_dirty(
> > +   struct page             *page)
> > +{
> > +   struct address_space    *mapping = page_mapping(page);
> 
> This breaks xfs as a kernel module:
> 
> $ make -j 8 M=fs/xfs
>   Building modules, stage 2.
>   MODPOST 1 modules
> WARNING: "page_mapping" [fs/xfs/xfs.ko] undefined!
>   ...

Oh, that should just be:

+       struct address_space    *mapping = page->mapping;

> I suppose we could export that symbol, but why wouldn't we just propose
> this change to __set_page_dirty_buffers()?

I'm not going to risk breaking other filesystems that have implicit
dependencies on buffers beyond EOF being dirtied.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>