aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-04-13 01:06:46 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:10 -0400
commit9abbc539bf7f299819ad0a235064a1b643ab6407 (patch)
tree0c15d4f4933bce3a1a1db19509f4993ce2e46286 /fs/xfs/xfs_log_recover.c
parente6b1f27370fc67ac9868b2dbe2c22bc26952900e (diff)
xfs: add log item recovery tracing
Currently there is no tracing in log recovery, so it is difficult to determine what is going on when something goes wrong. Add tracing for log item recovery to provide visibility into the log recovery process. The tracing added shows regions being extracted from the log transactions and added to the transaction hash forming recovery items, followed by the reordering, cancelling and finally recovery of the items. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 22e6efdc17ea..f21eb8ad2d97 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1408,6 +1408,7 @@ xlog_recover_add_item(
1408 1408
1409STATIC int 1409STATIC int
1410xlog_recover_add_to_cont_trans( 1410xlog_recover_add_to_cont_trans(
1411 struct log *log,
1411 xlog_recover_t *trans, 1412 xlog_recover_t *trans,
1412 xfs_caddr_t dp, 1413 xfs_caddr_t dp,
1413 int len) 1414 int len)
@@ -1434,6 +1435,7 @@ xlog_recover_add_to_cont_trans(
1434 memcpy(&ptr[old_len], dp, len); /* d, s, l */ 1435 memcpy(&ptr[old_len], dp, len); /* d, s, l */
1435 item->ri_buf[item->ri_cnt-1].i_len += len; 1436 item->ri_buf[item->ri_cnt-1].i_len += len;
1436 item->ri_buf[item->ri_cnt-1].i_addr = ptr; 1437 item->ri_buf[item->ri_cnt-1].i_addr = ptr;
1438 trace_xfs_log_recover_item_add_cont(log, trans, item, 0);
1437 return 0; 1439 return 0;
1438} 1440}
1439 1441
@@ -1452,6 +1454,7 @@ xlog_recover_add_to_cont_trans(
1452 */ 1454 */
1453STATIC int 1455STATIC int
1454xlog_recover_add_to_trans( 1456xlog_recover_add_to_trans(
1457 struct log *log,
1455 xlog_recover_t *trans, 1458 xlog_recover_t *trans,
1456 xfs_caddr_t dp, 1459 xfs_caddr_t dp,
1457 int len) 1460 int len)
@@ -1510,6 +1513,7 @@ xlog_recover_add_to_trans(
1510 item->ri_buf[item->ri_cnt].i_addr = ptr; 1513 item->ri_buf[item->ri_cnt].i_addr = ptr;
1511 item->ri_buf[item->ri_cnt].i_len = len; 1514 item->ri_buf[item->ri_cnt].i_len = len;
1512 item->ri_cnt++; 1515 item->ri_cnt++;
1516 trace_xfs_log_recover_item_add(log, trans, item, 0);
1513 return 0; 1517 return 0;
1514} 1518}
1515 1519
@@ -1521,7 +1525,9 @@ xlog_recover_add_to_trans(
1521 */ 1525 */
1522STATIC int 1526STATIC int
1523xlog_recover_reorder_trans( 1527xlog_recover_reorder_trans(
1524 xlog_recover_t *trans) 1528 struct log *log,
1529 xlog_recover_t *trans,
1530 int pass)
1525{ 1531{
1526 xlog_recover_item_t *item, *n; 1532 xlog_recover_item_t *item, *n;
1527 LIST_HEAD(sort_list); 1533 LIST_HEAD(sort_list);
@@ -1535,6 +1541,8 @@ xlog_recover_reorder_trans(
1535 switch (ITEM_TYPE(item)) { 1541 switch (ITEM_TYPE(item)) {
1536 case XFS_LI_BUF: 1542 case XFS_LI_BUF:
1537 if (!(buf_f->blf_flags & XFS_BLI_CANCEL)) { 1543 if (!(buf_f->blf_flags & XFS_BLI_CANCEL)) {
1544 trace_xfs_log_recover_item_reorder_head(log,
1545 trans, item, pass);
1538 list_move(&item->ri_list, &trans->r_itemq); 1546 list_move(&item->ri_list, &trans->r_itemq);
1539 break; 1547 break;
1540 } 1548 }
@@ -1543,6 +1551,8 @@ xlog_recover_reorder_trans(
1543 case XFS_LI_QUOTAOFF: 1551 case XFS_LI_QUOTAOFF:
1544 case XFS_LI_EFD: 1552 case XFS_LI_EFD:
1545 case XFS_LI_EFI: 1553 case XFS_LI_EFI:
1554 trace_xfs_log_recover_item_reorder_tail(log,
1555 trans, item, pass);
1546 list_move_tail(&item->ri_list, &trans->r_itemq); 1556 list_move_tail(&item->ri_list, &trans->r_itemq);
1547 break; 1557 break;
1548 default: 1558 default:
@@ -1592,8 +1602,10 @@ xlog_recover_do_buffer_pass1(
1592 /* 1602 /*
1593 * If this isn't a cancel buffer item, then just return. 1603 * If this isn't a cancel buffer item, then just return.
1594 */ 1604 */
1595 if (!(flags & XFS_BLI_CANCEL)) 1605 if (!(flags & XFS_BLI_CANCEL)) {
1606 trace_xfs_log_recover_buf_not_cancel(log, buf_f);
1596 return; 1607 return;
1608 }
1597 1609
1598 /* 1610 /*
1599 * Insert an xfs_buf_cancel record into the hash table of 1611 * Insert an xfs_buf_cancel record into the hash table of
@@ -1627,6 +1639,7 @@ xlog_recover_do_buffer_pass1(
1627 while (nextp != NULL) { 1639 while (nextp != NULL) {
1628 if (nextp->bc_blkno == blkno && nextp->bc_len == len) { 1640 if (nextp->bc_blkno == blkno && nextp->bc_len == len) {
1629 nextp->bc_refcount++; 1641 nextp->bc_refcount++;
1642 trace_xfs_log_recover_buf_cancel_ref_inc(log, buf_f);
1630 return; 1643 return;
1631 } 1644 }
1632 prevp = nextp; 1645 prevp = nextp;
@@ -1640,6 +1653,7 @@ xlog_recover_do_buffer_pass1(
1640 bcp->bc_refcount = 1; 1653 bcp->bc_refcount = 1;
1641 bcp->bc_next = NULL; 1654 bcp->bc_next = NULL;
1642 prevp->bc_next = bcp; 1655 prevp->bc_next = bcp;
1656 trace_xfs_log_recover_buf_cancel_add(log, buf_f);
1643} 1657}
1644 1658
1645/* 1659/*
@@ -1779,6 +1793,8 @@ xlog_recover_do_inode_buffer(
1779 unsigned int *data_map = NULL; 1793 unsigned int *data_map = NULL;
1780 unsigned int map_size = 0; 1794 unsigned int map_size = 0;
1781 1795
1796 trace_xfs_log_recover_buf_inode_buf(mp->m_log, buf_f);
1797
1782 switch (buf_f->blf_type) { 1798 switch (buf_f->blf_type) {
1783 case XFS_LI_BUF: 1799 case XFS_LI_BUF:
1784 data_map = buf_f->blf_data_map; 1800 data_map = buf_f->blf_data_map;
@@ -1874,6 +1890,7 @@ xlog_recover_do_inode_buffer(
1874/*ARGSUSED*/ 1890/*ARGSUSED*/
1875STATIC void 1891STATIC void
1876xlog_recover_do_reg_buffer( 1892xlog_recover_do_reg_buffer(
1893 struct xfs_mount *mp,
1877 xlog_recover_item_t *item, 1894 xlog_recover_item_t *item,
1878 xfs_buf_t *bp, 1895 xfs_buf_t *bp,
1879 xfs_buf_log_format_t *buf_f) 1896 xfs_buf_log_format_t *buf_f)
@@ -1885,6 +1902,8 @@ xlog_recover_do_reg_buffer(
1885 unsigned int map_size = 0; 1902 unsigned int map_size = 0;
1886 int error; 1903 int error;
1887 1904
1905 trace_xfs_log_recover_buf_reg_buf(mp->m_log, buf_f);
1906
1888 switch (buf_f->blf_type) { 1907 switch (buf_f->blf_type) {
1889 case XFS_LI_BUF: 1908 case XFS_LI_BUF:
1890 data_map = buf_f->blf_data_map; 1909 data_map = buf_f->blf_data_map;
@@ -2083,6 +2102,8 @@ xlog_recover_do_dquot_buffer(
2083{ 2102{
2084 uint type; 2103 uint type;
2085 2104
2105 trace_xfs_log_recover_buf_dquot_buf(log, buf_f);
2106
2086 /* 2107 /*
2087 * Filesystems are required to send in quota flags at mount time. 2108 * Filesystems are required to send in quota flags at mount time.
2088 */ 2109 */
@@ -2103,7 +2124,7 @@ xlog_recover_do_dquot_buffer(
2103 if (log->l_quotaoffs_flag & type) 2124 if (log->l_quotaoffs_flag & type)
2104 return; 2125 return;
2105 2126
2106 xlog_recover_do_reg_buffer(item, bp, buf_f); 2127 xlog_recover_do_reg_buffer(mp, item, bp, buf_f);
2107} 2128}
2108 2129
2109/* 2130/*
@@ -2164,9 +2185,11 @@ xlog_recover_do_buffer_trans(
2164 */ 2185 */
2165 cancel = xlog_recover_do_buffer_pass2(log, buf_f); 2186 cancel = xlog_recover_do_buffer_pass2(log, buf_f);
2166 if (cancel) { 2187 if (cancel) {
2188 trace_xfs_log_recover_buf_cancel(log, buf_f);
2167 return 0; 2189 return 0;
2168 } 2190 }
2169 } 2191 }
2192 trace_xfs_log_recover_buf_recover(log, buf_f);
2170 switch (buf_f->blf_type) { 2193 switch (buf_f->blf_type) {
2171 case XFS_LI_BUF: 2194 case XFS_LI_BUF:
2172 blkno = buf_f->blf_blkno; 2195 blkno = buf_f->blf_blkno;
@@ -2204,7 +2227,7 @@ xlog_recover_do_buffer_trans(
2204 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) { 2227 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) {
2205 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); 2228 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f);
2206 } else { 2229 } else {
2207 xlog_recover_do_reg_buffer(item, bp, buf_f); 2230 xlog_recover_do_reg_buffer(mp, item, bp, buf_f);
2208 } 2231 }
2209 if (error) 2232 if (error)
2210 return XFS_ERROR(error); 2233 return XFS_ERROR(error);
@@ -2284,8 +2307,10 @@ xlog_recover_do_inode_trans(
2284 if (xlog_check_buffer_cancelled(log, in_f->ilf_blkno, 2307 if (xlog_check_buffer_cancelled(log, in_f->ilf_blkno,
2285 in_f->ilf_len, 0)) { 2308 in_f->ilf_len, 0)) {
2286 error = 0; 2309 error = 0;
2310 trace_xfs_log_recover_inode_cancel(log, in_f);
2287 goto error; 2311 goto error;
2288 } 2312 }
2313 trace_xfs_log_recover_inode_recover(log, in_f);
2289 2314
2290 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 2315 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
2291 XBF_LOCK); 2316 XBF_LOCK);
@@ -2337,6 +2362,7 @@ xlog_recover_do_inode_trans(
2337 /* do nothing */ 2362 /* do nothing */
2338 } else { 2363 } else {
2339 xfs_buf_relse(bp); 2364 xfs_buf_relse(bp);
2365 trace_xfs_log_recover_inode_skip(log, in_f);
2340 error = 0; 2366 error = 0;
2341 goto error; 2367 goto error;
2342 } 2368 }
@@ -2758,11 +2784,12 @@ xlog_recover_do_trans(
2758 int error = 0; 2784 int error = 0;
2759 xlog_recover_item_t *item; 2785 xlog_recover_item_t *item;
2760 2786
2761 error = xlog_recover_reorder_trans(trans); 2787 error = xlog_recover_reorder_trans(log, trans, pass);
2762 if (error) 2788 if (error)
2763 return error; 2789 return error;
2764 2790
2765 list_for_each_entry(item, &trans->r_itemq, ri_list) { 2791 list_for_each_entry(item, &trans->r_itemq, ri_list) {
2792 trace_xfs_log_recover_item_recover(log, trans, item, pass);
2766 switch (ITEM_TYPE(item)) { 2793 switch (ITEM_TYPE(item)) {
2767 case XFS_LI_BUF: 2794 case XFS_LI_BUF:
2768 error = xlog_recover_do_buffer_trans(log, item, pass); 2795 error = xlog_recover_do_buffer_trans(log, item, pass);
@@ -2919,8 +2946,9 @@ xlog_recover_process_data(
2919 error = xlog_recover_unmount_trans(trans); 2946 error = xlog_recover_unmount_trans(trans);
2920 break; 2947 break;
2921 case XLOG_WAS_CONT_TRANS: 2948 case XLOG_WAS_CONT_TRANS:
2922 error = xlog_recover_add_to_cont_trans(trans, 2949 error = xlog_recover_add_to_cont_trans(log,
2923 dp, be32_to_cpu(ohead->oh_len)); 2950 trans, dp,
2951 be32_to_cpu(ohead->oh_len));
2924 break; 2952 break;
2925 case XLOG_START_TRANS: 2953 case XLOG_START_TRANS:
2926 xlog_warn( 2954 xlog_warn(
@@ -2930,7 +2958,7 @@ xlog_recover_process_data(
2930 break; 2958 break;
2931 case 0: 2959 case 0:
2932 case XLOG_CONTINUE_TRANS: 2960 case XLOG_CONTINUE_TRANS:
2933 error = xlog_recover_add_to_trans(trans, 2961 error = xlog_recover_add_to_trans(log, trans,
2934 dp, be32_to_cpu(ohead->oh_len)); 2962 dp, be32_to_cpu(ohead->oh_len));
2935 break; 2963 break;
2936 default: 2964 default: