From d0efb7dea9b8a5c571d63a0e019f16e75d16131f Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Tue, 13 Dec 2011 02:28:08 +0800 Subject: [PATCH] LU-748 test: shorten the runtime of sanity subtest_220 in sanity.sh, test_220 tries to exhaust all of the inodes on the OSTs in order to verify that when it returns -ENOSPC to inode precreate request, but there is still free blocks, then the MDS continues to use these precreated inodes on the OSTs. Signed-off-by: Hongchao Zhang Change-Id: Icaad07311125f362f0efb26da76534c7dca27b6a Reviewed-on: http://review.whamcloud.com/1676 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong --- libcfs/include/libcfs/libcfs_fail.h | 8 +++++++- libcfs/libcfs/fail.c | 7 +++++++ lustre/include/obd_support.h | 2 ++ lustre/obdfilter/filter.c | 15 +++++++-------- lustre/tests/sanity.sh | 28 +++++++++++++++++----------- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_fail.h b/libcfs/include/libcfs/libcfs_fail.h index 5edd20d..c5bbb42 100644 --- a/libcfs/include/libcfs/libcfs_fail.h +++ b/libcfs/include/libcfs/libcfs_fail.h @@ -48,7 +48,8 @@ int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set); enum { CFS_FAIL_LOC_NOSET = 0, CFS_FAIL_LOC_ORSET = 1, - CFS_FAIL_LOC_RESET = 2 + CFS_FAIL_LOC_RESET = 2, + CFS_FAIL_LOC_VALUE = 3 }; /* Failure injection control */ @@ -87,6 +88,11 @@ static inline int cfs_fail_check_set(__u32 id, __u32 value, int set) #define CFS_FAIL_CHECK(id) \ cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET) +/* If id hit cfs_fail_loc and cfs_fail_val == (-1 or value) return 1, + * otherwise return 0 */ +#define CFS_FAIL_CHECK_VALUE(id, value) \ + cfs_fail_check_set(id, value, CFS_FAIL_LOC_VALUE) + /* If id hit cfs_fail_loc, cfs_fail_loc |= value and return 1, * otherwise return 0 */ #define CFS_FAIL_CHECK_ORSET(id, value) \ diff --git a/libcfs/libcfs/fail.c b/libcfs/libcfs/fail.c index d653ee6..a863ee5 100644 --- a/libcfs/libcfs/fail.c +++ b/libcfs/libcfs/fail.c @@ -73,6 +73,12 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set) return 0; } + /* check cfs_fail_val... */ + if (set == CFS_FAIL_LOC_VALUE) { + if (cfs_fail_val != -1 && cfs_fail_val != value) + return 0; + } + /* Fail cfs_fail_val times, overridden by FAIL_ONCE */ if (cfs_fail_loc & CFS_FAIL_SOME && (!(cfs_fail_loc & CFS_FAIL_ONCE) || cfs_fail_val <= 1)) { @@ -100,6 +106,7 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set) switch (set) { case CFS_FAIL_LOC_NOSET: + case CFS_FAIL_LOC_VALUE: break; case CFS_FAIL_LOC_ORSET: cfs_fail_loc |= value & ~(CFS_FAILED | CFS_FAIL_ONCE); diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 9e40c43..739f2e0 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -285,6 +285,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_OST_NOMEM 0x226 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227 #define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228 +#define OBD_FAIL_OST_ENOINO 0x229 #define OBD_FAIL_LDLM 0x300 #define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 @@ -428,6 +429,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, /* Assign references to moved code to reduce code changes */ #define OBD_FAIL_PRECHECK(id) CFS_FAIL_PRECHECK(id) #define OBD_FAIL_CHECK(id) CFS_FAIL_CHECK(id) +#define OBD_FAIL_CHECK_VALUE(id, value) CFS_FAIL_CHECK_VALUE(id, value) #define OBD_FAIL_CHECK_ORSET(id, value) CFS_FAIL_CHECK_ORSET(id, value) #define OBD_FAIL_CHECK_RESET(id, value) CFS_FAIL_CHECK_RESET(id, value) #define OBD_FAIL_RETURN(id, ret) CFS_FAIL_RETURN(id, ret) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index a77ca65..ffd551e 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3704,6 +3704,7 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs, { struct filter_obd *filter = &obd->u.filter; int blockbits = obd->u.obt.obt_sb->s_blocksize_bits; + struct lr_server_data *lsd = class_server_data(obd); int rc; ENTRY; @@ -3727,15 +3728,13 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs, ((filter->fo_tot_dirty + filter->fo_tot_pending + osfs->os_bsize - 1) >> blockbits)); - if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOSPC)) { - struct lr_server_data *lsd = class_server_data(obd); - int index = le32_to_cpu(lsd->lsd_ost_index); + if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOSPC, + le32_to_cpu(lsd->lsd_ost_index))) + osfs->os_bfree = osfs->os_bavail = 2; - if (cfs_fail_val == -1 || index == cfs_fail_val) - osfs->os_bfree = osfs->os_bavail = 2; - else if (cfs_fail_loc & OBD_FAIL_ONCE) - cfs_fail_loc &= ~OBD_FAILED; /* reset flag */ - } + if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOINO, + le32_to_cpu(lsd->lsd_ost_index))) + osfs->os_ffree = 0; /* set EROFS to state field if FS is mounted as RDONLY. The goal is to * stop creating files on MDS if OST is not good shape to create diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f1235f1..b397284 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8308,13 +8308,14 @@ test_219() { run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND" test_220() { #LU-325 + remote_ost_nodsh && skip "remote OST with nodsh" && return local OSTIDX=0 mkdir -p $DIR/$tdir local OST=$(lfs osts | grep ${OSTIDX}": " | \ awk '{print $2}' | sed -e 's/_UUID$//') - # on the mdt's osc + # on the mdt's osc local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST) local last_id=$(do_facet $SINGLEMDS lctl get_param -n \ osc.$mdtosc_proc1.prealloc_last_id) @@ -8323,20 +8324,22 @@ test_220() { #LU-325 $LFS df -i + do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1 + #define OBD_FAIL_OST_ENOINO 0x229 + do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME - echo "preallocated objects in MDS is $((last_id - next_id))" \ - "($last_id - $next_id)" + MDSOBJS=$((last_id - next_id)) + echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)" - count=$($LFS df -i $MOUNT | grep ^$OST | awk '{print $4}') - echo "OST still has $count objects" + blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }') + echo "OST still has $count kbytes free" - free=$((count + last_id - next_id)) - echo "create $((free - next_id)) files @next_id..." - createmany -o $DIR/$tdir/f $next_id $free || return 3 + echo "create $MDSOBJS files @next_id..." + createmany -o $DIR/$tdir/f $MDSOBJS || return 3 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \ osc.$mdtosc_proc1.prealloc_last_id) @@ -8348,12 +8351,15 @@ test_220() { #LU-325 echo "cleanup..." + do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0 + do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0 + do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5 - echo "unlink $((free - next_id)) files @ $next_id..." - unlinkmany $DIR/$tdir/f $next_id $free || return 3 + echo "unlink $MDSOBJS files @$next_id..." + unlinkmany $DIR/$tdir/f $MDSOBJS || return 6 } -run_test 220 "the preallocated objects in MDS still can be used if ENOSPC is returned by OST with enough disk space" +run_test 220 "preallocated MDS objects still used if ENOSPC from OST" test_221() { cp `which date` $MOUNT -- 1.8.3.1