* to write them out
*/
for(i = lnb_start; i < lnb_start + pages_in_chunk; i++) {
+ if (write && lnbs[i].lnb_rc > 0) {
+ CDEBUG(D_SEC, "set lnb %i len to %u\n",
+ i, lnbs[i].lnb_rc);
+ lnbs[i].lnb_len = lnbs[i].lnb_rc;
+ }
+
/* if there's no data in this page, we must clear it */
if (!write && lnbs[i].lnb_rc == 0) {
CDEBUG(D_SEC, "%s: no data, clearing: page %d, "DFID" at %llu\n",
nr_read, true);
if (unlikely(rc != 0))
GOTO(err, rc);
+
+ /*
+ * If any lnb will not be decompressed it needs to have
+ * original data size in the lnb. Save it here.
+ */
+ for (i = 0; i < nr_read; i++) {
+ unsigned int size_delta = la->la_size - read_lnb[i].lnb_file_offset;
+ if (read_lnb[i].lnb_rc > 0 && size_delta < PAGE_SIZE)
+ read_lnb[i].lnb_rc = size_delta;
+ }
+
rc = ofd_decompress_read(env, exp, oa, rnb, read_lnb, obj,
nr_read, eof_rnb, type, lvl,
chunk_bits, true);