From a94c5c0f3b8363aaf82264094047a095d76dcf49 Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Wed, 6 Jul 2022 00:00:58 +0300 Subject: [PATCH] LU-16281 clio: append to non-existent component should return an error, but it fails now with a BUG below because @rc of lov_io_layout_at() is not checked for < 0 stripe_width()) ASSERTION( index < lsm->lsm_entry_count ) failed: BUG: unable to handle kernel paging request at ffff99d3c2f74030 Call Trace: lov_stripe_number+0x19/0x40 [lov] lov_page_init_composite+0x103/0x5f0 [lov] ? kmem_cache_alloc+0x12e/0x270 cl_page_alloc+0x19f/0x660 [obdclass] cl_page_find+0x1a0/0x250 [obdclass] ll_write_begin+0x1f7/0xfb0 [lustre] Lustre-change: https://review.whamcloud.com/48994 Lustre-commit: 8fdeca3b6faf22c72f6687aa23b86715d39ceeb1 HPE-bug-id: LUS-11075 Signed-off-by: Vitaly Fertman Change-Id: I4371f56cd9cdb3429d52a283831fb0a768e5c9c3 Reviewed-by: Alexander Zarochentsev Reviewed-by: Alexander Boyko Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54133 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Zhenyu Xu --- lustre/lov/lov_page.c | 2 ++ lustre/tests/sanity-pfl.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lustre/lov/lov_page.c b/lustre/lov/lov_page.c index dbdb03e..ed1de81 100644 --- a/lustre/lov/lov_page.c +++ b/lustre/lov/lov_page.c @@ -99,6 +99,8 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, suboff = lio->lis_cached_suboff + offset - lio->lis_cached_off; } else { entry = lov_io_layout_at(lio, offset); + if (entry < 0) + return(-ENODATA); stripe = lov_stripe_number(loo->lo_lsm, entry, offset); rc = lov_stripe_offset(loo->lo_lsm, entry, offset, stripe, diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index 33d3c2c..bafe4a2 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -2508,6 +2508,28 @@ test_25() { } run_test 25 "Verify old lov stripe API with PFL files" +test_26a() { + $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile + dd if=/dev/urandom bs=1M count=10 >> $DIR/$tfile + [ $? != 0 ] || error "append must return an error" +} +run_test 26a "Append to not-existent component" + +test_26b() { + $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile + dd if=/dev/urandom bs=1M count=1 > $DIR/$tfile + dd if=/dev/urandom bs=1M count=1 >> $DIR/$tfile + [ $? != 0 ] || error "append must return an error" +} +run_test 26b "Append to not-existend component, file size is unknown" + +test_26c() { + $LFS setstripe -E 1m -S 1M -c 1 $DIR/$tfile + dd if=/dev/urandom bs=2M count=1 >> $DIR/$tfile + [ $? != 0 ] || error "append must return an error" +} +run_test 26c "Append to not-existend component, crossing the component border" + export LFS_SETSTRIPE_COMPR_OK="yes" test_100a() { (( $MDS1_VERSION >= $(version_code 2.14.0.92) )) || -- 1.8.3.1