From 185bddb360a9eef9bea96308675c68cd22c8debc Mon Sep 17 00:00:00 2001
From: anserper <anserper>
Date: Tue, 14 Oct 2008 19:14:58 +0000
Subject: [PATCH] Branch b1_6 b=17152 i=Johann Lombardi i=Alexey Lyashkov

Take additional references to lov while operating over it
---
 lustre/lov/lov_obd.c | 12 +++++++++---
 lustre/lov/lov_qos.c |  2 --
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c
index 1ceaf61745..449287eca8 100644
--- a/lustre/lov/lov_obd.c
+++ b/lustre/lov/lov_obd.c
@@ -1194,11 +1194,12 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         if (!lov->desc.ld_active_tgt_count)
                 RETURN(-EIO);
 
+        lov_getref(exp->exp_obd);
         /* Recreate a specific object id at the given OST index */
         if ((src_oa->o_valid & OBD_MD_FLFLAGS) &&
             (src_oa->o_flags & OBD_FL_RECREATE_OBJS)) {
                  rc = lov_recreate(exp, src_oa, ea, oti);
-                 RETURN(rc);
+                 GOTO(out, rc);
         }
 
         maxage = cfs_time_shift_64(-lov->desc.ld_qos_maxage);
@@ -1206,7 +1207,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
 
         rc = lov_prep_create_set(exp, &oinfo, ea, src_oa, oti, &set);
         if (rc)
-                RETURN(rc);
+                GOTO(out, rc);
 
         list_for_each_entry(req, &set->set_list, rq_link) {
                 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
@@ -1215,6 +1216,8 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
                 lov_update_create_set(set, req, rc);
         }
         rc = lov_fini_create_set(set, ea);
+out:
+        lov_putref(exp->exp_obd);
         RETURN(rc);
 }
 
@@ -1249,9 +1252,10 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
         }
 
         lov = &exp->exp_obd->u.lov;
+        lov_getref(exp->exp_obd);
         rc = lov_prep_destroy_set(exp, &oinfo, oa, lsm, oti, &set);
         if (rc)
-                RETURN(rc);
+                GOTO(out, rc);
 
         list_for_each (pos, &set->set_list) {
                 int err;
@@ -1278,6 +1282,8 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
                 rc = lsm_op_find(lsm->lsm_magic)->lsm_destroy(lsm, oa, md_exp);
         }
         err = lov_fini_destroy_set(set);
+out:
+        lov_putref(exp->exp_obd);
         RETURN(rc ? rc : err);
 }
 
diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c
index d37cfd75df..501fab4644 100644
--- a/lustre/lov/lov_qos.c
+++ b/lustre/lov/lov_qos.c
@@ -862,7 +862,6 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
                         /* Find a small number of stripes we can use
                            (up to # of active osts). */
                         stripes = 1;
-                        lov_getref(exp->exp_obd);
                         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                                 if (!lov->lov_tgts[i] ||
                                     !lov->lov_tgts[i]->ltd_active)
@@ -872,7 +871,6 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
                                         break;
                                 stripes++;
                         }
-                        lov_putref(exp->exp_obd);
 
                         if (stripes < stripes_def)
                                 stripes = stripes_def;
-- 
GitLab