Whamcloud - gitweb
LU-6714 llog: fix wrong offset in llog_process_thread()
[fs/lustre-release.git] / lustre / obdclass / llog_osd.c
index 0a09fb5..a79b1ec 100644 (file)
@@ -641,13 +641,19 @@ out:
  * actual records are larger than minimum size) we just skip
  * some more records.
  */
-static inline void llog_skip_over(__u64 *off, int curr, int goal,
-                                 __u32 chunk_size)
+static inline void llog_skip_over(struct llog_log_hdr *llh, __u64 *off,
+                                 int curr, int goal, __u32 chunk_size)
 {
-       if (goal <= curr)
-               return;
-       *off = (*off + (goal - curr - 1) * LLOG_MIN_REC_SIZE) &
-               ~(chunk_size - 1);
+       if (goal > curr) {
+               if (llh->llh_size == 0) {
+                       /* variable size records */
+                       *off = (*off + (goal - curr - 1) * LLOG_MIN_REC_SIZE);
+               } else {
+                       *off = chunk_size + (goal - 1) * llh->llh_size;
+               }
+       }
+       /* always align with lower chunk boundary*/
+       *off &= ~(chunk_size - 1);
 }
 
 /**
@@ -734,7 +740,8 @@ static int llog_osd_next_block(const struct lu_env *env,
                struct llog_rec_hdr     *rec, *last_rec;
                struct llog_rec_tail    *tail;
 
-               llog_skip_over(cur_offset, *cur_idx, next_idx, chunk_size);
+               llog_skip_over(loghandle->lgh_hdr, cur_offset, *cur_idx,
+                              next_idx, chunk_size);
 
                /* read up to next llog chunk_size block */
                lgi->lgi_buf.lb_len = chunk_size -
@@ -864,7 +871,8 @@ static int llog_osd_prev_block(const struct lu_env *env,
        LASSERT(dt);
 
        cur_offset = chunk_size;
-       llog_skip_over(&cur_offset, 0, prev_idx, chunk_size);
+       llog_skip_over(loghandle->lgh_hdr, &cur_offset, 0, prev_idx,
+                      chunk_size);
 
        rc = dt_attr_get(env, o, &lgi->lgi_attr);
        if (rc)