* [PATCH v3 2/3] ext4: Wait for writeback to complete while making pages writable
[not found] ` <20110422000226.GA22189@tux1.beaverton.ibm.com>
@ 2011-05-04 17:41 ` Darrick J. Wong
2011-05-04 17:42 ` [PATCH v3 3/3] mm: Wait for writeback when grabbing pages to begin a write Darrick J. Wong
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2011-05-04 17:41 UTC (permalink / raw)
To: Theodore Ts'o
Cc: Christoph Hellwig, Chris Mason, Jeff Layton, Jan Kara,
Dave Chinner, Joel Becker, Martin K. Petersen, Jens Axboe,
linux-kernel, linux-fsdevel, Mingming Cao, linux-scsi,
Dave Hansen, linux-mm, linux-ext4
In order to stabilize pages during disk writes, ext4_page_mkwrite must wait for
writeback operations to complete before making a page writable. Furthermore,
the function must return locked pages, and recheck the writeback status if the
page lock is ever dropped.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
fs/ext4/inode.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3db34b2..1d162a2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5809,15 +5809,19 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
goto out_unlock;
}
ret = 0;
- if (PageMappedToDisk(page))
- goto out_unlock;
+
+ lock_page(page);
+ wait_on_page_writeback(page);
+ if (PageMappedToDisk(page)) {
+ up_read(&inode->i_alloc_sem);
+ return VM_FAULT_LOCKED;
+ }
if (page->index == size >> PAGE_CACHE_SHIFT)
len = size & ~PAGE_CACHE_MASK;
else
len = PAGE_CACHE_SIZE;
- lock_page(page);
/*
* return if we have all the buffers mapped. This avoid
* the need to call write_begin/write_end which does a
@@ -5827,8 +5831,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)) {
- unlock_page(page);
- goto out_unlock;
+ up_read(&inode->i_alloc_sem);
+ return VM_FAULT_LOCKED;
}
}
unlock_page(page);
@@ -5848,6 +5852,16 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
if (ret < 0)
goto out_unlock;
ret = 0;
+
+ /*
+ * write_begin/end might have created a dirty page and someone
+ * could wander in and start the IO. Make sure that hasn't
+ * happened.
+ */
+ lock_page(page);
+ wait_on_page_writeback(page);
+ up_read(&inode->i_alloc_sem);
+ return VM_FAULT_LOCKED;
out_unlock:
if (ret)
ret = VM_FAULT_SIGBUS;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3 3/3] mm: Wait for writeback when grabbing pages to begin a write
[not found] ` <20110422000226.GA22189@tux1.beaverton.ibm.com>
2011-05-04 17:41 ` [PATCH v3 2/3] ext4: Wait for writeback to complete while making pages writable Darrick J. Wong
@ 2011-05-04 17:42 ` Darrick J. Wong
2011-05-04 18:48 ` Christoph Hellwig
1 sibling, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2011-05-04 17:42 UTC (permalink / raw)
To: Theodore Ts'o
Cc: Christoph Hellwig, Chris Mason, Jeff Layton, Jan Kara,
Dave Chinner, Joel Becker, Martin K. Petersen, Jens Axboe,
linux-kernel, linux-fsdevel, Mingming Cao, linux-scsi,
Dave Hansen, linux-mm, linux-ext4
When grabbing a page for a buffered IO write, the mm should wait for writeback
on the page to complete so that the page does not become writable during the IO
operation.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
mm/filemap.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index c641edf..c22675f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2287,8 +2287,10 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
gfp_notmask = __GFP_FS;
repeat:
page = find_lock_page(mapping, index);
- if (page)
+ if (page) {
+ wait_on_page_writeback(page);
return page;
+ }
page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
if (!page)
@@ -2301,6 +2303,7 @@ repeat:
goto repeat;
return NULL;
}
+ wait_on_page_writeback(page);
return page;
}
EXPORT_SYMBOL(grab_cache_page_write_begin);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 3/3] mm: Wait for writeback when grabbing pages to begin a write
2011-05-04 17:42 ` [PATCH v3 3/3] mm: Wait for writeback when grabbing pages to begin a write Darrick J. Wong
@ 2011-05-04 18:48 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2011-05-04 18:48 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Theodore Ts'o, Christoph Hellwig, Chris Mason, Jeff Layton,
Jan Kara, Dave Chinner, Joel Becker, Martin K. Petersen,
Jens Axboe, linux-kernel, linux-fsdevel, Mingming Cao, linux-scsi,
Dave Hansen, linux-mm, linux-ext4
On Wed, May 04, 2011 at 10:42:27AM -0700, Darrick J. Wong wrote:
> When grabbing a page for a buffered IO write, the mm should wait for writeback
> on the page to complete so that the page does not become writable during the IO
> operation.
>
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> ---
>
> mm/filemap.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index c641edf..c22675f 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2287,8 +2287,10 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
> gfp_notmask = __GFP_FS;
> repeat:
> page = find_lock_page(mapping, index);
> - if (page)
> + if (page) {
> + wait_on_page_writeback(page);
> return page;
> + }
goto found;
>
> page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
> if (!page)
> @@ -2301,6 +2303,7 @@ repeat:
> goto repeat;
> return NULL;
> }
found:
> + wait_on_page_writeback(page);
> return page;
> }
> EXPORT_SYMBOL(grab_cache_page_write_begin);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-04 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20110321164305.GC7153@quack.suse.cz>
[not found] ` <20110406232938.GF1110@tux1.beaverton.ibm.com>
[not found] ` <20110407165700.GB7363@quack.suse.cz>
[not found] ` <20110408203135.GH1110@tux1.beaverton.ibm.com>
[not found] ` <20110411124229.47bc28f6@corrin.poochiereds.net>
[not found] ` <1302543595-sup-4352@think>
[not found] ` <1302569212.2580.13.camel@mingming-laptop>
[not found] ` <20110412005719.GA23077@infradead.org>
[not found] ` <1302742128.2586.274.camel@mingming-laptop>
[not found] ` <20110422000226.GA22189@tux1.beaverton.ibm.com>
2011-05-04 17:41 ` [PATCH v3 2/3] ext4: Wait for writeback to complete while making pages writable Darrick J. Wong
2011-05-04 17:42 ` [PATCH v3 3/3] mm: Wait for writeback when grabbing pages to begin a write Darrick J. Wong
2011-05-04 18:48 ` Christoph Hellwig
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).