From 12fe638ba189351cc14cb6f1f23c90f63928088a Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 19 Sep 2008 23:37:36 +0000 Subject: [PATCH] b=14836 i=jc.lafoucriere i=johann pools fix missing unlock qos remove extra putref --- lustre/lov/lov_qos.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c index e913324..27618a3 100644 --- a/lustre/lov/lov_qos.c +++ b/lustre/lov/lov_qos.c @@ -508,7 +508,7 @@ static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt, char *poolname, int flags) { unsigned array_idx; - int i, *idx_pos; + int i, rc, *idx_pos; __u32 ost_idx; int ost_start_idx_temp; int speed = 0; @@ -528,12 +528,9 @@ static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt, lqr = &(pool->pool_rr); } - i = qos_calc_rr(lov, osts, lqr); - if (i) { - if (pool != NULL) - read_unlock(&pool_tgt_rwlock(pool)); - RETURN(i); - } + rc = qos_calc_rr(lov, osts, lqr); + if (rc) + GOTO(out, rc); if (--lqr->lqr_start_count <= 0) { lqr->lqr_start_idx = ll_rand() % osts->op_count; @@ -599,13 +596,13 @@ repeat_find: goto repeat_find; } - if (pool != NULL) - read_unlock(&pool_tgt_rwlock(pool)); - up_read(&lov->lov_qos.lq_rw_sem); *stripe_cnt = idx_pos - idx_arr; - RETURN(0); +out: + if (pool != NULL) + read_unlock(&pool_tgt_rwlock(pool)); + RETURN(rc); } /* alloc objects on osts with specific stripe offset */ @@ -613,9 +610,9 @@ static int alloc_specific(struct lov_obd *lov, struct lov_stripe_md *lsm, int *idx_arr) { unsigned ost_idx, array_idx, ost_count; - int i, *idx_pos; + int i, rc, *idx_pos; int speed = 0; - struct pool_desc *pool = NULL; + struct pool_desc *pool; struct ost_pool *osts; ENTRY; @@ -639,11 +636,9 @@ repeat_find: } } if (i == ost_count) { - if (pool != NULL) - read_unlock(&pool_tgt_rwlock(pool)); CERROR("Start index %d not found in pool '%s'\n", lsm->lsm_oinfo[0]->loi_ost_idx, lsm->lsm_pool_name); - RETURN(-EINVAL); + GOTO(out, rc = -EINVAL); } idx_pos = idx_arr; @@ -669,11 +664,8 @@ repeat_find: *idx_pos = ost_idx; idx_pos++; /* We have enough stripes */ - if (idx_pos - idx_arr == lsm->lsm_stripe_count) { - if (pool != NULL) - read_unlock(&pool_tgt_rwlock(pool)); - RETURN(0); - } + if (idx_pos - idx_arr == lsm->lsm_stripe_count) + GOTO(out, rc = 0); } if (speed < 2) { /* Try again, allowing slower OSCs */ @@ -690,11 +682,11 @@ repeat_find: CERROR("can't lstripe objid "LPX64": have %d want %u\n", lsm->lsm_object_id, (int)(idx_pos - idx_arr), lsm->lsm_stripe_count); - + rc = -EFBIG; +out: if (pool != NULL) read_unlock(&pool_tgt_rwlock(pool)); - - RETURN(-EFBIG); + RETURN(rc); } /* Alloc objects on osts with optimization based on: @@ -710,13 +702,13 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt, __u64 total_bavail, total_weight = 0; int nfound, good_osts, i, warn = 0, rc = 0; int stripe_cnt_min = min_stripe_count(*stripe_cnt, flags); - struct pool_desc *pool = NULL; + struct pool_desc *pool; struct ost_pool *osts; struct lov_qos_rr *lqr; ENTRY; if (stripe_cnt_min < 1) - GOTO(out, rc = -EINVAL); + RETURN(-EINVAL); pool = lov_find_pool(lov, poolname); if (pool == NULL) { @@ -867,11 +859,11 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt, LASSERT(nfound == *stripe_cnt); out: + up_write(&lov->lov_qos.lq_rw_sem); + if (pool != NULL) read_unlock(&pool_tgt_rwlock(pool)); - up_write(&lov->lov_qos.lq_rw_sem); - if (rc == -EAGAIN) rc = alloc_rr(lov, idx_arr, stripe_cnt, poolname, flags); -- 1.8.3.1