commit 217c29d47ca6ff3c9abbc8d1ab0d9649fa822143
Author: Erez Zadok <[EMAIL PROTECTED]>
Date:   Sun Sep 30 13:42:12 2007 -0400

    Unionfs: use page_offset() helper
    
    Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>

diff --git a/fs/unionfs/compat.h b/fs/unionfs/compat.h
index c8c2064..bb4540f 100644
--- a/fs/unionfs/compat.h
+++ b/fs/unionfs/compat.h
@@ -75,5 +75,12 @@ static inline int atomic_inc_return(atomic_t *v)
   return atomic_read(v);
 }
 
+/*
+ * Return byte-offset into filesystem object for page.
+ */
+static inline loff_t page_offset(struct page *page)
+{
+       return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
+}
 
 #endif /* _UNIONFS_COMPAT_H_ */
diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index f474e5d..695bade 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -175,8 +175,7 @@ static int unionfs_do_readpage(struct file *file, struct 
page *page)
         * may be a little slower, but a lot safer, as the VFS does a lot of
         * the necessary magic for us.
         */
-       offset = lower_file->f_pos =
-               ((loff_t) page->index << PAGE_CACHE_SHIFT);
+       offset = lower_file->f_pos = page_offset(page);
        old_fs = get_fs();
        set_fs(KERNEL_DS);
        err = vfs_read(lower_file, page_data, PAGE_CACHE_SIZE,
@@ -286,7 +285,7 @@ static int unionfs_commit_write(struct file *file, struct 
page *page,
        BUG_ON(lower_file == NULL);
 
        page_data = (char *)kmap(page);
-       lower_file->f_pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + from;
+       lower_file->f_pos = page_offset(page) + from;
 
        /*
         * We use vfs_write instead of copying page data and the
@@ -308,7 +307,7 @@ static int unionfs_commit_write(struct file *file, struct 
page *page,
 
        inode->i_blocks = lower_inode->i_blocks;
        /* we may have to update i_size */
-       pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + to;
+       pos = page_offset(page) + to;
        if (pos > i_size_read(inode))
                i_size_write(inode, pos);
        /* if vfs_write succeeded above, sync up our times */
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to