Skip to content

Commit

Permalink
xfs: Convert xlog_warn to new logging interface
Browse files Browse the repository at this point in the history
Convert the xfs log operations to use the new error logging
interfaces. This removes the xlog_{warn,panic} wrappers and makes
almost all errors emit the device they belong to instead of just
refering to "XFS".

Signed-off-by: Dave Chinner <[email protected]>
Reviewed-by: Alex Elder <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Dave Chinner authored and dchinner committed Mar 6, 2011
1 parent 4f10700 commit a0fa2b6
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 189 deletions.
10 changes: 6 additions & 4 deletions fs/xfs/quota/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,10 @@ xfs_qm_dqtobp(
/*
* A simple sanity check in case we got a corrupted dquot...
*/
if (xfs_qm_dqcheck(ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES,
error = xfs_qm_dqcheck(mp, ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES,
flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN),
"dqtobp")) {
"dqtobp");
if (error) {
if (!(flags & XFS_QMOPT_DQREPAIR)) {
xfs_trans_brelse(tp, bp);
return XFS_ERROR(EIO);
Expand Down Expand Up @@ -1207,8 +1208,9 @@ xfs_qm_dqflush(
/*
* A simple sanity check in case we got a corrupted dquot..
*/
if (xfs_qm_dqcheck(&dqp->q_core, be32_to_cpu(ddqp->d_id), 0,
XFS_QMOPT_DOWARN, "dqflush (incore copy)")) {
error = xfs_qm_dqcheck(mp, &dqp->q_core, be32_to_cpu(ddqp->d_id), 0,
XFS_QMOPT_DOWARN, "dqflush (incore copy)");
if (error) {
xfs_buf_relse(bp);
xfs_dqfunlock(dqp);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/quota/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ xfs_qm_reset_dqcounts(
* output any warnings because it's perfectly possible to
* find uninitialised dquot blks. See comment in xfs_qm_dqcheck.
*/
(void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR,
(void) xfs_qm_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR,
"xfs_quotacheck");
ddq->d_bcount = 0;
ddq->d_icount = 0;
Expand Down
124 changes: 59 additions & 65 deletions fs/xfs/xfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,10 @@ xfs_log_mount(
int error;

if (!(mp->m_flags & XFS_MOUNT_NORECOVERY))
cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname);
xfs_notice(mp, "Mounting Filesystem");
else {
cmn_err(CE_NOTE,
"Mounting filesystem \"%s\" in no-recovery mode. Filesystem will be inconsistent.",
mp->m_fsname);
xfs_notice(mp,
"Mounting filesystem in no-recovery mode. Filesystem will be inconsistent.");
ASSERT(mp->m_flags & XFS_MOUNT_RDONLY);
}

Expand All @@ -393,7 +392,7 @@ xfs_log_mount(
*/
error = xfs_trans_ail_init(mp);
if (error) {
cmn_err(CE_WARN, "XFS: AIL initialisation failed: error %d", error);
xfs_warn(mp, "AIL initialisation failed: error %d", error);
goto out_free_log;
}
mp->m_log->l_ailp = mp->m_ail;
Expand All @@ -413,7 +412,8 @@ xfs_log_mount(
if (readonly)
mp->m_flags |= XFS_MOUNT_RDONLY;
if (error) {
cmn_err(CE_WARN, "XFS: log mount/recovery failed: error %d", error);
xfs_warn(mp, "log mount/recovery failed: error %d",
error);
goto out_destroy_ail;
}
}
Expand Down Expand Up @@ -542,10 +542,8 @@ xfs_log_unmount_write(xfs_mount_t *mp)
*/
}

if (error) {
xfs_fs_cmn_err(CE_ALERT, mp,
"xfs_log_unmount: unmount record failed");
}
if (error)
xfs_alert(mp, "%s: unmount record failed", __func__);


spin_lock(&log->l_icloglock);
Expand Down Expand Up @@ -852,7 +850,7 @@ xlog_space_left(
* In this case we just want to return the size of the
* log as the amount of space left.
*/
xfs_fs_cmn_err(CE_ALERT, log->l_mp,
xfs_alert(log->l_mp,
"xlog_space_left: head behind tail\n"
" tail_cycle = %d, tail_bytes = %d\n"
" GH cycle = %d, GH bytes = %d",
Expand Down Expand Up @@ -1001,7 +999,7 @@ xlog_alloc_log(xfs_mount_t *mp,

log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL);
if (!log) {
xlog_warn("XFS: Log allocation failed: No memory!");
xfs_warn(mp, "Log allocation failed: No memory!");
goto out;
}

Expand Down Expand Up @@ -1029,24 +1027,24 @@ xlog_alloc_log(xfs_mount_t *mp,
if (xfs_sb_version_hassector(&mp->m_sb)) {
log2_size = mp->m_sb.sb_logsectlog;
if (log2_size < BBSHIFT) {
xlog_warn("XFS: Log sector size too small "
"(0x%x < 0x%x)", log2_size, BBSHIFT);
xfs_warn(mp, "Log sector size too small (0x%x < 0x%x)",
log2_size, BBSHIFT);
goto out_free_log;
}

log2_size -= BBSHIFT;
if (log2_size > mp->m_sectbb_log) {
xlog_warn("XFS: Log sector size too large "
"(0x%x > 0x%x)", log2_size, mp->m_sectbb_log);
xfs_warn(mp, "Log sector size too large (0x%x > 0x%x)",
log2_size, mp->m_sectbb_log);
goto out_free_log;
}

/* for larger sector sizes, must have v2 or external log */
if (log2_size && log->l_logBBstart > 0 &&
!xfs_sb_version_haslogv2(&mp->m_sb)) {

xlog_warn("XFS: log sector size (0x%x) invalid "
"for configuration.", log2_size);
xfs_warn(mp,
"log sector size (0x%x) invalid for configuration.",
log2_size);
goto out_free_log;
}
}
Expand Down Expand Up @@ -1563,38 +1561,36 @@ xlog_print_tic_res(
"SWAPEXT"
};

xfs_fs_cmn_err(CE_WARN, mp,
"xfs_log_write: reservation summary:\n"
" trans type = %s (%u)\n"
" unit res = %d bytes\n"
" current res = %d bytes\n"
" total reg = %u bytes (o/flow = %u bytes)\n"
" ophdrs = %u (ophdr space = %u bytes)\n"
" ophdr + reg = %u bytes\n"
" num regions = %u\n",
((ticket->t_trans_type <= 0 ||
ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ?
"bad-trans-type" : trans_type_str[ticket->t_trans_type-1]),
ticket->t_trans_type,
ticket->t_unit_res,
ticket->t_curr_res,
ticket->t_res_arr_sum, ticket->t_res_o_flow,
ticket->t_res_num_ophdrs, ophdr_spc,
ticket->t_res_arr_sum +
ticket->t_res_o_flow + ophdr_spc,
ticket->t_res_num);
xfs_warn(mp,
"xfs_log_write: reservation summary:\n"
" trans type = %s (%u)\n"
" unit res = %d bytes\n"
" current res = %d bytes\n"
" total reg = %u bytes (o/flow = %u bytes)\n"
" ophdrs = %u (ophdr space = %u bytes)\n"
" ophdr + reg = %u bytes\n"
" num regions = %u\n",
((ticket->t_trans_type <= 0 ||
ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ?
"bad-trans-type" : trans_type_str[ticket->t_trans_type-1]),
ticket->t_trans_type,
ticket->t_unit_res,
ticket->t_curr_res,
ticket->t_res_arr_sum, ticket->t_res_o_flow,
ticket->t_res_num_ophdrs, ophdr_spc,
ticket->t_res_arr_sum +
ticket->t_res_o_flow + ophdr_spc,
ticket->t_res_num);

for (i = 0; i < ticket->t_res_num; i++) {
uint r_type = ticket->t_res_arr[i].r_type;
cmn_err(CE_WARN,
"region[%u]: %s - %u bytes\n",
i,
uint r_type = ticket->t_res_arr[i].r_type;
xfs_warn(mp, "region[%u]: %s - %u bytes\n", i,
((r_type <= 0 || r_type > XLOG_REG_TYPE_MAX) ?
"bad-rtype" : res_type_str[r_type-1]),
ticket->t_res_arr[i].r_len);
}

xfs_cmn_err(XFS_PTAG_LOGRES, CE_ALERT, mp,
xfs_alert_tag(mp, XFS_PTAG_LOGRES,
"xfs_log_write: reservation ran out. Need to up reservation");
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
}
Expand Down Expand Up @@ -1682,7 +1678,7 @@ xlog_write_setup_ophdr(
case XFS_LOG:
break;
default:
xfs_fs_cmn_err(CE_WARN, log->l_mp,
xfs_warn(log->l_mp,
"Bad XFS transaction clientid 0x%x in ticket 0x%p",
ophdr->oh_clientid, ticket);
return NULL;
Expand Down Expand Up @@ -2264,7 +2260,7 @@ xlog_state_do_callback(
if (repeats > 5000) {
flushcnt += repeats;
repeats = 0;
xfs_fs_cmn_err(CE_WARN, log->l_mp,
xfs_warn(log->l_mp,
"%s: possible infinite loop (%d iterations)",
__func__, flushcnt);
}
Expand Down Expand Up @@ -3052,10 +3048,8 @@ xfs_log_force(
int error;

error = _xfs_log_force(mp, flags, NULL);
if (error) {
xfs_fs_cmn_err(CE_WARN, mp, "xfs_log_force: "
"error %d returned.", error);
}
if (error)
xfs_warn(mp, "%s: error %d returned.", __func__, error);
}

/*
Expand Down Expand Up @@ -3204,10 +3198,8 @@ xfs_log_force_lsn(
int error;

error = _xfs_log_force_lsn(mp, lsn, flags, NULL);
if (error) {
xfs_fs_cmn_err(CE_WARN, mp, "xfs_log_force: "
"error %d returned.", error);
}
if (error)
xfs_warn(mp, "%s: error %d returned.", __func__, error);
}

/*
Expand Down Expand Up @@ -3412,7 +3404,7 @@ xlog_verify_dest_ptr(
}

if (!good_ptr)
xlog_panic("xlog_verify_dest_ptr: invalid ptr");
xfs_emerg(log->l_mp, "%s: invalid ptr", __func__);
}

STATIC void
Expand Down Expand Up @@ -3448,16 +3440,16 @@ xlog_verify_tail_lsn(xlog_t *log,
blocks =
log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn));
if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize))
xlog_panic("xlog_verify_tail_lsn: ran out of log space");
xfs_emerg(log->l_mp, "%s: ran out of log space", __func__);
} else {
ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle);

if (BLOCK_LSN(tail_lsn) == log->l_prev_block)
xlog_panic("xlog_verify_tail_lsn: tail wrapped");
xfs_emerg(log->l_mp, "%s: tail wrapped", __func__);

blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block;
if (blocks < BTOBB(iclog->ic_offset) + 1)
xlog_panic("xlog_verify_tail_lsn: ran out of log space");
xfs_emerg(log->l_mp, "%s: ran out of log space", __func__);
}
} /* xlog_verify_tail_lsn */

Expand Down Expand Up @@ -3497,22 +3489,23 @@ xlog_verify_iclog(xlog_t *log,
icptr = log->l_iclog;
for (i=0; i < log->l_iclog_bufs; i++) {
if (icptr == NULL)
xlog_panic("xlog_verify_iclog: invalid ptr");
xfs_emerg(log->l_mp, "%s: invalid ptr", __func__);
icptr = icptr->ic_next;
}
if (icptr != log->l_iclog)
xlog_panic("xlog_verify_iclog: corrupt iclog ring");
xfs_emerg(log->l_mp, "%s: corrupt iclog ring", __func__);
spin_unlock(&log->l_icloglock);

/* check log magic numbers */
if (be32_to_cpu(iclog->ic_header.h_magicno) != XLOG_HEADER_MAGIC_NUM)
xlog_panic("xlog_verify_iclog: invalid magic num");
xfs_emerg(log->l_mp, "%s: invalid magic num", __func__);

ptr = (xfs_caddr_t) &iclog->ic_header;
for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count;
ptr += BBSIZE) {
if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
xlog_panic("xlog_verify_iclog: unexpected magic num");
xfs_emerg(log->l_mp, "%s: unexpected magic num",
__func__);
}

/* check fields */
Expand Down Expand Up @@ -3542,9 +3535,10 @@ xlog_verify_iclog(xlog_t *log,
}
}
if (clientid != XFS_TRANSACTION && clientid != XFS_LOG)
cmn_err(CE_WARN, "xlog_verify_iclog: "
"invalid clientid %d op 0x%p offset 0x%lx",
clientid, ophead, (unsigned long)field_offset);
xfs_warn(log->l_mp,
"%s: invalid clientid %d op 0x%p offset 0x%lx",
__func__, clientid, ophead,
(unsigned long)field_offset);

/* check length */
field_offset = (__psint_t)
Expand Down
4 changes: 0 additions & 4 deletions fs/xfs/xfs_log_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ static inline uint xlog_get_client_id(__be32 i)
return be32_to_cpu(i) >> 24;
}

#define xlog_panic(args...) cmn_err(CE_PANIC, ## args)
#define xlog_exit(args...) cmn_err(CE_PANIC, ## args)
#define xlog_warn(args...) cmn_err(CE_WARN, ## args)

/*
* In core log state
*/
Expand Down
Loading

0 comments on commit a0fa2b6

Please sign in to comment.