Commit 3ae4c9deb30a8d5ee305b461625dcb298c9804a9
Committed by
Alex Elder
1 parent
cd07202cc8
Exists in
master
and in
7 other branches
xfs: use range primitives for xfs page cache operations
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@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Showing 1 changed file with 15 additions and 16 deletions Side-by-side Diff
fs/xfs/linux-2.6/xfs_fs_subr.c
... | ... | @@ -32,10 +32,9 @@ |
32 | 32 | xfs_off_t last, |
33 | 33 | int fiopt) |
34 | 34 | { |
35 | - struct address_space *mapping = VFS_I(ip)->i_mapping; | |
36 | - | |
37 | - if (mapping->nrpages) | |
38 | - truncate_inode_pages(mapping, first); | |
35 | + /* can't toss partial tail pages, so mask them out */ | |
36 | + last &= ~(PAGE_SIZE - 1); | |
37 | + truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last - 1); | |
39 | 38 | } |
40 | 39 | |
41 | 40 | int |
... | ... | @@ -50,12 +49,11 @@ |
50 | 49 | |
51 | 50 | trace_xfs_pagecache_inval(ip, first, last); |
52 | 51 | |
53 | - if (mapping->nrpages) { | |
54 | - xfs_iflags_clear(ip, XFS_ITRUNCATED); | |
55 | - ret = filemap_write_and_wait(mapping); | |
56 | - if (!ret) | |
57 | - truncate_inode_pages(mapping, first); | |
58 | - } | |
52 | + xfs_iflags_clear(ip, XFS_ITRUNCATED); | |
53 | + ret = filemap_write_and_wait_range(mapping, first, | |
54 | + last == -1 ? LLONG_MAX : last); | |
55 | + if (!ret) | |
56 | + truncate_inode_pages_range(mapping, first, last); | |
59 | 57 | return -ret; |
60 | 58 | } |
61 | 59 | |
... | ... | @@ -71,10 +69,9 @@ |
71 | 69 | int ret = 0; |
72 | 70 | int ret2; |
73 | 71 | |
74 | - if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { | |
75 | - xfs_iflags_clear(ip, XFS_ITRUNCATED); | |
76 | - ret = -filemap_fdatawrite(mapping); | |
77 | - } | |
72 | + xfs_iflags_clear(ip, XFS_ITRUNCATED); | |
73 | + ret = -filemap_fdatawrite_range(mapping, first, | |
74 | + last == -1 ? LLONG_MAX : last); | |
78 | 75 | if (flags & XBF_ASYNC) |
79 | 76 | return ret; |
80 | 77 | ret2 = xfs_wait_on_pages(ip, first, last); |
... | ... | @@ -91,8 +88,10 @@ |
91 | 88 | { |
92 | 89 | struct address_space *mapping = VFS_I(ip)->i_mapping; |
93 | 90 | |
94 | - if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) | |
95 | - return -filemap_fdatawait(mapping); | |
91 | + if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) { | |
92 | + return -filemap_fdatawait_range(mapping, first, | |
93 | + last == -1 ? ip->i_size - 1 : last); | |
94 | + } | |
96 | 95 | return 0; |
97 | 96 | } |