} else {
struct niobuf_local lnb = lnbs[first + i];;
+ CDEBUG(D_SEC, "lnb %d, at %llu, len %d, rc %d\n",
+ first + i, lnb.lnb_file_offset, lnb.lnb_len,
+ lnb.lnb_rc);
/* can't merge pages with errors in the data */
if (lnb.lnb_rc < 0)
return lnb.lnb_rc;
+ /* there's no data in this lnb, so stop merging here */
+ if (lnb.lnb_rc == 0)
+ break;
vmpage = lnb.lnb_page;
pg_len = lnb.lnb_len;
offset = lnb.lnb_file_offset;
*size += pg_len;
}
- return 0;
+ return i;
}
EXPORT_SYMBOL(merge_chunk);
/* place the raw compressed data in a contiguous buffer */
rc = merge_chunk(NULL, lnbs, lnb_start, pages_in_chunk, (char *) bounce_src,
&src_size);
- if (rc != 0) {
+ if (rc < 0) {
CERROR("%s: Data error in lnbs at %llu, rc: %d\n",
obd_name, lnbs[lnb_start].lnb_file_offset, rc);
GOTO(out, rc);
}
LASSERT(src_size <= chunk_size);
- CDEBUG(D_SEC, "merged size: %u\n", src_size);
+ CDEBUG(D_SEC, "merged size: %u, pages merged %d\n", src_size, rc);
+ /* merge_chunk returns the number of pages in this chunk with data,
+ * so don't try to decompress if there was no data in this chunk
+ */
+ if (rc == 0)
+ GOTO(out, rc = 0);
rc = decompress_chunk(obd_name, cc,
((char *) bounce_src) + hdr_size,