Re: [PATCH] debugfs:fix repeated output problem with logdump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



friendly ping...

On 2022/12/15 10:31, lihaoxiang (F) wrote:
> Hi professor Tytso, we found that logdump has the problem to print circulately in the case which logs area are full of valid transactions. We propose the final solution as follow:
> ---------------------------------------------------------------------
> Date: Thu, 10 Nov 2022 17:09:20 +0800
> Subject: [PATCH] debugfs:fix repeated output problem with logdump
> 
> Currently, the module of logdump with parameter -O or -On might fall
> into printing duplicate transactions circulately.
> 
> In fact, it would exit when it check the no magic number in transaction's
> block head. But sometimes there hasn't no magic number block spanning
> the whole log area so it cause the multi meaningless loop until a new no
> magic block was founded.
> 
> We record the first blocknr of logs for comparing this value to that when
> it meet the block again. If the comparison is equal then it exit immediately.
> 
> Signed-off-by: lihaoxiang <lihaoxiang9@xxxxxxxxxx>
> ---
>  debugfs/logdump.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/debugfs/logdump.c b/debugfs/logdump.c
> index 614414e5..a6d03f5c 100644
> --- a/debugfs/logdump.c
> +++ b/debugfs/logdump.c
> @@ -376,11 +376,14 @@ static void dump_journal(char *cmdname, FILE *out_file,
>  	journal_header_t	*header;
>  	tid_t			transaction;
>  	unsigned int		blocknr = 0;
> +	unsigned int		last_blocknr;
> +	unsigned int		first_transaction_blocknr;
>  	int			fc_done;
>  	__u64			total_len;
>  	__u32			maxlen;
>  	int64_t			cur_counts = 0;
>  	bool			exist_no_magic = false;
> +	bool			reverse_flag = false;
> 
>  	/* First, check to see if there's an ext2 superblock header */
>  	retval = read_journal_block(cmdname, source, 0, buf, 2048);
> @@ -470,10 +473,22 @@ static void dump_journal(char *cmdname, FILE *out_file,
>  			blocknr = 1;
>  	}
> 
> +	first_transaction_blocknr = blocknr;
> +	last_blocknr = blocknr - 1;
> +
>  	while (1) {
>  		if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
>  			break;
> 
> +		if (last_blocknr != (blocknr - 1))
> +			reverse_flag = true;
> +		last_blocknr = blocknr;
> +
> +		if ((blocknr == first_transaction_blocknr) && reverse_flag) {
> +			fprintf(out_file, "Dump all %lld journal records.\n", cur_counts);
> +			break;
> +		}
> +
>  		retval = read_journal_block(cmdname, source,
>  				((ext2_loff_t) blocknr) * blocksize,
>  				buf, blocksize);



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux