Commit 62b96d76 authored by Nathan Scott's avatar Nathan Scott Committed by Christoph Hellwig

[XFS] Make log recovery code style consistent with a/ itself and b/ much of

the rest of XFS.  Fix numerous crimes against whitespace.

SGI Modid: 2.5.x-xfs:slinx:149398a
parent aa56b310
...@@ -65,20 +65,17 @@ ...@@ -65,20 +65,17 @@
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_rw.h" #include "xfs_rw.h"
STATIC int xlog_find_zeroed(struct log *log, xfs_daddr_t *blk_no); STATIC int xlog_find_zeroed(xlog_t *, xfs_daddr_t *);
STATIC int xlog_clear_stale_blocks(xlog_t *, xfs_lsn_t);
STATIC int xlog_clear_stale_blocks(xlog_t *log, xfs_lsn_t tail_lsn);
STATIC void xlog_recover_insert_item_backq(xlog_recover_item_t **q, STATIC void xlog_recover_insert_item_backq(xlog_recover_item_t **q,
xlog_recover_item_t *item); xlog_recover_item_t *item);
#if defined(DEBUG) #if defined(DEBUG)
STATIC void xlog_recover_check_summary(xlog_t *log); STATIC void xlog_recover_check_summary(xlog_t *);
STATIC void xlog_recover_check_ail(xfs_mount_t *mp, xfs_log_item_t *lip, STATIC void xlog_recover_check_ail(xfs_mount_t *, xfs_log_item_t *, int);
int gen);
#else #else
#define xlog_recover_check_summary(log) #define xlog_recover_check_summary(log)
#define xlog_recover_check_ail(mp, lip, gen) #define xlog_recover_check_ail(mp, lip, gen)
#endif /* DEBUG */ #endif
/* /*
...@@ -203,28 +200,35 @@ xlog_align( ...@@ -203,28 +200,35 @@ xlog_align(
#ifdef DEBUG #ifdef DEBUG
/* /*
* check log record header for recovery * dump debug superblock and log record information
*/ */
static void STATIC void
xlog_header_check_dump(xfs_mount_t *mp, xlog_rec_header_t *head) xlog_header_check_dump(
xfs_mount_t *mp,
xlog_rec_header_t *head)
{ {
int b; int b;
printk("%s: SB : uuid = ", __FUNCTION__); printk("%s: SB : uuid = ", __FUNCTION__);
for (b=0;b<16;b++) printk("%02x",((unsigned char *)&mp->m_sb.sb_uuid)[b]); for (b = 0; b < 16; b++)
printk(", fmt = %d\n",XLOG_FMT); printk("%02x",((unsigned char *)&mp->m_sb.sb_uuid)[b]);
printk(", fmt = %d\n", XLOG_FMT);
printk(" log : uuid = "); printk(" log : uuid = ");
for (b=0;b<16;b++) printk("%02x",((unsigned char *)&head->h_fs_uuid)[b]); for (b = 0; b < 16; b++)
printk("%02x",((unsigned char *)&head->h_fs_uuid)[b]);
printk(", fmt = %d\n", INT_GET(head->h_fmt, ARCH_CONVERT)); printk(", fmt = %d\n", INT_GET(head->h_fmt, ARCH_CONVERT));
} }
#else
#define xlog_header_check_dump(mp, head)
#endif #endif
/* /*
* check log record header for recovery * check log record header for recovery
*/ */
STATIC int STATIC int
xlog_header_check_recover(xfs_mount_t *mp, xlog_rec_header_t *head) xlog_header_check_recover(
xfs_mount_t *mp,
xlog_rec_header_t *head)
{ {
ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM); ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM);
...@@ -233,57 +237,48 @@ xlog_header_check_recover(xfs_mount_t *mp, xlog_rec_header_t *head) ...@@ -233,57 +237,48 @@ xlog_header_check_recover(xfs_mount_t *mp, xlog_rec_header_t *head)
* (XLOG_FMT_UNKNOWN). This stops us from trying to recover * (XLOG_FMT_UNKNOWN). This stops us from trying to recover
* a dirty log created in IRIX. * a dirty log created in IRIX.
*/ */
if (unlikely(INT_GET(head->h_fmt, ARCH_CONVERT) != XLOG_FMT)) { if (unlikely(INT_GET(head->h_fmt, ARCH_CONVERT) != XLOG_FMT)) {
xlog_warn("XFS: dirty log written in incompatible format - can't recover"); xlog_warn(
#ifdef DEBUG "XFS: dirty log written in incompatible format - can't recover");
xlog_header_check_dump(mp, head); xlog_header_check_dump(mp, head);
#endif
XFS_ERROR_REPORT("xlog_header_check_recover(1)", XFS_ERROR_REPORT("xlog_header_check_recover(1)",
XFS_ERRLEVEL_HIGH, mp); XFS_ERRLEVEL_HIGH, mp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
xlog_warn("XFS: dirty log entry has mismatched uuid - can't recover"); xlog_warn(
#ifdef DEBUG "XFS: dirty log entry has mismatched uuid - can't recover");
xlog_header_check_dump(mp, head); xlog_header_check_dump(mp, head);
#endif
XFS_ERROR_REPORT("xlog_header_check_recover(2)", XFS_ERROR_REPORT("xlog_header_check_recover(2)",
XFS_ERRLEVEL_HIGH, mp); XFS_ERRLEVEL_HIGH, mp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
return 0; return 0;
} }
/* /*
* read the head block of the log and check the header * read the head block of the log and check the header
*/ */
STATIC int STATIC int
xlog_header_check_mount(xfs_mount_t *mp, xlog_rec_header_t *head) xlog_header_check_mount(
xfs_mount_t *mp,
xlog_rec_header_t *head)
{ {
ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM); ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM);
if (uuid_is_nil(&head->h_fs_uuid)) { if (uuid_is_nil(&head->h_fs_uuid)) {
/* /*
* IRIX doesn't write the h_fs_uuid or h_fmt fields. If * IRIX doesn't write the h_fs_uuid or h_fmt fields. If
* h_fs_uuid is nil, we assume this log was last mounted * h_fs_uuid is nil, we assume this log was last mounted
* by IRIX and continue. * by IRIX and continue.
*/ */
xlog_warn("XFS: nil uuid in log - IRIX style log"); xlog_warn("XFS: nil uuid in log - IRIX style log");
} else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
xlog_warn("XFS: log has mismatched uuid - can't recover"); xlog_warn("XFS: log has mismatched uuid - can't recover");
#ifdef DEBUG
xlog_header_check_dump(mp, head); xlog_header_check_dump(mp, head);
#endif
XFS_ERROR_REPORT("xlog_header_check_mount", XFS_ERROR_REPORT("xlog_header_check_mount",
XFS_ERRLEVEL_HIGH, mp); XFS_ERRLEVEL_HIGH, mp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
return 0; return 0;
} }
...@@ -292,6 +287,7 @@ xlog_recover_iodone( ...@@ -292,6 +287,7 @@ xlog_recover_iodone(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_mount_t *mp; xfs_mount_t *mp;
ASSERT(XFS_BUF_FSPRIVATE(bp, void *)); ASSERT(XFS_BUF_FSPRIVATE(bp, void *));
if (XFS_BUF_GETERROR(bp)) { if (XFS_BUF_GETERROR(bp)) {
...@@ -316,7 +312,8 @@ xlog_recover_iodone( ...@@ -316,7 +312,8 @@ xlog_recover_iodone(
* necessarily be perfect. * necessarily be perfect.
*/ */
int int
xlog_find_cycle_start(xlog_t *log, xlog_find_cycle_start(
xlog_t *log,
xfs_buf_t *bp, xfs_buf_t *bp,
xfs_daddr_t first_blk, xfs_daddr_t first_blk,
xfs_daddr_t *last_blk, xfs_daddr_t *last_blk,
...@@ -346,8 +343,7 @@ xlog_find_cycle_start(xlog_t *log, ...@@ -346,8 +343,7 @@ xlog_find_cycle_start(xlog_t *log,
(mid_blk == *last_blk && mid_blk-1 == first_blk)); (mid_blk == *last_blk && mid_blk-1 == first_blk));
return 0; return 0;
} /* xlog_find_cycle_start */ }
/* /*
* Check that the range of blocks does not contain the cycle number * Check that the range of blocks does not contain the cycle number
...@@ -359,9 +355,9 @@ xlog_find_cycle_start(xlog_t *log, ...@@ -359,9 +355,9 @@ xlog_find_cycle_start(xlog_t *log,
* Set blkno to -1 if we encounter no errors. This is an invalid block number * Set blkno to -1 if we encounter no errors. This is an invalid block number
* since we don't ever expect logs to get this large. * since we don't ever expect logs to get this large.
*/ */
STATIC int STATIC int
xlog_find_verify_cycle( xlog_t *log, xlog_find_verify_cycle(
xlog_t *log,
xfs_daddr_t start_blk, xfs_daddr_t start_blk,
int nbblks, int nbblks,
uint stop_on_cycle_no, uint stop_on_cycle_no,
...@@ -370,9 +366,9 @@ xlog_find_verify_cycle( xlog_t *log, ...@@ -370,9 +366,9 @@ xlog_find_verify_cycle( xlog_t *log,
xfs_daddr_t i, j; xfs_daddr_t i, j;
uint cycle; uint cycle;
xfs_buf_t *bp; xfs_buf_t *bp;
char *buf = NULL;
int error = 0;
xfs_daddr_t bufblks; xfs_daddr_t bufblks;
xfs_caddr_t buf = NULL;
int error = 0;
bufblks = 1 << ffs(nbblks); bufblks = 1 << ffs(nbblks);
...@@ -407,10 +403,8 @@ xlog_find_verify_cycle( xlog_t *log, ...@@ -407,10 +403,8 @@ xlog_find_verify_cycle( xlog_t *log,
out: out:
xlog_put_bp(bp); xlog_put_bp(bp);
return error; return error;
} /* xlog_find_verify_cycle */ }
/* /*
* Potentially backup over partial log record write. * Potentially backup over partial log record write.
...@@ -424,9 +418,9 @@ xlog_find_verify_cycle( xlog_t *log, ...@@ -424,9 +418,9 @@ xlog_find_verify_cycle( xlog_t *log,
* extra_bblks is the number of blocks potentially verified on a previous * extra_bblks is the number of blocks potentially verified on a previous
* call to this routine. * call to this routine.
*/ */
STATIC int STATIC int
xlog_find_verify_log_record(xlog_t *log, xlog_find_verify_log_record(
xlog_t *log,
xfs_daddr_t start_blk, xfs_daddr_t start_blk,
xfs_daddr_t *last_blk, xfs_daddr_t *last_blk,
int extra_bblks) int extra_bblks)
...@@ -456,7 +450,8 @@ xlog_find_verify_log_record(xlog_t *log, ...@@ -456,7 +450,8 @@ xlog_find_verify_log_record(xlog_t *log,
for (i = (*last_blk) - 1; i >= 0; i--) { for (i = (*last_blk) - 1; i >= 0; i--) {
if (i < start_blk) { if (i < start_blk) {
/* legal log record not found */ /* legal log record not found */
xlog_warn("XFS: Log inconsistent (didn't find previous header)"); xlog_warn(
"XFS: Log inconsistent (didn't find previous header)");
ASSERT(0); ASSERT(0);
error = XFS_ERROR(EIO); error = XFS_ERROR(EIO);
goto out; goto out;
...@@ -470,7 +465,8 @@ xlog_find_verify_log_record(xlog_t *log, ...@@ -470,7 +465,8 @@ xlog_find_verify_log_record(xlog_t *log,
head = (xlog_rec_header_t *)offset; head = (xlog_rec_header_t *)offset;
if (INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM) if (XLOG_HEADER_MAGIC_NUM ==
INT_GET(head->h_magicno, ARCH_CONVERT))
break; break;
if (!smallmem) if (!smallmem)
...@@ -487,10 +483,10 @@ xlog_find_verify_log_record(xlog_t *log, ...@@ -487,10 +483,10 @@ xlog_find_verify_log_record(xlog_t *log,
goto out; goto out;
} }
/* we have the final block of the good log (the first block /*
* We have the final block of the good log (the first block
* of the log record _before_ the head. So we check the uuid. * of the log record _before_ the head. So we check the uuid.
*/ */
if ((error = xlog_header_check_mount(log->l_mp, head))) if ((error = xlog_header_check_mount(log->l_mp, head)))
goto out; goto out;
...@@ -512,14 +508,13 @@ xlog_find_verify_log_record(xlog_t *log, ...@@ -512,14 +508,13 @@ xlog_find_verify_log_record(xlog_t *log,
} }
if (*last_blk - i + extra_bblks if (*last_blk - i + extra_bblks
!= BTOBB(INT_GET(head->h_len, ARCH_CONVERT))+xhdrs) != BTOBB(INT_GET(head->h_len, ARCH_CONVERT)) + xhdrs)
*last_blk = i; *last_blk = i;
out: out:
xlog_put_bp(bp); xlog_put_bp(bp);
return error; return error;
} /* xlog_find_verify_log_record */ }
/* /*
* Head is defined to be the point of the log where the next log write * Head is defined to be the point of the log where the next log write
...@@ -532,8 +527,6 @@ xlog_find_verify_log_record(xlog_t *log, ...@@ -532,8 +527,6 @@ xlog_find_verify_log_record(xlog_t *log,
* last_blk contains the block number of the first block with a given * last_blk contains the block number of the first block with a given
* cycle number. * cycle number.
* *
* Also called from xfs_log_print.c
*
* Return: zero if normal, non-zero if error. * Return: zero if normal, non-zero if error.
*/ */
int int
...@@ -799,7 +792,8 @@ xlog_find_head(xlog_t *log, ...@@ -799,7 +792,8 @@ xlog_find_head(xlog_t *log,
* available. * available.
*/ */
int int
xlog_find_tail(xlog_t *log, xlog_find_tail(
xlog_t *log,
xfs_daddr_t *head_blk, xfs_daddr_t *head_blk,
xfs_daddr_t *tail_blk, xfs_daddr_t *tail_blk,
int readonly) int readonly)
...@@ -980,10 +974,8 @@ xlog_find_tail(xlog_t *log, ...@@ -980,10 +974,8 @@ xlog_find_tail(xlog_t *log,
if (error) if (error)
xlog_warn("XFS: failed to locate log tail"); xlog_warn("XFS: failed to locate log tail");
return error; return error;
} /* xlog_find_tail */ }
/* /*
* Is the log zeroed at all? * Is the log zeroed at all?
...@@ -1002,7 +994,8 @@ xlog_find_tail(xlog_t *log, ...@@ -1002,7 +994,8 @@ xlog_find_tail(xlog_t *log,
* >0 => error has occurred * >0 => error has occurred
*/ */
int int
xlog_find_zeroed(struct log *log, xlog_find_zeroed(
xlog_t *log,
xfs_daddr_t *blk_no) xfs_daddr_t *blk_no)
{ {
xfs_buf_t *bp; xfs_buf_t *bp;
...@@ -1091,7 +1084,7 @@ xlog_find_zeroed(struct log *log, ...@@ -1091,7 +1084,7 @@ xlog_find_zeroed(struct log *log,
if (error) if (error)
return error; return error;
return -1; return -1;
} /* xlog_find_zeroed */ }
/* /*
* These are simple subroutines used by xlog_clear_stale_blocks() below * These are simple subroutines used by xlog_clear_stale_blocks() below
...@@ -1334,7 +1327,8 @@ xlog_clear_stale_blocks( ...@@ -1334,7 +1327,8 @@ xlog_clear_stale_blocks(
*/ */
STATIC xlog_recover_t * STATIC xlog_recover_t *
xlog_recover_find_tid(xlog_recover_t *q, xlog_recover_find_tid(
xlog_recover_t *q,
xlog_tid_t tid) xlog_tid_t tid)
{ {
xlog_recover_t *p = q; xlog_recover_t *p = q;
...@@ -1345,30 +1339,30 @@ xlog_recover_find_tid(xlog_recover_t *q, ...@@ -1345,30 +1339,30 @@ xlog_recover_find_tid(xlog_recover_t *q,
p = p->r_next; p = p->r_next;
} }
return p; return p;
} /* xlog_recover_find_tid */ }
STATIC void STATIC void
xlog_recover_put_hashq(xlog_recover_t **q, xlog_recover_put_hashq(
xlog_recover_t **q,
xlog_recover_t *trans) xlog_recover_t *trans)
{ {
trans->r_next = *q; trans->r_next = *q;
*q = trans; *q = trans;
} /* xlog_recover_put_hashq */ }
STATIC void STATIC void
xlog_recover_add_item(xlog_recover_item_t **itemq) xlog_recover_add_item(
xlog_recover_item_t **itemq)
{ {
xlog_recover_item_t *item; xlog_recover_item_t *item;
item = kmem_zalloc(sizeof(xlog_recover_item_t), 0); item = kmem_zalloc(sizeof(xlog_recover_item_t), 0);
xlog_recover_insert_item_backq(itemq, item); xlog_recover_insert_item_backq(itemq, item);
} /* xlog_recover_add_item */ }
STATIC int STATIC int
xlog_recover_add_to_cont_trans(xlog_recover_t *trans, xlog_recover_add_to_cont_trans(
xlog_recover_t *trans,
xfs_caddr_t dp, xfs_caddr_t dp,
int len) int len)
{ {
...@@ -1380,7 +1374,8 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans, ...@@ -1380,7 +1374,8 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans,
if (item == 0) { if (item == 0) {
/* finish copying rest of trans header */ /* finish copying rest of trans header */
xlog_recover_add_item(&trans->r_itemq); xlog_recover_add_item(&trans->r_itemq);
ptr = (xfs_caddr_t)&trans->r_theader+sizeof(xfs_trans_header_t)-len; ptr = (xfs_caddr_t) &trans->r_theader +
sizeof(xfs_trans_header_t) - len;
memcpy(ptr, dp, len); /* d, s, l */ memcpy(ptr, dp, len); /* d, s, l */
return 0; return 0;
} }
...@@ -1394,10 +1389,10 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans, ...@@ -1394,10 +1389,10 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans,
item->ri_buf[item->ri_cnt-1].i_len += len; item->ri_buf[item->ri_cnt-1].i_len += len;
item->ri_buf[item->ri_cnt-1].i_addr = ptr; item->ri_buf[item->ri_cnt-1].i_addr = ptr;
return 0; return 0;
} /* xlog_recover_add_to_cont_trans */ }
/* The next region to add is the start of a new region. It could be /*
* The next region to add is the start of a new region. It could be
* a whole region or it could be the first part of a new region. Because * a whole region or it could be the first part of a new region. Because
* of this, the assumption here is that the type and size fields of all * of this, the assumption here is that the type and size fields of all
* format structures fit into the first 32 bits of the structure. * format structures fit into the first 32 bits of the structure.
...@@ -1410,7 +1405,8 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans, ...@@ -1410,7 +1405,8 @@ xlog_recover_add_to_cont_trans(xlog_recover_t *trans,
* will appear in the current log item. * will appear in the current log item.
*/ */
STATIC int STATIC int
xlog_recover_add_to_trans(xlog_recover_t *trans, xlog_recover_add_to_trans(
xlog_recover_t *trans,
xfs_caddr_t dp, xfs_caddr_t dp,
int len) int len)
{ {
...@@ -1429,7 +1425,7 @@ xlog_recover_add_to_trans(xlog_recover_t *trans, ...@@ -1429,7 +1425,7 @@ xlog_recover_add_to_trans(xlog_recover_t *trans,
return 0; return 0;
} }
ptr = kmem_alloc(len, 0); ptr = kmem_alloc(len, KM_SLEEP);
memcpy(ptr, dp, len); memcpy(ptr, dp, len);
in_f = (xfs_inode_log_format_t *)ptr; in_f = (xfs_inode_log_format_t *)ptr;
...@@ -1452,25 +1448,25 @@ xlog_recover_add_to_trans(xlog_recover_t *trans, ...@@ -1452,25 +1448,25 @@ xlog_recover_add_to_trans(xlog_recover_t *trans,
item->ri_buf[item->ri_cnt].i_len = len; item->ri_buf[item->ri_cnt].i_len = len;
item->ri_cnt++; item->ri_cnt++;
return 0; return 0;
} /* xlog_recover_add_to_trans */ }
STATIC void STATIC void
xlog_recover_new_tid(xlog_recover_t **q, xlog_recover_new_tid(
xlog_recover_t **q,
xlog_tid_t tid, xlog_tid_t tid,
xfs_lsn_t lsn) xfs_lsn_t lsn)
{ {
xlog_recover_t *trans; xlog_recover_t *trans;
trans = kmem_zalloc(sizeof(xlog_recover_t), 0); trans = kmem_zalloc(sizeof(xlog_recover_t), KM_SLEEP);
trans->r_log_tid = tid; trans->r_log_tid = tid;
trans->r_lsn = lsn; trans->r_lsn = lsn;
xlog_recover_put_hashq(q, trans); xlog_recover_put_hashq(q, trans);
} /* xlog_recover_new_tid */ }
STATIC int STATIC int
xlog_recover_unlink_tid(xlog_recover_t **q, xlog_recover_unlink_tid(
xlog_recover_t **q,
xlog_recover_t *trans) xlog_recover_t *trans)
{ {
xlog_recover_t *tp; xlog_recover_t *tp;
...@@ -1497,10 +1493,11 @@ xlog_recover_unlink_tid(xlog_recover_t **q, ...@@ -1497,10 +1493,11 @@ xlog_recover_unlink_tid(xlog_recover_t **q,
tp->r_next = tp->r_next->r_next; tp->r_next = tp->r_next->r_next;
} }
return 0; return 0;
} /* xlog_recover_unlink_tid */ }
STATIC void STATIC void
xlog_recover_insert_item_backq(xlog_recover_item_t **q, xlog_recover_insert_item_backq(
xlog_recover_item_t **q,
xlog_recover_item_t *item) xlog_recover_item_t *item)
{ {
if (*q == 0) { if (*q == 0) {
...@@ -1512,18 +1509,20 @@ xlog_recover_insert_item_backq(xlog_recover_item_t **q, ...@@ -1512,18 +1509,20 @@ xlog_recover_insert_item_backq(xlog_recover_item_t **q,
(*q)->ri_prev = item; (*q)->ri_prev = item;
item->ri_prev->ri_next = item; item->ri_prev->ri_next = item;
} }
} /* xlog_recover_insert_item_backq */ }
STATIC void STATIC void
xlog_recover_insert_item_frontq(xlog_recover_item_t **q, xlog_recover_insert_item_frontq(
xlog_recover_item_t **q,
xlog_recover_item_t *item) xlog_recover_item_t *item)
{ {
xlog_recover_insert_item_backq(q, item); xlog_recover_insert_item_backq(q, item);
*q = item; *q = item;
} /* xlog_recover_insert_item_frontq */ }
STATIC int STATIC int
xlog_recover_reorder_trans(xlog_t *log, xlog_recover_reorder_trans(
xlog_t *log,
xlog_recover_t *trans) xlog_recover_t *trans)
{ {
xlog_recover_item_t *first_item, *itemq, *itemq_next; xlog_recover_item_t *first_item, *itemq, *itemq_next;
...@@ -1535,32 +1534,28 @@ xlog_recover_reorder_trans(xlog_t *log, ...@@ -1535,32 +1534,28 @@ xlog_recover_reorder_trans(xlog_t *log,
switch (ITEM_TYPE(itemq)) { switch (ITEM_TYPE(itemq)) {
case XFS_LI_BUF: case XFS_LI_BUF:
case XFS_LI_6_1_BUF: case XFS_LI_6_1_BUF:
case XFS_LI_5_3_BUF: { case XFS_LI_5_3_BUF:
xlog_recover_insert_item_frontq(&trans->r_itemq, itemq); xlog_recover_insert_item_frontq(&trans->r_itemq, itemq);
break; break;
}
case XFS_LI_INODE: case XFS_LI_INODE:
case XFS_LI_6_1_INODE: case XFS_LI_6_1_INODE:
case XFS_LI_5_3_INODE: case XFS_LI_5_3_INODE:
case XFS_LI_DQUOT: case XFS_LI_DQUOT:
case XFS_LI_QUOTAOFF: case XFS_LI_QUOTAOFF:
case XFS_LI_EFD: case XFS_LI_EFD:
case XFS_LI_EFI: { case XFS_LI_EFI:
xlog_recover_insert_item_backq(&trans->r_itemq, itemq); xlog_recover_insert_item_backq(&trans->r_itemq, itemq);
break; break;
} default:
default: {
xlog_warn( xlog_warn(
"XFS: xlog_recover_reorder_trans: unrecognized type of log operation"); "XFS: xlog_recover_reorder_trans: unrecognized type of log operation");
ASSERT(0); ASSERT(0);
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
} }
}
itemq = itemq_next; itemq = itemq_next;
} while (first_item != itemq); } while (first_item != itemq);
return 0; return 0;
} /* xlog_recover_reorder_trans */ }
/* /*
* Build up the table of buf cancel records so that we don't replay * Build up the table of buf cancel records so that we don't replay
...@@ -1575,7 +1570,8 @@ xlog_recover_reorder_trans(xlog_t *log, ...@@ -1575,7 +1570,8 @@ xlog_recover_reorder_trans(xlog_t *log,
* record during the second pass. * record during the second pass.
*/ */
STATIC void STATIC void
xlog_recover_do_buffer_pass1(xlog_t *log, xlog_recover_do_buffer_pass1(
xlog_t *log,
xfs_buf_log_format_t *buf_f) xfs_buf_log_format_t *buf_f)
{ {
xfs_buf_cancel_t *bcp; xfs_buf_cancel_t *bcp;
...@@ -1583,9 +1579,9 @@ xlog_recover_do_buffer_pass1(xlog_t *log, ...@@ -1583,9 +1579,9 @@ xlog_recover_do_buffer_pass1(xlog_t *log,
xfs_buf_cancel_t *prevp; xfs_buf_cancel_t *prevp;
xfs_buf_cancel_t **bucket; xfs_buf_cancel_t **bucket;
xfs_buf_log_format_v1_t *obuf_f; xfs_buf_log_format_v1_t *obuf_f;
xfs_daddr_t blkno=0; xfs_daddr_t blkno = 0;
uint len=0; uint len = 0;
ushort flags=0; ushort flags = 0;
switch (buf_f->blf_type) { switch (buf_f->blf_type) {
case XFS_LI_BUF: case XFS_LI_BUF:
...@@ -1605,9 +1601,8 @@ xlog_recover_do_buffer_pass1(xlog_t *log, ...@@ -1605,9 +1601,8 @@ xlog_recover_do_buffer_pass1(xlog_t *log,
/* /*
* If this isn't a cancel buffer item, then just return. * If this isn't a cancel buffer item, then just return.
*/ */
if (!(flags & XFS_BLI_CANCEL)) { if (!(flags & XFS_BLI_CANCEL))
return; return;
}
/* /*
* Insert an xfs_buf_cancel record into the hash table of * Insert an xfs_buf_cancel record into the hash table of
...@@ -1621,7 +1616,7 @@ xlog_recover_do_buffer_pass1(xlog_t *log, ...@@ -1621,7 +1616,7 @@ xlog_recover_do_buffer_pass1(xlog_t *log,
* the bucket. * the bucket.
*/ */
if (*bucket == NULL) { if (*bucket == NULL) {
bcp = (xfs_buf_cancel_t*)kmem_alloc(sizeof(xfs_buf_cancel_t), bcp = (xfs_buf_cancel_t *)kmem_alloc(sizeof(xfs_buf_cancel_t),
KM_SLEEP); KM_SLEEP);
bcp->bc_blkno = blkno; bcp->bc_blkno = blkno;
bcp->bc_len = len; bcp->bc_len = len;
...@@ -1647,7 +1642,7 @@ xlog_recover_do_buffer_pass1(xlog_t *log, ...@@ -1647,7 +1642,7 @@ xlog_recover_do_buffer_pass1(xlog_t *log,
nextp = nextp->bc_next; nextp = nextp->bc_next;
} }
ASSERT(prevp != NULL); ASSERT(prevp != NULL);
bcp = (xfs_buf_cancel_t*)kmem_alloc(sizeof(xfs_buf_cancel_t), bcp = (xfs_buf_cancel_t *)kmem_alloc(sizeof(xfs_buf_cancel_t),
KM_SLEEP); KM_SLEEP);
bcp->bc_blkno = blkno; bcp->bc_blkno = blkno;
bcp->bc_len = len; bcp->bc_len = len;
...@@ -1670,17 +1665,17 @@ xlog_recover_do_buffer_pass1(xlog_t *log, ...@@ -1670,17 +1665,17 @@ xlog_recover_do_buffer_pass1(xlog_t *log,
* made at that point. * made at that point.
*/ */
STATIC int STATIC int
xlog_recover_do_buffer_pass2(xlog_t *log, xlog_recover_do_buffer_pass2(
xlog_t *log,
xfs_buf_log_format_t *buf_f) xfs_buf_log_format_t *buf_f)
{ {
xfs_buf_cancel_t *bcp; xfs_buf_cancel_t *bcp;
xfs_buf_cancel_t *prevp; xfs_buf_cancel_t *prevp;
xfs_buf_cancel_t **bucket; xfs_buf_cancel_t **bucket;
xfs_buf_log_format_v1_t *obuf_f; xfs_buf_log_format_v1_t *obuf_f;
xfs_daddr_t blkno=0; xfs_daddr_t blkno = 0;
ushort flags=0; ushort flags = 0;
uint len=0; uint len = 0;
switch (buf_f->blf_type) { switch (buf_f->blf_type) {
case XFS_LI_BUF: case XFS_LI_BUF:
...@@ -1757,7 +1752,6 @@ xlog_recover_do_buffer_pass2(xlog_t *log, ...@@ -1757,7 +1752,6 @@ xlog_recover_do_buffer_pass2(xlog_t *log,
return 0; return 0;
} }
/* /*
* Perform recovery for a buffer full of inodes. In these buffers, * Perform recovery for a buffer full of inodes. In these buffers,
* the only data which should be recovered is that which corresponds * the only data which should be recovered is that which corresponds
...@@ -1772,7 +1766,8 @@ xlog_recover_do_buffer_pass2(xlog_t *log, ...@@ -1772,7 +1766,8 @@ xlog_recover_do_buffer_pass2(xlog_t *log,
* sent to xlog_recover_do_reg_buffer() below during recovery. * sent to xlog_recover_do_reg_buffer() below during recovery.
*/ */
STATIC int STATIC int
xlog_recover_do_inode_buffer(xfs_mount_t *mp, xlog_recover_do_inode_buffer(
xfs_mount_t *mp,
xlog_recover_item_t *item, xlog_recover_item_t *item,
xfs_buf_t *bp, xfs_buf_t *bp,
xfs_buf_log_format_t *buf_f) xfs_buf_log_format_t *buf_f)
...@@ -1788,8 +1783,8 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp, ...@@ -1788,8 +1783,8 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp,
xfs_agino_t *logged_nextp; xfs_agino_t *logged_nextp;
xfs_agino_t *buffer_nextp; xfs_agino_t *buffer_nextp;
xfs_buf_log_format_v1_t *obuf_f; xfs_buf_log_format_v1_t *obuf_f;
unsigned int *data_map=NULL; unsigned int *data_map = NULL;
unsigned int map_size=0; unsigned int map_size = 0;
switch (buf_f->blf_type) { switch (buf_f->blf_type) {
case XFS_LI_BUF: case XFS_LI_BUF:
...@@ -1880,7 +1875,7 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp, ...@@ -1880,7 +1875,7 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp,
} }
return 0; return 0;
} /* xlog_recover_do_inode_buffer */ }
/* /*
* Perform a 'normal' buffer recovery. Each logged region of the * Perform a 'normal' buffer recovery. Each logged region of the
...@@ -1890,7 +1885,8 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp, ...@@ -1890,7 +1885,8 @@ xlog_recover_do_inode_buffer(xfs_mount_t *mp,
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
STATIC void STATIC void
xlog_recover_do_reg_buffer(xfs_mount_t *mp, xlog_recover_do_reg_buffer(
xfs_mount_t *mp,
xlog_recover_item_t *item, xlog_recover_item_t *item,
xfs_buf_t *bp, xfs_buf_t *bp,
xfs_buf_log_format_t *buf_f) xfs_buf_log_format_t *buf_f)
...@@ -1899,8 +1895,8 @@ xlog_recover_do_reg_buffer(xfs_mount_t *mp, ...@@ -1899,8 +1895,8 @@ xlog_recover_do_reg_buffer(xfs_mount_t *mp,
int bit; int bit;
int nbits; int nbits;
xfs_buf_log_format_v1_t *obuf_f; xfs_buf_log_format_v1_t *obuf_f;
unsigned int *data_map=NULL; unsigned int *data_map = NULL;
unsigned int map_size=0; unsigned int map_size = 0;
int error; int error;
switch (buf_f->blf_type) { switch (buf_f->blf_type) {
...@@ -1950,7 +1946,7 @@ xlog_recover_do_reg_buffer(xfs_mount_t *mp, ...@@ -1950,7 +1946,7 @@ xlog_recover_do_reg_buffer(xfs_mount_t *mp,
/* Shouldn't be any more regions */ /* Shouldn't be any more regions */
ASSERT(i == item->ri_total); ASSERT(i == item->ri_total);
} /* xlog_recover_do_reg_buffer */ }
/* /*
* Do some primitive error checking on ondisk dquot data structures. * Do some primitive error checking on ondisk dquot data structures.
...@@ -2128,7 +2124,8 @@ xlog_recover_do_dquot_buffer( ...@@ -2128,7 +2124,8 @@ xlog_recover_do_dquot_buffer(
* for more details on the implementation of the table of cancel records. * for more details on the implementation of the table of cancel records.
*/ */
STATIC int STATIC int
xlog_recover_do_buffer_trans(xlog_t *log, xlog_recover_do_buffer_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
int pass) int pass)
{ {
...@@ -2242,10 +2239,11 @@ xlog_recover_do_buffer_trans(xlog_t *log, ...@@ -2242,10 +2239,11 @@ xlog_recover_do_buffer_trans(xlog_t *log,
} }
return (error); return (error);
} /* xlog_recover_do_buffer_trans */ }
STATIC int STATIC int
xlog_recover_do_inode_trans(xlog_t *log, xlog_recover_do_inode_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
int pass) int pass)
{ {
...@@ -2467,7 +2465,6 @@ xlog_recover_do_inode_trans(xlog_t *log, ...@@ -2467,7 +2465,6 @@ xlog_recover_do_inode_trans(xlog_t *log,
} }
} }
write_inode_buffer: write_inode_buffer:
if (ITEM_TYPE(item) == XFS_LI_INODE) { if (ITEM_TYPE(item) == XFS_LI_INODE) {
ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL || ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL ||
...@@ -2481,8 +2478,7 @@ xlog_recover_do_inode_trans(xlog_t *log, ...@@ -2481,8 +2478,7 @@ xlog_recover_do_inode_trans(xlog_t *log,
} }
return (error); return (error);
} /* xlog_recover_do_inode_trans */ }
/* /*
* Recover QUOTAOFF records. We simply make a note of it in the xlog_t * Recover QUOTAOFF records. We simply make a note of it in the xlog_t
...@@ -2490,7 +2486,8 @@ xlog_recover_do_inode_trans(xlog_t *log, ...@@ -2490,7 +2486,8 @@ xlog_recover_do_inode_trans(xlog_t *log,
* of that type. * of that type.
*/ */
STATIC int STATIC int
xlog_recover_do_quotaoff_trans(xlog_t *log, xlog_recover_do_quotaoff_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
int pass) int pass)
{ {
...@@ -2515,12 +2512,12 @@ xlog_recover_do_quotaoff_trans(xlog_t *log, ...@@ -2515,12 +2512,12 @@ xlog_recover_do_quotaoff_trans(xlog_t *log,
return (0); return (0);
} }
/* /*
* Recover a dquot record * Recover a dquot record
*/ */
STATIC int STATIC int
xlog_recover_do_dquot_trans(xlog_t *log, xlog_recover_do_dquot_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
int pass) int pass)
{ {
...@@ -2606,7 +2603,7 @@ xlog_recover_do_dquot_trans(xlog_t *log, ...@@ -2606,7 +2603,7 @@ xlog_recover_do_dquot_trans(xlog_t *log,
xfs_bdwrite(mp, bp); xfs_bdwrite(mp, bp);
return (0); return (0);
} /* xlog_recover_do_dquot_trans */ }
/* /*
* This routine is called to create an in-core extent free intent * This routine is called to create an in-core extent free intent
...@@ -2616,7 +2613,8 @@ xlog_recover_do_dquot_trans(xlog_t *log, ...@@ -2616,7 +2613,8 @@ xlog_recover_do_dquot_trans(xlog_t *log,
* LSN. * LSN.
*/ */
STATIC void STATIC void
xlog_recover_do_efi_trans(xlog_t *log, xlog_recover_do_efi_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
xfs_lsn_t lsn, xfs_lsn_t lsn,
int pass) int pass)
...@@ -2648,7 +2646,7 @@ xlog_recover_do_efi_trans(xlog_t *log, ...@@ -2648,7 +2646,7 @@ xlog_recover_do_efi_trans(xlog_t *log,
* xfs_trans_update_ail() drops the AIL lock. * xfs_trans_update_ail() drops the AIL lock.
*/ */
xfs_trans_update_ail(mp, (xfs_log_item_t *)efip, lsn, s); xfs_trans_update_ail(mp, (xfs_log_item_t *)efip, lsn, s);
} /* xlog_recover_do_efi_trans */ }
/* /*
...@@ -2660,13 +2658,14 @@ xlog_recover_do_efi_trans(xlog_t *log, ...@@ -2660,13 +2658,14 @@ xlog_recover_do_efi_trans(xlog_t *log,
* AIL and free it. * AIL and free it.
*/ */
STATIC void STATIC void
xlog_recover_do_efd_trans(xlog_t *log, xlog_recover_do_efd_trans(
xlog_t *log,
xlog_recover_item_t *item, xlog_recover_item_t *item,
int pass) int pass)
{ {
xfs_mount_t *mp; xfs_mount_t *mp;
xfs_efd_log_format_t *efd_formatp; xfs_efd_log_format_t *efd_formatp;
xfs_efi_log_item_t *efip=NULL; xfs_efi_log_item_t *efip = NULL;
xfs_log_item_t *lip; xfs_log_item_t *lip;
int gen; int gen;
int nexts; int nexts;
...@@ -2721,7 +2720,7 @@ xlog_recover_do_efd_trans(xlog_t *log, ...@@ -2721,7 +2720,7 @@ xlog_recover_do_efd_trans(xlog_t *log,
kmem_zone_free(xfs_efi_zone, efip); kmem_zone_free(xfs_efi_zone, efip);
} }
} }
} /* xlog_recover_do_efd_trans */ }
/* /*
* Perform the transaction * Perform the transaction
...@@ -2730,7 +2729,8 @@ xlog_recover_do_efd_trans(xlog_t *log, ...@@ -2730,7 +2729,8 @@ xlog_recover_do_efd_trans(xlog_t *log,
* EFIs and EFDs get queued up by adding entries into the AIL for them. * EFIs and EFDs get queued up by adding entries into the AIL for them.
*/ */
STATIC int STATIC int
xlog_recover_do_trans(xlog_t *log, xlog_recover_do_trans(
xlog_t *log,
xlog_recover_t *trans, xlog_recover_t *trans,
int pass) int pass)
{ {
...@@ -2785,8 +2785,7 @@ xlog_recover_do_trans(xlog_t *log, ...@@ -2785,8 +2785,7 @@ xlog_recover_do_trans(xlog_t *log,
} while (first_item != item); } while (first_item != item);
return error; return error;
} /* xlog_recover_do_trans */ }
/* /*
* Free up any resources allocated by the transaction * Free up any resources allocated by the transaction
...@@ -2794,7 +2793,8 @@ xlog_recover_do_trans(xlog_t *log, ...@@ -2794,7 +2793,8 @@ xlog_recover_do_trans(xlog_t *log,
* Remember that EFIs, EFDs, and IUNLINKs are handled later. * Remember that EFIs, EFDs, and IUNLINKs are handled later.
*/ */
STATIC void STATIC void
xlog_recover_free_trans(xlog_recover_t *trans) xlog_recover_free_trans(
xlog_recover_t *trans)
{ {
xlog_recover_item_t *first_item, *item, *free_item; xlog_recover_item_t *first_item, *item, *free_item;
int i; int i;
...@@ -2815,11 +2815,11 @@ xlog_recover_free_trans(xlog_recover_t *trans) ...@@ -2815,11 +2815,11 @@ xlog_recover_free_trans(xlog_recover_t *trans)
} while (first_item != item); } while (first_item != item);
/* Free the transaction recover structure */ /* Free the transaction recover structure */
kmem_free(trans, sizeof(xlog_recover_t)); kmem_free(trans, sizeof(xlog_recover_t));
} /* xlog_recover_free_trans */ }
STATIC int STATIC int
xlog_recover_commit_trans(xlog_t *log, xlog_recover_commit_trans(
xlog_t *log,
xlog_recover_t **q, xlog_recover_t **q,
xlog_recover_t *trans, xlog_recover_t *trans,
int pass) int pass)
...@@ -2832,18 +2832,16 @@ xlog_recover_commit_trans(xlog_t *log, ...@@ -2832,18 +2832,16 @@ xlog_recover_commit_trans(xlog_t *log,
return error; return error;
xlog_recover_free_trans(trans); /* no error */ xlog_recover_free_trans(trans); /* no error */
return 0; return 0;
} /* xlog_recover_commit_trans */ }
/*ARGSUSED*/
STATIC int STATIC int
xlog_recover_unmount_trans(xlog_recover_t *trans) xlog_recover_unmount_trans(
xlog_recover_t *trans)
{ {
/* Do nothing now */ /* Do nothing now */
xlog_warn("XFS: xlog_recover_unmount_trans: Unmount LR"); xlog_warn("XFS: xlog_recover_unmount_trans: Unmount LR");
return( 0 ); return 0;
} /* xlog_recover_unmount_trans */ }
/* /*
* There are two valid states of the r_state field. 0 indicates that the * There are two valid states of the r_state field. 0 indicates that the
...@@ -2855,14 +2853,15 @@ xlog_recover_unmount_trans(xlog_recover_t *trans) ...@@ -2855,14 +2853,15 @@ xlog_recover_unmount_trans(xlog_recover_t *trans)
* NOTE: skip LRs with 0 data length. * NOTE: skip LRs with 0 data length.
*/ */
STATIC int STATIC int
xlog_recover_process_data(xlog_t *log, xlog_recover_process_data(
xlog_t *log,
xlog_recover_t *rhash[], xlog_recover_t *rhash[],
xlog_rec_header_t *rhead, xlog_rec_header_t *rhead,
xfs_caddr_t dp, xfs_caddr_t dp,
int pass) int pass)
{ {
xfs_caddr_t lp = dp+INT_GET(rhead->h_len, ARCH_CONVERT); xfs_caddr_t lp;
int num_logops = INT_GET(rhead->h_num_logops, ARCH_CONVERT); int num_logops;
xlog_op_header_t *ohead; xlog_op_header_t *ohead;
xlog_recover_t *trans; xlog_recover_t *trans;
xlog_tid_t tid; xlog_tid_t tid;
...@@ -2870,6 +2869,9 @@ xlog_recover_process_data(xlog_t *log, ...@@ -2870,6 +2869,9 @@ xlog_recover_process_data(xlog_t *log,
unsigned long hash; unsigned long hash;
uint flags; uint flags;
lp = dp + INT_GET(rhead->h_len, ARCH_CONVERT);
num_logops = INT_GET(rhead->h_num_logops, ARCH_CONVERT);
/* check the log format matches our own - else we can't recover */ /* check the log format matches our own - else we can't recover */
if (xlog_header_check_recover(log->l_mp, rhead)) if (xlog_header_check_recover(log->l_mp, rhead))
return (XFS_ERROR(EIO)); return (XFS_ERROR(EIO));
...@@ -2880,7 +2882,8 @@ xlog_recover_process_data(xlog_t *log, ...@@ -2880,7 +2882,8 @@ xlog_recover_process_data(xlog_t *log,
dp += sizeof(xlog_op_header_t); dp += sizeof(xlog_op_header_t);
if (ohead->oh_clientid != XFS_TRANSACTION && if (ohead->oh_clientid != XFS_TRANSACTION &&
ohead->oh_clientid != XFS_LOG) { ohead->oh_clientid != XFS_LOG) {
xlog_warn("XFS: xlog_recover_process_data: bad clientid"); xlog_warn(
"XFS: xlog_recover_process_data: bad clientid");
ASSERT(0); ASSERT(0);
return (XFS_ERROR(EIO)); return (XFS_ERROR(EIO));
} }
...@@ -2889,62 +2892,61 @@ xlog_recover_process_data(xlog_t *log, ...@@ -2889,62 +2892,61 @@ xlog_recover_process_data(xlog_t *log,
trans = xlog_recover_find_tid(rhash[hash], tid); trans = xlog_recover_find_tid(rhash[hash], tid);
if (trans == NULL) { /* not found; add new tid */ if (trans == NULL) { /* not found; add new tid */
if (ohead->oh_flags & XLOG_START_TRANS) if (ohead->oh_flags & XLOG_START_TRANS)
xlog_recover_new_tid(&rhash[hash], tid, INT_GET(rhead->h_lsn, ARCH_CONVERT)); xlog_recover_new_tid(&rhash[hash], tid,
INT_GET(rhead->h_lsn, ARCH_CONVERT));
} else { } else {
ASSERT(dp+INT_GET(ohead->oh_len, ARCH_CONVERT) <= lp); ASSERT(dp+INT_GET(ohead->oh_len, ARCH_CONVERT) <= lp);
flags = ohead->oh_flags & ~XLOG_END_TRANS; flags = ohead->oh_flags & ~XLOG_END_TRANS;
if (flags & XLOG_WAS_CONT_TRANS) if (flags & XLOG_WAS_CONT_TRANS)
flags &= ~XLOG_CONTINUE_TRANS; flags &= ~XLOG_CONTINUE_TRANS;
switch (flags) { switch (flags) {
case XLOG_COMMIT_TRANS: { case XLOG_COMMIT_TRANS:
error = xlog_recover_commit_trans(log, &rhash[hash], error = xlog_recover_commit_trans(log,
trans, pass); &rhash[hash], trans, pass);
break; break;
} case XLOG_UNMOUNT_TRANS:
case XLOG_UNMOUNT_TRANS: {
error = xlog_recover_unmount_trans(trans); error = xlog_recover_unmount_trans(trans);
break; break;
} case XLOG_WAS_CONT_TRANS:
case XLOG_WAS_CONT_TRANS: { error = xlog_recover_add_to_cont_trans(trans,
error = xlog_recover_add_to_cont_trans(trans, dp, dp, INT_GET(ohead->oh_len,
INT_GET(ohead->oh_len, ARCH_CONVERT)); ARCH_CONVERT));
break; break;
} case XLOG_START_TRANS:
case XLOG_START_TRANS : { xlog_warn(
xlog_warn("XFS: xlog_recover_process_data: bad transaction"); "XFS: xlog_recover_process_data: bad transaction");
ASSERT(0); ASSERT(0);
error = XFS_ERROR(EIO); error = XFS_ERROR(EIO);
break; break;
}
case 0: case 0:
case XLOG_CONTINUE_TRANS: { case XLOG_CONTINUE_TRANS:
error = xlog_recover_add_to_trans(trans, dp, error = xlog_recover_add_to_trans(trans,
INT_GET(ohead->oh_len, ARCH_CONVERT)); dp, INT_GET(ohead->oh_len,
ARCH_CONVERT));
break; break;
} default:
default: { xlog_warn(
xlog_warn("XFS: xlog_recover_process_data: bad flag"); "XFS: xlog_recover_process_data: bad flag");
ASSERT(0); ASSERT(0);
error = XFS_ERROR(EIO); error = XFS_ERROR(EIO);
break; break;
} }
} /* switch */
if (error) if (error)
return error; return error;
} /* if */ }
dp += INT_GET(ohead->oh_len, ARCH_CONVERT); dp += INT_GET(ohead->oh_len, ARCH_CONVERT);
num_logops--; num_logops--;
} }
return( 0 ); return 0;
} /* xlog_recover_process_data */ }
/* /*
* Process an extent free intent item that was recovered from * Process an extent free intent item that was recovered from
* the log. We need to free the extents that it describes. * the log. We need to free the extents that it describes.
*/ */
STATIC void STATIC void
xlog_recover_process_efi(xfs_mount_t *mp, xlog_recover_process_efi(
xfs_mount_t *mp,
xfs_efi_log_item_t *efip) xfs_efi_log_item_t *efip)
{ {
xfs_efd_log_item_t *efdp; xfs_efd_log_item_t *efdp;
...@@ -2990,8 +2992,7 @@ xlog_recover_process_efi(xfs_mount_t *mp, ...@@ -2990,8 +2992,7 @@ xlog_recover_process_efi(xfs_mount_t *mp,
efip->efi_flags |= XFS_EFI_RECOVERED; efip->efi_flags |= XFS_EFI_RECOVERED;
xfs_trans_commit(tp, 0, NULL); xfs_trans_commit(tp, 0, NULL);
} /* xlog_recover_process_efi */ }
/* /*
* Verify that once we've encountered something other than an EFI * Verify that once we've encountered something other than an EFI
...@@ -2999,13 +3000,13 @@ xlog_recover_process_efi(xfs_mount_t *mp, ...@@ -2999,13 +3000,13 @@ xlog_recover_process_efi(xfs_mount_t *mp,
*/ */
#if defined(DEBUG) #if defined(DEBUG)
STATIC void STATIC void
xlog_recover_check_ail(xfs_mount_t *mp, xlog_recover_check_ail(
xfs_mount_t *mp,
xfs_log_item_t *lip, xfs_log_item_t *lip,
int gen) int gen)
{ {
int orig_gen; int orig_gen = gen;
orig_gen = gen;
do { do {
ASSERT(lip->li_type != XFS_LI_EFI); ASSERT(lip->li_type != XFS_LI_EFI);
lip = xfs_trans_next_ail(mp, lip, &gen, NULL); lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
...@@ -3020,7 +3021,6 @@ xlog_recover_check_ail(xfs_mount_t *mp, ...@@ -3020,7 +3021,6 @@ xlog_recover_check_ail(xfs_mount_t *mp,
} }
#endif /* DEBUG */ #endif /* DEBUG */
/* /*
* When this is called, all of the EFIs which did not have * When this is called, all of the EFIs which did not have
* corresponding EFDs should be in the AIL. What we do now * corresponding EFDs should be in the AIL. What we do now
...@@ -3040,7 +3040,8 @@ xlog_recover_check_ail(xfs_mount_t *mp, ...@@ -3040,7 +3040,8 @@ xlog_recover_check_ail(xfs_mount_t *mp,
* we see something other than an EFI in the AIL. * we see something other than an EFI in the AIL.
*/ */
STATIC void STATIC void
xlog_recover_process_efis(xlog_t *log) xlog_recover_process_efis(
xlog_t *log)
{ {
xfs_log_item_t *lip; xfs_log_item_t *lip;
xfs_efi_log_item_t *efip; xfs_efi_log_item_t *efip;
...@@ -3076,8 +3077,7 @@ xlog_recover_process_efis(xlog_t *log) ...@@ -3076,8 +3077,7 @@ xlog_recover_process_efis(xlog_t *log)
lip = xfs_trans_next_ail(mp, lip, &gen, NULL); lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
} }
AIL_UNLOCK(mp, s); AIL_UNLOCK(mp, s);
} /* xlog_recover_process_efis */ }
/* /*
* This routine performs a transaction to null out a bad inode pointer * This routine performs a transaction to null out a bad inode pointer
...@@ -3120,8 +3120,7 @@ xlog_recover_clear_agi_bucket( ...@@ -3120,8 +3120,7 @@ xlog_recover_clear_agi_bucket(
(offset + sizeof(xfs_agino_t) - 1)); (offset + sizeof(xfs_agino_t) - 1));
(void) xfs_trans_commit(tp, 0, NULL); (void) xfs_trans_commit(tp, 0, NULL);
} /* xlog_recover_clear_agi_bucket */ }
/* /*
* xlog_iunlink_recover * xlog_iunlink_recover
...@@ -3136,7 +3135,8 @@ xlog_recover_clear_agi_bucket( ...@@ -3136,7 +3135,8 @@ xlog_recover_clear_agi_bucket(
* atomic. * atomic.
*/ */
void void
xlog_recover_process_iunlinks(xlog_t *log) xlog_recover_process_iunlinks(
xlog_t *log)
{ {
xfs_mount_t *mp; xfs_mount_t *mp;
xfs_agnumber_t agno; xfs_agnumber_t agno;
...@@ -3278,8 +3278,7 @@ xlog_recover_process_iunlinks(xlog_t *log) ...@@ -3278,8 +3278,7 @@ xlog_recover_process_iunlinks(xlog_t *log)
} }
mp->m_dmevmask = mp_dmevmask; mp->m_dmevmask = mp_dmevmask;
}
} /* xlog_recover_process_iunlinks */
#ifdef DEBUG #ifdef DEBUG
...@@ -3684,7 +3683,8 @@ xlog_do_recovery_pass(xlog_t *log, ...@@ -3684,7 +3683,8 @@ xlog_do_recovery_pass(xlog_t *log,
* the log recovery has been completed. * the log recovery has been completed.
*/ */
STATIC int STATIC int
xlog_do_log_recovery(xlog_t *log, xlog_do_log_recovery(
xlog_t *log,
xfs_daddr_t head_blk, xfs_daddr_t head_blk,
xfs_daddr_t tail_blk) xfs_daddr_t tail_blk)
{ {
...@@ -3731,7 +3731,8 @@ xlog_do_log_recovery(xlog_t *log, ...@@ -3731,7 +3731,8 @@ xlog_do_log_recovery(xlog_t *log,
* Do the actual recovery * Do the actual recovery
*/ */
STATIC int STATIC int
xlog_do_recover(xlog_t *log, xlog_do_recover(
xlog_t *log,
xfs_daddr_t head_blk, xfs_daddr_t head_blk,
xfs_daddr_t tail_blk) xfs_daddr_t tail_blk)
{ {
...@@ -3795,7 +3796,7 @@ xlog_do_recover(xlog_t *log, ...@@ -3795,7 +3796,7 @@ xlog_do_recover(xlog_t *log,
/* Normal transactions can now occur */ /* Normal transactions can now occur */
log->l_flags &= ~XLOG_ACTIVE_RECOVERY; log->l_flags &= ~XLOG_ACTIVE_RECOVERY;
return 0; return 0;
} /* xlog_do_recover */ }
/* /*
* Perform recovery and re-initialize some log variables in xlog_find_tail. * Perform recovery and re-initialize some log variables in xlog_find_tail.
...@@ -3803,13 +3804,14 @@ xlog_do_recover(xlog_t *log, ...@@ -3803,13 +3804,14 @@ xlog_do_recover(xlog_t *log,
* Return error or zero. * Return error or zero.
*/ */
int int
xlog_recover(xlog_t *log, int readonly) xlog_recover(
xlog_t *log,
int readonly)
{ {
xfs_daddr_t head_blk, tail_blk; xfs_daddr_t head_blk, tail_blk;
int error; int error;
/* find the tail of the log */ /* find the tail of the log */
if ((error = xlog_find_tail(log, &head_blk, &tail_blk, readonly))) if ((error = xlog_find_tail(log, &head_blk, &tail_blk, readonly)))
return error; return error;
...@@ -3839,8 +3841,7 @@ xlog_recover(xlog_t *log, int readonly) ...@@ -3839,8 +3841,7 @@ xlog_recover(xlog_t *log, int readonly)
log->l_flags |= XLOG_RECOVERY_NEEDED; log->l_flags |= XLOG_RECOVERY_NEEDED;
} }
return error; return error;
} /* xlog_recover */ }
/* /*
* In the first part of recovery we replay inodes and buffers and build * In the first part of recovery we replay inodes and buffers and build
...@@ -3852,7 +3853,9 @@ xlog_recover(xlog_t *log, int readonly) ...@@ -3852,7 +3853,9 @@ xlog_recover(xlog_t *log, int readonly)
* in the real-time portion of the file system. * in the real-time portion of the file system.
*/ */
int int
xlog_recover_finish(xlog_t *log, int mfsi_flags) xlog_recover_finish(
xlog_t *log,
int mfsi_flags)
{ {
/* /*
* Now we're ready to do the transactions needed for the * Now we're ready to do the transactions needed for the
...@@ -3891,7 +3894,7 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags) ...@@ -3891,7 +3894,7 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags)
log->l_mp->m_fsname); log->l_mp->m_fsname);
} }
return 0; return 0;
} /* xlog_recover_finish */ }
#if defined(DEBUG) #if defined(DEBUG)
...@@ -3900,7 +3903,8 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags) ...@@ -3900,7 +3903,8 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags)
* are consistent with the superblock counters. * are consistent with the superblock counters.
*/ */
void void
xlog_recover_check_summary(xlog_t *log) xlog_recover_check_summary(
xlog_t *log)
{ {
xfs_mount_t *mp; xfs_mount_t *mp;
xfs_agf_t *agfp; xfs_agf_t *agfp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment