mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-09 00:00:04 +03:00
list_journal: Add -n for number of entries to print
The entire journal can be too big to fit in memory in textual form, making grep difficult: this adds an option to print a specific number of journal entries. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
ca4bb4155a
commit
c25cc1b531
11
cmd_debug.c
11
cmd_debug.c
@ -578,6 +578,7 @@ static void list_journal_usage(void)
|
|||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -a Read entire journal, not just dirty entries\n"
|
" -a Read entire journal, not just dirty entries\n"
|
||||||
|
" -n Number of journal entries to print, starting from the most recent\n"
|
||||||
" -h Display this help and exit\n"
|
" -h Display this help and exit\n"
|
||||||
"Report bugs to <linux-bcache@vger.kernel.org>");
|
"Report bugs to <linux-bcache@vger.kernel.org>");
|
||||||
}
|
}
|
||||||
@ -596,6 +597,7 @@ static void star_start_of_lines(char *buf)
|
|||||||
int cmd_list_journal(int argc, char *argv[])
|
int cmd_list_journal(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct bch_opts opts = bch2_opts_empty();
|
struct bch_opts opts = bch2_opts_empty();
|
||||||
|
u32 nr_entries = U32_MAX;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt_set(opts, nochanges, true);
|
opt_set(opts, nochanges, true);
|
||||||
@ -606,11 +608,15 @@ int cmd_list_journal(int argc, char *argv[])
|
|||||||
opt_set(opts, keep_journal, true);
|
opt_set(opts, keep_journal, true);
|
||||||
opt_set(opts, read_journal_only,true);
|
opt_set(opts, read_journal_only,true);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ah")) != -1)
|
while ((opt = getopt(argc, argv, "an:h")) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
opt_set(opts, read_entire_journal, true);
|
opt_set(opts, read_entire_journal, true);
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
nr_entries = kstrtouint(optarg, 10, &nr_entries);
|
||||||
|
opt_set(opts, read_entire_journal, true);
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
list_journal_usage();
|
list_journal_usage();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -634,6 +640,9 @@ int cmd_list_journal(int argc, char *argv[])
|
|||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (le64_to_cpu(p->j.seq) + nr_entries < atomic64_read(&c->journal.seq))
|
||||||
|
continue;
|
||||||
|
|
||||||
bool blacklisted =
|
bool blacklisted =
|
||||||
bch2_journal_seq_is_blacklisted(c,
|
bch2_journal_seq_is_blacklisted(c,
|
||||||
le64_to_cpu(p->j.seq), false);
|
le64_to_cpu(p->j.seq), false);
|
||||||
|
Loading…
Reference in New Issue
Block a user