Whamcloud - gitweb
LU-7039 llog: skip to next chunk for corrupt record 40/16740/3
authorDi Wang <di.wang@intel.com>
Mon, 5 Oct 2015 03:34:41 +0000 (20:34 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 30 Oct 2015 16:39:19 +0000 (16:39 +0000)
Skip to next chunk if current record is corrupted.

Signed-off-by: Di Wang <di.wang@intel.com>
Change-Id: I7729ca1b10646fa796a3f94aabe39d8d36cf613a
Reviewed-on: http://review.whamcloud.com/16740
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/llog_reader.c

index 5b2cb7c..f4644c5 100644 (file)
@@ -258,9 +258,10 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
        ptr = file_buf + le32_to_cpu((*llog)->llh_hdr.lrh_len);
        i = 0;
 
-       while (i < recs_num) {
+       while (ptr < (file_buf + file_size)) {
                struct llog_rec_hdr *cur_rec;
                int idx;
+               unsigned long offset;
 
                if (ptr + sizeof(struct llog_rec_hdr) >
                    file_buf + file_size) {
@@ -273,10 +274,17 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
                cur_rec = (struct llog_rec_hdr *)ptr;
                idx = le32_to_cpu(cur_rec->lrh_index);
                recs_pr[i] = cur_rec;
-
-               if (ext2_test_bit(idx, LLOG_HDR_BITMAP(*llog))) {
-                       printf("rec #%d type=%x len=%u\n", idx,
-                              cur_rec->lrh_type, cur_rec->lrh_len);
+               offset = (unsigned long)ptr - (unsigned long)file_buf;
+               if (cur_rec->lrh_len == 0 ||
+                   cur_rec->lrh_len > (*llog)->llh_hdr.lrh_len) {
+                       cur_rec->lrh_len = (*llog)->llh_hdr.lrh_len -
+                               offset % (*llog)->llh_hdr.lrh_len;
+                       printf("off %lu skip %u to next chunk.\n", offset,
+                              cur_rec->lrh_len);
+                       i--;
+               } else if (ext2_test_bit(idx, LLOG_HDR_BITMAP(*llog))) {
+                       printf("rec #%d type=%x len=%u offset %lu\n", idx,
+                              cur_rec->lrh_type, cur_rec->lrh_len, offset);
                } else {
                        printf("Bit %d of %d not set\n", idx, recs_num);
                        cur_rec->lrh_id = CANCELLED;