From: Erez_Zadok Date: Sat, 5 May 2007 23:27:33 +0000 (-0400) Subject: mmap: proper locking to interoperate with branch-management code X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=4a28fbec9f3a59b7ab42c8434d8801014d20e0d8;p=unionfs-3.6.y.git 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 5302dcdfa12..ade8c926b26 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 */ }