GIT: unionfs2-2.6.27.y: mmap: proper locking to interoperate with branch-management code

Erez Zadok ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:16:21 EDT 2010


commit 55fe9cfa13e6089659bfd8e2003b023b9ed02a6f
Author: Erez_Zadok <ezk at cs.sunysb.edu>
Date:   Sat May 5 19:27:33 2007 -0400

    mmap: proper locking to interoperate with branch-management code
    
    Include proper read un/lock calls as in file.c.  Make unionfs_do_readpage
    static as no one else should call this helper function.

diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index 5302dcd..ade8c92 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -73,7 +73,7 @@ out:
  *
  * Readpage expects a locked page, and must unlock it.
  */
-int unionfs_do_readpage(struct file *file, struct page *page)
+static int unionfs_do_readpage(struct file *file, struct page *page)
 {
 	int err = -EIO;
 	struct dentry *dentry;
@@ -162,6 +162,7 @@ int unionfs_readpage(struct file *file, struct page *page)
 {
 	int err;
 
+	unionfs_read_lock(file->f_dentry->d_sb);
 	if ((err = unionfs_file_revalidate(file, 0)))
 		goto out_err;
 
@@ -175,6 +176,7 @@ int unionfs_readpage(struct file *file, struct page *page)
 
 out_err:
 	unlock_page(page);
+	unionfs_read_unlock(file->f_dentry->d_sb);
 
 	return err;
 }
@@ -182,7 +184,13 @@ out_err:
 int unionfs_prepare_write(struct file *file, struct page *page, unsigned from,
 			  unsigned to)
 {
-	return unionfs_file_revalidate(file, 1);
+	int err;
+
+	unionfs_read_lock(file->f_dentry->d_sb);
+	err = unionfs_file_revalidate(file, 1);
+	unionfs_read_unlock(file->f_dentry->d_sb);
+
+	return err;
 }
 
 int unionfs_commit_write(struct file *file, struct page *page, unsigned from,
@@ -198,6 +206,7 @@ int unionfs_commit_write(struct file *file, struct page *page, unsigned from,
 
 	BUG_ON(file == NULL);
 
+	unionfs_read_lock(file->f_dentry->d_sb);
 	if ((err = unionfs_file_revalidate(file, 1)))
 		goto out;
 
@@ -247,6 +256,7 @@ out:
 	if (err < 0)
 		ClearPageUptodate(page);
 
+	unionfs_read_unlock(file->f_dentry->d_sb);
 	return err;		/* assume all is ok */
 }
 


More information about the unionfs-cvs mailing list