From: Peter Staubach <staubach@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org,
nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 22/43] CacheFiles: Add a hook to write a single page of data to an inode [ver #46]
Date: Thu, 02 Apr 2009 11:32:14 -0400 [thread overview]
Message-ID: <49D4DA7E.7010508@redhat.com> (raw)
In-Reply-To: <20090401230515.28177.73948.stgit@warthog.procyon.org.uk>
David Howells wrote:
> Add an address space operation to write one single page of data to an inode at
> a page-aligned location (thus permitting the implementation to be highly
> optimised). The data source is a single page.
>
> This is used by CacheFiles to store the contents of netfs pages into their
> backing file pages.
>
> Supply a generic implementation for this that uses the write_begin() and
> write_end() address_space operations to bind a copy directly into the page
> cache.
>
> Hook the Ext2 and Ext3 operations to the generic implementation.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Steve Dickson <steved@redhat.com>
> Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
>
> fs/ext2/inode.c | 2 ++
> fs/ext3/inode.c | 3 +++
> include/linux/fs.h | 7 ++++++
> mm/filemap.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 73 insertions(+), 0 deletions(-)
>
>
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index b43b955..5d17070 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -817,6 +817,8 @@ const struct address_space_operations ext2_nobh_aops = {
> .direct_IO = ext2_direct_IO,
> .writepages = ext2_writepages,
> .migratepage = buffer_migrate_page,
> + .write_one_page = generic_file_buffered_write_one_page,
> + .write_one_page = generic_file_buffered_write_one_page,
>
You probably only need one of these lines, don't you?
Thanx...
ps
> };
>
> /*
> diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
> index d897033..a2e5fef 100644
> --- a/fs/ext3/inode.c
> +++ b/fs/ext3/inode.c
> @@ -1803,6 +1803,7 @@ static const struct address_space_operations ext3_ordered_aops = {
> .direct_IO = ext3_direct_IO,
> .migratepage = buffer_migrate_page,
> .is_partially_uptodate = block_is_partially_uptodate,
> + .write_one_page = generic_file_buffered_write_one_page,
> };
>
> static const struct address_space_operations ext3_writeback_aops = {
> @@ -1818,6 +1819,7 @@ static const struct address_space_operations ext3_writeback_aops = {
> .direct_IO = ext3_direct_IO,
> .migratepage = buffer_migrate_page,
> .is_partially_uptodate = block_is_partially_uptodate,
> + .write_one_page = generic_file_buffered_write_one_page,
> };
>
> static const struct address_space_operations ext3_journalled_aops = {
> @@ -1832,6 +1834,7 @@ static const struct address_space_operations ext3_journalled_aops = {
> .invalidatepage = ext3_invalidatepage,
> .releasepage = ext3_releasepage,
> .is_partially_uptodate = block_is_partially_uptodate,
> + .write_one_page = generic_file_buffered_write_one_page,
> };
>
> void ext3_set_aops(struct inode *inode)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 61211ad..df93cdf 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -532,6 +532,11 @@ struct address_space_operations {
> int (*launder_page) (struct page *);
> int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
> unsigned long);
> +
> + /* write the contents of the source page over the page at the specified
> + * index in the target address space (the source page does not need to
> + * be related to the target address space) */
> + int (*write_one_page)(struct address_space *, pgoff_t, struct page *);
> };
>
> /*
> @@ -2119,6 +2124,8 @@ extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *,
> unsigned long *, loff_t, loff_t *, size_t, size_t);
> extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *,
> unsigned long, loff_t, loff_t *, size_t, ssize_t);
> +extern int generic_file_buffered_write_one_page(struct address_space *,
> + pgoff_t, struct page *);
> extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
> extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
> extern int generic_segment_checks(const struct iovec *iov,
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 3c55c1a..d766c2f 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2320,6 +2320,67 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
> }
> EXPORT_SYMBOL(generic_file_buffered_write);
>
> +/**
> + * generic_file_buffered_write_one_page - Write a single page of data to an
> + * inode
> + * @mapping - The address space of the target inode
> + * @index - The target page in the target inode to fill
> + * @source - The data to write into the target page
> + *
> + * Write the data from the source page to the page in the nominated address
> + * space at the @index specified. Note that the file will not be extended if
> + * the page crosses the EOF marker, in which case only the first part of the
> + * page will be written.
> + *
> + * The @source page does not need to have any association with the file or the
> + * target page offset.
> + */
> +int generic_file_buffered_write_one_page(struct address_space *mapping,
> + pgoff_t index,
> + struct page *source)
> +{
> + const struct address_space_operations *a_ops = mapping->a_ops;
> + struct page *page;
> + unsigned len;
> + loff_t isize, pos;
> + void *fsdata;
> + int ret;
> +
> + pos = index;
> + pos <<= PAGE_CACHE_SHIFT;
> +
> + len = PAGE_CACHE_SIZE;
> + isize = i_size_read(mapping->host);
> + if ((isize >> PAGE_CACHE_SHIFT) == index)
> + len = isize & (PAGE_CACHE_SIZE - 1);
> +
> + ret = pagecache_write_begin(NULL, mapping, pos, len,
> + AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);
> + if (ret < 0)
> + goto sync;
> +
> + copy_highpage(page, source);
> +
> + ret = pagecache_write_end(NULL, mapping, pos, len, len, page, fsdata);
> + if (ret < 0)
> + goto sync;
> +
> + balance_dirty_pages_ratelimited(mapping);
> + cond_resched();
> +
> +sync:
> + /* the caller must handle O_SYNC themselves, but we handle S_SYNC and
> + * MS_SYNCHRONOUS here */
> + if (unlikely(IS_SYNC(mapping->host)) && !a_ops->writepage)
> + ret = generic_osync_inode(mapping->host, mapping,
> + OSYNC_METADATA | OSYNC_DATA);
> +
> + /* the caller must handle O_DIRECT for themselves */
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(generic_file_buffered_write_one_page);
> +
> static ssize_t
> __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
> unsigned long nr_segs, loff_t *ppos)
>
> _______________________________________________
> NFSv4 mailing list
> NFSv4@linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
>
next prev parent reply other threads:[~2009-04-02 15:32 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-01 23:03 [PATCH 00/43] Permit filesystem local caching [ver #46] David Howells
2009-04-01 23:03 ` [PATCH 01/43] Create a dynamically sized pool of threads for doing very slow work items " David Howells
2009-04-01 23:03 ` [PATCH 02/43] Make slow-work thread pool actually dynamic " David Howells
2009-04-01 23:03 ` [PATCH 03/43] Make the slow work pool configurable " David Howells
2009-04-01 23:03 ` [PATCH 04/43] Document the slow work thread pool " David Howells
2009-04-01 23:03 ` [PATCH 05/43] FS-Cache: Release page->private after failed readahead " David Howells
2009-04-02 13:51 ` Nick Piggin
2009-04-02 14:21 ` David Howells
2009-04-02 17:17 ` Rik van Riel
2009-04-01 23:03 ` [PATCH 06/43] FS-Cache: Recruit a couple of page flags for cache management " David Howells
2009-04-02 13:55 ` Nick Piggin
2009-04-02 14:36 ` David Howells
2009-04-02 15:25 ` Nick Piggin
2009-04-02 15:51 ` David Howells
2009-04-02 16:15 ` Nick Piggin
2009-04-02 16:53 ` Nick Piggin
2009-04-02 17:09 ` David Howells
2009-04-02 17:31 ` Nick Piggin
2009-04-02 17:40 ` David Howells
2009-04-02 18:14 ` Nick Piggin
2009-04-02 19:19 ` Trond Myklebust
2009-04-03 1:11 ` David Howells
2009-04-02 16:48 ` What I mean by a 'netfs' when dealing with FS-Cache David Howells
2009-04-02 17:06 ` David Howells
2009-04-02 18:23 ` [PATCH 06/43] FS-Cache: Recruit a couple of page flags for cache management [ver #46] Rik van Riel
2009-04-01 23:03 ` [PATCH 07/43] FS-Cache: Add the FS-Cache netfs API and documentation " David Howells
2009-04-01 23:04 ` [PATCH 08/43] FS-Cache: Add the FS-Cache cache backend " David Howells
2009-04-01 23:04 ` [PATCH 09/43] FS-Cache: Add main configuration option, module entry points and debugging " David Howells
2009-04-01 23:04 ` [PATCH 10/43] FS-Cache: Add use of /proc and presentation of statistics " David Howells
2009-04-01 23:04 ` [PATCH 11/43] FS-Cache: Root index definition " David Howells
2009-04-01 23:04 ` [PATCH 12/43] FS-Cache: Add cache tag handling " David Howells
2009-04-01 23:04 ` [PATCH 13/43] FS-Cache: Add cache management " David Howells
2009-04-01 23:04 ` [PATCH 14/43] FS-Cache: Provide a slab for cookie allocation " David Howells
2009-04-01 23:04 ` [PATCH 15/43] FS-Cache: Add netfs registration " David Howells
2009-04-01 23:04 ` [PATCH 16/43] FS-Cache: Bit waiting helpers " David Howells
2009-04-01 23:04 ` [PATCH 17/43] FS-Cache: Object management state machine " David Howells
2009-04-01 23:04 ` [PATCH 18/43] FS-Cache: Implement the cookie management part of the netfs API " David Howells
2009-04-01 23:04 ` [PATCH 19/43] FS-Cache: Add and document asynchronous operation handling " David Howells
2009-04-01 23:05 ` [PATCH 20/43] FS-Cache: Implement data I/O part of netfs API " David Howells
2009-04-01 23:05 ` [PATCH 21/43] CacheFiles: Be consistent about the use of mapping vs file->f_mapping in Ext3 " David Howells
2009-04-02 18:52 ` Rik van Riel
2009-04-01 23:05 ` [PATCH 22/43] CacheFiles: Add a hook to write a single page of data to an inode " David Howells
2009-04-02 14:00 ` Nick Piggin
2009-04-02 14:55 ` David Howells
2009-04-02 15:32 ` Nick Piggin
2009-04-02 16:37 ` Christoph Hellwig
2009-04-02 16:47 ` Nick Piggin
2009-04-02 16:55 ` Christoph Hellwig
2009-04-02 17:07 ` Nick Piggin
2009-04-02 17:26 ` Jan Kara
2009-04-02 17:22 ` David Howells
2009-04-02 18:18 ` David Howells
2009-04-02 22:44 ` David Howells
2009-04-03 13:41 ` David Howells
2009-04-02 16:02 ` David Howells
2009-04-02 15:32 ` Peter Staubach [this message]
2009-04-02 16:03 ` David Howells
2009-04-02 18:48 ` Rik van Riel
2009-04-01 23:05 ` [PATCH 23/43] CacheFiles: Permit the page lock state to be monitored " David Howells
2009-04-02 15:37 ` Nick Piggin
2009-04-02 16:14 ` David Howells
2009-04-02 16:35 ` Nick Piggin
2009-04-02 17:05 ` David Howells
2009-04-02 18:03 ` Nick Piggin
2009-04-02 18:51 ` Rik van Riel
2009-04-01 23:05 ` [PATCH 24/43] CacheFiles: Export things for CacheFiles " David Howells
2009-04-02 18:53 ` Rik van Riel
2009-04-01 23:05 ` [PATCH 25/43] CacheFiles: A cache that backs onto a mounted filesystem " David Howells
2009-04-01 23:05 ` [PATCH 26/43] FS-Cache: Make kAFS use FS-Cache " David Howells
2009-04-01 23:05 ` [PATCH 27/43] NFS: Add comment banners to some NFS functions " David Howells
2009-04-01 23:05 ` [PATCH 28/43] NFS: Add FS-Cache option bit and debug bit " David Howells
2009-04-01 23:05 ` [PATCH 29/43] NFS: Permit local filesystem caching to be enabled for NFS " David Howells
2009-04-01 23:05 ` [PATCH 30/43] NFS: Register NFS for caching and retrieve the top-level index " David Howells
2009-04-01 23:06 ` [PATCH 31/43] NFS: Define and create server-level objects " David Howells
2009-04-01 23:06 ` [PATCH 32/43] NFS: Define and create superblock-level " David Howells
2009-04-01 23:06 ` [PATCH 33/43] NFS: Define and create inode-level cache " David Howells
2009-04-01 23:06 ` [PATCH 34/43] NFS: Use local disk inode cache " David Howells
2009-04-01 23:06 ` [PATCH 35/43] NFS: Invalidate FsCache page flags when cache removed " David Howells
2009-04-01 23:06 ` [PATCH 36/43] NFS: Add some new I/O counters for FS-Cache doing things for NFS " David Howells
2009-04-01 23:06 ` [PATCH 37/43] NFS: FS-Cache page management " David Howells
2009-04-01 23:06 ` [PATCH 38/43] NFS: Add read context retention for FS-Cache to call back with " David Howells
2009-04-01 23:06 ` [PATCH 39/43] NFS: nfs_readpage_async() needs to be accessible as a fallback for local caching " David Howells
2009-04-01 23:06 ` [PATCH 40/43] NFS: Read pages from FS-Cache into an NFS inode " David Howells
2009-04-01 23:06 ` [PATCH 41/43] NFS: Store pages from an NFS inode into a local cache " David Howells
2009-04-01 23:06 ` [PATCH 42/43] NFS: Display local caching state " David Howells
2009-04-01 23:07 ` [PATCH 43/43] NFS: Add mount options to enable local caching on NFS " David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49D4DA7E.7010508@redhat.com \
--to=staubach@redhat.com \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).