From: Sergey Cheremencev Date: Wed, 23 Jun 2021 15:08:00 +0000 (+0300) Subject: LU-15067 lod: fix error handling in lod_new_pool X-Git-Tag: 2.14.56~133 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b6ac7490f3a30c80dba8453dc7240a56780b953b LU-15067 lod: fix error handling in lod_new_pool - correct error handling in lod_new_pool - ENOMEM from tgt_pool_init may cause incorrect pool_count. - optimisation in lu_tgt_pool_add. Do not extend a pool, if the target is already exists. HPE-bug-id: LUS-6995 Change-Id: I0ea00d335217f3994334bd02ae36c34653e7da98 Reviewed-by: Alexander Zarochentsev Reviewed-by: Artem Blagodarenko Signed-off-by: Sergey Cheremencev Reviewed-on: https://review.whamcloud.com/45137 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_pool.c b/lustre/lod/lod_pool.c index 35e0601..9bcdf22 100644 --- a/lustre/lod/lod_pool.c +++ b/lustre/lod/lod_pool.c @@ -440,7 +440,7 @@ int lod_pool_new(struct obd_device *obd, char *poolname) atomic_set(&new_pool->pool_refcount, 1); rc = lu_tgt_pool_init(&new_pool->pool_obds, 0); if (rc) - GOTO(out_err, rc); + GOTO(out_free_pool, rc); lu_qos_rr_init(&new_pool->pool_rr); @@ -510,6 +510,7 @@ out_err: lu_tgt_pool_free(&new_pool->pool_rr.lqr_pool); out_free_pool_obds: lu_tgt_pool_free(&new_pool->pool_obds); +out_free_pool: OBD_FREE_PTR(new_pool); return rc; } diff --git a/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c index 5ce1741..500846f 100644 --- a/lustre/lov/lov_pool.c +++ b/lustre/lov/lov_pool.c @@ -273,7 +273,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) atomic_set(&new_pool->pool_refcount, 1); rc = lu_tgt_pool_init(&new_pool->pool_obds, 0); if (rc) - GOTO(out_err, rc); + GOTO(out_free_pool, rc); #ifdef CONFIG_PROC_FS /* get ref for /proc file */ @@ -321,6 +321,7 @@ out_err: spin_unlock(&obd->obd_dev_lock); lprocfs_remove(&new_pool->pool_proc_entry); lu_tgt_pool_free(&new_pool->pool_obds); +out_free_pool: OBD_FREE_PTR(new_pool); return rc; diff --git a/lustre/obdclass/lu_tgt_pool.c b/lustre/obdclass/lu_tgt_pool.c index bd8aa1d..7ca36bd 100644 --- a/lustre/obdclass/lu_tgt_pool.c +++ b/lustre/obdclass/lu_tgt_pool.c @@ -140,15 +140,16 @@ int lu_tgt_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count) down_write(&op->op_rw_sem); - rc = lu_tgt_pool_extend(op, min_count); - if (rc) - GOTO(out, rc); - /* search ost in pool array */ for (i = 0; i < op->op_count; i++) { if (op->op_array[i] == idx) GOTO(out, rc = -EEXIST); } + + rc = lu_tgt_pool_extend(op, min_count); + if (rc) + GOTO(out, rc); + /* ost not found we add it */ op->op_array[op->op_count] = idx; op->op_count++;