xfs: checksum log record ext headers based on record size
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_log.c
index 7ce278d66577f75ed40f25b15eb27d68df49f496..a98daa68045d1d68f8dfae3cc8bee1384c5431fa 100644 (file)
@@ -1670,8 +1670,13 @@ xlog_cksum(
        if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
                union xlog_in_core2 *xhdr = (union xlog_in_core2 *)rhead;
                int             i;
+               int             xheads;
 
-               for (i = 1; i < log->l_iclog_heads; i++) {
+               xheads = size / XLOG_HEADER_CYCLE_SIZE;
+               if (size % XLOG_HEADER_CYCLE_SIZE)
+                       xheads++;
+
+               for (i = 1; i < xheads; i++) {
                        crc = crc32c(crc, &xhdr[i].hic_xheader,
                                     sizeof(struct xlog_rec_ext_header));
                }