Re: [PATCH]: v9fs: add readpage support

From: Andrew Morton
Date: Fri Jan 13 2006 - 17:11:40 EST


Eric Van Hensbergen <ericvh@xxxxxxxxx> wrote:
>
> > > @@ -289,6 +289,8 @@ v9fs_file_write(struct file *filp, const
> > > total += result;
> > > } while (count);
> > >
> > > + invalidate_inode_pages2(inode->i_mapping);
> > > +
> > > return total;
> > > }
> >
>
> I went looking for an example of how to do this better. More or less,
> v9fs reads and writes are similar to DirectIO since they don't go
> through the page-cache.

hm. Why not?

> So, I looked at what NFS does when it gets a
> DirectIO write, and it looks (to me) like it does more or less the
> same thing:
> (from nfs_file_direct_write() in fs/nfs/direct.c)
> retval = nfs_direct_write(inode, ctx, &iov, pos, 1);
> if (mapping->nrpages)
> invalidate_inode_pages2(mapping);
>
> Now, that being said, it still seems to me to be a bit heavy weight --
> do folks have a better pointer to code that I can use as an example of
> how to do this more efficiently?

Not really. If that's what you need to do then that's the way to do it.
We've had nasty races and other problems wrt invalidate_inode_pages2 and
pagefaults, so I suggest you test that mix carefully.

Have you tried fsx-linux? It's really good for finding data integrity
bugs. There's a copy in
http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz.

I'd suggest that you want the mapping->nrpages test - it'll be a useful
speedup in the common case.

Of course, someone could come in and add a page to pagecache via a
pagefault at any time after that test, but that's true of
invalidate_inode_pages2() in general.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/