Whamcloud - gitweb
EX-7601 obd: do not decompress empty lnbs
authorPatrick Farrell <pfarrell@whamcloud.com>
Tue, 12 Dec 2023 20:54:37 +0000 (15:54 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 29 Dec 2023 10:59:22 +0000 (10:59 +0000)
For reads which cross EOF, we may get lnbs with no data in
them (similarly for writes which cross EOF).

For these cases, it's important to only copy from the lnbs
where there is data, and only do decompression on the lnbs
if there's actually data in them.

Modify merge chunk to do this.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I83fefcfa6d1396dcd97fad994334bf29438bb4bf
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53430
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
lustre/obdclass/lustre_compr.c
lustre/ofd/ofd_compress.c

index 83d41cb..29a89e0 100644 (file)
@@ -373,9 +373,15 @@ int merge_chunk(struct brw_page **pga, struct niobuf_local *lnbs,
                } 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;
@@ -388,7 +394,7 @@ int merge_chunk(struct brw_page **pga, struct niobuf_local *lnbs,
                *size += pg_len;
        }
 
-       return 0;
+       return i;
 }
 EXPORT_SYMBOL(merge_chunk);
 
index 74f348b..5d84696 100644 (file)
@@ -92,13 +92,18 @@ static int decompress_chunk_in_lnb(const char *obd_name,
        /* 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,