Whamcloud - gitweb
LU-4825 osp: check max_create_count before use OSP 05/16105/19
authorLai Siyao <lai.siyao@intel.com>
Wed, 20 Jul 2016 23:22:09 +0000 (19:22 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 27 Jul 2016 03:01:23 +0000 (03:01 +0000)
in OSP precreate, if max_create_count is 0, return error directly
to use next OST, this can be used in OST migration.

add sanity.sh 311 for this.

Signed-off-by: Lai Siyao <lai.siyao@intel.com>
Change-Id: I3f1cb84b30229911564969bcfc52b9e7c03a00d4
Reviewed-on: http://review.whamcloud.com/16105
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osp/osp_precreate.c
lustre/tests/sanity.sh

index e341faf..ff9711d 100644 (file)
@@ -1317,6 +1317,10 @@ int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
                 "Next FID "DFID"\n", PFID(&d->opd_pre_last_created_fid),
                 PFID(&d->opd_pre_used_fid));
 
+       /* opd_pre_max_create_count 0 to not use specified OST. */
+       if (d->opd_pre_max_create_count == 0)
+               RETURN(-ENOBUFS);
+
        /*
         * wait till:
         *  - preallocation is done
index 6618b42..4b3c74c 100644 (file)
@@ -5553,34 +5553,59 @@ test_65k() { # bug11679
        [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
-    echo "Check OST status: "
-    local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
-              awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
+       local disable_precreate=true
+       [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
+               disable_precreate=false
 
-    for OSC in $MDS_OSCS; do
-        echo $OSC "is activate"
-        do_facet $SINGLEMDS lctl --device %$OSC activate
-    done
+       echo "Check OST status: "
+       local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
+               awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
 
-    mkdir -p $DIR/$tdir
-    for INACTIVE_OSC in $MDS_OSCS; do
-        echo "Deactivate: " $INACTIVE_OSC
-        do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
-        for STRIPE_OSC in $MDS_OSCS; do
-            OST=`osc_to_ost $STRIPE_OSC`
-            IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
-                 awk -F: /$OST/'{ print $1 }' | head -n 1`
-
-            [ -f $DIR/$tdir/$IDX ] && continue
-            echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
-            $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
-            RC=$?
-            [ $RC -ne 0 ] && error "setstripe should have succeeded"
-        done
-        rm -f $DIR/$tdir/*
-        echo $INACTIVE_OSC "is Activate."
-        do_facet $SINGLEMDS lctl --device  %$INACTIVE_OSC activate
-    done
+       for OSC in $MDS_OSCS; do
+               echo $OSC "is active"
+               do_facet $SINGLEMDS lctl --device %$OSC activate
+       done
+
+       for INACTIVE_OSC in $MDS_OSCS; do
+               local ost=$(osc_to_ost $INACTIVE_OSC)
+               local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
+                              lov.*md*.target_obd |
+                              awk -F: /$ost/'{ print $1 }' | head -n 1)
+
+               mkdir -p $DIR/$tdir
+               $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
+               createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
+
+               echo "Deactivate: " $INACTIVE_OSC
+               do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
+
+               local count=$(do_facet $SINGLEMDS "lctl get_param -n \
+                             osp.$ost*MDT0000.create_count")
+               local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
+                                 osp.$ost*MDT0000.max_create_count")
+               $disable_precreate &&
+                       do_facet $SINGLEMDS "lctl set_param -n \
+                               osp.$ost*MDT0000.max_create_count=0"
+
+               for idx in $(seq 0 $((OSTCOUNT - 1))); do
+                       [ -f $DIR/$tdir/$idx ] && continue
+                       echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
+                       $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
+                               error "setstripe $idx should succeed"
+                       rm -f $DIR/$tdir/$idx || error "rm $idx failed"
+               done
+               unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
+               rmdir $DIR/$tdir
+
+               do_facet $SINGLEMDS "lctl set_param -n \
+                       osp.$ost*MDT0000.max_create_count=$max_count"
+               do_facet $SINGLEMDS "lctl set_param -n \
+                       osp.$ost*MDT0000.create_count=$count"
+               do_facet $SINGLEMDS lctl --device  %$INACTIVE_OSC activate
+               echo $INACTIVE_OSC "is Activate"
+
+               wait_osc_import_state mds ost$ostnum FULL
+       done
 }
 run_test 65k "validate manual striping works properly with deactivated OSCs"
 
@@ -14677,6 +14702,56 @@ test_310c() {
 }
 run_test 310c "open-unlink remote file with multiple links"
 
+#LU-4825
+test_311() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
+               skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+
+       local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
+
+       mkdir -p $DIR/$tdir
+       $SETSTRIPE -i 0 -c 1 $DIR/$tdir
+       createmany -o $DIR/$tdir/$tfile. 1000
+
+       # statfs data is not real time, let's just calculate it
+       old_iused=$((old_iused + 1000))
+
+       local count=$(do_facet $SINGLEMDS "lctl get_param -n \
+                       osp.*OST0000*MDT0000.create_count")
+       local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
+                               osp.*OST0000*MDT0000.max_create_count")
+       for idx in $(seq $MDSCOUNT); do
+               do_facet mds$idx "lctl set_param -n \
+                       osp.*OST0000*MDT000?.max_create_count=0"
+       done
+
+       $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
+       local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
+       [ $index -ne 0 ] || error "$tfile stripe index is 0"
+
+       unlinkmany $DIR/$tdir/$tfile. 1000
+
+       for idx in $(seq $MDSCOUNT); do
+               do_facet mds$idx "lctl set_param -n \
+                       osp.*OST0000*MDT000?.max_create_count=$max_count"
+               do_facet mds$idx "lctl set_param -n \
+                       osp.*OST0000*MDT000?.create_count=$count"
+       done
+
+       local new_iused
+       for i in $(seq 120); do
+               new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
+               [ $new_iused -lt $((old_iused - 900)) ] && break
+               sleep 1
+       done
+
+       echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
+       [ $new_iused -lt $((old_iused - 900)) ] ||
+               error "objs not destroyed after unlink"
+}
+run_test 311 "disable OSP precreate, and unlink should destroy objs"
+
 test_400a() { # LU-1606, was conf-sanity test_74
        local extra_flags=''
        local out=$TMP/$tfile