Whamcloud - gitweb
EX-7601 ldiskfs: fix detection of compressed extent
authorPatrick Farrell <pfarrell@whamcloud.com>
Wed, 3 Jan 2024 22:23:20 +0000 (17:23 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 13 Jan 2024 02:46:01 +0000 (02:46 +0000)
The code in ldiskfs_map_inode_pages which detects a
compressed extent checks the first lnb for that extent, but
it's possible for some lnbs and not others to be compressed
in a given extent, so we must check all of them.  This
occurs when multiple writes have been combined in to one
RPC.

If we don't detect compression correctly, we won't set the
file size correctly and we'll get data corruption.

Fixes: b489a2a397 ("EX-7600 osc: save compressed object size")
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I11d50bdc45c40d93bb1b829fcd930165b7626432
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53588
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osc/osc_request.c
lustre/osd-ldiskfs/osd_io.c
lustre/tests/test-framework.sh

index 11a8ad9..ec01ec3 100644 (file)
@@ -1821,6 +1821,8 @@ retry_encrypt:
                struct brw_page *brwpg = ncpga[ncpcount - 1];
                oa->o_size = brwpg->off + brwpg->count;
                oa->o_valid |= OBD_MD_FLSIZE;
+               CDEBUG(D_SEC, "compressed, setting file size to %llu\n",
+                      oa->o_size);
        }
 
         for (niocount = i = 1; i < page_count; i++) {
index 4e1fa32..bbcc2e0 100644 (file)
@@ -1142,10 +1142,12 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode,
                struct ldiskfs_map_blocks map = { 0 };
                ktime_t time;
 
+               compressed |= iobuf->dr_lnbs[i]->lnb_flags & OBD_BRW_COMPRESSED;
+               CDEBUG(D_SEC, "lnb at %llu, compressed ? %d\n",
+                      iobuf->dr_lnbs[i]->lnb_file_offset,
+                      iobuf->dr_lnbs[i]->lnb_flags & OBD_BRW_COMPRESSED);
                if (fp == NULL) { /* start new extent */
                        fp = *page++;
-                       compressed |= iobuf->dr_lnbs[i - clen]->lnb_flags &
-                               OBD_BRW_COMPRESSED;
                        clen = 1;
                        if (++i != pages)
                                continue;
index 37d08b8..1dd8506 100755 (executable)
@@ -10691,6 +10691,7 @@ disable_compression() {
 }
 
 flush_and_compare() {
+       ls -la $1 $2
        # Compare using data in cache
        cmp -bl $1 $2 || error "$3 failed compare in cache"
        # Sync to disk and drop cache