Blame view
fs/xfs/xfs_fs_subr.c
2.33 KB
1da177e4c
|
1 |
/* |
7d4fb40ad
|
2 |
* Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc. |
7b7187698
|
3 |
* All Rights Reserved. |
1da177e4c
|
4 |
* |
7b7187698
|
5 6 |
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as |
1da177e4c
|
7 8 |
* published by the Free Software Foundation. * |
7b7187698
|
9 10 11 12 |
* This program is distributed in the hope that it would be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. |
1da177e4c
|
13 |
* |
7b7187698
|
14 15 16 |
* You should have received a copy of the GNU General Public License * along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1da177e4c
|
17 |
*/ |
1da177e4c
|
18 |
#include "xfs.h" |
993386c19
|
19 |
#include "xfs_vnodeops.h" |
993386c19
|
20 |
#include "xfs_bmap_btree.h" |
993386c19
|
21 |
#include "xfs_inode.h" |
0b1b213fc
|
22 |
#include "xfs_trace.h" |
1da177e4c
|
23 |
|
2e6560929
|
24 25 26 27 |
/* * note: all filemap functions return negative error codes. These * need to be inverted before returning to the xfs core functions. */ |
1da177e4c
|
28 |
void |
993386c19
|
29 30 |
xfs_tosspages( xfs_inode_t *ip, |
1da177e4c
|
31 32 33 34 |
xfs_off_t first, xfs_off_t last, int fiopt) { |
3ae4c9deb
|
35 36 37 |
/* can't toss partial tail pages, so mask them out */ last &= ~(PAGE_SIZE - 1); truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last - 1); |
1da177e4c
|
38 |
} |
d3cf20947
|
39 |
int |
993386c19
|
40 41 |
xfs_flushinval_pages( xfs_inode_t *ip, |
1da177e4c
|
42 43 44 45 |
xfs_off_t first, xfs_off_t last, int fiopt) { |
016516462
|
46 |
struct address_space *mapping = VFS_I(ip)->i_mapping; |
d3cf20947
|
47 |
int ret = 0; |
1da177e4c
|
48 |
|
0b1b213fc
|
49 |
trace_xfs_pagecache_inval(ip, first, last); |
3ae4c9deb
|
50 51 52 53 54 |
xfs_iflags_clear(ip, XFS_ITRUNCATED); ret = filemap_write_and_wait_range(mapping, first, last == -1 ? LLONG_MAX : last); if (!ret) truncate_inode_pages_range(mapping, first, last); |
2e6560929
|
55 |
return -ret; |
1da177e4c
|
56 |
} |
1da177e4c
|
57 |
int |
993386c19
|
58 59 |
xfs_flush_pages( xfs_inode_t *ip, |
1da177e4c
|
60 61 62 63 64 |
xfs_off_t first, xfs_off_t last, uint64_t flags, int fiopt) { |
016516462
|
65 |
struct address_space *mapping = VFS_I(ip)->i_mapping; |
d3cf20947
|
66 67 |
int ret = 0; int ret2; |
1da177e4c
|
68 |
|
3ae4c9deb
|
69 70 71 |
xfs_iflags_clear(ip, XFS_ITRUNCATED); ret = -filemap_fdatawrite_range(mapping, first, last == -1 ? LLONG_MAX : last); |
0cadda1c5
|
72 |
if (flags & XBF_ASYNC) |
a8d770d98
|
73 74 75 76 77 |
return ret; ret2 = xfs_wait_on_pages(ip, first, last); if (!ret) ret = ret2; return ret; |
2e6560929
|
78 79 80 81 82 83 84 85 86 |
} int xfs_wait_on_pages( xfs_inode_t *ip, xfs_off_t first, xfs_off_t last) { struct address_space *mapping = VFS_I(ip)->i_mapping; |
3ae4c9deb
|
87 88 89 90 |
if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) { return -filemap_fdatawait_range(mapping, first, last == -1 ? ip->i_size - 1 : last); } |
2e6560929
|
91 |
return 0; |
1da177e4c
|
92 |
} |