blob: 1eefe61f0e10baa80a68c416b7e4f92dba816538 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7d4fb402006-06-09 15:27:16 +10002 * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc.
Nathan Scott7b718762005-11-02 14:58:39 +11003 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
Christoph Hellwig993386c2007-08-28 16:12:30 +100019#include "xfs_vnodeops.h"
Christoph Hellwig993386c2007-08-28 16:12:30 +100020#include "xfs_bmap_btree.h"
Christoph Hellwig993386c2007-08-28 16:12:30 +100021#include "xfs_inode.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Nathan Scott7d4fb402006-06-09 15:27:16 +100023int fs_noerr(void) { return 0; }
24int fs_nosys(void) { return ENOSYS; }
25void fs_noval(void) { return; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027void
Christoph Hellwig993386c2007-08-28 16:12:30 +100028xfs_tosspages(
29 xfs_inode_t *ip,
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 xfs_off_t first,
31 xfs_off_t last,
32 int fiopt)
33{
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110034 struct address_space *mapping = ip->i_vnode->i_mapping;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110036 if (mapping->nrpages)
37 truncate_inode_pages(mapping, first);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100040int
Christoph Hellwig993386c2007-08-28 16:12:30 +100041xfs_flushinval_pages(
42 xfs_inode_t *ip,
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 xfs_off_t first,
44 xfs_off_t last,
45 int fiopt)
46{
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110047 struct address_space *mapping = ip->i_vnode->i_mapping;
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100048 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110050 if (mapping->nrpages) {
Christoph Hellwigb3aea4e2007-08-29 11:44:37 +100051 xfs_iflags_clear(ip, XFS_ITRUNCATED);
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110052 ret = filemap_write_and_wait(mapping);
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100053 if (!ret)
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110054 truncate_inode_pages(mapping, first);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 }
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100056 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059int
Christoph Hellwig993386c2007-08-28 16:12:30 +100060xfs_flush_pages(
61 xfs_inode_t *ip,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 xfs_off_t first,
63 xfs_off_t last,
64 uint64_t flags,
65 int fiopt)
66{
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110067 struct address_space *mapping = ip->i_vnode->i_mapping;
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100068 int ret = 0;
69 int ret2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110071 if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
Christoph Hellwigb3aea4e2007-08-29 11:44:37 +100072 xfs_iflags_clear(ip, XFS_ITRUNCATED);
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110073 ret = filemap_fdatawrite(mapping);
Nathan Scottee348072005-11-02 10:32:38 +110074 if (flags & XFS_B_ASYNC)
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100075 return ret;
Christoph Hellwiga8b3acd2008-03-06 13:44:41 +110076 ret2 = filemap_fdatawait(mapping);
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100077 if (!ret)
78 ret = ret2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 }
Lachlan McIlroyd3cf2092007-05-08 13:49:27 +100080 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}