2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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.
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.
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
20 #include "xfs_types.h"
24 #include "xfs_trans.h"
28 #include "xfs_dmapi.h"
29 #include "xfs_mount.h"
30 #include "xfs_da_btree.h"
31 #include "xfs_bmap_btree.h"
32 #include "xfs_ialloc_btree.h"
33 #include "xfs_alloc_btree.h"
34 #include "xfs_dir2_sf.h"
35 #include "xfs_attr_sf.h"
36 #include "xfs_dinode.h"
37 #include "xfs_inode.h"
38 #include "xfs_inode_item.h"
39 #include "xfs_btree.h"
40 #include "xfs_alloc.h"
41 #include "xfs_ialloc.h"
42 #include "xfs_quota.h"
43 #include "xfs_error.h"
46 #include "xfs_buf_item.h"
47 #include "xfs_log_priv.h"
48 #include "xfs_dir2_trace.h"
49 #include "xfs_extfree_item.h"
53 #include "xfs_mru_cache.h"
54 #include "xfs_filestream.h"
55 #include "xfs_fsops.h"
56 #include "xfs_vnodeops.h"
57 #include "xfs_vfsops.h"
58 #include "xfs_utils.h"
63 * xfs_unmount_flush implements a set of flush operation on special
64 * inodes, which are needed as a separate set of operations so that
65 * they can be called as part of relocation process.
69 xfs_mount_t *mp, /* Mount structure we are getting
71 int relocation) /* Called from vfs relocation. */
73 xfs_inode_t *rip = mp->m_rootip;
75 xfs_inode_t *rsumip = NULL;
78 xfs_ilock(rip, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
82 * Flush out the real time inodes.
84 if ((rbmip = mp->m_rbmip) != NULL) {
85 xfs_ilock(rbmip, XFS_ILOCK_EXCL);
87 error = xfs_iflush(rbmip, XFS_IFLUSH_SYNC);
88 xfs_iunlock(rbmip, XFS_ILOCK_EXCL);
90 if (error == EFSCORRUPTED)
93 ASSERT(vn_count(VFS_I(rbmip)) == 1);
95 rsumip = mp->m_rsumip;
96 xfs_ilock(rsumip, XFS_ILOCK_EXCL);
98 error = xfs_iflush(rsumip, XFS_IFLUSH_SYNC);
99 xfs_iunlock(rsumip, XFS_ILOCK_EXCL);
101 if (error == EFSCORRUPTED)
104 ASSERT(vn_count(VFS_I(rsumip)) == 1);
108 * Synchronously flush root inode to disk
110 error = xfs_iflush(rip, XFS_IFLUSH_SYNC);
111 if (error == EFSCORRUPTED)
114 if (vn_count(VFS_I(rip)) != 1 && !relocation) {
115 xfs_iunlock(rip, XFS_ILOCK_EXCL);
116 return XFS_ERROR(EBUSY);
120 * Release dquot that rootinode, rbmino and rsumino might be holding,
121 * flush and purge the quota inodes.
123 error = XFS_QM_UNMOUNT(mp);
124 if (error == EFSCORRUPTED)
132 xfs_iunlock(rip, XFS_ILOCK_EXCL);
139 xfs_iunlock(rip, XFS_ILOCK_EXCL);
141 return XFS_ERROR(EFSCORRUPTED);