[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110519224903.28755.2703.stgit@elm3c44.beaverton.ibm.com>
Date: Thu, 19 May 2011 15:49:03 -0700
From: "Darrick J. Wong" <djwong@...ibm.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
"Darrick J. Wong" <djwong@...ibm.com>
Cc: Jens Axboe <axboe@...nel.dk>, Theodore Tso <tytso@....edu>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Jeff Layton <jlayton@...hat.com>,
Dave Chinner <david@...morbit.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Christoph Hellwig <hch@...radead.org>, linux-mm@...ck.org,
Chris Mason <chris.mason@...cle.com>,
Joel Becker <jlbec@...lplan.org>,
linux-scsi <linux-scsi@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Jan Kara <jack@...e.cz>, linux-ext4@...r.kernel.org,
Mingming Cao <mcao@...ibm.com>
Subject: [PATCH 3/3] mm: Provide stub page_mkwrite functionality to stabilize
pages during writes
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@...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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists