Whamcloud - gitweb
LU-1626 lov: fix lov request set finish check race
[fs/lustre-release.git] / lustre / lov / lov_qos.c
index 527620a..2b22ea4 100644 (file)
@@ -529,30 +529,33 @@ static int lov_check_and_create_object(struct lov_obd *lov, int ost_idx,
 
 int qos_remedy_create(struct lov_request_set *set, struct lov_request *req)
 {
-        struct lov_stripe_md *lsm = set->set_oi->oi_md;
-        struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
-        unsigned ost_idx = 0, ost_count;
-        struct pool_desc *pool;
-        struct ost_pool *osts = NULL;
-        int i, rc = -EIO;
-        ENTRY;
-
-        /* First check whether we can create the objects on the pool */
-        pool = lov_find_pool(lov, lsm->lsm_pool_name);
-        if (pool != NULL) {
-                cfs_down_read(&pool_tgt_rw_sem(pool));
-                osts = &(pool->pool_obds);
-                ost_count = osts->op_count;
-                for (i = 0; i < ost_count; i++, ost_idx = osts->op_array[i]) {
-                        rc = lov_check_and_create_object(lov, ost_idx, lsm, req,
-                                                         set->set_oti);
-                        if (rc == 0)
-                                break;
-                }
-                cfs_up_read(&pool_tgt_rw_sem(pool));
-                lov_pool_putref(pool);
-                RETURN(rc);
-        }
+       struct lov_stripe_md    *lsm = set->set_oi->oi_md;
+       struct lov_obd          *lov = &set->set_exp->exp_obd->u.lov;
+       unsigned                ost_idx;
+       unsigned                ost_count;
+       struct pool_desc        *pool;
+       struct ost_pool         *osts = NULL;
+       int                     i;
+       int                     rc = -EIO;
+       ENTRY;
+
+       /* First check whether we can create the objects on the pool */
+       pool = lov_find_pool(lov, lsm->lsm_pool_name);
+       if (pool != NULL) {
+               cfs_down_read(&pool_tgt_rw_sem(pool));
+               osts = &(pool->pool_obds);
+               ost_count = osts->op_count;
+               for (i = 0, ost_idx = osts->op_array[0]; i < ost_count;
+                    i++, ost_idx = osts->op_array[i]) {
+                       rc = lov_check_and_create_object(lov, ost_idx, lsm, req,
+                                                        set->set_oti);
+                       if (rc == 0)
+                               break;
+               }
+               cfs_up_read(&pool_tgt_rw_sem(pool));
+               lov_pool_putref(pool);
+               RETURN(rc);
+       }
 
         ost_count = lov->desc.ld_tgt_count;
         /* Then check whether we can create the objects on other OSTs */