xfs
[Top] [All Lists]

[PATCH 1/2] xfs: use range primitives for xfs page cache operations

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/2] xfs: use range primitives for xfs page cache operations
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 27 Jul 2010 15:55:28 +1000
In-reply-to: <1280210129-10925-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1280210129-10925-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

While XFS passes ranges to operate on from the core code, the
functions being called ignore the either the entire range or the end
of the range. This is historical because when the function were
written linux didn't have the necessary range operations. Update the
functions to use the correct operations.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/linux-2.6/xfs_fs_subr.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 1f279b0..e76d31d 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -32,10 +32,7 @@ xfs_tosspages(
        xfs_off_t       last,
        int             fiopt)
 {
-       struct address_space *mapping = VFS_I(ip)->i_mapping;
-
-       if (mapping->nrpages)
-               truncate_inode_pages(mapping, first);
+       truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last);
 }
 
 int
@@ -52,9 +49,10 @@ xfs_flushinval_pages(
 
        if (mapping->nrpages) {
                xfs_iflags_clear(ip, XFS_ITRUNCATED);
-               ret = filemap_write_and_wait(mapping);
+               ret = filemap_write_and_wait_range(mapping, first,
+                                       last == -1 ? LLONG_MAX : last);
                if (!ret)
-                       truncate_inode_pages(mapping, first);
+                       truncate_inode_pages_range(mapping, first, last);
        }
        return -ret;
 }
@@ -73,7 +71,8 @@ xfs_flush_pages(
 
        if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
                xfs_iflags_clear(ip, XFS_ITRUNCATED);
-               ret = -filemap_fdatawrite(mapping);
+               ret = -filemap_fdatawrite_range(mapping, first,
+                                       last == -1 ? LLONG_MAX : last);
        }
        if (flags & XBF_ASYNC)
                return ret;
@@ -91,7 +90,9 @@ xfs_wait_on_pages(
 {
        struct address_space *mapping = VFS_I(ip)->i_mapping;
 
-       if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
-               return -filemap_fdatawait(mapping);
+       if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
+               return -filemap_fdatawait_range(mapping, first,
+                                       last == -1 ? ip->i_size - 1 : last);
+       }
        return 0;
 }
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>