• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
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
7  * published by the Free Software Foundation.
8  *
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.
13  *
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
17  */
18 #include "xfs.h"
19 #include "xfs_vnodeops.h"
20 #include "xfs_bmap_btree.h"
21 #include "xfs_inode.h"
22 
fs_noerr(void)23 int  fs_noerr(void) { return 0; }
fs_nosys(void)24 int  fs_nosys(void) { return ENOSYS; }
fs_noval(void)25 void fs_noval(void) { return; }
26 
27 /*
28  * note: all filemap functions return negative error codes. These
29  * need to be inverted before returning to the xfs core functions.
30  */
31 void
xfs_tosspages(xfs_inode_t * ip,xfs_off_t first,xfs_off_t last,int fiopt)32 xfs_tosspages(
33 	xfs_inode_t	*ip,
34 	xfs_off_t	first,
35 	xfs_off_t	last,
36 	int		fiopt)
37 {
38 	struct address_space *mapping = VFS_I(ip)->i_mapping;
39 
40 	if (mapping->nrpages)
41 		truncate_inode_pages(mapping, first);
42 }
43 
44 int
xfs_flushinval_pages(xfs_inode_t * ip,xfs_off_t first,xfs_off_t last,int fiopt)45 xfs_flushinval_pages(
46 	xfs_inode_t	*ip,
47 	xfs_off_t	first,
48 	xfs_off_t	last,
49 	int		fiopt)
50 {
51 	struct address_space *mapping = VFS_I(ip)->i_mapping;
52 	int		ret = 0;
53 
54 	if (mapping->nrpages) {
55 		xfs_iflags_clear(ip, XFS_ITRUNCATED);
56 		ret = filemap_write_and_wait(mapping);
57 		if (!ret)
58 			truncate_inode_pages(mapping, first);
59 	}
60 	return -ret;
61 }
62 
63 int
xfs_flush_pages(xfs_inode_t * ip,xfs_off_t first,xfs_off_t last,uint64_t flags,int fiopt)64 xfs_flush_pages(
65 	xfs_inode_t	*ip,
66 	xfs_off_t	first,
67 	xfs_off_t	last,
68 	uint64_t	flags,
69 	int		fiopt)
70 {
71 	struct address_space *mapping = VFS_I(ip)->i_mapping;
72 	int		ret = 0;
73 	int		ret2;
74 
75 	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
76 		xfs_iflags_clear(ip, XFS_ITRUNCATED);
77 		ret = filemap_fdatawrite(mapping);
78 		if (flags & XFS_B_ASYNC)
79 			return -ret;
80 		ret2 = filemap_fdatawait(mapping);
81 		if (!ret)
82 			ret = ret2;
83 	}
84 	return -ret;
85 }
86 
87 int
xfs_wait_on_pages(xfs_inode_t * ip,xfs_off_t first,xfs_off_t last)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;
98 }
99