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 CH |
19 | #include "xfs_vnodeops.h" |
20 | ||
21 | /* | |
22 | * The following six includes are needed so that we can include | |
23 | * xfs_inode.h. What a mess.. | |
24 | */ | |
25 | #include "xfs_bmap_btree.h" | |
26 | #include "xfs_inum.h" | |
27 | #include "xfs_dir2.h" | |
28 | #include "xfs_dir2_sf.h" | |
29 | #include "xfs_attr_sf.h" | |
30 | #include "xfs_dinode.h" | |
31 | ||
32 | #include "xfs_inode.h" | |
1da177e4 | 33 | |
7d4fb40a NS |
34 | int fs_noerr(void) { return 0; } |
35 | int fs_nosys(void) { return ENOSYS; } | |
36 | void fs_noval(void) { return; } | |
1da177e4 | 37 | |
1da177e4 | 38 | void |
993386c1 CH |
39 | xfs_tosspages( |
40 | xfs_inode_t *ip, | |
1da177e4 LT |
41 | xfs_off_t first, |
42 | xfs_off_t last, | |
43 | int fiopt) | |
44 | { | |
993386c1 CH |
45 | bhv_vnode_t *vp = XFS_ITOV(ip); |
46 | struct inode *inode = vn_to_inode(vp); | |
1da177e4 LT |
47 | |
48 | if (VN_CACHED(vp)) | |
993386c1 | 49 | truncate_inode_pages(inode->i_mapping, first); |
1da177e4 LT |
50 | } |
51 | ||
d3cf2094 | 52 | int |
993386c1 CH |
53 | xfs_flushinval_pages( |
54 | xfs_inode_t *ip, | |
1da177e4 LT |
55 | xfs_off_t first, |
56 | xfs_off_t last, | |
57 | int fiopt) | |
58 | { | |
993386c1 CH |
59 | bhv_vnode_t *vp = XFS_ITOV(ip); |
60 | struct inode *inode = vn_to_inode(vp); | |
d3cf2094 | 61 | int ret = 0; |
1da177e4 LT |
62 | |
63 | if (VN_CACHED(vp)) { | |
b3aea4ed | 64 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
993386c1 | 65 | ret = filemap_write_and_wait(inode->i_mapping); |
d3cf2094 | 66 | if (!ret) |
993386c1 | 67 | truncate_inode_pages(inode->i_mapping, first); |
1da177e4 | 68 | } |
d3cf2094 | 69 | return ret; |
1da177e4 LT |
70 | } |
71 | ||
1da177e4 | 72 | int |
993386c1 CH |
73 | xfs_flush_pages( |
74 | xfs_inode_t *ip, | |
1da177e4 LT |
75 | xfs_off_t first, |
76 | xfs_off_t last, | |
77 | uint64_t flags, | |
78 | int fiopt) | |
79 | { | |
993386c1 CH |
80 | bhv_vnode_t *vp = XFS_ITOV(ip); |
81 | struct inode *inode = vn_to_inode(vp); | |
d3cf2094 LM |
82 | int ret = 0; |
83 | int ret2; | |
1da177e4 | 84 | |
7d4fb40a | 85 | if (VN_DIRTY(vp)) { |
b3aea4ed | 86 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
993386c1 | 87 | ret = filemap_fdatawrite(inode->i_mapping); |
ee34807a | 88 | if (flags & XFS_B_ASYNC) |
d3cf2094 | 89 | return ret; |
993386c1 | 90 | ret2 = filemap_fdatawait(inode->i_mapping); |
d3cf2094 LM |
91 | if (!ret) |
92 | ret = ret2; | |
1da177e4 | 93 | } |
d3cf2094 | 94 | return ret; |
1da177e4 | 95 | } |