Re: [PATCH 14/15] dax: associate mappings with inodes, and warn if dma collides with truncate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 20-12-17 14:41:14, Dan Williams wrote:
> On Wed, Dec 20, 2017 at 6:38 AM, Jan Kara <jack@xxxxxxx> wrote:
> > On Tue 19-12-17 17:11:38, Dan Williams wrote:
> >> On Fri, Nov 10, 2017 at 1:08 AM, Christoph Hellwig <hch@xxxxxx> wrote:
> >> >> +             struct {
> >> >> +                     /*
> >> >> +                      * ZONE_DEVICE pages are never on an lru or handled by
> >> >> +                      * a slab allocator, this points to the hosting device
> >> >> +                      * page map.
> >> >> +                      */
> >> >> +                     struct dev_pagemap *pgmap;
> >> >> +                     /*
> >> >> +                      * inode association for MEMORY_DEVICE_FS_DAX page-idle
> >> >> +                      * callbacks. Note that we don't use ->mapping since
> >> >> +                      * that has hard coded page-cache assumptions in
> >> >> +                      * several paths.
> >> >> +                      */
> >> >
> >> > What assumptions?  I'd much rather fix those up than having two fields
> >> > that have the same functionality.
> >>
> >> [ Reviving this old thread where you asked why I introduce page->inode
> >> instead of reusing page->mapping ]
> >>
> >> For example, xfs_vm_set_page_dirty() assumes that page->mapping being
> >> non-NULL indicates a typical page cache page, this is a false
> >> assumption for DAX. My guess at a fix for this is to add
> >> pagecache_page() checks to locations like this, but I worry about how
> >> to find them all. Where pagecache_page() is:
> >>
> >> bool pagecache_page(struct page *page)
> >> {
> >>         if (!page->mapping)
> >>                 return false;
> >>         if (!IS_DAX(page->mapping->host))
> >>                 return false;
> >>         return true;
> >> }
> >>
> >> Otherwise we go off the rails:
> >>
> >>  WARNING: CPU: 27 PID: 1783 at fs/xfs/xfs_aops.c:1468
> >> xfs_vm_set_page_dirty+0xf3/0x1b0 [xfs]
> >
> > But this just shows that mapping->a_ops are wrong for this mapping, doesn't
> > it? ->set_page_dirty handler for DAX mapping should just properly handle
> > DAX pages... (and only those)
> 
> Ah, yes. Now that I change ->mapping to be non-NULL for DAX pages I
> enable all the address_space_operations to start firing. However,
> instead of adding DAX specific address_space_operations it appears
> ->mapping should never be set for DAX pages, because DAX pages are
> disconnected from the page-writeback machinery.

page->mapping is not only about page-writeback machinery. It is generally
about page <-> inode relation and that still exists for DAX pages. We even
reuse the mapping->page_tree to store DAX pages. Also requiring proper
address_space_operations for DAX inodes is IMO not a bad thing as such.

That being said I'm not 100% convinced we should really set page->mapping
for DAX pages. After all they are not page cache pages but rather a
physical storage for the data, don't ever get to LRU, etc. But if you need
page->inode relation somewhere, that is a good indication to me that it
might be just easier to set page->mapping and provide aops that do the
right thing (i.e. usually not much) for them.

BTW: the ->set_page_dirty() in particular actually *does* need to do
something for DAX pages - corresponding radix tree entries should be
marked dirty so that caches can get flushed when needed.

> In other words never
> setting ->mapping bypasses all the possible broken assumptions and
> code paths that take page-cache specific actions before calling an
> address_space_operation.

If there are any assumptions left after aops are set properly, then we can
reconsider this but for now setting ->mapping and proper aops looks cleaner
to me...

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux