commit 15d3e53d9a2a590763c28a0bbc8af0df20e501c9
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Sun May 20 14:54:57 2007 -0400
mmap: file revalidation and fanout invariant validation
Added the newer checks to file revalidation and fanout invariants to the
newly merged mmap code. Also minor mmap related comments added.
Conflicts:
fs/unionfs/commonfops.c
fs/unionfs/file.c
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index
dd37c9fd6bedaac79ef801877916d627145c06b3..1120ebd9f7f6d7b765997374e83d7a82ab08d605
100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -694,6 +694,10 @@ int unionfs_file_release(struct inode *i
*/
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
+ fileinfo = UNIONFS_F(file);
+ BUG_ON(file->f_dentry->d_inode != inode);
+ inodeinfo = UNIONFS_I(inode);
+
/* fput all the hidden files */
fgen = atomic_read(&fileinfo->generation);
bstart = fbstart(file);
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index
9cf5d44a5d91626c840f1cc65c4e2c390764221a..373679b71c4837ada9e5cd5993bb8559405edc71
100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -275,7 +275,8 @@ static int __copyup_reg_data(struct dent
kfree(buf);
if (!err)
- err = output_file->f_op->fsync(output_file, new_hidden_dentry,
0);
+ err = output_file->f_op->fsync(output_file,
+ new_hidden_dentry, 0);
if (err)
goto out_close_out;
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index
7e7cbf8ba9b5e72652664bc4435ce4a04df1761b..59b1c918f134540e037974f2d09ab008e1857504
100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -28,6 +28,7 @@ static ssize_t unionfs_read(struct file
int err;
unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
if ((err = unionfs_file_revalidate(file, 0)))
goto out;
@@ -46,7 +47,13 @@ out:
static ssize_t unionfs_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
- int err;
+ int err = 0;
+ struct file *file = iocb->ki_filp;
+
+ unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
+ if ((err = unionfs_file_revalidate(file, 0)))
+ goto out;
err = generic_file_aio_read(iocb, iov, nr_segs, pos);
@@ -54,17 +61,21 @@ static ssize_t unionfs_aio_read(struct k
err = wait_on_sync_kiocb(iocb);
if (err >= 0)
- touch_atime(unionfs_lower_mnt(iocb->ki_filp->f_path.dentry),
- unionfs_lower_dentry(iocb->ki_filp->f_path.dentry));
+ touch_atime(unionfs_lower_mnt(file->f_path.dentry),
+ unionfs_lower_dentry(file->f_path.dentry));
+out:
+ unionfs_read_unlock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
return err;
}
static ssize_t unionfs_write(struct file * file, const char __user * buf,
- size_t count, loff_t * ppos)
+ size_t count, loff_t *ppos)
{
int err = 0;
unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
@@ -88,7 +99,11 @@ static int unionfs_mmap(struct file *fil
int willwrite;
unionfs_read_lock(file->f_dentry->d_sb);
- /* This might could be deferred to mmap's writepage. */
+ unionfs_check_file(file);
+ if ((err = unionfs_file_revalidate(file, 1)))
+ goto out;
+
+ /* This might be deferred to mmap's writepage */
willwrite = ((vma->vm_flags | VM_SHARED | VM_WRITE) == vma->vm_flags);
if ((err = unionfs_file_revalidate(file, willwrite)))
goto out;
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index
88b46136b3daf3ece875cc55b3ede7d88a2c188d..b5d4a2e02a1f4fcb7dc10410131414a9427c2f24
100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -801,6 +801,7 @@ static int unionfs_setattr(struct dentry
break;
}
+ /* for mmap */
if (ia->ia_valid & ATTR_SIZE) {
if (ia->ia_size != i_size_read(inode)) {
err = vmtruncate(inode, ia->ia_size);
diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index
93aba3ae81a8e335fa288ef53c7235c1cc22fae2..ccad33f3b131c2409380121efabfd7291d568d4c
100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -163,8 +163,9 @@ int unionfs_readpage(struct file *file,
int err;
unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
if ((err = unionfs_file_revalidate(file, 0)))
- goto out_err;
+ goto out;
err = unionfs_do_readpage(file, page);
@@ -177,9 +178,9 @@ int unionfs_readpage(struct file *file,
* page. but we no longer have to wakeup on our page here, b/c
* UnlockPage does it
*/
-
-out_err:
+out:
unlock_page(page);
+ unionfs_check_file(file);
unionfs_read_unlock(file->f_dentry->d_sb);
return err;
@@ -191,7 +192,9 @@ int unionfs_prepare_write(struct file *f
int err;
unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
err = unionfs_file_revalidate(file, 1);
+ unionfs_check_file(file);
unionfs_read_unlock(file->f_dentry->d_sb);
return err;
@@ -211,6 +214,7 @@ int unionfs_commit_write(struct file *fi
BUG_ON(file == NULL);
unionfs_read_lock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
@@ -220,7 +224,8 @@ int unionfs_commit_write(struct file *fi
if (UNIONFS_F(file) != NULL)
lower_file = unionfs_lower_file(file);
- BUG_ON(lower_file == NULL); /* FIXME: is this assertion right here?
*/
+ /* FIXME: is this assertion right here? */
+ BUG_ON(lower_file == NULL);
page_data = (char *)kmap(page);
lower_file->f_pos = (page->index << PAGE_CACHE_SHIFT) + from;
@@ -261,6 +266,7 @@ out:
ClearPageUptodate(page);
unionfs_read_unlock(file->f_dentry->d_sb);
+ unionfs_check_file(file);
return err; /* assume all is ok */
}
@@ -281,6 +287,10 @@ void unionfs_sync_page(struct page *page
/* do the actual sync */
mapping = lower_page->mapping;
+ /*
+ * XXX: can we optimize ala RAIF and set the lower page to be
+ * discarded after a successful sync_page?
+ */
if (mapping && mapping->a_ops && mapping->a_ops->sync_page)
mapping->a_ops->sync_page(lower_page);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs