From: Jan Kara <jack@suse.cz>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
linux-ext4 <linux-ext4@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [RFC PATCH 2/2] mm: Gate stable page writes on the bdi flag
Date: Mon, 29 Oct 2012 19:28:57 +0100 [thread overview]
Message-ID: <20121029182857.GI18767@quack.suse.cz> (raw)
In-Reply-To: <20121027013608.GB19591@blackbox.djwong.org>
On Fri 26-10-12 18:36:08, Darrick J. Wong wrote:
> Create a helper function to decide if a particular address space is backed by a
> device that requires stable page writes. For each wait_on_page_writeback call
> that was inserted in the original stable page write patchset, change it to wait
> only if the helper says it's necessary. This should eliminate unnecessary
> waiting for devices that don't require page contents to be immutable during
> writeout.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>
> fs/buffer.c | 3 ++-
> fs/ext4/inode.c | 4 ++--
> include/linux/fs.h | 2 ++
> mm/filemap.c | 3 ++-
> mm/page-writeback.c | 7 +++++++
> 5 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index b5f0442..f508ece 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -2334,7 +2334,8 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
> if (unlikely(ret < 0))
> goto out_unlock;
> set_page_dirty(page);
> - wait_on_page_writeback(page);
> + if (page->mapping && mapping_needs_stable_writes(page->mapping))
> + wait_on_page_writeback(page);
The page is locked and we checked whether it belongs to the right mapping
just after we locked it down. So you can safely skip the page->mapping
test.
> return 0;
> out_unlock:
> unlock_page(page);
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index b3c243b..82908b8 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4813,8 +4813,8 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
> if (page_has_buffers(page)) {
> if (!walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
> ext4_bh_unmapped)) {
> - /* Wait so that we don't change page under IO */
> - wait_on_page_writeback(page);
> + if (mapping_needs_stable_writes(mapping))
> + wait_on_page_writeback(page);
> ret = VM_FAULT_LOCKED;
> goto out;
> }
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index b33cfc9..d99db0e 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -466,6 +466,8 @@ struct block_device {
> struct percpu_rw_semaphore bd_block_size_semaphore;
> };
>
> +int mapping_needs_stable_writes(struct address_space *mapping);
> +
> /*
> * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
> * radix trees
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 83efee7..aedc6bd 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2274,7 +2274,8 @@ repeat:
> return NULL;
> }
> found:
> - wait_on_page_writeback(page);
> + if (mapping_needs_stable_writes(mapping))
> + wait_on_page_writeback(page);
> return page;
> }
> EXPORT_SYMBOL(grab_cache_page_write_begin);
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 830893b..d0f042c 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2275,3 +2275,10 @@ int mapping_tagged(struct address_space *mapping, int tag)
> return radix_tree_tagged(&mapping->page_tree, tag);
> }
> EXPORT_SYMBOL(mapping_tagged);
> +
> +int mapping_needs_stable_writes(struct address_space *mapping)
> +{
> + return mapping->backing_dev_info &&
> + bdi_cap_stable_writes(mapping->backing_dev_info);
> +}
> +EXPORT_SYMBOL_GPL(mapping_needs_stable_writes);
Traditional name for these shortcuts is "mapping_cap_..." and put them in
linux/backing-dev.h. And you don't have to check
mapping->backing_dev_info.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2012-10-29 18:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 10:19 semi-stable page writes Darrick J. Wong
2012-10-27 1:35 ` [RFC PATCH 1/2] bdi: Create a flag to indicate that a backing device needs stable " Darrick J. Wong
2012-10-29 18:13 ` Jan Kara
2012-10-29 18:30 ` Jan Kara
2012-10-29 23:48 ` NeilBrown
2012-10-30 0:10 ` Jan Kara
2012-10-30 0:34 ` NeilBrown
2012-10-30 13:38 ` Jan Kara
2012-10-30 21:49 ` NeilBrown
2012-10-30 4:10 ` Martin K. Petersen
2012-10-30 4:48 ` NeilBrown
2012-10-30 12:19 ` Martin K. Petersen
2012-10-30 20:14 ` Darrick J. Wong
2012-10-30 22:14 ` NeilBrown
2012-10-30 23:58 ` Boaz Harrosh
2012-10-31 8:56 ` Darrick J. Wong
2012-10-31 11:56 ` Jan Kara
2012-10-31 19:36 ` Darrick J. Wong
2012-10-31 23:12 ` Boaz Harrosh
2012-11-01 5:51 ` Darrick J. Wong
2012-11-01 6:25 ` Boaz Harrosh
2012-11-01 8:59 ` Jan Kara
2012-11-01 17:24 ` Boaz Harrosh
2012-11-01 22:42 ` Jan Kara
2012-10-30 22:40 ` Boaz Harrosh
2012-10-27 1:36 ` [RFC PATCH 2/2] mm: Gate stable page writes on the bdi flag Darrick J. Wong
2012-10-29 18:28 ` Jan Kara [this message]
2012-10-31 8:58 ` Darrick J. Wong
2012-10-29 22:01 ` semi-stable page writes Dave Chinner
2012-10-30 1:00 ` Theodore Ts'o
2012-10-30 23:30 ` Dave Chinner
2012-10-31 11:45 ` Jan Kara
2012-10-30 20:40 ` Darrick J. Wong
2012-10-30 23:43 ` Dave Chinner
2012-10-31 9:05 ` Darrick J. Wong
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=20121029182857.GI18767@quack.suse.cz \
--to=jack@suse.cz \
--cc=darrick.wong@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
/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).