From: Patrick Farrell Date: Wed, 3 Jan 2024 22:23:20 +0000 (-0500) Subject: EX-7601 ldiskfs: fix detection of compressed extent X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=cca275d7fead875dbb6e3e10b1ebf18ab75f4f5b;p=fs%2Flustre-release.git EX-7601 ldiskfs: fix detection of compressed extent 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 Change-Id: I11d50bdc45c40d93bb1b829fcd930165b7626432 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53588 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 11a8ad9..ec01ec3 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -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++) { diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 4e1fa32..bbcc2e0 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -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; diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 37d08b8..1dd8506 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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