Whamcloud - gitweb
debugfs: fix infinite loop while dumping the journal
authorWenchao Hao <haowenchao2@huawei.com>
Fri, 17 Nov 2023 10:23:15 +0000 (18:23 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 17 Apr 2024 04:22:07 +0000 (00:22 -0400)
commit272173a300822b5cfe19bef597609523baab0c66
tree718c33862055a8bc25d1c54b808700c9ce8e6add
parente0e6b13d0ea7330234a6fe51ec3ba13ef884735e
debugfs: fix infinite loop while dumping the journal

There are 2 scenarios which would trigger infinite loop:

1. None log is recorded, then dumplog with "-n", for example:
   debugfs -R "logdump -O -n 10" /dev/xxx
   while /dev/xxx has no valid log recorded.
2. The log area is full and cycle write is triggered, then dumplog with
   debugfs -R "logdump -aOS" /dev/xxx

This patch add a new flag "wrapped_flag" to mark if logdump has
reached to tail of logarea set in macro WRAP().

If wrapped_flag is true, and we comes to first_transaction_blocknr
again, just break the logdump loop.

[ Renamed reverse_flag to wrapped_flag to make it clearer what it is. -- TYT ]

Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20231117102315.2431846-1-haowenchao2@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/logdump.c