Commit aa56b310 authored by Nathan Scott's avatar Nathan Scott Committed by Christoph Hellwig

[XFS] Rationalise xlog_in_core2 definition, remove some ifdef __KERNEL__ code

which is unnecessary in log recovery, clarify some recovery debug code.

SGI Modid: 2.5.x-xfs:slinx:149396a
parent 71c029eb
...@@ -406,6 +406,7 @@ typedef struct xlog_rec_ext_header { ...@@ -406,6 +406,7 @@ typedef struct xlog_rec_ext_header {
uint xh_cycle; /* write cycle of log : 4 */ uint xh_cycle; /* write cycle of log : 4 */
uint xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ uint xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
} xlog_rec_ext_header_t; } xlog_rec_ext_header_t;
#ifdef __KERNEL__ #ifdef __KERNEL__
/* /*
* - A log record header is 512 bytes. There is plenty of room to grow the * - A log record header is 512 bytes. There is plenty of room to grow the
...@@ -444,12 +445,10 @@ typedef struct xlog_iclog_fields { ...@@ -444,12 +445,10 @@ typedef struct xlog_iclog_fields {
char *ic_datap; /* pointer to iclog data */ char *ic_datap; /* pointer to iclog data */
} xlog_iclog_fields_t; } xlog_iclog_fields_t;
typedef struct xlog_in_core2 { typedef union xlog_in_core2 {
union { xlog_rec_header_t hic_header;
xlog_rec_header_t hic_header; xlog_rec_ext_header_t hic_xheader;
xlog_rec_ext_header_t hic_xheader; char hic_sector[XLOG_HEADER_SIZE];
char hic_sector[XLOG_HEADER_SIZE];
} ic_h;
} xlog_in_core_2_t; } xlog_in_core_2_t;
typedef struct xlog_in_core { typedef struct xlog_in_core {
...@@ -476,7 +475,7 @@ typedef struct xlog_in_core { ...@@ -476,7 +475,7 @@ typedef struct xlog_in_core {
#define ic_bwritecnt hic_fields.ic_bwritecnt #define ic_bwritecnt hic_fields.ic_bwritecnt
#define ic_state hic_fields.ic_state #define ic_state hic_fields.ic_state
#define ic_datap hic_fields.ic_datap #define ic_datap hic_fields.ic_datap
#define ic_header hic_data->ic_h.hic_header #define ic_header hic_data->hic_header
/* /*
* The reservation head lsn is not made up of a cycle number and block number. * The reservation head lsn is not made up of a cycle number and block number.
......
...@@ -951,7 +951,6 @@ xlog_find_tail(xlog_t *log, ...@@ -951,7 +951,6 @@ xlog_find_tail(xlog_t *log,
} }
} }
#ifdef __KERNEL__
/* /*
* Make sure that there are no blocks in front of the head * Make sure that there are no blocks in front of the head
* with the same cycle number as the head. This can happen * with the same cycle number as the head. This can happen
...@@ -971,11 +970,9 @@ xlog_find_tail(xlog_t *log, ...@@ -971,11 +970,9 @@ xlog_find_tail(xlog_t *log,
* But... if the -device- itself is readonly, just skip this. * But... if the -device- itself is readonly, just skip this.
* We can't recover this device anyway, so it won't matter. * We can't recover this device anyway, so it won't matter.
*/ */
if (!xfs_readonly_buftarg(log->l_mp->m_logdev_targp)) { if (!xfs_readonly_buftarg(log->l_mp->m_logdev_targp)) {
error = xlog_clear_stale_blocks(log, tail_lsn); error = xlog_clear_stale_blocks(log, tail_lsn);
} }
#endif
bread_err: bread_err:
exit: exit:
...@@ -3285,36 +3282,44 @@ xlog_recover_process_iunlinks(xlog_t *log) ...@@ -3285,36 +3282,44 @@ xlog_recover_process_iunlinks(xlog_t *log)
} /* xlog_recover_process_iunlinks */ } /* xlog_recover_process_iunlinks */
/*
* Stamp cycle number in every block
*
* This routine is also called in xfs_log.c
*/
/*ARGSUSED*/
void
xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog)
{
int i, j, k;
int size = iclog->ic_offset + iclog->ic_roundoff;
xfs_caddr_t dp;
union ich {
xlog_rec_ext_header_t hic_xheader;
char hic_sector[XLOG_HEADER_SIZE];
} *xhdr;
uint cycle_lsn;
#ifdef DEBUG #ifdef DEBUG
uint *up; STATIC void
uint chksum = 0; xlog_pack_data_checksum(
xlog_t *log,
xlog_in_core_t *iclog,
int size)
{
int i;
uint *up;
uint chksum = 0;
up = (uint *)iclog->ic_datap; up = (uint *)iclog->ic_datap;
/* divide length by 4 to get # words */ /* divide length by 4 to get # words */
for (i=0; i<size >> 2; i++) { for (i = 0; i < (size >> 2); i++) {
chksum ^= INT_GET(*up, ARCH_CONVERT); chksum ^= INT_GET(*up, ARCH_CONVERT);
up++; up++;
} }
INT_SET(iclog->ic_header.h_chksum, ARCH_CONVERT, chksum); INT_SET(iclog->ic_header.h_chksum, ARCH_CONVERT, chksum);
#endif /* DEBUG */ }
#else
#define xlog_pack_data_checksum(log, iclog, size)
#endif
/*
* Stamp cycle number in every block
*/
void
xlog_pack_data(
xlog_t *log,
xlog_in_core_t *iclog)
{
int i, j, k;
int size = iclog->ic_offset + iclog->ic_roundoff;
uint cycle_lsn;
xfs_caddr_t dp;
xlog_in_core_2_t *xhdr;
xlog_pack_data_checksum(log, iclog, size);
cycle_lsn = CYCLE_LSN_NOCONV(iclog->ic_header.h_lsn, ARCH_CONVERT); cycle_lsn = CYCLE_LSN_NOCONV(iclog->ic_header.h_lsn, ARCH_CONVERT);
...@@ -3327,7 +3332,7 @@ xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog) ...@@ -3327,7 +3332,7 @@ xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog)
} }
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
xhdr = (union ich*)&iclog->ic_header; xhdr = (xlog_in_core_2_t *)&iclog->ic_header;
for ( ; i < BTOBB(size); i++) { for ( ; i < BTOBB(size); i++) {
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
...@@ -3340,45 +3345,18 @@ xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog) ...@@ -3340,45 +3345,18 @@ xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog)
xhdr[i].hic_xheader.xh_cycle = cycle_lsn; xhdr[i].hic_xheader.xh_cycle = cycle_lsn;
} }
} }
}
} /* xlog_pack_data */ #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
/*ARGSUSED*/
STATIC void STATIC void
xlog_unpack_data(xlog_rec_header_t *rhead, xlog_unpack_data_checksum(
xfs_caddr_t dp, xlog_rec_header_t *rhead,
xlog_t *log) xfs_caddr_t dp,
xlog_t *log)
{ {
int i, j, k; uint *up = (uint *)dp;
union ich { uint chksum = 0;
xlog_rec_header_t hic_header;
xlog_rec_ext_header_t hic_xheader;
char hic_sector[XLOG_HEADER_SIZE];
} *xhdr;
#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
uint *up = (uint *)dp;
uint chksum = 0;
#endif
for (i=0; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)) &&
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
*(uint *)dp = *(uint *)&rhead->h_cycle_data[i];
dp += BBSIZE;
}
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
xhdr = (union ich*)rhead;
for ( ; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); i++) {
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
*(uint *)dp = xhdr[j].hic_xheader.xh_cycle_data[k];
dp += BBSIZE;
}
}
#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
/* divide length by 4 to get # words */ /* divide length by 4 to get # words */
for (i=0; i < INT_GET(rhead->h_len, ARCH_CONVERT) >> 2; i++) { for (i=0; i < INT_GET(rhead->h_len, ARCH_CONVERT) >> 2; i++) {
chksum ^= INT_GET(*up, ARCH_CONVERT); chksum ^= INT_GET(*up, ARCH_CONVERT);
...@@ -3399,9 +3377,38 @@ xlog_unpack_data(xlog_rec_header_t *rhead, ...@@ -3399,9 +3377,38 @@ xlog_unpack_data(xlog_rec_header_t *rhead,
log->l_flags |= XLOG_CHKSUM_MISMATCH; log->l_flags |= XLOG_CHKSUM_MISMATCH;
} }
} }
#endif /* DEBUG && XFS_LOUD_RECOVERY */ }
} /* xlog_unpack_data */ #else
#define xlog_unpack_data_checksum(rhead, dp, log)
#endif
STATIC void
xlog_unpack_data(
xlog_rec_header_t *rhead,
xfs_caddr_t dp,
xlog_t *log)
{
int i, j, k;
xlog_in_core_2_t *xhdr;
for (i = 0; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)) &&
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
*(uint *)dp = *(uint *)&rhead->h_cycle_data[i];
dp += BBSIZE;
}
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
xhdr = (xlog_in_core_2_t *)rhead;
for ( ; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); i++) {
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
*(uint *)dp = xhdr[j].hic_xheader.xh_cycle_data[k];
dp += BBSIZE;
}
}
xlog_unpack_data_checksum(rhead, dp, log);
}
/* /*
* Read the log from tail to head and process the log records found. * Read the log from tail to head and process the log records found.
...@@ -3807,11 +3814,6 @@ xlog_recover(xlog_t *log, int readonly) ...@@ -3807,11 +3814,6 @@ xlog_recover(xlog_t *log, int readonly)
return error; return error;
if (tail_blk != head_blk) { if (tail_blk != head_blk) {
#ifndef __KERNEL__
extern xfs_daddr_t HEAD_BLK, TAIL_BLK;
head_blk = HEAD_BLK;
tail_blk = TAIL_BLK;
#endif
/* There used to be a comment here: /* There used to be a comment here:
* *
* disallow recovery on read-only mounts. note -- mount * disallow recovery on read-only mounts. note -- mount
...@@ -3823,30 +3825,16 @@ xlog_recover(xlog_t *log, int readonly) ...@@ -3823,30 +3825,16 @@ xlog_recover(xlog_t *log, int readonly)
* under the vfs layer, so we can get away with it unless * under the vfs layer, so we can get away with it unless
* the device itself is read-only, in which case we fail. * the device itself is read-only, in which case we fail.
*/ */
#ifdef __KERNEL__
if ((error = xfs_dev_is_read_only(log->l_mp, if ((error = xfs_dev_is_read_only(log->l_mp,
"recovery required"))) { "recovery required"))) {
return error; return error;
} }
#else
if (readonly) {
return ENOSPC;
}
#endif
#ifdef __KERNEL__
#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
cmn_err(CE_NOTE, cmn_err(CE_NOTE,
"Starting XFS recovery on filesystem: %s (dev: %d/%d)", "Starting XFS recovery on filesystem: %s (dev: %d/%d)",
log->l_mp->m_fsname, MAJOR(log->l_dev), log->l_mp->m_fsname, MAJOR(log->l_dev),
MINOR(log->l_dev)); MINOR(log->l_dev));
#else
cmn_err(CE_NOTE,
"!Starting XFS recovery on filesystem: %s (dev: %d/%d)",
log->l_mp->m_fsname, MAJOR(log->l_dev),
MINOR(log->l_dev));
#endif
#endif
error = xlog_do_recover(log, head_blk, tail_blk); error = xlog_do_recover(log, head_blk, tail_blk);
log->l_flags |= XLOG_RECOVERY_NEEDED; log->l_flags |= XLOG_RECOVERY_NEEDED;
} }
...@@ -3886,23 +3874,16 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags) ...@@ -3886,23 +3874,16 @@ xlog_recover_finish(xlog_t *log, int mfsi_flags)
(XFS_LOG_FORCE | XFS_LOG_SYNC)); (XFS_LOG_FORCE | XFS_LOG_SYNC));
if ( (mfsi_flags & XFS_MFSI_NOUNLINK) == 0 ) { if ( (mfsi_flags & XFS_MFSI_NOUNLINK) == 0 ) {
xlog_recover_process_iunlinks(log); xlog_recover_process_iunlinks(log);
} }
xlog_recover_check_summary(log); xlog_recover_check_summary(log);
#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
cmn_err(CE_NOTE, cmn_err(CE_NOTE,
"Ending XFS recovery on filesystem: %s (dev: %d/%d)", "Ending XFS recovery on filesystem: %s (dev: %d/%d)",
log->l_mp->m_fsname, MAJOR(log->l_dev), log->l_mp->m_fsname, MAJOR(log->l_dev),
MINOR(log->l_dev)); MINOR(log->l_dev));
#else
cmn_err(CE_NOTE,
"!Ending XFS recovery on filesystem: %s (dev: %d/%d)",
log->l_mp->m_fsname, MAJOR(log->l_dev),
MINOR(log->l_dev));
#endif
log->l_flags &= ~XLOG_RECOVERY_NEEDED; log->l_flags &= ~XLOG_RECOVERY_NEEDED;
} else { } else {
cmn_err(CE_DEBUG, cmn_err(CE_DEBUG,
......
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