[Ocfs2-devel] [PATCH 2/3] ocfs2: Hold mmap_sem while calling get_user_pages()

Sunil Mushran sunil.mushran at oracle.com
Mon May 4 16:10:31 PDT 2009


From: Kurt Garloff <garloff at novell.com>

This patch adds locking around get_user_pages() in ocfs2_get_write_source()
so as to prevent the vmas from changing underneath.

Fixes Novell bugzilla# 485827

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 fs/ocfs2/file.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 0c8e03a..267389c 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1967,9 +1967,11 @@ static struct page * ocfs2_get_write_source(char **ret_src_buf,
 		 * of the meta data locks in order to preserve locking
 		 * order in case of page fault.
 		 */
+		down_read(&current->mm->mmap_sem);
 		ret = get_user_pages(current, current->mm,
 				     (unsigned long)buf & PAGE_CACHE_MASK, 1,
 				     0, 0, &src_page, NULL);
+		up_read(&current->mm->mmap_sem);
 		if (ret == 1)
 			*ret_src_buf = kmap(src_page) + off;
 		else
-- 
1.5.6.3




More information about the Ocfs2-devel mailing list