offset = libxfs_log_header(p, &buf->owner->uuid,
xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
- mp->m_sb.sb_logsunit, XLOG_FMT,
- next_log_chunk, buf);
+ mp->m_sb.sb_logsunit, XLOG_FMT, NULLCOMMITLSN,
+ NULLCOMMITLSN, next_log_chunk, buf);
do_write(buf->owner);
return roundup(logstart + offset, buf->length);
(xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
uuidp,
xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
- mp->m_sb.sb_logsunit, XLOG_FMT)) {
+ mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE)) {
dbprintf(_("ERROR: cannot clear the log\n"));
return 0;
}
/* check or write log footer: specify device, log size in blocks & uuid */
typedef char *(libxfs_get_block_t)(char *, int, void *);
-extern int libxfs_log_clear (struct xfs_buftarg *, xfs_daddr_t, uint,
- uuid_t *, int, int, int);
-extern int libxfs_log_header (char *, uuid_t *, int, int, int,
- libxfs_get_block_t *, void *);
+/*
+ * Helpers to clear the log to a particular log cycle.
+ */
+#define XLOG_INIT_CYCLE 1
+extern int libxfs_log_clear(struct xfs_buftarg *, xfs_daddr_t, uint,
+ uuid_t *, int, int, int, int);
+extern int libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,
+ xfs_lsn_t, libxfs_get_block_t *, void *);
/* Shared utility routines */
uuid_t *fs_uuid,
int version,
int sunit,
- int fmt)
+ int fmt,
+ int cycle)
{
xfs_buf_t *bp;
int len;
+ xfs_lsn_t lsn;
if (!btp->dev || !fs_uuid)
return -EINVAL;
+ if (cycle != XLOG_INIT_CYCLE)
+ return -EINVAL;
+
+ lsn = xlog_assign_lsn(cycle, 0);
+
/* first zero the log */
libxfs_device_zero(btp, start, length);
len = ((version == 2) && sunit) ? BTOBB(sunit) : 2;
len = MAX(len, 2);
bp = libxfs_getbufr(btp, start, len);
- libxfs_log_header(XFS_BUF_PTR(bp),
- fs_uuid, version, sunit, fmt, next, bp);
+ libxfs_log_header(XFS_BUF_PTR(bp), fs_uuid, version, sunit, fmt, lsn,
+ lsn, next, bp);
bp->b_flags |= LIBXFS_B_DIRTY;
libxfs_putbufr(bp);
return 0;
int version,
int sunit,
int fmt,
+ xfs_lsn_t lsn,
+ xfs_lsn_t tail_lsn,
libxfs_get_block_t *nextfunc,
void *private)
{
__be32 cycle_lsn;
int i, len;
+ if (lsn == NULLCOMMITLSN)
+ lsn = xlog_assign_lsn(XLOG_INIT_CYCLE, 0);
+ if (tail_lsn == NULLCOMMITLSN)
+ tail_lsn = lsn;
+
len = ((version == 2) && sunit) ? BTOBB(sunit) : 1;
memset(p, 0, BBSIZE);
head->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
- head->h_cycle = cpu_to_be32(1);
+ head->h_cycle = cpu_to_be32(CYCLE_LSN(lsn));
head->h_version = cpu_to_be32(version);
if (len != 1)
head->h_len = cpu_to_be32(sunit - BBSIZE);
head->h_fmt = cpu_to_be32(fmt);
head->h_size = cpu_to_be32(XLOG_HEADER_CYCLE_SIZE);
- head->h_lsn = cpu_to_be64(xlog_assign_lsn(1, 0));
- head->h_tail_lsn = cpu_to_be64(xlog_assign_lsn(1, 0));
+ head->h_lsn = cpu_to_be64(lsn);
+ head->h_tail_lsn = cpu_to_be64(tail_lsn);
memcpy(&head->h_fs_uuid, fs_uuid, sizeof(uuid_t));
libxfs_log_clear(mp->m_logdev_targp,
XFS_FSB_TO_DADDR(mp, logstart),
(xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
- &sbp->sb_uuid, logversion, lsunit, XLOG_FMT);
+ &sbp->sb_uuid, logversion, lsunit, XLOG_FMT, XLOG_INIT_CYCLE);
mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 0);
if (mp == NULL) {
(xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
&mp->m_sb.sb_uuid,
xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
- mp->m_sb.sb_logsunit, XLOG_FMT);
+ mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE);
}
/*