aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/Makefile1
-rw-r--r--fs/xfs/xfs_dfrag.c10
-rw-r--r--fs/xfs/xfs_file.c23
-rw-r--r--fs/xfs/xfs_fs_subr.c46
-rw-r--r--fs/xfs/xfs_vnodeops.c11
-rw-r--r--fs/xfs/xfs_vnodeops.h2
6 files changed, 21 insertions, 72 deletions
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index e65357bb3dc6..d02201df855b 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -37,7 +37,6 @@ xfs-y += xfs_aops.o \
37 xfs_file.o \ 37 xfs_file.o \
38 xfs_filestream.o \ 38 xfs_filestream.o \
39 xfs_fsops.o \ 39 xfs_fsops.o \
40 xfs_fs_subr.o \
41 xfs_globals.o \ 40 xfs_globals.o \
42 xfs_icache.o \ 41 xfs_icache.o \
43 xfs_ioctl.o \ 42 xfs_ioctl.o \
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index b2c63a28afa7..d0e9c74d3d96 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -246,12 +246,10 @@ xfs_swap_extents(
246 goto out_unlock; 246 goto out_unlock;
247 } 247 }
248 248
249 if (VN_CACHED(VFS_I(tip)) != 0) { 249 error = -filemap_write_and_wait(VFS_I(ip)->i_mapping);
250 error = xfs_flushinval_pages(tip, 0, -1, 250 if (error)
251 FI_REMAPF_LOCKED); 251 goto out_unlock;
252 if (error) 252 truncate_pagecache_range(VFS_I(ip), 0, -1);
253 goto out_unlock;
254 }
255 253
256 /* Verify O_DIRECT for ftmp */ 254 /* Verify O_DIRECT for ftmp */
257 if (VN_CACHED(VFS_I(tip)) != 0) { 255 if (VN_CACHED(VFS_I(tip)) != 0) {
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index daf4066c24b2..c42f99e71f14 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -255,15 +255,14 @@ xfs_file_aio_read(
255 xfs_buftarg_t *target = 255 xfs_buftarg_t *target =
256 XFS_IS_REALTIME_INODE(ip) ? 256 XFS_IS_REALTIME_INODE(ip) ?
257 mp->m_rtdev_targp : mp->m_ddev_targp; 257 mp->m_rtdev_targp : mp->m_ddev_targp;
258 if ((iocb->ki_pos & target->bt_smask) || 258 if ((pos & target->bt_smask) || (size & target->bt_smask)) {
259 (size & target->bt_smask)) { 259 if (pos == i_size_read(inode))
260 if (iocb->ki_pos == i_size_read(inode))
261 return 0; 260 return 0;
262 return -XFS_ERROR(EINVAL); 261 return -XFS_ERROR(EINVAL);
263 } 262 }
264 } 263 }
265 264
266 n = mp->m_super->s_maxbytes - iocb->ki_pos; 265 n = mp->m_super->s_maxbytes - pos;
267 if (n <= 0 || size == 0) 266 if (n <= 0 || size == 0)
268 return 0; 267 return 0;
269 268
@@ -289,20 +288,21 @@ xfs_file_aio_read(
289 xfs_rw_ilock(ip, XFS_IOLOCK_EXCL); 288 xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
290 289
291 if (inode->i_mapping->nrpages) { 290 if (inode->i_mapping->nrpages) {
292 ret = -xfs_flushinval_pages(ip, 291 ret = -filemap_write_and_wait_range(
293 (iocb->ki_pos & PAGE_CACHE_MASK), 292 VFS_I(ip)->i_mapping,
294 -1, FI_REMAPF_LOCKED); 293 pos, -1);
295 if (ret) { 294 if (ret) {
296 xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL); 295 xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL);
297 return ret; 296 return ret;
298 } 297 }
298 truncate_pagecache_range(VFS_I(ip), pos, -1);
299 } 299 }
300 xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL); 300 xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
301 } 301 }
302 302
303 trace_xfs_file_read(ip, size, iocb->ki_pos, ioflags); 303 trace_xfs_file_read(ip, size, pos, ioflags);
304 304
305 ret = generic_file_aio_read(iocb, iovp, nr_segs, iocb->ki_pos); 305 ret = generic_file_aio_read(iocb, iovp, nr_segs, pos);
306 if (ret > 0) 306 if (ret > 0)
307 XFS_STATS_ADD(xs_read_bytes, ret); 307 XFS_STATS_ADD(xs_read_bytes, ret);
308 308
@@ -670,10 +670,11 @@ xfs_file_dio_aio_write(
670 goto out; 670 goto out;
671 671
672 if (mapping->nrpages) { 672 if (mapping->nrpages) {
673 ret = -xfs_flushinval_pages(ip, (pos & PAGE_CACHE_MASK), -1, 673 ret = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
674 FI_REMAPF_LOCKED); 674 pos, -1);
675 if (ret) 675 if (ret)
676 goto out; 676 goto out;
677 truncate_pagecache_range(VFS_I(ip), pos, -1);
677 } 678 }
678 679
679 /* 680 /*
diff --git a/fs/xfs/xfs_fs_subr.c b/fs/xfs/xfs_fs_subr.c
deleted file mode 100644
index b5380893728e..000000000000
--- a/fs/xfs/xfs_fs_subr.c
+++ /dev/null
@@ -1,46 +0,0 @@
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#include "xfs_trace.h"
23
24/*
25 * note: all filemap functions return negative error codes. These
26 * need to be inverted before returning to the xfs core functions.
27 */
28int
29xfs_flushinval_pages(
30 xfs_inode_t *ip,
31 xfs_off_t first,
32 xfs_off_t last,
33 int fiopt)
34{
35 struct address_space *mapping = VFS_I(ip)->i_mapping;
36 int ret = 0;
37
38 trace_xfs_pagecache_inval(ip, first, last);
39
40 xfs_iflags_clear(ip, XFS_ITRUNCATED);
41 ret = filemap_write_and_wait_range(mapping, first,
42 last == -1 ? LLONG_MAX : last);
43 if (!ret)
44 truncate_inode_pages_range(mapping, first, last);
45 return -ret;
46}
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index c00326afa7bf..81c61fd17890 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1958,12 +1958,11 @@ xfs_free_file_space(
1958 1958
1959 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1959 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
1960 ioffset = offset & ~(rounding - 1); 1960 ioffset = offset & ~(rounding - 1);
1961 1961 error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1962 if (VN_CACHED(VFS_I(ip)) != 0) { 1962 ioffset, -1);
1963 error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED); 1963 if (error)
1964 if (error) 1964 goto out_unlock_iolock;
1965 goto out_unlock_iolock; 1965 truncate_pagecache_range(VFS_I(ip), ioffset, -1);
1966 }
1967 1966
1968 /* 1967 /*
1969 * Need to zero the stuff we're not freeing, on disk. 1968 * Need to zero the stuff we're not freeing, on disk.
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 73cb3cb15f75..91a03fa3814f 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -48,8 +48,6 @@ int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name,
48int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags); 48int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags);
49int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, 49int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
50 int flags, struct attrlist_cursor_kern *cursor); 50 int flags, struct attrlist_cursor_kern *cursor);
51int xfs_flushinval_pages(struct xfs_inode *ip, xfs_off_t first,
52 xfs_off_t last, int fiopt);
53 51
54int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); 52int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t);
55int xfs_free_eofblocks(struct xfs_mount *, struct xfs_inode *, bool); 53int xfs_free_eofblocks(struct xfs_mount *, struct xfs_inode *, bool);