2 * Copyright (c) 2000-2006 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"
27 #include "xfs_mount.h"
28 #include "xfs_bmap_btree.h"
29 #include "xfs_dinode.h"
30 #include "xfs_inode.h"
31 #include "xfs_error.h"
35 * Force a shutdown of the filesystem instantly while keeping
36 * the filesystem consistent. We don't do an unmount here; just shutdown
37 * the shop, make sure that absolutely nothing persistent happens to
38 * this filesystem after this point.
41 xfs_do_force_shutdown(
49 logerror
= flags
& SHUTDOWN_LOG_IO_ERROR
;
51 if (!(flags
& SHUTDOWN_FORCE_UMOUNT
)) {
53 "%s(0x%x) called from line %d of file %s. Return address = 0x%p",
54 __func__
, flags
, lnnum
, fname
, __return_address
);
57 * No need to duplicate efforts.
59 if (XFS_FORCED_SHUTDOWN(mp
) && !logerror
)
63 * This flags XFS_MOUNT_FS_SHUTDOWN, makes sure that we don't
64 * queue up anybody new on the log reservations, and wakes up
65 * everybody who's sleeping on log reservations to tell them
68 if (xfs_log_force_umount(mp
, logerror
))
71 if (flags
& SHUTDOWN_CORRUPT_INCORE
) {
72 xfs_alert_tag(mp
, XFS_PTAG_SHUTDOWN_CORRUPT
,
73 "Corruption of in-memory data detected. Shutting down filesystem");
74 if (XFS_ERRLEVEL_HIGH
<= xfs_error_level
)
76 } else if (!(flags
& SHUTDOWN_FORCE_UMOUNT
)) {
78 xfs_alert_tag(mp
, XFS_PTAG_SHUTDOWN_LOGERROR
,
79 "Log I/O Error Detected. Shutting down filesystem");
80 } else if (flags
& SHUTDOWN_DEVICE_REQ
) {
81 xfs_alert_tag(mp
, XFS_PTAG_SHUTDOWN_IOERROR
,
82 "All device paths lost. Shutting down filesystem");
83 } else if (!(flags
& SHUTDOWN_REMOTE_REQ
)) {
84 xfs_alert_tag(mp
, XFS_PTAG_SHUTDOWN_IOERROR
,
85 "I/O Error Detected. Shutting down filesystem");
88 if (!(flags
& SHUTDOWN_FORCE_UMOUNT
)) {
90 "Please umount the filesystem and rectify the problem(s)");
95 * This isn't an absolute requirement, but it is
96 * just a good idea to call xfs_read_buf instead of
97 * directly doing a read_buf call. For one, we shouldn't
98 * be doing this disk read if we are in SHUTDOWN state anyway,
99 * so this stops that from happening. Secondly, this does all
100 * the error checking stuff and the brelse if appropriate for
101 * the caller, so the code can be a little leaner.
106 struct xfs_mount
*mp
,
107 xfs_buftarg_t
*target
,
117 flags
= XBF_LOCK
| XBF_MAPPED
;
119 bp
= xfs_buf_read(target
, blkno
, len
, flags
);
121 return XFS_ERROR(EIO
);
123 if (!error
&& !XFS_FORCED_SHUTDOWN(mp
)) {
128 xfs_buf_ioerror_alert(bp
, __func__
);
130 error
= XFS_ERROR(EIO
);
136 * brelse clears B_ERROR and b_error
145 * helper function to extract extent size hint from inode
149 struct xfs_inode
*ip
)
151 if ((ip
->i_d
.di_flags
& XFS_DIFLAG_EXTSIZE
) && ip
->i_d
.di_extsize
)
152 return ip
->i_d
.di_extsize
;
153 if (XFS_IS_REALTIME_INODE(ip
))
154 return ip
->i_mount
->m_sb
.sb_rextsize
;