Skip to content

Commit

Permalink
cmd_list_journal: Indicate which journal entries are blacklisted
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
koverstreet committed Mar 2, 2022
1 parent 87f685d commit 465e903
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions cmd_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "libbcachefs/error.h"
#include "libbcachefs/journal.h"
#include "libbcachefs/journal_io.h"
#include "libbcachefs/journal_seq_blacklist.h"
#include "libbcachefs/super.h"

static void dump_usage(void)
Expand Down Expand Up @@ -577,6 +578,17 @@ static void list_journal_usage(void)
"Report bugs to <[email protected]>");
}

static void star_start_of_lines(char *buf)
{
char *p = buf;

if (*p == ' ')
*p = '*';

while ((p = strstr(p, "\n ")))
p[1] = '*';
}

int cmd_list_journal(int argc, char *argv[])
{
struct bch_opts opts = bch2_opts_empty();
Expand Down Expand Up @@ -610,21 +622,34 @@ int cmd_list_journal(int argc, char *argv[])

struct journal_replay *p;
struct jset_entry *entry;
struct printbuf buf = PRINTBUF;

list_for_each_entry(p, &c->journal_entries, list) {
struct printbuf buf = PRINTBUF;
bool blacklisted =
bch2_journal_seq_is_blacklisted(c,
le64_to_cpu(p->j.seq), false);

bch2_journal_ptrs_to_text(&buf, c, p);

printf("journal entry %llu\n"
" version %u\n"
" last seq %llu\n"
" written at %s\n"
,
le64_to_cpu(p->j.seq),
if (blacklisted)
printf("blacklisted ");

printf("journal entry %llu\n", le64_to_cpu(p->j.seq));

printbuf_reset(&buf);

pr_buf(&buf,
" version %u\n"
" last seq %llu\n"
" flush %u\n"
" written at ",
le32_to_cpu(p->j.version),
le64_to_cpu(p->j.last_seq),
buf.buf);
!JSET_NO_FLUSH(&p->j));
bch2_journal_ptrs_to_text(&buf, c, p);

if (blacklisted)
star_start_of_lines(buf.buf);
printf("%s\n", buf.buf);

vstruct_for_each(&p->j, entry) {
printbuf_reset(&buf);
Expand All @@ -636,12 +661,14 @@ int cmd_list_journal(int argc, char *argv[])
pr_indent_push(&buf,
entry->type == BCH_JSET_ENTRY_log ? 2 : 4);
bch2_journal_entry_to_text(&buf, c, entry);

if (blacklisted)
star_start_of_lines(buf.buf);
printf("%s\n", buf.buf);
}

printbuf_exit(&buf);
}

printbuf_exit(&buf);
bch2_fs_stop(c);
return 0;
}

0 comments on commit 465e903

Please sign in to comment.