diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-12-01 17:06:24 -0500 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-12-16 17:05:30 -0500 |
commit | c9f71f5fc4390ea3a8087c00d53a799e7e0f0f8e (patch) | |
tree | a8d7ffe0a1fe4e547ef0672a0060ce5d2f5f66f0 | |
parent | d0450948641b2090b5d467ba638bbebd40b20b21 (diff) |
xfs: untangle phase1 vs phase2 recovery helpers
Dispatch to a different helper for phase1 vs phase2 in
xlog_recover_commit_trans instead of doing it in all the
low-level functions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 194 |
1 files changed, 93 insertions, 101 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 26e18052a648..4ab4f6ff48aa 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -1616,11 +1616,12 @@ xlog_recover_reorder_trans( | |||
1616 | * record in the table to tell us how many times we expect to see this | 1616 | * record in the table to tell us how many times we expect to see this |
1617 | * record during the second pass. | 1617 | * record during the second pass. |
1618 | */ | 1618 | */ |
1619 | STATIC void | 1619 | STATIC int |
1620 | xlog_recover_do_buffer_pass1( | 1620 | xlog_recover_buffer_pass1( |
1621 | struct log *log, | 1621 | struct log *log, |
1622 | xfs_buf_log_format_t *buf_f) | 1622 | xlog_recover_item_t *item) |
1623 | { | 1623 | { |
1624 | xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; | ||
1624 | struct list_head *bucket; | 1625 | struct list_head *bucket; |
1625 | struct xfs_buf_cancel *bcp; | 1626 | struct xfs_buf_cancel *bcp; |
1626 | 1627 | ||
@@ -1629,7 +1630,7 @@ xlog_recover_do_buffer_pass1( | |||
1629 | */ | 1630 | */ |
1630 | if (!(buf_f->blf_flags & XFS_BLF_CANCEL)) { | 1631 | if (!(buf_f->blf_flags & XFS_BLF_CANCEL)) { |
1631 | trace_xfs_log_recover_buf_not_cancel(log, buf_f); | 1632 | trace_xfs_log_recover_buf_not_cancel(log, buf_f); |
1632 | return; | 1633 | return 0; |
1633 | } | 1634 | } |
1634 | 1635 | ||
1635 | /* | 1636 | /* |
@@ -1642,7 +1643,7 @@ xlog_recover_do_buffer_pass1( | |||
1642 | bcp->bc_len == buf_f->blf_len) { | 1643 | bcp->bc_len == buf_f->blf_len) { |
1643 | bcp->bc_refcount++; | 1644 | bcp->bc_refcount++; |
1644 | trace_xfs_log_recover_buf_cancel_ref_inc(log, buf_f); | 1645 | trace_xfs_log_recover_buf_cancel_ref_inc(log, buf_f); |
1645 | return; | 1646 | return 0; |
1646 | } | 1647 | } |
1647 | } | 1648 | } |
1648 | 1649 | ||
@@ -1653,6 +1654,7 @@ xlog_recover_do_buffer_pass1( | |||
1653 | list_add_tail(&bcp->bc_list, bucket); | 1654 | list_add_tail(&bcp->bc_list, bucket); |
1654 | 1655 | ||
1655 | trace_xfs_log_recover_buf_cancel_add(log, buf_f); | 1656 | trace_xfs_log_recover_buf_cancel_add(log, buf_f); |
1657 | return 0; | ||
1656 | } | 1658 | } |
1657 | 1659 | ||
1658 | /* | 1660 | /* |
@@ -2081,10 +2083,9 @@ xlog_recover_do_dquot_buffer( | |||
2081 | * for more details on the implementation of the table of cancel records. | 2083 | * for more details on the implementation of the table of cancel records. |
2082 | */ | 2084 | */ |
2083 | STATIC int | 2085 | STATIC int |
2084 | xlog_recover_do_buffer_trans( | 2086 | xlog_recover_buffer_pass2( |
2085 | xlog_t *log, | 2087 | xlog_t *log, |
2086 | xlog_recover_item_t *item, | 2088 | xlog_recover_item_t *item) |
2087 | int pass) | ||
2088 | { | 2089 | { |
2089 | xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; | 2090 | xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; |
2090 | xfs_mount_t *mp = log->l_mp; | 2091 | xfs_mount_t *mp = log->l_mp; |
@@ -2092,27 +2093,16 @@ xlog_recover_do_buffer_trans( | |||
2092 | int error; | 2093 | int error; |
2093 | uint buf_flags; | 2094 | uint buf_flags; |
2094 | 2095 | ||
2095 | if (pass == XLOG_RECOVER_PASS1) { | 2096 | /* |
2096 | /* | 2097 | * In this pass we only want to recover all the buffers which have |
2097 | * In this pass we're only looking for buf items | 2098 | * not been cancelled and are not cancellation buffers themselves. |
2098 | * with the XFS_BLF_CANCEL bit set. | 2099 | */ |
2099 | */ | 2100 | if (xlog_check_buffer_cancelled(log, buf_f->blf_blkno, |
2100 | xlog_recover_do_buffer_pass1(log, buf_f); | 2101 | buf_f->blf_len, buf_f->blf_flags)) { |
2102 | trace_xfs_log_recover_buf_cancel(log, buf_f); | ||
2101 | return 0; | 2103 | return 0; |
2102 | } else { | ||
2103 | /* | ||
2104 | * In this pass we want to recover all the buffers | ||
2105 | * which have not been cancelled and are not | ||
2106 | * cancellation buffers themselves. The routine | ||
2107 | * we call here will tell us whether or not to | ||
2108 | * continue with the replay of this buffer. | ||
2109 | */ | ||
2110 | if (xlog_check_buffer_cancelled(log, buf_f->blf_blkno, | ||
2111 | buf_f->blf_len, buf_f->blf_flags)) { | ||
2112 | trace_xfs_log_recover_buf_cancel(log, buf_f); | ||
2113 | return 0; | ||
2114 | } | ||
2115 | } | 2104 | } |
2105 | |||
2116 | trace_xfs_log_recover_buf_recover(log, buf_f); | 2106 | trace_xfs_log_recover_buf_recover(log, buf_f); |
2117 | 2107 | ||
2118 | buf_flags = XBF_LOCK; | 2108 | buf_flags = XBF_LOCK; |
@@ -2172,16 +2162,14 @@ xlog_recover_do_buffer_trans( | |||
2172 | } | 2162 | } |
2173 | 2163 | ||
2174 | STATIC int | 2164 | STATIC int |
2175 | xlog_recover_do_inode_trans( | 2165 | xlog_recover_inode_pass2( |
2176 | xlog_t *log, | 2166 | xlog_t *log, |
2177 | xlog_recover_item_t *item, | 2167 | xlog_recover_item_t *item) |
2178 | int pass) | ||
2179 | { | 2168 | { |
2180 | xfs_inode_log_format_t *in_f; | 2169 | xfs_inode_log_format_t *in_f; |
2181 | xfs_mount_t *mp; | 2170 | xfs_mount_t *mp = log->l_mp; |
2182 | xfs_buf_t *bp; | 2171 | xfs_buf_t *bp; |
2183 | xfs_dinode_t *dip; | 2172 | xfs_dinode_t *dip; |
2184 | xfs_ino_t ino; | ||
2185 | int len; | 2173 | int len; |
2186 | xfs_caddr_t src; | 2174 | xfs_caddr_t src; |
2187 | xfs_caddr_t dest; | 2175 | xfs_caddr_t dest; |
@@ -2191,10 +2179,6 @@ xlog_recover_do_inode_trans( | |||
2191 | xfs_icdinode_t *dicp; | 2179 | xfs_icdinode_t *dicp; |
2192 | int need_free = 0; | 2180 | int need_free = 0; |
2193 | 2181 | ||
2194 | if (pass == XLOG_RECOVER_PASS1) { | ||
2195 | return 0; | ||
2196 | } | ||
2197 | |||
2198 | if (item->ri_buf[0].i_len == sizeof(xfs_inode_log_format_t)) { | 2182 | if (item->ri_buf[0].i_len == sizeof(xfs_inode_log_format_t)) { |
2199 | in_f = item->ri_buf[0].i_addr; | 2183 | in_f = item->ri_buf[0].i_addr; |
2200 | } else { | 2184 | } else { |
@@ -2204,8 +2188,6 @@ xlog_recover_do_inode_trans( | |||
2204 | if (error) | 2188 | if (error) |
2205 | goto error; | 2189 | goto error; |
2206 | } | 2190 | } |
2207 | ino = in_f->ilf_ino; | ||
2208 | mp = log->l_mp; | ||
2209 | 2191 | ||
2210 | /* | 2192 | /* |
2211 | * Inode buffers can be freed, look out for it, | 2193 | * Inode buffers can be freed, look out for it, |
@@ -2240,8 +2222,8 @@ xlog_recover_do_inode_trans( | |||
2240 | xfs_buf_relse(bp); | 2222 | xfs_buf_relse(bp); |
2241 | xfs_fs_cmn_err(CE_ALERT, mp, | 2223 | xfs_fs_cmn_err(CE_ALERT, mp, |
2242 | "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", | 2224 | "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", |
2243 | dip, bp, ino); | 2225 | dip, bp, in_f->ilf_ino); |
2244 | XFS_ERROR_REPORT("xlog_recover_do_inode_trans(1)", | 2226 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", |
2245 | XFS_ERRLEVEL_LOW, mp); | 2227 | XFS_ERRLEVEL_LOW, mp); |
2246 | error = EFSCORRUPTED; | 2228 | error = EFSCORRUPTED; |
2247 | goto error; | 2229 | goto error; |
@@ -2251,8 +2233,8 @@ xlog_recover_do_inode_trans( | |||
2251 | xfs_buf_relse(bp); | 2233 | xfs_buf_relse(bp); |
2252 | xfs_fs_cmn_err(CE_ALERT, mp, | 2234 | xfs_fs_cmn_err(CE_ALERT, mp, |
2253 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, ino %Ld", | 2235 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, ino %Ld", |
2254 | item, ino); | 2236 | item, in_f->ilf_ino); |
2255 | XFS_ERROR_REPORT("xlog_recover_do_inode_trans(2)", | 2237 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", |
2256 | XFS_ERRLEVEL_LOW, mp); | 2238 | XFS_ERRLEVEL_LOW, mp); |
2257 | error = EFSCORRUPTED; | 2239 | error = EFSCORRUPTED; |
2258 | goto error; | 2240 | goto error; |
@@ -2280,12 +2262,12 @@ xlog_recover_do_inode_trans( | |||
2280 | if (unlikely((dicp->di_mode & S_IFMT) == S_IFREG)) { | 2262 | if (unlikely((dicp->di_mode & S_IFMT) == S_IFREG)) { |
2281 | if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && | 2263 | if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && |
2282 | (dicp->di_format != XFS_DINODE_FMT_BTREE)) { | 2264 | (dicp->di_format != XFS_DINODE_FMT_BTREE)) { |
2283 | XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(3)", | 2265 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)", |
2284 | XFS_ERRLEVEL_LOW, mp, dicp); | 2266 | XFS_ERRLEVEL_LOW, mp, dicp); |
2285 | xfs_buf_relse(bp); | 2267 | xfs_buf_relse(bp); |
2286 | xfs_fs_cmn_err(CE_ALERT, mp, | 2268 | xfs_fs_cmn_err(CE_ALERT, mp, |
2287 | "xfs_inode_recover: Bad regular inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2269 | "xfs_inode_recover: Bad regular inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2288 | item, dip, bp, ino); | 2270 | item, dip, bp, in_f->ilf_ino); |
2289 | error = EFSCORRUPTED; | 2271 | error = EFSCORRUPTED; |
2290 | goto error; | 2272 | goto error; |
2291 | } | 2273 | } |
@@ -2293,40 +2275,40 @@ xlog_recover_do_inode_trans( | |||
2293 | if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && | 2275 | if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && |
2294 | (dicp->di_format != XFS_DINODE_FMT_BTREE) && | 2276 | (dicp->di_format != XFS_DINODE_FMT_BTREE) && |
2295 | (dicp->di_format != XFS_DINODE_FMT_LOCAL)) { | 2277 | (dicp->di_format != XFS_DINODE_FMT_LOCAL)) { |
2296 | XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(4)", | 2278 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(4)", |
2297 | XFS_ERRLEVEL_LOW, mp, dicp); | 2279 | XFS_ERRLEVEL_LOW, mp, dicp); |
2298 | xfs_buf_relse(bp); | 2280 | xfs_buf_relse(bp); |
2299 | xfs_fs_cmn_err(CE_ALERT, mp, | 2281 | xfs_fs_cmn_err(CE_ALERT, mp, |
2300 | "xfs_inode_recover: Bad dir inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2282 | "xfs_inode_recover: Bad dir inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2301 | item, dip, bp, ino); | 2283 | item, dip, bp, in_f->ilf_ino); |
2302 | error = EFSCORRUPTED; | 2284 | error = EFSCORRUPTED; |
2303 | goto error; | 2285 | goto error; |
2304 | } | 2286 | } |
2305 | } | 2287 | } |
2306 | if (unlikely(dicp->di_nextents + dicp->di_anextents > dicp->di_nblocks)){ | 2288 | if (unlikely(dicp->di_nextents + dicp->di_anextents > dicp->di_nblocks)){ |
2307 | XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(5)", | 2289 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(5)", |
2308 | XFS_ERRLEVEL_LOW, mp, dicp); | 2290 | XFS_ERRLEVEL_LOW, mp, dicp); |
2309 | xfs_buf_relse(bp); | 2291 | xfs_buf_relse(bp); |
2310 | xfs_fs_cmn_err(CE_ALERT, mp, | 2292 | xfs_fs_cmn_err(CE_ALERT, mp, |
2311 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, total extents = %d, nblocks = %Ld", | 2293 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, total extents = %d, nblocks = %Ld", |
2312 | item, dip, bp, ino, | 2294 | item, dip, bp, in_f->ilf_ino, |
2313 | dicp->di_nextents + dicp->di_anextents, | 2295 | dicp->di_nextents + dicp->di_anextents, |
2314 | dicp->di_nblocks); | 2296 | dicp->di_nblocks); |
2315 | error = EFSCORRUPTED; | 2297 | error = EFSCORRUPTED; |
2316 | goto error; | 2298 | goto error; |
2317 | } | 2299 | } |
2318 | if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { | 2300 | if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { |
2319 | XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(6)", | 2301 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(6)", |
2320 | XFS_ERRLEVEL_LOW, mp, dicp); | 2302 | XFS_ERRLEVEL_LOW, mp, dicp); |
2321 | xfs_buf_relse(bp); | 2303 | xfs_buf_relse(bp); |
2322 | xfs_fs_cmn_err(CE_ALERT, mp, | 2304 | xfs_fs_cmn_err(CE_ALERT, mp, |
2323 | "xfs_inode_recover: Bad inode log rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, forkoff 0x%x", | 2305 | "xfs_inode_recover: Bad inode log rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, forkoff 0x%x", |
2324 | item, dip, bp, ino, dicp->di_forkoff); | 2306 | item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); |
2325 | error = EFSCORRUPTED; | 2307 | error = EFSCORRUPTED; |
2326 | goto error; | 2308 | goto error; |
2327 | } | 2309 | } |
2328 | if (unlikely(item->ri_buf[1].i_len > sizeof(struct xfs_icdinode))) { | 2310 | if (unlikely(item->ri_buf[1].i_len > sizeof(struct xfs_icdinode))) { |
2329 | XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(7)", | 2311 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(7)", |
2330 | XFS_ERRLEVEL_LOW, mp, dicp); | 2312 | XFS_ERRLEVEL_LOW, mp, dicp); |
2331 | xfs_buf_relse(bp); | 2313 | xfs_buf_relse(bp); |
2332 | xfs_fs_cmn_err(CE_ALERT, mp, | 2314 | xfs_fs_cmn_err(CE_ALERT, mp, |
@@ -2418,7 +2400,7 @@ xlog_recover_do_inode_trans( | |||
2418 | break; | 2400 | break; |
2419 | 2401 | ||
2420 | default: | 2402 | default: |
2421 | xlog_warn("XFS: xlog_recover_do_inode_trans: Invalid flag"); | 2403 | xlog_warn("XFS: xlog_recover_inode_pass2: Invalid flag"); |
2422 | ASSERT(0); | 2404 | ASSERT(0); |
2423 | xfs_buf_relse(bp); | 2405 | xfs_buf_relse(bp); |
2424 | error = EIO; | 2406 | error = EIO; |
@@ -2442,18 +2424,11 @@ error: | |||
2442 | * of that type. | 2424 | * of that type. |
2443 | */ | 2425 | */ |
2444 | STATIC int | 2426 | STATIC int |
2445 | xlog_recover_do_quotaoff_trans( | 2427 | xlog_recover_quotaoff_pass1( |
2446 | xlog_t *log, | 2428 | xlog_t *log, |
2447 | xlog_recover_item_t *item, | 2429 | xlog_recover_item_t *item) |
2448 | int pass) | ||
2449 | { | 2430 | { |
2450 | xfs_qoff_logformat_t *qoff_f; | 2431 | xfs_qoff_logformat_t *qoff_f = item->ri_buf[0].i_addr; |
2451 | |||
2452 | if (pass == XLOG_RECOVER_PASS2) { | ||
2453 | return (0); | ||
2454 | } | ||
2455 | |||
2456 | qoff_f = item->ri_buf[0].i_addr; | ||
2457 | ASSERT(qoff_f); | 2432 | ASSERT(qoff_f); |
2458 | 2433 | ||
2459 | /* | 2434 | /* |
@@ -2474,22 +2449,17 @@ xlog_recover_do_quotaoff_trans( | |||
2474 | * Recover a dquot record | 2449 | * Recover a dquot record |
2475 | */ | 2450 | */ |
2476 | STATIC int | 2451 | STATIC int |
2477 | xlog_recover_do_dquot_trans( | 2452 | xlog_recover_dquot_pass2( |
2478 | xlog_t *log, | 2453 | xlog_t *log, |
2479 | xlog_recover_item_t *item, | 2454 | xlog_recover_item_t *item) |
2480 | int pass) | ||
2481 | { | 2455 | { |
2482 | xfs_mount_t *mp; | 2456 | xfs_mount_t *mp = log->l_mp; |
2483 | xfs_buf_t *bp; | 2457 | xfs_buf_t *bp; |
2484 | struct xfs_disk_dquot *ddq, *recddq; | 2458 | struct xfs_disk_dquot *ddq, *recddq; |
2485 | int error; | 2459 | int error; |
2486 | xfs_dq_logformat_t *dq_f; | 2460 | xfs_dq_logformat_t *dq_f; |
2487 | uint type; | 2461 | uint type; |
2488 | 2462 | ||
2489 | if (pass == XLOG_RECOVER_PASS1) { | ||
2490 | return 0; | ||
2491 | } | ||
2492 | mp = log->l_mp; | ||
2493 | 2463 | ||
2494 | /* | 2464 | /* |
2495 | * Filesystems are required to send in quota flags at mount time. | 2465 | * Filesystems are required to send in quota flags at mount time. |
@@ -2533,7 +2503,7 @@ xlog_recover_do_dquot_trans( | |||
2533 | if ((error = xfs_qm_dqcheck(recddq, | 2503 | if ((error = xfs_qm_dqcheck(recddq, |
2534 | dq_f->qlf_id, | 2504 | dq_f->qlf_id, |
2535 | 0, XFS_QMOPT_DOWARN, | 2505 | 0, XFS_QMOPT_DOWARN, |
2536 | "xlog_recover_do_dquot_trans (log copy)"))) { | 2506 | "xlog_recover_dquot_pass2 (log copy)"))) { |
2537 | return XFS_ERROR(EIO); | 2507 | return XFS_ERROR(EIO); |
2538 | } | 2508 | } |
2539 | ASSERT(dq_f->qlf_len == 1); | 2509 | ASSERT(dq_f->qlf_len == 1); |
@@ -2556,7 +2526,7 @@ xlog_recover_do_dquot_trans( | |||
2556 | * minimal initialization then. | 2526 | * minimal initialization then. |
2557 | */ | 2527 | */ |
2558 | if (xfs_qm_dqcheck(ddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, | 2528 | if (xfs_qm_dqcheck(ddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, |
2559 | "xlog_recover_do_dquot_trans")) { | 2529 | "xlog_recover_dquot_pass2")) { |
2560 | xfs_buf_relse(bp); | 2530 | xfs_buf_relse(bp); |
2561 | return XFS_ERROR(EIO); | 2531 | return XFS_ERROR(EIO); |
2562 | } | 2532 | } |
@@ -2579,24 +2549,18 @@ xlog_recover_do_dquot_trans( | |||
2579 | * LSN. | 2549 | * LSN. |
2580 | */ | 2550 | */ |
2581 | STATIC int | 2551 | STATIC int |
2582 | xlog_recover_do_efi_trans( | 2552 | xlog_recover_efi_pass2( |
2583 | xlog_t *log, | 2553 | xlog_t *log, |
2584 | xlog_recover_item_t *item, | 2554 | xlog_recover_item_t *item, |
2585 | xfs_lsn_t lsn, | 2555 | xfs_lsn_t lsn) |
2586 | int pass) | ||
2587 | { | 2556 | { |
2588 | int error; | 2557 | int error; |
2589 | xfs_mount_t *mp; | 2558 | xfs_mount_t *mp = log->l_mp; |
2590 | xfs_efi_log_item_t *efip; | 2559 | xfs_efi_log_item_t *efip; |
2591 | xfs_efi_log_format_t *efi_formatp; | 2560 | xfs_efi_log_format_t *efi_formatp; |
2592 | 2561 | ||
2593 | if (pass == XLOG_RECOVER_PASS1) { | ||
2594 | return 0; | ||
2595 | } | ||
2596 | |||
2597 | efi_formatp = item->ri_buf[0].i_addr; | 2562 | efi_formatp = item->ri_buf[0].i_addr; |
2598 | 2563 | ||
2599 | mp = log->l_mp; | ||
2600 | efip = xfs_efi_init(mp, efi_formatp->efi_nextents); | 2564 | efip = xfs_efi_init(mp, efi_formatp->efi_nextents); |
2601 | if ((error = xfs_efi_copy_format(&(item->ri_buf[0]), | 2565 | if ((error = xfs_efi_copy_format(&(item->ri_buf[0]), |
2602 | &(efip->efi_format)))) { | 2566 | &(efip->efi_format)))) { |
@@ -2623,11 +2587,10 @@ xlog_recover_do_efi_trans( | |||
2623 | * efd format structure. If we find it, we remove the efi from the | 2587 | * efd format structure. If we find it, we remove the efi from the |
2624 | * AIL and free it. | 2588 | * AIL and free it. |
2625 | */ | 2589 | */ |
2626 | STATIC void | 2590 | STATIC int |
2627 | xlog_recover_do_efd_trans( | 2591 | xlog_recover_efd_pass2( |
2628 | xlog_t *log, | 2592 | xlog_t *log, |
2629 | xlog_recover_item_t *item, | 2593 | xlog_recover_item_t *item) |
2630 | int pass) | ||
2631 | { | 2594 | { |
2632 | xfs_efd_log_format_t *efd_formatp; | 2595 | xfs_efd_log_format_t *efd_formatp; |
2633 | xfs_efi_log_item_t *efip = NULL; | 2596 | xfs_efi_log_item_t *efip = NULL; |
@@ -2636,10 +2599,6 @@ xlog_recover_do_efd_trans( | |||
2636 | struct xfs_ail_cursor cur; | 2599 | struct xfs_ail_cursor cur; |
2637 | struct xfs_ail *ailp = log->l_ailp; | 2600 | struct xfs_ail *ailp = log->l_ailp; |
2638 | 2601 | ||
2639 | if (pass == XLOG_RECOVER_PASS1) { | ||
2640 | return; | ||
2641 | } | ||
2642 | |||
2643 | efd_formatp = item->ri_buf[0].i_addr; | 2602 | efd_formatp = item->ri_buf[0].i_addr; |
2644 | ASSERT((item->ri_buf[0].i_len == (sizeof(xfs_efd_log_format_32_t) + | 2603 | ASSERT((item->ri_buf[0].i_len == (sizeof(xfs_efd_log_format_32_t) + |
2645 | ((efd_formatp->efd_nextents - 1) * sizeof(xfs_extent_32_t)))) || | 2604 | ((efd_formatp->efd_nextents - 1) * sizeof(xfs_extent_32_t)))) || |
@@ -2671,6 +2630,8 @@ xlog_recover_do_efd_trans( | |||
2671 | } | 2630 | } |
2672 | xfs_trans_ail_cursor_done(ailp, &cur); | 2631 | xfs_trans_ail_cursor_done(ailp, &cur); |
2673 | spin_unlock(&ailp->xa_lock); | 2632 | spin_unlock(&ailp->xa_lock); |
2633 | |||
2634 | return 0; | ||
2674 | } | 2635 | } |
2675 | 2636 | ||
2676 | /* | 2637 | /* |
@@ -2699,31 +2660,59 @@ xlog_recover_free_trans( | |||
2699 | } | 2660 | } |
2700 | 2661 | ||
2701 | STATIC int | 2662 | STATIC int |
2702 | xlog_recover_commit_item( | 2663 | xlog_recover_commit_pass1( |
2703 | struct log *log, | 2664 | struct log *log, |
2704 | struct xlog_recover *trans, | 2665 | struct xlog_recover *trans, |
2705 | xlog_recover_item_t *item, | 2666 | xlog_recover_item_t *item) |
2706 | int pass) | ||
2707 | { | 2667 | { |
2708 | trace_xfs_log_recover_item_recover(log, trans, item, pass); | 2668 | trace_xfs_log_recover_item_recover(log, trans, item, XLOG_RECOVER_PASS1); |
2709 | 2669 | ||
2710 | switch (ITEM_TYPE(item)) { | 2670 | switch (ITEM_TYPE(item)) { |
2711 | case XFS_LI_BUF: | 2671 | case XFS_LI_BUF: |
2712 | return xlog_recover_do_buffer_trans(log, item, pass); | 2672 | return xlog_recover_buffer_pass1(log, item); |
2673 | case XFS_LI_QUOTAOFF: | ||
2674 | return xlog_recover_quotaoff_pass1(log, item); | ||
2713 | case XFS_LI_INODE: | 2675 | case XFS_LI_INODE: |
2714 | return xlog_recover_do_inode_trans(log, item, pass); | ||
2715 | case XFS_LI_EFI: | 2676 | case XFS_LI_EFI: |
2716 | return xlog_recover_do_efi_trans(log, item, trans->r_lsn, pass); | ||
2717 | case XFS_LI_EFD: | 2677 | case XFS_LI_EFD: |
2718 | xlog_recover_do_efd_trans(log, item, pass); | 2678 | case XFS_LI_DQUOT: |
2679 | /* nothing to do in pass 1 */ | ||
2719 | return 0; | 2680 | return 0; |
2681 | default: | ||
2682 | xlog_warn( | ||
2683 | "XFS: invalid item type (%d) xlog_recover_commit_pass1", | ||
2684 | ITEM_TYPE(item)); | ||
2685 | ASSERT(0); | ||
2686 | return XFS_ERROR(EIO); | ||
2687 | } | ||
2688 | } | ||
2689 | |||
2690 | STATIC int | ||
2691 | xlog_recover_commit_pass2( | ||
2692 | struct log *log, | ||
2693 | struct xlog_recover *trans, | ||
2694 | xlog_recover_item_t *item) | ||
2695 | { | ||
2696 | trace_xfs_log_recover_item_recover(log, trans, item, XLOG_RECOVER_PASS2); | ||
2697 | |||
2698 | switch (ITEM_TYPE(item)) { | ||
2699 | case XFS_LI_BUF: | ||
2700 | return xlog_recover_buffer_pass2(log, item); | ||
2701 | case XFS_LI_INODE: | ||
2702 | return xlog_recover_inode_pass2(log, item); | ||
2703 | case XFS_LI_EFI: | ||
2704 | return xlog_recover_efi_pass2(log, item, trans->r_lsn); | ||
2705 | case XFS_LI_EFD: | ||
2706 | return xlog_recover_efd_pass2(log, item); | ||
2720 | case XFS_LI_DQUOT: | 2707 | case XFS_LI_DQUOT: |
2721 | return xlog_recover_do_dquot_trans(log, item, pass); | 2708 | return xlog_recover_dquot_pass2(log, item); |
2722 | case XFS_LI_QUOTAOFF: | 2709 | case XFS_LI_QUOTAOFF: |
2723 | return xlog_recover_do_quotaoff_trans(log, item, pass); | 2710 | /* nothing to do in pass2 */ |
2711 | return 0; | ||
2724 | default: | 2712 | default: |
2725 | xlog_warn( | 2713 | xlog_warn( |
2726 | "XFS: invalid item type (%d) xlog_recover_do_trans", ITEM_TYPE(item)); | 2714 | "XFS: invalid item type (%d) xlog_recover_commit_pass2", |
2715 | ITEM_TYPE(item)); | ||
2727 | ASSERT(0); | 2716 | ASSERT(0); |
2728 | return XFS_ERROR(EIO); | 2717 | return XFS_ERROR(EIO); |
2729 | } | 2718 | } |
@@ -2751,7 +2740,10 @@ xlog_recover_commit_trans( | |||
2751 | return error; | 2740 | return error; |
2752 | 2741 | ||
2753 | list_for_each_entry(item, &trans->r_itemq, ri_list) { | 2742 | list_for_each_entry(item, &trans->r_itemq, ri_list) { |
2754 | error = xlog_recover_commit_item(log, trans, item, pass); | 2743 | if (pass == XLOG_RECOVER_PASS1) |
2744 | error = xlog_recover_commit_pass1(log, trans, item); | ||
2745 | else | ||
2746 | error = xlog_recover_commit_pass2(log, trans, item); | ||
2755 | if (error) | 2747 | if (error) |
2756 | return error; | 2748 | return error; |
2757 | } | 2749 | } |