[PATCH] xfs_logprint: Fix super block buffer interpretation issue
From: Chi Zhiling
Date: Thu Oct 10 2024 - 23:09:32 EST
From: chizhiling <chizhiling@xxxxxxxxxx>
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
Signed-off-by: chizhiling <chizhiling@xxxxxxxxxx>
---
logprint/log_misc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 8e86ac34..21da5b8b 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -288,13 +288,13 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
/*
* memmove because *ptr may not be 8-byte aligned
*/
- memmove(&a, *ptr, sizeof(__be64));
- memmove(&b, *ptr+8, sizeof(__be64));
+ memmove(&a, *ptr + offsetof(struct xfs_dsb, sb_icount), sizeof(__be64));
+ memmove(&b, *ptr + offsetof(struct xfs_dsb, sb_ifree), 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));
+ memmove(&a, *ptr + offsetof(struct xfs_dsb, sb_fdblocks), sizeof(__be64));
+ memmove(&b, *ptr + offsetof(struct xfs_dsb, sb_frextents), sizeof(__be64));
printf(_("fdblks: %llu frext: %llu\n"),
(unsigned long long) be64_to_cpu(a),
(unsigned long long) be64_to_cpu(b));
--
2.43.0