Whamcloud - gitweb
LU-16000 utils: align updatelog parameters in llog_reader 13/47913/2
authorEtienne AUJAMES <etienne.aujames@cea.fr>
Fri, 8 Jul 2022 10:36:10 +0000 (12:36 +0200)
committerOleg Drokin <green@whamcloud.com>
Mon, 18 Jul 2022 05:36:32 +0000 (05:36 +0000)
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.

Test-Parameters: trivial
Fixes: 9962d6f ("LU-14617 utils: llog_reader updatelog support")
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: I6871614ab4ea79d59c3c3b4644b377de395bad56
Reviewed-on: https://review.whamcloud.com/47913
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/llog_reader.c

index 1f574c0..dc2ef05 100644 (file)
@@ -43,6 +43,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 #ifdef HAVE_ENDIAN_H
 # include <endian.h>
 #endif
 #ifdef HAVE_ENDIAN_H
 # include <endian.h>
 #endif
@@ -876,6 +877,12 @@ char *buf2str(void *buf, unsigned int size)
        return string;
 }
 
        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;
 void print_update_rec(struct llog_update_record *lur)
 {
        struct update_records *rec = &lur->lur_update_rec;
@@ -909,8 +916,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));
        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");
 
        }
        printf("\n");