summaryrefslogtreecommitdiff
path: root/cmd_debug.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-03-20 02:38:55 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-03-20 02:39:38 -0400
commite76dbf1abd4472fa26c85f4b30e213d8768ccf64 (patch)
tree57dc18735b4db7fb8dfcecd2e764c4951aef1896 /cmd_debug.c
parent3765483ff0cf9abd0243fcafe11aebd0f9beb03d (diff)
cmd_debug: Add -j for dumping entire journal
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'cmd_debug.c')
-rw-r--r--cmd_debug.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/cmd_debug.c b/cmd_debug.c
index 36cadfa9..33c4a1b1 100644
--- a/cmd_debug.c
+++ b/cmd_debug.c
@@ -29,11 +29,13 @@ static void dump_usage(void)
"Options:\n"
" -o output Output qcow2 image(s)\n"
" -f Force; overwrite when needed\n"
+ " -j Dump entire journal, not just dirty entries\n"
" -h Display this help and exit\n"
"Report bugs to <linux-bcache@vger.kernel.org>");
}
-static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd)
+static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd,
+ bool entire_journal)
{
struct bch_sb *sb = ca->disk_sb.sb;
ranges data;
@@ -53,7 +55,8 @@ static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd)
/* Journal: */
for (i = 0; i < ca->journal.nr; i++)
- if (ca->journal.bucket_seq[i] >= c->journal.last_seq_ondisk) {
+ if (entire_journal ||
+ ca->journal.bucket_seq[i] >= c->journal.last_seq_ondisk) {
u64 bucket = ca->journal.buckets[i];
range_add(&data,
@@ -116,7 +119,7 @@ int cmd_dump(int argc, char *argv[])
struct bch_dev *ca;
char *out = NULL;
unsigned i, nr_devices = 0;
- bool force = false;
+ bool force = false, entire_journal = false;
int fd, opt;
opt_set(opts, nochanges, true);
@@ -125,7 +128,7 @@ int cmd_dump(int argc, char *argv[])
opt_set(opts, errors, BCH_ON_ERROR_continue);
opt_set(opts, fix_errors, FSCK_OPT_NO);
- while ((opt = getopt(argc, argv, "o:fvh")) != -1)
+ while ((opt = getopt(argc, argv, "o:fjvh")) != -1)
switch (opt) {
case 'o':
out = optarg;
@@ -133,6 +136,9 @@ int cmd_dump(int argc, char *argv[])
case 'f':
force = true;
break;
+ case 'j':
+ entire_journal = true;
+ break;
case 'v':
opt_set(opts, verbose, true);
break;
@@ -174,7 +180,7 @@ int cmd_dump(int argc, char *argv[])
fd = xopen(path, flags, 0600);
free(path);
- dump_one_device(c, ca, fd);
+ dump_one_device(c, ca, fd, entire_journal);
close(fd);
}