From: Chi Zhiling <chizhiling@163.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org, Chi Zhiling <chizhiling@kylinos.cn>,
Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v4] xfs_logprint: Fix super block buffer interpretation issue
Date: Thu, 16 Jan 2025 09:38:26 +0800 [thread overview]
Message-ID: <43a586fb-5cee-4668-b15e-f75b294a243a@163.com> (raw)
In-Reply-To: <20250116003350.GD3566461@frogsfrogsfrogs>
On 2025/1/16 08:33, Darrick J. Wong wrote:
> On Sun, Oct 13, 2024 at 12:29:52PM +0800, Chi Zhiling wrote:
>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>
>> When using xfs_logprint to interpret the buffer of the super block, the
>> icount will always be 6360863066640355328 (0x5846534200001000). This is
>> because the offset of icount is incorrect, causing xfs_logprint to
>> misinterpret the MAGIC number as icount.
>> This patch fixes the offset value of the SB counters in xfs_logprint.
>>
>> Before this patch:
>> icount: 6360863066640355328 ifree: 5242880 fdblks: 0 frext: 0
>>
>> After this patch:
>> icount: 10240 ifree: 4906 fdblks: 37 frext: 0
>>
>> Suggested-by: Darrick J. Wong <djwong@kernel.org>
>> Suggested-by: Dave Chinner <david@fromorbit.com>
>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>> ---
>> logprint/log_misc.c | 17 +++++------------
>
> Hmm, I don't think this ever got merged...
>
> but shouldn't log_print_all.c also get fixed? I think it has the same
> pointer arithmetic problem that could be replaced by get_unaligned_be64
> calls just like you did below.
Indeed, the same issue also exists in log_print_all.c. I will fix it in
the next push.
Thanks,
Chi Zhiling
>
> --D
>
>> 1 file changed, 5 insertions(+), 12 deletions(-)
>>
>> diff --git a/logprint/log_misc.c b/logprint/log_misc.c
>> index 8e86ac34..803e4d2f 100644
>> --- a/logprint/log_misc.c
>> +++ b/logprint/log_misc.c
>> @@ -282,22 +282,15 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
>> if (be32_to_cpu(head->oh_len) < 4*8) {
>> printf(_("Out of space\n"));
>> } else {
>> - __be64 a, b;
>> + struct xfs_dsb *dsb = (struct xfs_dsb *) *ptr;
>>
>> printf("\n");
>> - /*
>> - * memmove because *ptr may not be 8-byte aligned
>> - */
>> - memmove(&a, *ptr, sizeof(__be64));
>> - memmove(&b, *ptr+8, sizeof(__be64));
>> printf(_("icount: %llu ifree: %llu "),
>> - (unsigned long long) be64_to_cpu(a),
>> - (unsigned long long) be64_to_cpu(b));
>> - memmove(&a, *ptr+16, sizeof(__be64));
>> - memmove(&b, *ptr+24, sizeof(__be64));
>> + (unsigned long long) get_unaligned_be64(dsb->sb_icount),
>> + (unsigned long long) get_unaligned_be64(dsb->sb_ifree));
>> printf(_("fdblks: %llu frext: %llu\n"),
>> - (unsigned long long) be64_to_cpu(a),
>> - (unsigned long long) be64_to_cpu(b));
>> + (unsigned long long) get_unaligned_be64(dsb->sb_fdblocks),
>> + (unsigned long long) get_unaligned_be64(dsb->sb_frextents));
>> }
>> super_block = 0;
>> } else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_AGI_MAGIC) {
>> --
>>
>> 2.43.0
>>
>>
prev parent reply other threads:[~2025-01-16 1:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 4:29 [PATCH v4] xfs_logprint: Fix super block buffer interpretation issue Chi Zhiling
2025-01-16 0:33 ` Darrick J. Wong
2025-01-16 1:38 ` Chi Zhiling [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43a586fb-5cee-4668-b15e-f75b294a243a@163.com \
--to=chizhiling@163.com \
--cc=cem@kernel.org \
--cc=chizhiling@kylinos.cn \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.