]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/log_print_trans.c
mkfs: discard only after all validations
[thirdparty/xfsprogs-dev.git] / logprint / log_print_trans.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6 #include "libxfs.h"
7 #include "libxlog.h"
8
9 #include "logprint.h"
10
11 void
12 xlog_recover_print_trans_head(
13 xlog_recover_t *tr)
14 {
15 printf(_("TRANS: tid:0x%x #items:%d trans:0x%x q:0x%lx\n"),
16 tr->r_log_tid,
17 tr->r_theader.th_num_items,
18 tr->r_theader.th_tid, (long)&tr->r_itemq);
19 }
20
21 int
22 xlog_recover_do_trans(
23 struct xlog *log,
24 xlog_recover_t *trans,
25 int pass)
26 {
27 xlog_recover_print_trans(trans, &trans->r_itemq, 3);
28 return 0;
29 }
30
31 void
32 xfs_log_print_trans(
33 struct xlog *log,
34 int print_block_start)
35 {
36 xfs_daddr_t head_blk, tail_blk;
37 int error;
38
39 error = xlog_find_tail(log, &head_blk, &tail_blk);
40 if (error) {
41 fprintf(stderr, _("%s: failed to find head and tail, error: %d\n"),
42 progname, error);
43 exit(1);
44 }
45
46 printf(_(" log tail: %lld head: %lld state: %s\n"),
47 (long long)tail_blk,
48 (long long)head_blk,
49 (tail_blk == head_blk)?"<CLEAN>":"<DIRTY>");
50
51 if (print_block_start != -1) {
52 printf(_(" override tail: %d\n"), print_block_start);
53 tail_blk = print_block_start;
54 }
55 printf("\n");
56
57 print_record_header = 1;
58
59 if (head_blk == tail_blk)
60 return;
61
62 /*
63 * Version 5 superblock log feature mask validation. We know the
64 * log is dirty so check if there are any unknown log features
65 * in what we need to recover. If there are unknown features
66 * (e.g. unsupported transactions) then warn about it.
67 */
68 if (XFS_SB_VERSION_NUM(&log->l_mp->m_sb) == XFS_SB_VERSION_5 &&
69 xfs_sb_has_incompat_log_feature(&log->l_mp->m_sb,
70 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN)) {
71 printf(_(
72 "Superblock has unknown incompatible log features (0x%x) enabled.\n"
73 "Output may be incomplete or inaccurate. It is recommended that you\n"
74 "upgrade your xfsprogs installation to match the filesystem features.\n"),
75 (log->l_mp->m_sb.sb_features_log_incompat &
76 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN));
77 }
78
79 if ((error = xlog_do_recovery_pass(log, head_blk, tail_blk, XLOG_RECOVER_PASS1))) {
80 fprintf(stderr, _("%s: failed in xfs_do_recovery_pass, error: %d\n"),
81 progname, error);
82 exit(1);
83 }
84 }