Whamcloud - gitweb
debugfs: fix repeated output problem with `logdump -O -n <num_trans>`
authorlihaoxiang (F) <lihaoxiang9@huawei.com>
Tue, 15 Nov 2022 08:29:55 +0000 (16:29 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 26 Jan 2023 03:50:19 +0000 (22:50 -0500)
commitd37a9f1818fa04fc91a497b3541ed205804720af
tree2b96278f7984b30d12226fd4064f0b4053bc4188
parentc640cf1f3a9a7ac6ecbf82c27539c8e158f8ea24
debugfs: fix repeated output problem with `logdump -O -n <num_trans>`

Previously, patch 6e4cc3d5eeb2dfaa055e652b5390beaa6c3d05da introduces
the function of printing the specified number of logs. But there exists
a shortage when n is larger than the total number of logs, it dumped the
duplicated records circulately.

For example, the disk sda only has three records, but using instruction logdump
-On5, it would output the result as follow:
----------------------------------------------------------------------
Journal starts at block 1, transaction 6
Found expected sequence 6, type 1 (descriptor block) at block 1
Found expected sequence 6, type 2 (commit block) at block 4
No magic number at block 5: end of journal.
Found sequence 2 (not 7) at block 7: end of journal.
Found expected sequence 2, type 2 (commit block) at block 7
Found sequence 3 (not 8) at block 8: end of journal.
Found expected sequence 3, type 1 (descriptor block) at block 8
Found sequence 3 (not 8) at block 15: end of journal.
Found expected sequence 3, type 2 (commit block) at block 15
Found sequence 6 (not 9) at block 1: end of journal.       <---------begin loop
Found expected sequence 6, type 1 (descriptor block) at block 1
Found sequence 6 (not 9) at block 4: end of journal.
Found expected sequence 6, type 2 (commit block) at block 4
Found sequence 2 (not 10) at block 7: end of journal.
Found expected sequence 2, type 2 (commit block) at block 7
logdump: short read (read 0, expected 1024) while reading journal

In this commit, we solve the problem above by exiting dumping if the
blocknr had already encountered, displayed the total number of logs
that the disk only possessed.

Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/logdump.c