Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
7d4fb40a | 2 | * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc. |
7b718769 | 3 | * All Rights Reserved. |
1da177e4 | 4 | * |
7b718769 NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
1da177e4 LT |
7 | * published by the Free Software Foundation. |
8 | * | |
7b718769 NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
1da177e4 | 13 | * |
7b718769 NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
1da177e4 | 17 | */ |
1da177e4 | 18 | #include "xfs.h" |
993386c1 | 19 | #include "xfs_vnodeops.h" |
993386c1 | 20 | #include "xfs_bmap_btree.h" |
993386c1 | 21 | #include "xfs_inode.h" |
1da177e4 | 22 | |
7d4fb40a NS |
23 | int fs_noerr(void) { return 0; } |
24 | int fs_nosys(void) { return ENOSYS; } | |
25 | void fs_noval(void) { return; } | |
1da177e4 | 26 | |
2e656092 DC |
27 | /* |
28 | * note: all filemap functions return negative error codes. These | |
29 | * need to be inverted before returning to the xfs core functions. | |
30 | */ | |
1da177e4 | 31 | void |
993386c1 CH |
32 | xfs_tosspages( |
33 | xfs_inode_t *ip, | |
1da177e4 LT |
34 | xfs_off_t first, |
35 | xfs_off_t last, | |
36 | int fiopt) | |
37 | { | |
01651646 | 38 | struct address_space *mapping = VFS_I(ip)->i_mapping; |
1da177e4 | 39 | |
a8b3acd5 CH |
40 | if (mapping->nrpages) |
41 | truncate_inode_pages(mapping, first); | |
1da177e4 LT |
42 | } |
43 | ||
d3cf2094 | 44 | int |
993386c1 CH |
45 | xfs_flushinval_pages( |
46 | xfs_inode_t *ip, | |
1da177e4 LT |
47 | xfs_off_t first, |
48 | xfs_off_t last, | |
49 | int fiopt) | |
50 | { | |
01651646 | 51 | struct address_space *mapping = VFS_I(ip)->i_mapping; |
d3cf2094 | 52 | int ret = 0; |
1da177e4 | 53 | |
a8b3acd5 | 54 | if (mapping->nrpages) { |
b3aea4ed | 55 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
a8b3acd5 | 56 | ret = filemap_write_and_wait(mapping); |
d3cf2094 | 57 | if (!ret) |
a8b3acd5 | 58 | truncate_inode_pages(mapping, first); |
1da177e4 | 59 | } |
2e656092 | 60 | return -ret; |
1da177e4 LT |
61 | } |
62 | ||
1da177e4 | 63 | int |
993386c1 CH |
64 | xfs_flush_pages( |
65 | xfs_inode_t *ip, | |
1da177e4 LT |
66 | xfs_off_t first, |
67 | xfs_off_t last, | |
68 | uint64_t flags, | |
69 | int fiopt) | |
70 | { | |
01651646 | 71 | struct address_space *mapping = VFS_I(ip)->i_mapping; |
d3cf2094 LM |
72 | int ret = 0; |
73 | int ret2; | |
1da177e4 | 74 | |
a8b3acd5 | 75 | if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { |
b3aea4ed | 76 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
a8d770d9 | 77 | ret = -filemap_fdatawrite(mapping); |
1da177e4 | 78 | } |
a8d770d9 DC |
79 | if (flags & XFS_B_ASYNC) |
80 | return ret; | |
81 | ret2 = xfs_wait_on_pages(ip, first, last); | |
82 | if (!ret) | |
83 | ret = ret2; | |
84 | return ret; | |
2e656092 DC |
85 | } |
86 | ||
87 | int | |
88 | xfs_wait_on_pages( | |
89 | xfs_inode_t *ip, | |
90 | xfs_off_t first, | |
91 | xfs_off_t last) | |
92 | { | |
93 | struct address_space *mapping = VFS_I(ip)->i_mapping; | |
94 | ||
95 | if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) | |
96 | return -filemap_fdatawait(mapping); | |
97 | return 0; | |
1da177e4 | 98 | } |