Whamcloud - gitweb
LU-13941 osp: Silently lower requested create_count to maximum 67/39967/9
authorShaun Tancheff <shaun.tancheff@hpe.com>
Mon, 23 Aug 2021 14:40:39 +0000 (09:40 -0500)
committerOleg Drokin <green@whamcloud.com>
Sun, 17 Oct 2021 18:11:12 +0000 (18:11 +0000)
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 <shaun.tancheff@hpe.com>
Change-Id: I4727ba6fca747e1ae9850188ef63c7abb89904be
Reviewed-on: https://review.whamcloud.com/39967
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osp/lproc_osp.c
lustre/tests/functions.sh
lustre/tests/sanity.sh

index 65a4b87..f915719 100644 (file)
@@ -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;
 }
index 0913c84..b016732 100644 (file)
@@ -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
index 5c88214..9e6b357 100755 (executable)
@@ -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
 #