From: "Darrick J. Wong" <djwong@us.ibm.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
"Darrick J. Wong" <djwong@us.ibm.com>
Cc: Jens Axboe <axboe@kernel.dk>, Theodore Tso <tytso@mit.edu>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Jeff Layton <jlayton@redhat.com>,
Dave Chinner <david@fromorbit.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Christoph Hellwig <hch@infradead.org>,
linux-mm@kvack.org, Chris Mason <chris.mason@oracle.com>,
Joel Becker <jlbec@evilplan.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Jan Kara <jack@suse.cz>,
linux-ext4@vger.kernel.org, Mingming Cao <mcao@us.ibm.com>
Subject: [PATCH 3/3] mm: Provide stub page_mkwrite functionality to stabilize pages during writes
Date: Thu, 19 May 2011 15:49:03 -0700 [thread overview]
Message-ID: <20110519224903.28755.2703.stgit@elm3c44.beaverton.ibm.com> (raw)
In-Reply-To: <20110519224841.28755.80650.stgit@elm3c44.beaverton.ibm.com>
For filesystems that do not provide any page_mkwrite handler, provide a stub
page_mkwrite function that locks the page and waits for pending writeback to
complete. This is needed to stabilize pages during writes for a large variety
of filesystem drivers (ext2, ext3, vfat, hfs...).
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
mm/filemap.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index fd0e7f2..2a922b4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1713,8 +1713,27 @@ page_not_uptodate:
}
EXPORT_SYMBOL(filemap_fault);
+static int stub_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+ struct page *page = vmf->page;
+ struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
+ loff_t size;
+
+ lock_page(page);
+ size = i_size_read(inode);
+ if ((page->mapping != inode->i_mapping) ||
+ (page_offset(page) > size)) {
+ /* page got truncated out from underneath us */
+ unlock_page(page);
+ return VM_FAULT_NOPAGE;
+ }
+ wait_on_page_writeback(page);
+ return VM_FAULT_LOCKED;
+}
+
const struct vm_operations_struct generic_file_vm_ops = {
.fault = filemap_fault,
+ .page_mkwrite = stub_page_mkwrite,
};
/* This is used for a general mmap of a disk file */
--
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>
next prev parent reply other threads:[~2011-05-19 22:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-19 22:48 [PATCHSET v3.2 0/3] data integrity: Stabilize pages during writeback for various fses Darrick J. Wong
2011-05-19 22:48 ` [PATCH 1/3] mm: Wait for writeback when grabbing pages to begin a write Darrick J. Wong
2011-05-19 22:48 ` [PATCH 2/3] fs: block_page_mkwrite should wait for writeback to finish Darrick J. Wong
2011-05-19 22:49 ` Darrick J. Wong [this message]
2011-05-27 7:33 ` [PATCHSET v3.2 0/3] data integrity: Stabilize pages during writeback for various fses Christoph Hellwig
2011-05-27 16:20 ` 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=20110519224903.28755.2703.stgit@elm3c44.beaverton.ibm.com \
--to=djwong@us.ibm.com \
--cc=axboe@kernel.dk \
--cc=chris.mason@oracle.com \
--cc=dave@linux.vnet.ibm.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jlayton@redhat.com \
--cc=jlbec@evilplan.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mcao@us.ibm.com \
--cc=tytso@mit.edu \
--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).