aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c174
1 files changed, 76 insertions, 98 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 14faabaabf29..8ab7df768063 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1,66 +1,51 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
38#include "xfs_ag.h" 23#include "xfs_inum.h"
39#include "xfs_sb.h"
40#include "xfs_trans.h" 24#include "xfs_trans.h"
25#include "xfs_sb.h"
26#include "xfs_ag.h"
41#include "xfs_dir.h" 27#include "xfs_dir.h"
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_error.h" 31#include "xfs_error.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
47#include "xfs_alloc.h" 33#include "xfs_alloc_btree.h"
48#include "xfs_attr_sf.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
50#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
51#include "xfs_dinode.h" 38#include "xfs_dinode.h"
52#include "xfs_imap.h"
53#include "xfs_inode_item.h"
54#include "xfs_inode.h" 39#include "xfs_inode.h"
55#include "xfs_ialloc_btree.h" 40#include "xfs_inode_item.h"
41#include "xfs_imap.h"
42#include "xfs_alloc.h"
56#include "xfs_ialloc.h" 43#include "xfs_ialloc.h"
57#include "xfs_log_priv.h" 44#include "xfs_log_priv.h"
58#include "xfs_buf_item.h" 45#include "xfs_buf_item.h"
59#include "xfs_alloc_btree.h"
60#include "xfs_log_recover.h" 46#include "xfs_log_recover.h"
61#include "xfs_extfree_item.h" 47#include "xfs_extfree_item.h"
62#include "xfs_trans_priv.h" 48#include "xfs_trans_priv.h"
63#include "xfs_bit.h"
64#include "xfs_quota.h" 49#include "xfs_quota.h"
65#include "xfs_rw.h" 50#include "xfs_rw.h"
66 51
@@ -2013,79 +1998,74 @@ xfs_qm_dqcheck(
2013 * This is all fine; things are still consistent, and we haven't lost 1998 * This is all fine; things are still consistent, and we haven't lost
2014 * any quota information. Just don't complain about bad dquot blks. 1999 * any quota information. Just don't complain about bad dquot blks.
2015 */ 2000 */
2016 if (INT_GET(ddq->d_magic, ARCH_CONVERT) != XFS_DQUOT_MAGIC) { 2001 if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) {
2017 if (flags & XFS_QMOPT_DOWARN) 2002 if (flags & XFS_QMOPT_DOWARN)
2018 cmn_err(CE_ALERT, 2003 cmn_err(CE_ALERT,
2019 "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", 2004 "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x",
2020 str, id, 2005 str, id, be16_to_cpu(ddq->d_magic), XFS_DQUOT_MAGIC);
2021 INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_MAGIC);
2022 errs++; 2006 errs++;
2023 } 2007 }
2024 if (INT_GET(ddq->d_version, ARCH_CONVERT) != XFS_DQUOT_VERSION) { 2008 if (ddq->d_version != XFS_DQUOT_VERSION) {
2025 if (flags & XFS_QMOPT_DOWARN) 2009 if (flags & XFS_QMOPT_DOWARN)
2026 cmn_err(CE_ALERT, 2010 cmn_err(CE_ALERT,
2027 "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", 2011 "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x",
2028 str, id, 2012 str, id, ddq->d_version, XFS_DQUOT_VERSION);
2029 INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_VERSION);
2030 errs++; 2013 errs++;
2031 } 2014 }
2032 2015
2033 if (INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_USER && 2016 if (ddq->d_flags != XFS_DQ_USER &&
2034 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_PROJ && 2017 ddq->d_flags != XFS_DQ_PROJ &&
2035 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_GROUP) { 2018 ddq->d_flags != XFS_DQ_GROUP) {
2036 if (flags & XFS_QMOPT_DOWARN) 2019 if (flags & XFS_QMOPT_DOWARN)
2037 cmn_err(CE_ALERT, 2020 cmn_err(CE_ALERT,
2038 "%s : XFS dquot ID 0x%x, unknown flags 0x%x", 2021 "%s : XFS dquot ID 0x%x, unknown flags 0x%x",
2039 str, id, INT_GET(ddq->d_flags, ARCH_CONVERT)); 2022 str, id, ddq->d_flags);
2040 errs++; 2023 errs++;
2041 } 2024 }
2042 2025
2043 if (id != -1 && id != INT_GET(ddq->d_id, ARCH_CONVERT)) { 2026 if (id != -1 && id != be32_to_cpu(ddq->d_id)) {
2044 if (flags & XFS_QMOPT_DOWARN) 2027 if (flags & XFS_QMOPT_DOWARN)
2045 cmn_err(CE_ALERT, 2028 cmn_err(CE_ALERT,
2046 "%s : ondisk-dquot 0x%p, ID mismatch: " 2029 "%s : ondisk-dquot 0x%p, ID mismatch: "
2047 "0x%x expected, found id 0x%x", 2030 "0x%x expected, found id 0x%x",
2048 str, ddq, id, INT_GET(ddq->d_id, ARCH_CONVERT)); 2031 str, ddq, id, be32_to_cpu(ddq->d_id));
2049 errs++; 2032 errs++;
2050 } 2033 }
2051 2034
2052 if (!errs && ddq->d_id) { 2035 if (!errs && ddq->d_id) {
2053 if (INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT) && 2036 if (ddq->d_blk_softlimit &&
2054 INT_GET(ddq->d_bcount, ARCH_CONVERT) >= 2037 be64_to_cpu(ddq->d_bcount) >=
2055 INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT)) { 2038 be64_to_cpu(ddq->d_blk_softlimit)) {
2056 if (!ddq->d_btimer) { 2039 if (!ddq->d_btimer) {
2057 if (flags & XFS_QMOPT_DOWARN) 2040 if (flags & XFS_QMOPT_DOWARN)
2058 cmn_err(CE_ALERT, 2041 cmn_err(CE_ALERT,
2059 "%s : Dquot ID 0x%x (0x%p) " 2042 "%s : Dquot ID 0x%x (0x%p) "
2060 "BLK TIMER NOT STARTED", 2043 "BLK TIMER NOT STARTED",
2061 str, (int) 2044 str, (int)be32_to_cpu(ddq->d_id), ddq);
2062 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2063 errs++; 2045 errs++;
2064 } 2046 }
2065 } 2047 }
2066 if (INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT) && 2048 if (ddq->d_ino_softlimit &&
2067 INT_GET(ddq->d_icount, ARCH_CONVERT) >= 2049 be64_to_cpu(ddq->d_icount) >=
2068 INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT)) { 2050 be64_to_cpu(ddq->d_ino_softlimit)) {
2069 if (!ddq->d_itimer) { 2051 if (!ddq->d_itimer) {
2070 if (flags & XFS_QMOPT_DOWARN) 2052 if (flags & XFS_QMOPT_DOWARN)
2071 cmn_err(CE_ALERT, 2053 cmn_err(CE_ALERT,
2072 "%s : Dquot ID 0x%x (0x%p) " 2054 "%s : Dquot ID 0x%x (0x%p) "
2073 "INODE TIMER NOT STARTED", 2055 "INODE TIMER NOT STARTED",
2074 str, (int) 2056 str, (int)be32_to_cpu(ddq->d_id), ddq);
2075 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2076 errs++; 2057 errs++;
2077 } 2058 }
2078 } 2059 }
2079 if (INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT) && 2060 if (ddq->d_rtb_softlimit &&
2080 INT_GET(ddq->d_rtbcount, ARCH_CONVERT) >= 2061 be64_to_cpu(ddq->d_rtbcount) >=
2081 INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT)) { 2062 be64_to_cpu(ddq->d_rtb_softlimit)) {
2082 if (!ddq->d_rtbtimer) { 2063 if (!ddq->d_rtbtimer) {
2083 if (flags & XFS_QMOPT_DOWARN) 2064 if (flags & XFS_QMOPT_DOWARN)
2084 cmn_err(CE_ALERT, 2065 cmn_err(CE_ALERT,
2085 "%s : Dquot ID 0x%x (0x%p) " 2066 "%s : Dquot ID 0x%x (0x%p) "
2086 "RTBLK TIMER NOT STARTED", 2067 "RTBLK TIMER NOT STARTED",
2087 str, (int) 2068 str, (int)be32_to_cpu(ddq->d_id), ddq);
2088 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2089 errs++; 2069 errs++;
2090 } 2070 }
2091 } 2071 }
@@ -2103,10 +2083,11 @@ xfs_qm_dqcheck(
2103 ASSERT(id != -1); 2083 ASSERT(id != -1);
2104 ASSERT(flags & XFS_QMOPT_DQREPAIR); 2084 ASSERT(flags & XFS_QMOPT_DQREPAIR);
2105 memset(d, 0, sizeof(xfs_dqblk_t)); 2085 memset(d, 0, sizeof(xfs_dqblk_t));
2106 INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); 2086
2107 INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); 2087 d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
2108 INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); 2088 d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
2109 INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); 2089 d->dd_diskdq.d_flags = type;
2090 d->dd_diskdq.d_id = cpu_to_be32(id);
2110 2091
2111 return errs; 2092 return errs;
2112} 2093}
@@ -2226,8 +2207,9 @@ xlog_recover_do_buffer_trans(
2226 break; 2207 break;
2227 default: 2208 default:
2228 xfs_fs_cmn_err(CE_ALERT, log->l_mp, 2209 xfs_fs_cmn_err(CE_ALERT, log->l_mp,
2229 "xfs_log_recover: unknown buffer type 0x%x, dev %s", 2210 "xfs_log_recover: unknown buffer type 0x%x, logdev %s",
2230 buf_f->blf_type, XFS_BUFTARG_NAME(log->l_targ)); 2211 buf_f->blf_type, log->l_mp->m_logname ?
2212 log->l_mp->m_logname : "internal");
2231 XFS_ERROR_REPORT("xlog_recover_do_buffer_trans", 2213 XFS_ERROR_REPORT("xlog_recover_do_buffer_trans",
2232 XFS_ERRLEVEL_LOW, log->l_mp); 2214 XFS_ERRLEVEL_LOW, log->l_mp);
2233 return XFS_ERROR(EFSCORRUPTED); 2215 return XFS_ERROR(EFSCORRUPTED);
@@ -3178,13 +3160,12 @@ xlog_recover_clear_agi_bucket(
3178 } 3160 }
3179 3161
3180 agi = XFS_BUF_TO_AGI(agibp); 3162 agi = XFS_BUF_TO_AGI(agibp);
3181 if (INT_GET(agi->agi_magicnum, ARCH_CONVERT) != XFS_AGI_MAGIC) { 3163 if (be32_to_cpu(agi->agi_magicnum) != XFS_AGI_MAGIC) {
3182 xfs_trans_cancel(tp, XFS_TRANS_ABORT); 3164 xfs_trans_cancel(tp, XFS_TRANS_ABORT);
3183 return; 3165 return;
3184 } 3166 }
3185 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
3186 3167
3187 INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, NULLAGINO); 3168 agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
3188 offset = offsetof(xfs_agi_t, agi_unlinked) + 3169 offset = offsetof(xfs_agi_t, agi_unlinked) +
3189 (sizeof(xfs_agino_t) * bucket); 3170 (sizeof(xfs_agino_t) * bucket);
3190 xfs_trans_log_buf(tp, agibp, offset, 3171 xfs_trans_log_buf(tp, agibp, offset,
@@ -3243,12 +3224,11 @@ xlog_recover_process_iunlinks(
3243 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp))); 3224 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)));
3244 } 3225 }
3245 agi = XFS_BUF_TO_AGI(agibp); 3226 agi = XFS_BUF_TO_AGI(agibp);
3246 ASSERT(XFS_AGI_MAGIC == 3227 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agi->agi_magicnum));
3247 INT_GET(agi->agi_magicnum, ARCH_CONVERT));
3248 3228
3249 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { 3229 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
3250 3230
3251 agino = INT_GET(agi->agi_unlinked[bucket], ARCH_CONVERT); 3231 agino = be32_to_cpu(agi->agi_unlinked[bucket]);
3252 while (agino != NULLAGINO) { 3232 while (agino != NULLAGINO) {
3253 3233
3254 /* 3234 /*
@@ -3336,8 +3316,8 @@ xlog_recover_process_iunlinks(
3336 XFS_AGI_DADDR(mp))); 3316 XFS_AGI_DADDR(mp)));
3337 } 3317 }
3338 agi = XFS_BUF_TO_AGI(agibp); 3318 agi = XFS_BUF_TO_AGI(agibp);
3339 ASSERT(XFS_AGI_MAGIC == INT_GET( 3319 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(
3340 agi->agi_magicnum, ARCH_CONVERT)); 3320 agi->agi_magicnum));
3341 } 3321 }
3342 } 3322 }
3343 3323
@@ -3938,8 +3918,9 @@ xlog_recover(
3938 } 3918 }
3939 3919
3940 cmn_err(CE_NOTE, 3920 cmn_err(CE_NOTE,
3941 "Starting XFS recovery on filesystem: %s (dev: %s)", 3921 "Starting XFS recovery on filesystem: %s (logdev: %s)",
3942 log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); 3922 log->l_mp->m_fsname, log->l_mp->m_logname ?
3923 log->l_mp->m_logname : "internal");
3943 3924
3944 error = xlog_do_recover(log, head_blk, tail_blk); 3925 error = xlog_do_recover(log, head_blk, tail_blk);
3945 log->l_flags |= XLOG_RECOVERY_NEEDED; 3926 log->l_flags |= XLOG_RECOVERY_NEEDED;
@@ -3987,8 +3968,9 @@ xlog_recover_finish(
3987 xlog_recover_check_summary(log); 3968 xlog_recover_check_summary(log);
3988 3969
3989 cmn_err(CE_NOTE, 3970 cmn_err(CE_NOTE,
3990 "Ending XFS recovery on filesystem: %s (dev: %s)", 3971 "Ending XFS recovery on filesystem: %s (logdev: %s)",
3991 log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); 3972 log->l_mp->m_fsname, log->l_mp->m_logname ?
3973 log->l_mp->m_logname : "internal");
3992 log->l_flags &= ~XLOG_RECOVERY_NEEDED; 3974 log->l_flags &= ~XLOG_RECOVERY_NEEDED;
3993 } else { 3975 } else {
3994 cmn_err(CE_DEBUG, 3976 cmn_err(CE_DEBUG,
@@ -4038,14 +4020,12 @@ xlog_recover_check_summary(
4038 mp, agfbp, agfdaddr); 4020 mp, agfbp, agfdaddr);
4039 } 4021 }
4040 agfp = XFS_BUF_TO_AGF(agfbp); 4022 agfp = XFS_BUF_TO_AGF(agfbp);
4041 ASSERT(XFS_AGF_MAGIC == 4023 ASSERT(XFS_AGF_MAGIC == be32_to_cpu(agfp->agf_magicnum));
4042 INT_GET(agfp->agf_magicnum, ARCH_CONVERT)); 4024 ASSERT(XFS_AGF_GOOD_VERSION(be32_to_cpu(agfp->agf_versionnum)));
4043 ASSERT(XFS_AGF_GOOD_VERSION( 4025 ASSERT(be32_to_cpu(agfp->agf_seqno) == agno);
4044 INT_GET(agfp->agf_versionnum, ARCH_CONVERT))); 4026
4045 ASSERT(INT_GET(agfp->agf_seqno, ARCH_CONVERT) == agno); 4027 freeblks += be32_to_cpu(agfp->agf_freeblks) +
4046 4028 be32_to_cpu(agfp->agf_flcount);
4047 freeblks += INT_GET(agfp->agf_freeblks, ARCH_CONVERT) +
4048 INT_GET(agfp->agf_flcount, ARCH_CONVERT);
4049 xfs_buf_relse(agfbp); 4029 xfs_buf_relse(agfbp);
4050 4030
4051 agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)); 4031 agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp));
@@ -4056,14 +4036,12 @@ xlog_recover_check_summary(
4056 mp, agibp, agidaddr); 4036 mp, agibp, agidaddr);
4057 } 4037 }
4058 agip = XFS_BUF_TO_AGI(agibp); 4038 agip = XFS_BUF_TO_AGI(agibp);
4059 ASSERT(XFS_AGI_MAGIC == 4039 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agip->agi_magicnum));
4060 INT_GET(agip->agi_magicnum, ARCH_CONVERT)); 4040 ASSERT(XFS_AGI_GOOD_VERSION(be32_to_cpu(agip->agi_versionnum)));
4061 ASSERT(XFS_AGI_GOOD_VERSION( 4041 ASSERT(be32_to_cpu(agip->agi_seqno) == agno);
4062 INT_GET(agip->agi_versionnum, ARCH_CONVERT))); 4042
4063 ASSERT(INT_GET(agip->agi_seqno, ARCH_CONVERT) == agno); 4043 itotal += be32_to_cpu(agip->agi_count);
4064 4044 ifree += be32_to_cpu(agip->agi_freecount);
4065 itotal += INT_GET(agip->agi_count, ARCH_CONVERT);
4066 ifree += INT_GET(agip->agi_freecount, ARCH_CONVERT);
4067 xfs_buf_relse(agibp); 4045 xfs_buf_relse(agibp);
4068 } 4046 }
4069 4047