From: Andreas Dilger Date: Thu, 4 Dec 2014 19:35:00 +0000 (+0800) Subject: LU-5246 tests: create OST objects on correct MDT X-Git-Tag: 2.7.58~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d44961b20961d7c46746f67fd43b64e07ce44d77;p=fs%2Flustre-release.git LU-5246 tests: create OST objects on correct MDT The sanity.sh test_220 is checking that precreated objects on the MDT can be used even when the OST has subsequently run out of inodes. The test was not correctly working if the directory was striped over multiple MDTs since the number of precreated objects on other MDTs may be fewer than the number of precreated objects $SINGLEMDS and run out of objects. Change the test to only create files on $SINGLEMDS so to avoid this. Also fix the return code of lod_alloc_specific() to be -ENOSPC if the stripe count is 1, since -EFBIG doesn't make sense in that case. Fix other code comments for lod_alloc_specific() and lod_alloc_qos(). Signed-off-by: Andreas Dilger Change-Id: I788706c3b212b426aa15424d02913aedcdb98b2a Reviewed-on: http://review.whamcloud.com/12937 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Emoly Liu Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 1cd345206..4bd0906 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -1146,12 +1146,12 @@ static int lod_alloc_ost_list(const struct lu_env *env, /** * Allocate a striping on a predefined set of OSTs. * - * Allocates new striping starting from OST provided lo->ldo_def_stripe_offset. + * Allocates new layout starting from OST index in lo->ldo_def_stripe_offset. * Full OSTs are not considered. The exact order of OSTs is not important and * varies depending on OST status. The allocation procedure prefers the targets * with precreated objects ready. The number of stripes needed and stripe - * offset are taken from the object. If that number can not be met, then the - * function returns a failure and then it's the caller's responsibility to + * offset are taken from the object. If that number cannot be met, then the + * function returns an error and then it's the caller's responsibility to * release the stripes allocated. All the internal structures are protected, * but no concurrent allocation is allowed on the same objects. * @@ -1162,9 +1162,10 @@ static int lod_alloc_ost_list(const struct lu_env *env, * \param[in] th transaction handle * * \retval 0 on success - * \retval -E2BIG if no enough OSTs are found + * \retval -ENOSPC if no OST objects are available at all + * \retval -EFBIG if not enough OST objects are found * \retval -EINVAL requested offset is invalid - * \retval negative negated errno on error + * \retval negative errno on failure */ static int lod_alloc_specific(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, int flags, @@ -1278,13 +1279,11 @@ repeat_find: /* If we were passed specific striping params, then a failure to * meet those requirements is an error, since we can't reallocate * that memory (it might be part of a larger array or something). - * - * We can only get here if lsm_stripe_count was originally > 1. */ CERROR("can't lstripe objid "DFID": have %d want %u\n", PFID(lu_object_fid(lod2lu_obj(lo))), stripe_num, lo->ldo_stripenr); - rc = -EFBIG; + rc = stripe_num == 0 ? -ENOSPC : -EFBIG; out: if (pool != NULL) { up_read(&pool_tgt_rw_sem(pool)); @@ -1331,19 +1330,21 @@ static inline int lod_qos_is_usable(struct lod_device *lod) * The function allocates OST objects to create a striping. The algorithm * used is based on weights (currently only using the free space), and it's * trying to ensure the space is used evenly by OSTs and OSSs. The striping - * configuration (# of stripes, offset, - * pool) is taken from the object and is prepared by the caller. + * configuration (# of stripes, offset, pool) is taken from the object and + * is prepared by the caller. + * * If LOV_USES_DEFAULT_STRIPE is not passed and prepared configuration can't - * be met due to too few OSTs, then allocation fails. If the flag is - * passed and less than 75% of the requested number of stripes can be - * allocated, then allocation fails. - * No concurrent allocation is allowed on the object and this must be - * ensured by the caller. All the internal structures are protected by the - * function. - * The algorithm has two steps: find available OSTs and calucate their weights, - * then select the OSTs the weights used as the probability. An OST with a - * higher weight is proportionately more likely to be selected than one with - * a lower weight. + * be met due to too few OSTs, then allocation fails. If the flag is passed + * fewer than 3/4 of the requested number of stripes can be allocated, then + * allocation fails. + * + * No concurrent allocation is allowed on the object and this must be ensured + * by the caller. All the internal structures are protected by the function. + * + * The algorithm has two steps: find available OSTs and calculate their + * weights, then select the OSTs with their weights used as the probability. + * An OST with a higher weight is proportionately more likely to be selected + * than one with a lower weight. * * \param[in] env execution environment for this thread * \param[in] lo LOD object @@ -1352,9 +1353,9 @@ static inline int lod_qos_is_usable(struct lod_device *lod) * \param[in] th transaction handle * * \retval 0 on success - * \retval -E2BIG if no enough OSTs are found - * \retval -EINVAL requested offset is invalid - * \retval negative negated errno on error + * \retval -EAGAIN not enough OSTs are found for specified stripe count + * \retval -EINVAL requested OST index is invalid + * \retval negative errno on failure */ static int lod_alloc_qos(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, int flags, @@ -1484,8 +1485,8 @@ static int lod_alloc_qos(const struct lu_env *env, struct lod_object *lo, rand = 0; } - /* On average, this will hit larger-weighted osts more often. - 0-weight osts will always get used last (only when rand=0) */ + /* On average, this will hit larger-weighted OSTs more often. + * 0-weight OSTs will always get used last (only when rand=0) */ for (i = 0; i < osts->op_count; i++) { __u32 idx = osts->op_array[i]; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 232c45c..f13bdd8 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -12061,9 +12061,10 @@ test_220() { #LU-325 remote_mgs_nodsh && skip "remote MGS with nodsh" && return local OSTIDX=0 - test_mkdir -p $DIR/$tdir - local OST=$($LFS osts | grep ${OSTIDX}": " | \ - awk '{print $2}' | sed -e 's/_UUID$//') + # create on MDT0000 so the last_id and next_id are correct + mkdir $DIR/$tdir + local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }') + OST=${OST%_UUID} # on the mdt's osc local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)