Whamcloud - gitweb
- do not issue RPC inside spin lock;
authoryury <yury>
Fri, 13 Oct 2006 13:06:17 +0000 (13:06 +0000)
committeryury <yury>
Fri, 13 Oct 2006 13:06:17 +0000 (13:06 +0000)
lustre/cmm/cmm_split.c
lustre/lmv/lmv_intent.c
lustre/mdd/mdd_handler.c

index a32414a..d466827 100644 (file)
@@ -86,21 +86,25 @@ cleanup:
         RETURN(rc);
 }
 
-#define cmm_md_size(stripes)                            \
+#define cmm_md_size(stripes) \
        (sizeof(struct lmv_stripe_md) + (stripes) * sizeof(struct lu_fid))
 
-static int cmm_alloc_fid(const struct lu_env *env, struct cmm_device *cmm,
+static int cmm_fid_alloc(const struct lu_env *env, struct cmm_device *cmm,
                          struct lu_fid *fid, int count)
 {
         struct  mdc_device *mc, *tmp;
         int rc = 0, i = 0;
 
         LASSERT(count == cmm->cmm_tgt_count);
-        /* FIXME: this spin_lock maybe not proper,
-         * because fid_alloc may need RPC */
-        spin_lock(&cmm->cmm_tgt_guard);
-        list_for_each_entry_safe(mc, tmp, &cmm->cmm_targets,
-                                 mc_linkage) {
+
+        /* 
+         * XXX: in fact here would be nice to protect cmm->cmm_targets but we
+         * can't use spinlock here and do something complex is no time for that,
+         * especially taking into account that split will be removed after
+         * acceptance. So we suppose no changes to targets should happen this
+         * time.
+         */
+        list_for_each_entry_safe(mc, tmp, &cmm->cmm_targets, mc_linkage) {
                 LASSERT(cmm->cmm_local_num != mc->mc_num);
 
                 rc = obd_fid_alloc(mc->mc_desc.cl_exp, &fid[i], NULL);
@@ -111,14 +115,16 @@ static int cmm_alloc_fid(const struct lu_env *env, struct cmm_device *cmm,
                         rc = fld_client_create(ls->ls_client_fld,
                                                fid_seq(&fid[i]),
                                                mc->mc_num, env);
+                        if (rc) {
+                                CERROR("Can't create fld entry, "
+                                       "rc %d\n", rc);
+                        }
                 }
-                if (rc < 0) {
-                        spin_unlock(&cmm->cmm_tgt_guard);
+                
+                if (rc < 0)
                         RETURN(rc);
-                }
                 i++;
         }
-        spin_unlock(&cmm->cmm_tgt_guard);
         LASSERT(i == count);
         if (rc == 1)
                 rc = 0;
@@ -201,7 +207,7 @@ static int cmm_create_slave_objects(const struct lu_env *env,
 
         lmv->mea_ids[0] = *lf;
 
-        rc = cmm_alloc_fid(env, cmm, &lmv->mea_ids[1],
+        rc = cmm_fid_alloc(env, cmm, &lmv->mea_ids[1],
                            cmm->cmm_tgt_count);
         if (rc)
                 GOTO(cleanup, rc);
index ce9afaf..968b68c 100644 (file)
@@ -148,7 +148,8 @@ int lmv_alloc_fid_for_split(struct obd_device *obd, struct lu_fid *pid,
 
         obj = lmv_obj_grab(obd, pid);
         if (!obj)
-               RETURN(0);
+                RETURN(0);
+        
         mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
                            (char *)op->name, op->namelen);
         rpid = &obj->lo_inodes[mds].li_fid;
@@ -157,21 +158,24 @@ int lmv_alloc_fid_for_split(struct obd_device *obd, struct lu_fid *pid,
                 GOTO(cleanup, rc);
 
         rc = obd_fid_alloc(lmv->tgts[mds].ltd_exp, fid, NULL);
-        if (rc < 0)
-                GOTO(cleanup, rc);
         if (rc > 0) {
                 LASSERT(fid_is_sane(fid));
                 rc = fld_client_create(&lmv->lmv_fld,
                                        fid_seq(fid), mds, NULL);
                 if (rc) {
-                        CERROR("can't create fld rc%d\n", rc);
+                        CERROR("Can't create fld entry, rc %d\n", rc);
                         GOTO(cleanup, rc);
                 }
         }
-        CDEBUG(D_INFO, "Allocate new fid"DFID"for split obj\n",PFID(fid));
+        if (rc >= 0) {
+                CDEBUG(D_INFO, "Allocate new fid "DFID" for split "
+                       "obj\n", PFID(fid));
+        }
+        
+        EXIT;
 cleanup:
         lmv_obj_put(obj);
-        RETURN(rc);
+        return rc;
 }
 
 /*
index a848eea..7883e9a 100644 (file)
@@ -2591,8 +2591,9 @@ static int mdd_object_create(const struct lu_env *env,
                 if (rc)
                         GOTO(unlock, rc);
                 pfid = spec->u.sp_ea.fid;
-                CWARN("set slave ea "DFID" eadatalen %d rc %d\n",
-                       PFID(mdo2fid(mdd_obj)), spec->u.sp_ea.eadatalen, rc);
+                
+                CWARN("Set slave ea "DFID", eadatalen %d, rc %d\n",
+                      PFID(mdo2fid(mdd_obj)), spec->u.sp_ea.eadatalen, rc);
                 rc = mdd_attr_set_internal(env, mdd_obj, &ma->ma_attr, handle);
         } else
                 rc = __mdd_object_initialize(env, pfid, mdd_obj, ma, handle);