From 626eb303591ff3b67144c33dedea2a983cab45cb Mon Sep 17 00:00:00 2001 From: Etienne AUJAMES Date: Fri, 8 Jul 2022 12:36:10 +0200 Subject: [PATCH] LU-16000 utils: align updatelog parameters in llog_reader Parameters in update log records are aligned on 64bits. llog_reader do not aligned these parameters: if a parameters size is not mutiple of 8, the next parameter size will be read incorrectly. Lustre-change: https://review.whamcloud.com/47913 Lustre-commit 6d74b759634355e7f6647ccaefef519a1ff208e2 Test-Parameters: trivial Fixes: 9962d6f ("LU-14617 utils: llog_reader updatelog support") Signed-off-by: Etienne AUJAMES Change-Id: I6871614ab4ea79d59c3c3b4644b377de395bad56 Reviewed-by: Alexander Boyko Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48308 Reviewed-by: Mikhail Pershin Tested-by: jenkins Tested-by: Maloo --- lustre/utils/llog_reader.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c index 60fc711..2b6cace 100644 --- a/lustre/utils/llog_reader.c +++ b/lustre/utils/llog_reader.c @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef HAVE_ENDIAN_H # include #endif @@ -883,6 +884,12 @@ char *buf2str(void *buf, unsigned int size) return string; } +static inline size_t +object_update_param_size(const struct object_update_param *param) +{ + return roundup(sizeof(*param) + param->oup_len, sizeof(__u64)); +} + void print_update_rec(struct llog_update_record *lur) { struct update_records *rec = &lur->lur_update_rec; @@ -916,8 +923,8 @@ void print_update_rec(struct llog_update_record *lur) for (i = 0; i < pm_count; i++) { printf("\tp_%d - %d/%s\n", i, pm->oup_len, buf2str(pm->oup_buf, pm->oup_len)); - pm = (struct object_update_param *)((char *)(pm + 1) + - pm->oup_len); + pm = (struct object_update_param *)((char *)pm + + object_update_param_size(pm)); } printf("\n"); -- 1.8.3.1