Whamcloud - gitweb
LU-4826 lmv: Ensure lmv_intent_lookup cleans up reqp
[fs/lustre-release.git] / lustre / lod / lod_dev.c
index 02a1e1e..1d4849f 100644 (file)
@@ -57,7 +57,7 @@
  * \param type indidcate the FID is on MDS or OST.
  **/
 int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
-                  const struct lu_fid *fid, __u32 *tgt, int type)
+                  const struct lu_fid *fid, __u32 *tgt, int *type)
 {
        struct lu_seq_range     range = { 0 };
        struct lu_server_fld    *server_fld;
@@ -65,24 +65,29 @@ int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
        ENTRY;
 
        LASSERTF(fid_is_sane(fid), "Invalid FID "DFID"\n", PFID(fid));
+
        if (fid_is_idif(fid)) {
                *tgt = fid_idif_ost_idx(fid);
+               *type = LU_SEQ_RANGE_OST;
                RETURN(rc);
        }
 
        if (!lod->lod_initialized || (!fid_seq_in_fldb(fid_seq(fid)))) {
                LASSERT(lu_site2seq(lod2lu_dev(lod)->ld_site) != NULL);
+
                *tgt = lu_site2seq(lod2lu_dev(lod)->ld_site)->ss_node_id;
+               *type = LU_SEQ_RANGE_MDT;
                RETURN(rc);
        }
 
        server_fld = lu_site2seq(lod2lu_dev(lod)->ld_site)->ss_server_fld;
-       fld_range_set_type(&range, type);
+       fld_range_set_type(&range, *type);
        rc = fld_server_lookup(env, server_fld, fid_seq(fid), &range);
        if (rc)
                RETURN(rc);
 
        *tgt = range.lsr_index;
+       *type = range.lsr_flags;
 
        CDEBUG(D_INFO, "LOD: got tgt %x for sequence: "
               LPX64"\n", *tgt, fid_seq(fid));
@@ -91,7 +96,6 @@ int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
 }
 
 extern struct lu_object_operations lod_lu_obj_ops;
-extern struct lu_object_operations lod_lu_robj_ops;
 extern struct dt_object_operations lod_obj_ops;
 
 /* Slab for OSD object allocation */
@@ -117,29 +121,17 @@ struct lu_object *lod_object_alloc(const struct lu_env *env,
 {
        struct lod_object       *lod_obj;
        struct lu_object        *lu_obj;
-       const struct lu_fid     *fid = &hdr->loh_fid;
-       mdsno_t                 mds;
-       int                     rc = 0;
        ENTRY;
 
-       OBD_SLAB_ALLOC_PTR_GFP(lod_obj, lod_object_kmem, __GFP_IO);
+       OBD_SLAB_ALLOC_PTR_GFP(lod_obj, lod_object_kmem, GFP_NOFS);
        if (lod_obj == NULL)
                RETURN(ERR_PTR(-ENOMEM));
 
-       rc = lod_fld_lookup(env, lu2lod_dev(dev), fid, &mds, LU_SEQ_RANGE_MDT);
-       if (rc) {
-               OBD_SLAB_FREE_PTR(lod_obj, lod_object_kmem);
-               RETURN(ERR_PTR(rc));
-       }
-
-       lod_obj->ldo_mds_num = mds;
        lu_obj = lod2lu_obj(lod_obj);
        dt_object_init(&lod_obj->ldo_obj, NULL, dev);
        lod_obj->ldo_obj.do_ops = &lod_obj_ops;
-       if (likely(mds == lu_site2seq(dev->ld_site)->ss_node_id))
-               lu_obj->lo_ops = &lod_lu_obj_ops;
-       else
-               lu_obj->lo_ops = &lod_lu_robj_ops;
+       lu_obj->lo_ops = &lod_lu_obj_ops;
+
        RETURN(lu_obj);
 }
 
@@ -418,71 +410,54 @@ static struct thandle *lod_trans_create(const struct lu_env *env,
        if (IS_ERR(th))
                return th;
 
-       CFS_INIT_LIST_HEAD(&th->th_remote_update_list);
        return th;
 }
 
-static int lod_remote_sync(const struct lu_env *env, struct dt_device *dev,
-                          struct thandle *th)
-{
-       struct update_request *update;
-       int    rc = 0;
-       ENTRY;
-
-       if (cfs_list_empty(&th->th_remote_update_list))
-               RETURN(0);
-
-       cfs_list_for_each_entry(update, &th->th_remote_update_list,
-                               ur_list) {
-               /* In DNE phase I, there should be only one OSP
-                * here, so we will do send/receive one by one,
-                * instead of sending them parallel, will fix this
-                * in Phase II */
-               th->th_current_request = update;
-               rc = dt_trans_start(env, update->ur_dt, th);
-               if (rc != 0) {
-                       /* FIXME how to revert the partial results
-                        * once error happened? Resolved by 2 Phase commit */
-                       update->ur_rc = rc;
-                       break;
-               }
-       }
-
-       RETURN(rc);
-}
-
 static int lod_trans_start(const struct lu_env *env, struct dt_device *dev,
                           struct thandle *th)
 {
        struct lod_device *lod = dt2lod_dev((struct dt_device *) dev);
-       int rc;
+       int rc = 0;
 
-       rc = lod_remote_sync(env, dev, th);
-       if (rc)
-               return rc;
+       if (unlikely(th->th_update != NULL)) {
+               struct thandle_update *tu = th->th_update;
+               struct dt_update_request *update;
 
+               list_for_each_entry(update, &tu->tu_remote_update_list,
+                                   dur_list) {
+                       LASSERT(update->dur_dt != NULL);
+                       rc = dt_trans_start(env, update->dur_dt, th);
+                       if (rc != 0)
+                               return rc;
+               }
+       }
        return dt_trans_start(env, lod->lod_child, th);
 }
 
-static int lod_trans_stop(const struct lu_env *env, struct thandle *th)
+static int lod_trans_stop(const struct lu_env *env, struct dt_device *dt,
+                         struct thandle *th)
 {
-       struct update_request *update;
-       struct update_request *tmp;
-       int rc = 0;
-       int rc2 = 0;
+       struct thandle_update           *tu = th->th_update;
+       struct dt_update_request        *update;
+       struct dt_update_request        *tmp;
+       int                             rc2 = 0;
+       int                             rc;
+       ENTRY;
 
-       cfs_list_for_each_entry_safe(update, tmp,
-                                    &th->th_remote_update_list,
-                                    ur_list) {
-               th->th_current_request = update;
-               rc2 = dt_trans_stop(env, update->ur_dt, th);
+       rc = dt_trans_stop(env, th->th_dev, th);
+       if (likely(tu == NULL))
+               RETURN(rc);
+
+       list_for_each_entry_safe(update, tmp,
+                                &tu->tu_remote_update_list,
+                                dur_list) {
+               /* update will be freed inside dt_trans_stop */
+               rc2 = dt_trans_stop(env, update->dur_dt, th);
                if (unlikely(rc2 != 0 && rc == 0))
                        rc = rc2;
        }
 
-       rc2 = dt_trans_stop(env, th->th_dev, th);
-
-       return rc2 != 0 ? rc2 : rc;
+       RETURN(rc);
 }
 
 static void lod_conf_get(const struct lu_env *env,