From 06e586016d3acc490f922e43e3aee6b8112a2803 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 23 Aug 2021 09:40:39 -0500 Subject: [PATCH] LU-13941 osp: Silently lower requested create_count to maximum When setting create_count it should silently accept a larger value and truncate it to the current maximum. This would avoid issues if that limit is changed in the future. HPE-bug-id: LUS-5960 Test-Parameters: trivial testlist=parallel-scale,sanity Signed-off-by: Shaun Tancheff Change-Id: I4727ba6fca747e1ae9850188ef63c7abb89904be Reviewed-on: https://review.whamcloud.com/39967 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin --- lustre/osp/lproc_osp.c | 23 ++++++++++++++--------- lustre/tests/functions.sh | 7 ++----- lustre/tests/sanity.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/lustre/osp/lproc_osp.c b/lustre/osp/lproc_osp.c index 65a4b87..f915719 100644 --- a/lustre/osp/lproc_osp.c +++ b/lustre/osp/lproc_osp.c @@ -337,12 +337,11 @@ static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr, dd_kobj); struct osp_device *osp = dt2osp_dev(dt); unsigned int val; - int rc, i; + int rc; if (!osp->opd_pre) return -EINVAL; - rc = kstrtouint(buffer, 0, &val); if (rc) return rc; @@ -353,18 +352,24 @@ static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr, * that is the maximum possible number of objects that will * ever be handled by MDT->OST recovery processing. * + * The OSP enforces the pre_create_count to amaximum of + * one half of opd_pre_max_create_count. + * * If the OST ever gets a request to delete more orphans, * this implies that something has gone badly on the MDT * and the OST will refuse to delete so much data from the - * filesystem as a safety measure. */ - if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE) - return -ERANGE; - if (val > osp->opd_pre_max_create_count) + * filesystem as a safety measure. + */ + if (val < OST_MIN_PRECREATE) return -ERANGE; + if (val > osp->opd_pre_max_create_count / 2) + val = osp->opd_pre_max_create_count / 2; - for (i = 1; (i << 1) <= val; i <<= 1) - ; - osp->opd_pre_create_count = i; + /* set to largest value <= 32, 64, 128 or a multiple of 256 */ + if (val > 256) + osp->opd_pre_create_count = val & 0xffffff00; + else + osp->opd_pre_create_count = rounddown_pow_of_two(val); return count; } diff --git a/lustre/tests/functions.sh b/lustre/tests/functions.sh index 0913c84..b016732 100644 --- a/lustre/tests/functions.sh +++ b/lustre/tests/functions.sh @@ -1061,16 +1061,13 @@ run_rr_alloc() { # create_count accepted values: # [OST_MIN_PRECREATE=32, OST_MAX_PRECREATE=20000] - # values outside this range are ignored and -ERANGE is returned. - # NOTE: actual maximum value is 16384 (2^14) + # values exceeding OST_MAX_PRECREATE are lowered to the maximum. [[ $create_count -lt 32 ]] && create_count=32 - [[ $create_count -gt 20000 ]] && create_count=20000 local i for i in $(seq $MDSCOUNT); do do_facet mds$i "$LCTL set_param -n \ lod.$FSNAME-MDT*.qos_threshold_rr=100 \ - osp.$FSNAME-OST*-osc-MDT*.create_count=$create_count" || - error "failed while setting qos_threshold_rr & creat_count" + osp.$FSNAME-OST*-osc-MDT*.create_count=$create_count" done # Create few temporary files in order to increase the precreated objects diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5c88214..9e6b357 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -27395,6 +27395,36 @@ test_822() { } run_test 822 "test precreate failure" +test_823() { + local p="$TMP/$TESTSUITE-$TESTNAME.parameters" + local OST_MAX_PRECREATE=20000 + + save_lustre_params mds1 \ + "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p + do_facet $SINGLEMDS "$LCTL set_param -n \ + osp.$FSNAME-OST*MDT0000.max_create_count=0" + do_facet $SINGLEMDS "$LCTL set_param -n \ + osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE" + + stack_trap "restore_lustre_params < $p; rm $p" + + do_facet $SINGLEMDS "$LCTL set_param -n \ + osp.$FSNAME-OST*-osc-MDT*.create_count=100200" + + local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \ + osp.$FSNAME-OST0000*MDT0000.create_count") + local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \ + osp.$FSNAME-OST0000*MDT0000.max_create_count") + local expect_count=$(((($max/2)/256) * 256)) + + log "setting create_count to 100200:" + log " -result- count: $count with max: $max, expecting: $expect_count" + + [[ $count -eq expect_count ]] || + error "Create count not set to max precreate." +} +run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum" + # # tests that do cleanup/setup should be run at the end # -- 1.8.3.1