]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - logprint/log_dump.c
xfs_repair: only update in-core extent state after scanning full extent
[thirdparty/xfsprogs-dev.git] / logprint / log_dump.c
CommitLineData
873b7c85 1/*
da23017d
NS
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
873b7c85 4 *
da23017d
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
873b7c85
GO
7 * published by the Free Software Foundation.
8 *
da23017d
NS
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
873b7c85 13 *
da23017d
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
873b7c85 17 */
6b803e5a
CH
18#include "libxfs.h"
19#include "libxlog.h"
873b7c85
GO
20
21#include "logprint.h"
22
23/*
24 * Dump log blocks, not data
25 */
26
27void
28xfs_log_dump(
999f0b9c 29 struct xlog *log,
873b7c85
GO
30 int fd,
31 int print_block_start)
32{
33 int r;
34 uint last_cycle = -1;
35 xfs_daddr_t blkno, dupblkno;
36 xlog_rec_header_t *hdr;
37 char buf[XLOG_HEADER_SIZE];
38
39 dupblkno = 0;
40 hdr = (xlog_rec_header_t *)buf;
41 xlog_print_lseek(log, fd, 0, SEEK_SET);
42 for (blkno = 0; blkno < log->l_logBBsize; blkno++) {
43 r = read(fd, buf, sizeof(buf));
44 if (r < 0) {
9ee7055c 45 fprintf(stderr, _("%s: read error (%lld): %s\n"),
873b7c85
GO
46 __FUNCTION__, (long long)blkno,
47 strerror(errno));
48 continue;
49 } else if (r == 0) {
9ee7055c 50 printf(_("%s: physical end of log at %lld\n"),
873b7c85
GO
51 __FUNCTION__, (long long)blkno);
52 break;
53 }
54
5e656dbb 55 if (CYCLE_LSN(be64_to_cpu(*(__be64 *)buf)) ==
46eca962 56 XLOG_HEADER_MAGIC_NUM && !print_no_data) {
9ee7055c
AM
57 printf(_(
58 "%6lld HEADER Cycle %d tail %d:%06d len %6d ops %d\n"),
873b7c85 59 (long long)blkno,
5e656dbb
BN
60 be32_to_cpu(hdr->h_cycle),
61 CYCLE_LSN(be64_to_cpu(hdr->h_tail_lsn)),
62 BLOCK_LSN(be64_to_cpu(hdr->h_tail_lsn)),
63 be32_to_cpu(hdr->h_len),
64 be32_to_cpu(hdr->h_num_logops));
873b7c85
GO
65 }
66
5e656dbb 67 if (xlog_get_cycle(buf) != last_cycle) {
9ee7055c
AM
68 printf(_(
69 "[%05lld - %05lld] Cycle 0x%08x New Cycle 0x%08x\n"),
873b7c85 70 (long long)dupblkno, (long long)blkno,
5e656dbb
BN
71 last_cycle, xlog_get_cycle(buf));
72 last_cycle = xlog_get_cycle(buf);
873b7c85
GO
73 dupblkno = blkno;
74 }
75 }
76}