From fa90434c14d6c3d3c471f3ff87edf16fdf9adbfb Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 30 Oct 2023 11:08:57 +0300 Subject: [PATCH] EX-8498 osd: const create in osd_ldiskfs_map_inode_pages() create flag is used to skip reads of unwritten blocks so don't use/modify it to enable dense writes. Fixes: f36eda6a1e ("LU-10026 osd-ldiskfs: use preallocation for dense writes") Signed-off-by: Alex Zhuravlev Change-Id: I63a08ae2b8ed30d8a8ef4c5570f05d300a2b430b Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52887 Tested-by: jenkins Tested-by: Andreas Dilger Reviewed-by: Andreas Dilger --- lustre/include/obd_support.h | 1 + lustre/osd-ldiskfs/osd_io.c | 16 +++++++++++----- lustre/tests/sanity-benchmark.sh | 4 +++- lustre/tests/sanity-compr.sh | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index a4a9ac1..cb2c18b 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -761,6 +761,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_BARRIER_FAILURE 0x2203 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301 +#define OBD_FAIL_OSD_MARK_COMPRESSED 0x2302 /* continuation of MDS related constants */ #define OBD_FAIL_MDS_PAUSE_CREATE_AFTER_LOOKUP 0x2401 diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 0da8eb7..750458a 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1073,7 +1073,8 @@ static void osd_decay_extent_bytes(struct osd_device *osd, static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct osd_iobuf *iobuf, struct osd_device *osd, - int create, __u64 user_size, + const int create, + __u64 user_size, int check_credits, struct thandle *thandle) { @@ -1091,6 +1092,7 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct niobuf_local *lnb1, *lnb2; loff_t size1, size2; bool compressed; + int flags = 0; max_page_index = inode->i_sb->s_maxbytes >> PAGE_SHIFT; @@ -1100,7 +1102,7 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode, compressed = iobuf->dr_lnbs[0]->lnb_flags & OBD_BRW_COMPRESSED; if (create) { - create = LDISKFS_GET_BLOCKS_CREATE; + flags = LDISKFS_GET_BLOCKS_CREATE; handle = ldiskfs_journal_current_handle(); LASSERT(handle != NULL); rc = osd_attach_jinode(inode); @@ -1174,12 +1176,16 @@ cont_map: oh->oh_declared_ext--; } #ifdef LDISKFS_GET_BLOCKS_VERY_DENSE - if (osd->od_extents_dense && compressed) - create |= LDISKFS_GET_BLOCKS_VERY_DENSE; + if (osd->od_extents_dense) { + if (OBD_FAIL_CHECK(OBD_FAIL_OSD_MARK_COMPRESSED)) + flags |= LDISKFS_GET_BLOCKS_VERY_DENSE; + if (compressed) + flags |= LDISKFS_GET_BLOCKS_VERY_DENSE; + } #endif time = ktime_get(); - rc = ldiskfs_map_blocks(handle, inode, &map, create); + rc = ldiskfs_map_blocks(handle, inode, &map, flags); time = ktime_sub(ktime_get(), time); if (rc >= 0) { diff --git a/lustre/tests/sanity-benchmark.sh b/lustre/tests/sanity-benchmark.sh index 36f482b..92e57fa 100644 --- a/lustre/tests/sanity-benchmark.sh +++ b/lustre/tests/sanity-benchmark.sh @@ -183,6 +183,7 @@ test_iozone() { run_test iozone "iozone" test_fsx() { + local fsx_layout="${fsx_STRIPEPARAMS:--c -1}" local testfile=$DIR/f0.fsxfile FSX_SIZE=$SIZE FSX_COUNT=1000 @@ -194,7 +195,8 @@ test_fsx() { $DEBUG_OFF FSX_SEED=${FSX_SEED:-$RANDOM} rm -f $testfile - $LFS setstripe -c -1 $testfile + $LFS setstripe $fsx_layout $testfile || + error "'setstripe $fsx_layout $testfile' failed" CMD="$FSX -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \ -N $((FSX_COUNT * 100)) $FSXOPT $testfile" echo "Using: $CMD" diff --git a/lustre/tests/sanity-compr.sh b/lustre/tests/sanity-compr.sh index d186672..ec9f8ac 100644 --- a/lustre/tests/sanity-compr.sh +++ b/lustre/tests/sanity-compr.sh @@ -141,6 +141,31 @@ test_1000() { } run_test 1000 "compressed vs uncompressed allocation" +test_fsx() { + [[ "$ost1_FSTYPE" == "ldiskfs" ]] || skip "need ldiskfs backend" + local osts=$(comma_list $(osts_nodes)) + + local dense=$(do_facet ost1 lctl get_param -n \ + osd*.*OST0000*.extents_dense) + [[ -n $dense ]] || skip "no dense writes supported" + do_nodes $osts $LCTL set_param osd*.*.extents_dense=1 || + error "cannot enable dense extent allocation" + stack_trap "do_nodes $osts $LCTL set_param osd*.*.extents_dense=$dense" + +#define OBD_FAIL_OSD_MARK_COMPRESSED 0x2302 + do_nodes $osts $LCTL set_param fail_loc=0x2302 || + error "cannot force dense writes" + stack_trap "do_nodes $osts $LCTL set_param fail_loc=0" + + $LCTL set_param llite.*.enable_compression=0 + stack_trap "$LCTL set_param llite.*.enable_compression=1" + + fsx_STRIPEPARAMS="-E eof -c -1 -Z none" ONLY=fsx bash sanity-benchmark.sh + + $DEBUG_ON +} +run_test fsx "verify dense writes with fsx on ldiskfs" + complete_test $SECONDS check_and_cleanup_lustre declare -a logs=($ONLY) -- 1.8.3.1