Whamcloud - gitweb
Fixes and cleanups in lmv.
authoryury <yury>
Fri, 11 Jun 2004 11:47:19 +0000 (11:47 +0000)
committeryury <yury>
Fri, 11 Jun 2004 11:47:19 +0000 (11:47 +0000)
Fixed:
* failure path in lmv_connect().
* added checks if late connect is success.
* added accounting of active mds.

14 files changed:
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_internal.h
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_objmgr.c
lustre/lov/lov_obd.c
lustre/mds/handler.c
lustre/mds/mds_lmv.c
lustre/mds/mds_lov.c
lustre/mds/mds_reint.c
lustre/obdclass/llog_obd.c
lustre/utils/lustre_cfg.c

index d7c9798..42eda84 100644 (file)
@@ -711,7 +711,8 @@ struct lov_desc {
 };
 
 struct lmv_desc {
-        __u32 ld_count;                    /* how many MDS's */
+        __u32 ld_tgt_count;                /* how many MDS's */
+        __u32 ld_active_tgt_count;         /* how many active */
         struct obd_uuid ld_uuid;
 };
 
index 04a0745..2d81605 100644 (file)
@@ -30,6 +30,7 @@
 # include <linux/fs.h>
 # include <linux/dcache.h>
 #endif
+
 #include <linux/lustre_handles.h>
 #include <linux/kp30.h>
 #include <linux/lustre_idl.h>
index 1b74b89..417cce0 100644 (file)
@@ -421,11 +421,13 @@ struct lov_obd {
 
 struct lmv_tgt_desc {
         struct obd_uuid         uuid;
-        struct obd_export       *exp;
+        struct obd_export       *ltd_exp;
+        int                      active; /* is this target up for requests */
 };
 
 struct lmv_obd {
-        int                     count;
+        spinlock_t              lmv_lock;
+        struct lmv_desc         desc;
         int                     bufsize;
         int                     refcount;
         struct lmv_tgt_desc     *tgts;
index 14640c4..449c01b 100644 (file)
@@ -88,7 +88,7 @@ int lmv_handle_remote_inode(struct obd_export *exp, struct ll_uctxt *uctxt,
 
                 nfid = body->fid1;
                 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
-                rc = md_intent_lock(lmv->tgts[nfid.mds].exp, uctxt, &nfid,
+                rc = md_intent_lock(lmv->tgts[nfid.mds].ltd_exp, uctxt, &nfid,
                                     NULL, 0, lmm, lmmsize, NULL, it, flags,
                                     &req, cb_blocking);
 
@@ -142,7 +142,7 @@ repeat:
                 CDEBUG(D_OTHER, "forward to MDS #%u\n", mds);
         }
 
-        rc = md_intent_lock(lmv->tgts[mds].exp, uctxt, &rpfid, name,
+        rc = md_intent_lock(lmv->tgts[mds].ltd_exp, uctxt, &rpfid, name,
                             len, lmm, lmmsize, cfid, it, flags, reqp,
                             cb_blocking);
         lmv_put_obj(obj);
@@ -228,7 +228,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct ll_uctxt *uctxt,
                          * _intent_lock(), but it may change some day */
                         rpfid = obj->objs[mds].fid;
                 }
-                rc = md_intent_lock(lmv->tgts[mds].exp, uctxt, &rpfid, name,
+                rc = md_intent_lock(lmv->tgts[mds].ltd_exp, uctxt, &rpfid, name,
                                     len, lmm, lmmsize, cfid, it, flags, reqp,
                                     cb_blocking);
                 if (obj && rc >= 0) {
@@ -265,7 +265,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct ll_uctxt *uctxt,
                        (unsigned long) rpfid.id,
                        (unsigned long) rpfid.generation);
         }
-        rc = md_intent_lock(lmv->tgts[mds].exp, uctxt, &rpfid, name,
+        rc = md_intent_lock(lmv->tgts[mds].ltd_exp, uctxt, &rpfid, name,
                             len, lmm, lmmsize, NULL, it, flags, reqp,
                             cb_blocking);
         if (rc < 0)
@@ -371,7 +371,7 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
                 /* is obj valid? */
                 memset(&it, 0, sizeof(it));
                 it.it_op = IT_GETATTR;
-                rc = md_intent_lock(lmv->tgts[fid.mds].exp, &uctxt, &fid,
+                rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &uctxt, &fid,
                                     NULL, 0, NULL, 0, &fid, &it, 0, &req,
                                     lmv_dirobj_blocking_ast);
                 lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle;
@@ -393,7 +393,7 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
                 req = NULL;
                 memset(&it, 0, sizeof(it));
                 it.it_op = IT_GETATTR;
-                rc = md_intent_lock(lmv->tgts[fid.mds].exp, &uctxt, &fid,
+                rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &uctxt, &fid,
                                     NULL, 0, NULL, 0, NULL, &it, 0, &req,
                                     lmv_dirobj_blocking_ast);
                 lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle;
@@ -466,7 +466,7 @@ int lmv_intent_lookup(struct obd_export *exp, struct ll_uctxt *uctxt,
                        (unsigned long) cfid->mds,
                        (unsigned long) cfid->id,
                        (unsigned long) cfid->generation, mds);
-                rc = md_intent_lock(lmv->tgts[mds].exp, uctxt, pfid, name,
+                rc = md_intent_lock(lmv->tgts[mds].ltd_exp, uctxt, pfid, name,
                                     len, lmm, lmmsize, cfid, it, flags,
                                     reqp, cb_blocking);
                 RETURN(rc);
@@ -486,7 +486,7 @@ repeat:
                 lmv_put_obj(obj);
         }
 
-        rc = md_intent_lock(lmv->tgts[mds].exp, uctxt, &rpfid, name,
+        rc = md_intent_lock(lmv->tgts[mds].ltd_exp, uctxt, &rpfid, name,
                             len, lmm, lmmsize, NULL, it, flags, reqp,
                             cb_blocking);
         if (rc > 0) {
@@ -560,7 +560,10 @@ int lmv_intent_lock(struct obd_export *exp, struct ll_uctxt *uctxt,
                         LL_IT2STR(it), len, name, (unsigned long) pfid->id,
                         (unsigned long) pfid->generation, pfid->mds);
 
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+
         if (it->it_op == IT_LOOKUP)
                 rc = lmv_intent_lookup(exp, uctxt, pfid, name, len, lmm,
                                        lmmsize, cfid, it, flags, reqp,
@@ -645,7 +648,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp,
                 }
 
                 /* is obj valid? */
-                rc = md_intent_lock(lmv->tgts[fid.mds].exp, &uctxt, &fid,
+                rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &uctxt, &fid,
                                     NULL, 0, NULL, 0, &fid, &it, 0, &req, cb);
                 lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle;
                 if (rc > 0) {
@@ -666,7 +669,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp,
                 req = NULL;
                 memset(&it, 0, sizeof(it));
                 it.it_op = IT_GETATTR;
-                rc = md_intent_lock(lmv->tgts[fid.mds].exp, &uctxt, &fid,
+                rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &uctxt, &fid,
                                     NULL, 0, NULL, 0, NULL, &it, 0, &req, cb);
                 lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle;
                 LASSERT(rc <= 0);
index 30688f2..c56cae2 100644 (file)
@@ -3,7 +3,7 @@
 
 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
 #define MEA_SIZE_LMV(lmv)       \
-        ((lmv)->count * sizeof(struct ll_fid) + sizeof(struct mea))
+        ((lmv)->desc.ld_tgt_count * sizeof(struct ll_fid) + sizeof(struct mea))
         
 struct lmv_inode {
         struct ll_fid   fid;            /* fid of dirobj */
@@ -45,7 +45,7 @@ int lmv_intent_open(struct obd_export *, struct ll_uctxt *,
                    struct ptlrpc_request **, ldlm_blocking_callback);
 int lmv_create_obj_from_attrs(struct obd_export *, struct ll_fid *,
                                struct mea *);
-int lmv_connect(struct obd_device *);
+int lmv_check_connect(struct obd_device *obd);
 int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **,
                           struct ll_fid *, struct lookup_intent *, int,
                          ldlm_blocking_callback cb_blocking);
index 52ec1de..5b2d95b 100644 (file)
 #include <linux/obd_lmv.h>
 #include "lmv_internal.h"
 
+/* Error codes:
+ *
+ *  -EINVAL  : UUID can't be found in the LMV's target list
+ *  -ENOTCONN: The UUID is found, but the target connection is bad (!)
+ *  -EBADF   : The UUID is found, but the OBD of the wrong type (!)
+ */
+static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
+                              int activate)
+{
+        struct obd_device *obd;
+        struct lmv_tgt_desc *tgt;
+        int i, rc = 0;
+        ENTRY;
+
+        CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n",
+               lmv, uuid->uuid, activate);
+
+        spin_lock(&lmv->lmv_lock);
+        for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
+                CDEBUG(D_INFO, "lmv idx %d is %s conn "LPX64"\n",
+                       i, tgt->uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
+                if (strncmp(uuid->uuid, tgt->uuid.uuid, sizeof uuid->uuid) == 0)
+                        break;
+        }
+
+        if (i == lmv->desc.ld_tgt_count)
+                GOTO(out, rc = -EINVAL);
+
+        obd = class_exp2obd(tgt->ltd_exp);
+        if (obd == NULL) {
+                /* This can happen if OST failure races with node shutdown */
+                GOTO(out, rc = -ENOTCONN);
+        }
+
+        CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n",
+               obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
+               obd->obd_type->typ_name, i);
+        LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0);
+
+        if (tgt->active == activate) {
+                CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
+                       activate ? "" : "in");
+                GOTO(out, rc);
+        }
+
+        CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in");
+
+        tgt->active = activate;
+        if (activate)
+                lmv->desc.ld_active_tgt_count++;
+        else
+                lmv->desc.ld_active_tgt_count--;
+
+        EXIT;
+ out:
+        spin_unlock(&lmv->lmv_lock);
+        return rc;
+}
+
+static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
+                      int active)
+{
+        int rc;
+        struct obd_uuid *uuid;
+
+        if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) {
+                CERROR("unexpected notification of %s %s!\n",
+                       watched->obd_type->typ_name,
+                       watched->obd_name);
+                return -EINVAL;
+        }
+        uuid = &watched->u.cli.cl_import->imp_target_uuid;
+
+        /* Set MDC as active before notifying the observer, so the
+         * observer can use the MDC normally.  
+         */
+        rc = lmv_set_mdc_active(&obd->u.lmv, uuid, active);
+        if (rc) {
+                CERROR("%sactivation of %s failed: %d\n",
+                       active ? "" : "de", uuid->uuid, rc);
+                RETURN(rc);
+        }
+
+        if (obd->obd_observer)
+                /* Pass the notification up the chain. */
+                rc = obd_notify(obd->obd_observer, watched, active);
+
+        RETURN(rc);
+}
+
 int lmv_attach(struct obd_device *dev, obd_count len, void *data)
 {
         struct lprocfs_static_vars lvars;
@@ -76,9 +166,11 @@ int lmv_detach(struct obd_device *dev)
         return lprocfs_obd_detach(dev);
 }
 
-static int lmv_connect_fake(struct lustre_handle *conn,
-                            struct obd_device *obd,
-                            struct obd_uuid *cluuid)
+/* This is fake connect function. Its purpose is to initialize lmv and 
+ * say caller that everything is okay. Real connection will be performed
+ * later. */
+static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd,
+                       struct obd_uuid *cluuid)
 {
         struct lmv_obd *lmv = &obd->u.lmv;
         struct obd_export *exp;
@@ -120,21 +212,21 @@ void lmv_set_timeouts(struct obd_device *obd)
         if (lmv->connected == 0)
                 return;
 
-        for (i = 0, tgts = lmv->tgts; i < lmv->count; i++, tgts++) {
-                if (tgts->exp == NULL)
+        for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
+                if (tgts->ltd_exp == NULL)
                         continue;
-                obd_set_info(tgts->exp, strlen("inter_mds"),
+                obd_set_info(tgts->ltd_exp, strlen("inter_mds"),
                              "inter_mds", 0, NULL);
         }
 }
 
-int lmv_connect(struct obd_device *obd)
-{
+/* Performs a check if passed obd is connected. If no - connect it. */
+int lmv_check_connect(struct obd_device *obd) {
         struct lmv_obd *lmv = &obd->u.lmv;
         struct obd_uuid *cluuid;
         struct lmv_tgt_desc *tgts;
         struct obd_export *exp;
-        int rc, i;
+        int rc, rc2, i;
         ENTRY;
 
         if (lmv->connected)
@@ -146,7 +238,7 @@ int lmv_connect(struct obd_device *obd)
         CDEBUG(D_OTHER, "time to connect %s to %s\n",
                         cluuid->uuid, obd->obd_name);
 
-        for (i = 0, tgts = lmv->tgts; i < lmv->count; i++, tgts++) {
+        for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
                 struct obd_device *tgt_obd;
                 struct obd_uuid lmv_osc_uuid = { "LMV_OSC_UUID" };
                 struct lustre_handle conn = {0, };
@@ -164,7 +256,7 @@ int lmv_connect(struct obd_device *obd)
                 if (obd_uuid_equals(&tgts->uuid, cluuid)) {
                         CDEBUG(D_OTHER, "don't connect back to %s\n",
                                cluuid->uuid);
-                        tgts->exp = NULL;
+                        tgts->ltd_exp = NULL;
                         continue;
                 }
 
@@ -184,19 +276,22 @@ int lmv_connect(struct obd_device *obd)
                                 tgts->uuid.uuid, rc);
                         GOTO(out_disc, rc);
                 }
-                tgts->exp = class_conn2export(&conn);
+                tgts->ltd_exp = class_conn2export(&conn);
 
-                obd_init_ea_size(tgts->exp, lmv->max_easize,
-                                        lmv->max_cookiesize);
+                obd_init_ea_size(tgts->ltd_exp, lmv->max_easize,
+                                 lmv->max_cookiesize);
                 
                 rc = obd_register_observer(tgt_obd, obd);
                 if (rc) {
                         CERROR("Target %s register_observer error %d\n",
                                tgts->uuid.uuid, rc);
-                        obd_disconnect(tgts->exp, 0);
+                        obd_disconnect(tgts->ltd_exp, 0);
                         GOTO(out_disc, rc);
                 }
 
+                lmv->desc.ld_active_tgt_count++;
+                tgts->active = 1;
+                
                 CDEBUG(D_OTHER, "connected to %s(%s) successfully (%d)\n",
                         tgt_obd->obd_name, tgt_obd->obd_uuid.uuid,
                         atomic_read(&obd->obd_refcount));
@@ -208,7 +303,18 @@ int lmv_connect(struct obd_device *obd)
         RETURN (0);
 
  out_disc:
-        /* FIXME: cleanup here */
+        while (i-- > 0) {
+                struct obd_uuid uuid;
+                --tgts;
+                --lmv->desc.ld_active_tgt_count;
+                tgts->active = 0;
+                /* save for CERROR below; (we know it's terminated) */
+                uuid = tgts->uuid;
+                rc2 = obd_disconnect(tgts->ltd_exp, 0);
+                if (rc2)
+                        CERROR("error: LMV target %s disconnect on MDT idx %d: "
+                               "rc = %d\n", uuid.uuid, i, rc2);
+        }
         class_disconnect(exp, 0);
         RETURN (rc);
 }
@@ -228,8 +334,8 @@ static int lmv_disconnect(struct obd_export *exp, int flags)
         if (lmv->refcount != 0)
                 goto out_local;
 
-        for (i = 0; i < lmv->count; i++) {
-                if (lmv->tgts[i].exp == NULL)
+        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+                if (lmv->tgts[i].ltd_exp == NULL)
                         continue;
 
                 if (obd->obd_no_recov) {
@@ -238,19 +344,23 @@ static int lmv_disconnect(struct obd_export *exp, int flags)
                          * XXX not a back-door flag on the OBD.  Ah well.
                          */
                         struct obd_device *mdc_obd;
-                        mdc_obd = class_exp2obd(lmv->tgts[i].exp);
+                        mdc_obd = class_exp2obd(lmv->tgts[i].ltd_exp);
                         if (mdc_obd)
                                 mdc_obd->obd_no_recov = 1;
                 }
 
                 CDEBUG(D_OTHER, "disconnected from %s(%s) successfully\n",
-                        lmv->tgts[i].exp->exp_obd->obd_name,
-                        lmv->tgts[i].exp->exp_obd->obd_uuid.uuid);
+                        lmv->tgts[i].ltd_exp->exp_obd->obd_name,
+                        lmv->tgts[i].ltd_exp->exp_obd->obd_uuid.uuid);
 
-                obd_register_observer(lmv->tgts[i].exp->exp_obd, NULL);
+                obd_register_observer(lmv->tgts[i].ltd_exp->exp_obd, NULL);
 
-                rc = obd_disconnect(lmv->tgts[i].exp, flags);
-                lmv->tgts[i].exp = NULL;
+                rc = obd_disconnect(lmv->tgts[i].ltd_exp, flags);
+                if (lmv->tgts[i].active) {
+                        lmv->desc.ld_active_tgt_count--;
+                        lmv->tgts[i].active = 0;
+                }
+                lmv->tgts[i].ltd_exp = NULL;
         }
 
  out_local:
@@ -269,7 +379,6 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf)
         struct obd_uuid *uuids;
         struct lmv_tgt_desc *tgts;
         int i;
-        int count;
         int rc = 0;
         ENTRY;
 
@@ -290,28 +399,28 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf)
                 RETURN(-EINVAL);
         }
 
-        count = desc->ld_count;
         uuids = (struct obd_uuid *)lcfg->lcfg_inlbuf2;
-        if (sizeof(*uuids) * count != lcfg->lcfg_inllen2) {
+        if (sizeof(*uuids) * desc->ld_tgt_count != lcfg->lcfg_inllen2) {
                 CERROR("UUID array size wrong: %u * %u != %u\n",
-                       sizeof(*uuids), count, lcfg->lcfg_inllen2);
+                       sizeof(*uuids), desc->ld_tgt_count, lcfg->lcfg_inllen2);
                 RETURN(-EINVAL);
         }
 
-        lmv->bufsize = sizeof(struct lmv_tgt_desc) * count;
+        lmv->bufsize = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count;
         OBD_ALLOC(lmv->tgts, lmv->bufsize);
         if (lmv->tgts == NULL) {
                 CERROR("Out of memory\n");
                 RETURN(-EINVAL);
         }
 
-        for (i = 0, tgts = lmv->tgts; i < count; i++, tgts++) {
+        lmv->desc = *desc;
+        spin_lock_init(&lmv->lmv_lock);
+        
+        for (i = 0, tgts = lmv->tgts; i < desc->ld_tgt_count; i++, tgts++)
                 tgts->uuid = uuids[i];
-                lmv->count++;
-        }
-
-        lmv->max_easize = sizeof(struct ll_fid) * lmv->count
-                                        + sizeof(struct mea);
+        
+        lmv->max_easize = sizeof(struct ll_fid) * desc->ld_tgt_count
+                + sizeof(struct mea);
         lmv->max_cookiesize = 0;
 
         RETURN(rc);
@@ -324,12 +433,16 @@ static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         struct obd_statfs temp;
         int rc = 0, i;
         ENTRY;
-        lmv_connect(obd);
-        for (i = 0; i < lmv->count; i++) {
-                rc = obd_statfs(lmv->tgts[i].exp->exp_obd, &temp, max_age);
+        
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+                
+        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+                rc = obd_statfs(lmv->tgts[i].ltd_exp->exp_obd, &temp, max_age);
                 if (rc) {
                         CERROR("can't stat MDS #%d (%s)\n", i,
-                               lmv->tgts[i].exp->exp_obd->obd_name);
+                               lmv->tgts[i].ltd_exp->exp_obd->obd_name);
                         RETURN(rc);
                 }
                 if (i == 0) {
@@ -359,8 +472,10 @@ static int lmv_getstatus(struct obd_export *exp, struct ll_fid *fid)
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc;
         ENTRY;
-        lmv_connect(obd);
-        rc = md_getstatus(lmv->tgts[0].exp, fid);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+        rc = md_getstatus(lmv->tgts[0].ltd_exp, fid);
         fid->mds = 0;
         RETURN(rc);
 }
@@ -374,7 +489,9 @@ static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid,
         int rc, i = fid->mds;
         struct lmv_obj *obj;
         ENTRY;
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
         obj = lmv_grab_obj(obd, fid, 0);
         CDEBUG(D_OTHER, "GETATTR for %lu/%lu/%lu %s\n",
                (unsigned long) fid->mds,
@@ -382,8 +499,8 @@ static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid,
                (unsigned long) fid->generation,
                obj ? "(splitted)" : "");
 
-        LASSERT(fid->mds < lmv->count);
-        rc = md_getattr(lmv->tgts[i].exp, fid,
+        LASSERT(fid->mds < lmv->desc.ld_tgt_count);
+        rc = md_getattr(lmv->tgts[i].ltd_exp, fid,
                              valid, ea_size, request);
         if (rc == 0 && obj) {
                 /* we have to loop over dirobjs here and gather attrs
@@ -402,13 +519,16 @@ static int lmv_change_cbdata(struct obd_export *exp,
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc = 0;
         ENTRY;
-        lmv_connect(obd);
+        
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
         CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu\n",
                (unsigned long) fid->mds,
                (unsigned long) fid->id,
                (unsigned long) fid->generation);
-        LASSERT(fid->mds < lmv->count);
-        rc = md_change_cbdata(lmv->tgts[fid->mds].exp, fid, it, data);
+        LASSERT(fid->mds < lmv->desc.ld_tgt_count);
+        rc = md_change_cbdata(lmv->tgts[fid->mds].ltd_exp, fid, it, data);
         RETURN(rc);
 }
 
@@ -421,9 +541,11 @@ static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid,
         struct lmv_obj *obj;
         int rc = 0, mds;
         ENTRY;
-        lmv_connect(obd);
-        LASSERT(pfid->mds < lmv->count);
-        LASSERT(cfid->mds < lmv->count);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+        LASSERT(pfid->mds < lmv->desc.ld_tgt_count);
+        LASSERT(cfid->mds < lmv->desc.ld_tgt_count);
         CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu:%*s -> %lu/%lu/%lu\n",
                (unsigned long) pfid->mds, (unsigned long) pfid->id,
                (unsigned long) pfid->generation, len, name,
@@ -438,7 +560,7 @@ static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid,
                 mds = raw_name2idx(obj->objcount, name, len);
                 lmv_put_obj(obj);
         }
-        rc = md_change_cbdata(lmv->tgts[mds].exp, cfid, it, data);
+        rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cfid, it, data);
         RETURN(rc);
 }
 
@@ -448,13 +570,15 @@ static int lmv_valid_attrs(struct obd_export *exp, struct ll_fid *fid)
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc = 0;
         ENTRY;
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
         CDEBUG(D_OTHER, "validate %lu/%lu/%lu\n",
                (unsigned long) fid->mds,
                (unsigned long) fid->id,
                (unsigned long) fid->generation);
-        LASSERT(fid->mds < lmv->count);
-        rc = md_valid_attrs(lmv->tgts[fid->mds].exp, fid);
+        LASSERT(fid->mds < lmv->desc.ld_tgt_count);
+        rc = md_valid_attrs(lmv->tgts[fid->mds].ltd_exp, fid);
         RETURN(rc);
 }
 
@@ -466,11 +590,13 @@ int lmv_close(struct obd_export *exp, struct obdo *obdo,
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc, i = obdo->o_mds;
         ENTRY;
-        lmv_connect(obd);
-        LASSERT(i < lmv->count);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+        LASSERT(i < lmv->desc.ld_tgt_count);
         CDEBUG(D_OTHER, "CLOSE %lu/%lu/%lu\n", (unsigned long) obdo->o_mds,
                (unsigned long) obdo->o_id, (unsigned long) obdo->o_generation);
-        rc = md_close(lmv->tgts[i].exp, obdo, och, request);
+        rc = md_close(lmv->tgts[i].ltd_exp, obdo, och, request);
         RETURN(rc);
 }
 
@@ -489,7 +615,7 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, struct ll_fid *fid)
         valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
 
         /* time to update mea of parent fid */
-        rc = md_getattr(lmv->tgts[fid->mds].exp, fid,
+        rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid,
                         valid, mealen, &req);
         if (rc) {
                 CERROR("md_getattr() failed, rc = %d\n", rc);
@@ -525,12 +651,17 @@ int lmv_create(struct obd_export *exp, struct mdc_op_data *op_data,
         int rc, mds;
         ENTRY;
 
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+
+        if (!lmv->desc.ld_active_tgt_count)
+                RETURN(-EIO);
 repeat:
         obj = lmv_grab_obj(obd, &op_data->fid1, 0);
         if (obj) {
                 mds = raw_name2idx(obj->objcount, op_data->name,
-                                        op_data->namelen);
+                                   op_data->namelen);
                 op_data->fid1 = obj->objs[mds].fid;
                 lmv_put_obj(obj);
         }
@@ -540,7 +671,7 @@ repeat:
                         (unsigned long) op_data->fid1.mds,
                         (unsigned long) op_data->fid1.id,
                         (unsigned long) op_data->fid1.generation);
-        rc = md_create(lmv->tgts[op_data->fid1.mds].exp, op_data, data,
+        rc = md_create(lmv->tgts[op_data->fid1.mds].ltd_exp, op_data, data,
                        datalen, mode, uid, gid, rdev, request);
         if (rc == 0) {
                 if (*request == NULL)
@@ -553,7 +684,7 @@ repeat:
                        (unsigned long) mds_body->fid1.generation,
                        op_data->fid1.mds);
                 LASSERT(mds_body->valid & OBD_MD_MDS ||
-                                mds_body->mds == op_data->fid1.mds);
+                        mds_body->mds == op_data->fid1.mds);
         } else if (rc == -ERESTART) {
                 /* directory got splitted. time to update local object
                  * and repeat the request with proper MDS */
@@ -572,9 +703,12 @@ int lmv_done_writing(struct obd_export *exp, struct obdo *obdo)
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc;
         ENTRY;
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+
         /* FIXME: choose right MDC here */
-        rc = md_done_writing(lmv->tgts[0].exp, obdo);
+        rc = md_done_writing(lmv->tgts[0].ltd_exp, obdo);
         RETURN(rc);
 }
 
@@ -590,7 +724,11 @@ int lmv_enqueue(struct obd_export *exp, int lock_type,
         struct lmv_obj *obj;
         int rc, mds;
         ENTRY;
-        lmv_connect(obd);
+
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
+
         if (data->namelen) {
                 obj = lmv_grab_obj(obd, &data->fid1, 0);
                 if (obj) {
@@ -605,7 +743,7 @@ int lmv_enqueue(struct obd_export *exp, int lock_type,
         CDEBUG(D_OTHER, "ENQUEUE '%s' on %lu/%lu\n",
                LL_IT2STR(it), (unsigned long) data->fid1.id,
                (unsigned long) data->fid1.generation);
-        rc = md_enqueue(lmv->tgts[data->fid1.mds].exp, lock_type, it,
+        rc = md_enqueue(lmv->tgts[data->fid1.mds].ltd_exp, lock_type, it,
                         lock_mode, data, lockh, lmm, lmmsize, cb_completion,
                         cb_blocking, cb_data);
 
@@ -623,7 +761,9 @@ int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid,
         struct mds_body *body;
         struct lmv_obj *obj;
         ENTRY;
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
 repeat:
         obj = lmv_grab_obj(obd, fid, 0);
         if (obj) {
@@ -637,7 +777,7 @@ repeat:
                (unsigned long) fid->id, (unsigned long) fid->generation,
                (unsigned long) rfid.mds, (unsigned long) rfid.id,
                (unsigned long) rfid.generation);
-        rc = md_getattr_name(lmv->tgts[mds].exp, &rfid, filename, namelen,
+        rc = md_getattr_name(lmv->tgts[mds].ltd_exp, &rfid, filename, namelen,
                                   valid, ea_size, request);
         if (rc == 0) {
                 /* this could be cross-node reference. in this case all
@@ -652,7 +792,7 @@ repeat:
                                (unsigned long) rfid.mds,
                                (unsigned long) rfid.id,
                                (unsigned long) rfid.generation);
-                        rc = md_getattr_name(lmv->tgts[rfid.mds].exp, &rfid,
+                        rc = md_getattr_name(lmv->tgts[rfid.mds].ltd_exp, &rfid,
                                              NULL, 1, valid, ea_size, &req);
                         ptlrpc_req_finished(*request);
                         *request = req;
@@ -682,7 +822,9 @@ int lmv_link(struct obd_export *exp, struct mdc_op_data *data,
         struct lmv_obj *obj;
         int rc;
         ENTRY;
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
         if (data->namelen != 0) {
                 /* usual link request */
                 obj = lmv_grab_obj(obd, &data->fid1, 0);
@@ -705,7 +847,7 @@ int lmv_link(struct obd_export *exp, struct mdc_op_data *data,
                        (unsigned) data->fid1.generation);
         }
                         
-        rc = md_link(lmv->tgts[data->fid1.mds].exp, data, request);
+        rc = md_link(lmv->tgts[data->fid1.mds].ltd_exp, data, request);
         RETURN(rc);
 }
 
@@ -735,7 +877,9 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data,
                       (unsigned long) data->fid2.id,
                       (unsigned long) data->fid2.generation, newlen, new);
 
-        lmv_connect(obd);
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
 
         if (oldlen == 0) {
                 /* MDS with old dir entry is asking another MDS
@@ -782,8 +926,8 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data,
         mds = data->fid1.mds;
 
 request:
-        rc = md_rename(lmv->tgts[mds].exp, data, old, oldlen,
-                            new, newlen, request); 
+        rc = md_rename(lmv->tgts[mds].ltd_exp, data, old, oldlen,
+                       new, newlen, request); 
         RETURN(rc);
 }
 
@@ -798,7 +942,11 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data,
         struct mds_body *mds_body;
         struct lmv_obj *obj;
         ENTRY;
-        lmv_connect(obd);
+
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
+
         obj = lmv_grab_obj(obd, &data->fid1, 0);
         CDEBUG(D_OTHER, "SETATTR for %lu/%lu/%lu, valid 0x%x%s\n",
                (unsigned long) data->fid1.mds,
@@ -808,7 +956,7 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data,
         if (obj) {
                 for (i = 0; i < obj->objcount; i++) {
                         data->fid1 = obj->objs[i].fid;
-                        rc = md_setattr(lmv->tgts[i].exp, data, iattr, ea,
+                        rc = md_setattr(lmv->tgts[i].ltd_exp, data, iattr, ea,
                                         ealen, ea2, ea2len, &req);
                         LASSERT(rc == 0);
                         if (fid_equal(&obj->fid, &obj->objs[i].fid)) {
@@ -821,8 +969,8 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data,
                 }
                 lmv_put_obj(obj);
         } else {
-                LASSERT(data->fid1.mds < lmv->count);
-                rc = md_setattr(lmv->tgts[i].exp, data, iattr, ea, ealen,
+                LASSERT(data->fid1.mds < lmv->desc.ld_tgt_count);
+                rc = md_setattr(lmv->tgts[i].ltd_exp, data, iattr, ea, ealen,
                                 ea2, ea2len, request); 
                 if (rc == 0) {
                         mds_body = lustre_msg_buf((*request)->rq_repmsg, 0,
@@ -841,8 +989,12 @@ int lmv_sync(struct obd_export *exp, struct ll_fid *fid,
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc;
         ENTRY;
-        lmv_connect(obd);
-        rc = md_sync(lmv->tgts[0].exp, fid, request); 
+
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
+
+        rc = md_sync(lmv->tgts[0].ltd_exp, fid, request); 
         RETURN(rc);
 }
 
@@ -911,9 +1063,12 @@ int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid,
         struct lmv_obj *obj;
         int rc, i;
         ENTRY;
-        lmv_connect(obd);
-       
-        LASSERT(mdc_fid->mds < lmv->count);
+
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
+
+        LASSERT(mdc_fid->mds < lmv->desc.ld_tgt_count);
         CDEBUG(D_OTHER, "READPAGE at %llu from %lu/%lu/%lu\n",
                offset, (unsigned long) rfid.mds,
                (unsigned long) rfid.id,
@@ -935,7 +1090,7 @@ int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid,
                        (unsigned long) rfid.generation,
                        (unsigned long) offset);
         }
-        rc = md_readpage(lmv->tgts[rfid.mds].exp, &rfid, offset, page, request);
+        rc = md_readpage(lmv->tgts[rfid.mds].ltd_exp, &rfid, offset, page, request);
         if (rc == 0 && !fid_equal(&rfid, mdc_fid)) {
                 /* this page isn't from master object. to avoid
                  * ./.. duplication in directory, we have to remove them
@@ -955,7 +1110,11 @@ int lmv_unlink(struct obd_export *exp, struct mdc_op_data *data,
         struct lmv_obd *lmv = &obd->u.lmv;
         int rc, i = 0;
         ENTRY;
-        lmv_connect(obd);
+
+       rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
+
         if (data->namelen != 0) {
                 struct lmv_obj *obj;
                 obj = lmv_grab_obj(obd, &data->fid1, 0);
@@ -976,7 +1135,7 @@ int lmv_unlink(struct obd_export *exp, struct mdc_op_data *data,
                        (unsigned long) data->fid1.id,
                        (unsigned long) data->fid1.generation);
         }
-        rc = md_unlink(lmv->tgts[data->fid1.mds].exp, data, request); 
+        rc = md_unlink(lmv->tgts[data->fid1.mds].ltd_exp, data, request); 
         RETURN(rc);
 }
 
@@ -985,9 +1144,13 @@ struct obd_device *lmv_get_real_obd(struct obd_export *exp,
 {
         struct obd_device *obd = exp->exp_obd;
         struct lmv_obd *lmv = &obd->u.lmv;
+        int rc;
         ENTRY;
-        lmv_connect(obd);
-        obd = lmv->tgts[0].exp->exp_obd;
+
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(ERR_PTR(rc));
+        obd = lmv->tgts[0].ltd_exp->exp_obd;
         EXIT;
         return obd;
 }
@@ -1014,8 +1177,8 @@ int lmv_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
                 RETURN(0);
 
         /* FIXME: error handling? */
-        for (i = 0; i < lmv->count; i++)
-                rc = obd_init_ea_size(lmv->tgts[i].exp, easize, cookiesize);
+        for (i = 0; i < lmv->desc.ld_tgt_count; i++)
+                rc = obd_init_ea_size(lmv->tgts[i].ltd_exp, easize, cookiesize);
         RETURN(rc);
 }
 
@@ -1028,12 +1191,15 @@ int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa,
         struct lov_stripe_md *obj_mdp = &obj_md;
         int rc = 0;
         ENTRY;
-        lmv_connect(obd);
+
+        rc = lmv_check_connect(obd);
+       if (rc)
+               RETURN(rc);
 
         LASSERT(ea == NULL);
-        LASSERT(oa->o_mds < lmv->count);
+        LASSERT(oa->o_mds < lmv->desc.ld_tgt_count);
 
-        rc = obd_create(lmv->tgts[oa->o_mds].exp, oa, &obj_mdp, oti);
+        rc = obd_create(lmv->tgts[oa->o_mds].ltd_exp, oa, &obj_mdp, oti);
         LASSERT(rc == 0);
 
         RETURN(rc);
@@ -1051,7 +1217,10 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa,
         int i, c, rc = 0;
         struct ll_fid mfid;
         ENTRY;
-        lmv_connect(obd);
+
+        rc = lmv_check_connect(obd);
+        if (rc)
+                RETURN(rc);
 
         LASSERT(oa != NULL);
         
@@ -1069,17 +1238,18 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa,
         mfid.id = oa->o_id;
         mfid.generation = oa->o_generation;
         rc = 0;
-        if (!mea->mea_count || mea->mea_count > lmv->count)
-                mea->mea_count = lmv->count;
+        if (!mea->mea_count || mea->mea_count > lmv->desc.ld_tgt_count)
+                mea->mea_count = lmv->desc.ld_tgt_count;
 
         mea->mea_master = -1;
         
         /* FIXME: error handling? */
-        for (i = 0, c = 0; c < mea->mea_count && i < lmv->count; i++) {
+        for (i = 0, c = 0; c < mea->mea_count && 
+                i < lmv->desc.ld_tgt_count; i++) {
                 struct lov_stripe_md obj_md;
                 struct lov_stripe_md *obj_mdp = &obj_md;
                
-                if (lmv->tgts[i].exp == NULL) {
+                if (lmv->tgts[i].ltd_exp == NULL) {
                         /* this is master MDS */
                         mea->mea_fids[c].id = mfid.id;
                         mea->mea_fids[c].generation = mfid.generation;
@@ -1097,7 +1267,7 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa,
                 oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLTYPE | OBD_MD_FLMODE
                                 | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLID;
 
-                rc = obd_create(lmv->tgts[c].exp, oa, &obj_mdp, oti);
+                rc = obd_create(lmv->tgts[c].ltd_exp, oa, &obj_mdp, oti);
                 /* FIXME: error handling here */
                 LASSERT(rc == 0);
 
@@ -1132,7 +1302,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
         if (keylen == 6 && memcmp(key, "mdsize", 6) == 0) {
                 __u32 *mdsize = val;
                 *vallen = sizeof(__u32);
-                *mdsize = sizeof(struct ll_fid) * lmv->count
+                *mdsize = sizeof(struct ll_fid) * lmv->desc.ld_tgt_count
                                 + sizeof(struct mea);
                 RETURN(0);
         } else if (keylen == 6 && memcmp(key, "mdsnum", 6) == 0) {
@@ -1141,7 +1311,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
                 __u32 *mdsnum = val;
                 int i;
 
-                for (i = 0, tgts = lmv->tgts; i < lmv->count; i++, tgts++) {
+                for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
                         if (obd_uuid_equals(&tgts->uuid, cluuid)) {
                                 *vallen = sizeof(__u32);
                                 *mdsnum = i;
@@ -1174,9 +1344,13 @@ int lmv_set_info(struct obd_export *exp, obd_count keylen,
                 struct lmv_tgt_desc *tgts;
                 int i, rc;
 
-                lmv_connect(obd);
-                for (i = 0, tgts = lmv->tgts; i < lmv->count; i++, tgts++) {
-                        rc = obd_set_info(tgts->exp, keylen, key, vallen, val);
+                rc = lmv_check_connect(obd);
+                if (rc)
+                        RETURN(rc);
+
+                for (i = 0, tgts = lmv->tgts; 
+                        i < lmv->desc.ld_tgt_count; i++, tgts++) {
+                        rc = obd_set_info(tgts->ltd_exp, keylen, key, vallen, val);
                         if (rc)
                                 RETURN(rc);
                 }
@@ -1198,7 +1372,8 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         int mea_size;
         ENTRY;
 
-       mea_size = sizeof(struct ll_fid) * lmv->count + sizeof(struct mea);
+       mea_size = sizeof(struct ll_fid) * 
+                lmv->desc.ld_tgt_count + sizeof(struct mea);
         if (!lmmp)
                 RETURN(mea_size);
 
@@ -1232,7 +1407,8 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt,
         int mea_size;
         ENTRY;
 
-       mea_size = sizeof(struct ll_fid) * lmv->count + sizeof(struct mea);
+       mea_size = sizeof(struct ll_fid) * 
+                lmv->desc.ld_tgt_count + sizeof(struct mea);
         if (mem_tgt == NULL)
                 return mea_size;
 
@@ -1267,53 +1443,54 @@ int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa,
         LASSERT(oa != NULL);
         LASSERT(ea != NULL);
         LASSERT(pgarr != NULL);
-        LASSERT(oa->o_mds < lmv->count);
+        LASSERT(oa->o_mds < lmv->desc.ld_tgt_count);
 
         oa->o_gr = mea->mea_fids[oa->o_mds].generation;
         oa->o_id = mea->mea_fids[oa->o_mds].id;
         oa->o_valid =  OBD_MD_FLID | OBD_MD_FLGROUP;
-        err = obd_brw(rw, lmv->tgts[oa->o_mds].exp, oa,
-                        NULL, oa_bufs, pgarr, oti);
+        err = obd_brw(rw, lmv->tgts[oa->o_mds].ltd_exp, oa,
+                      NULL, oa_bufs, pgarr, oti);
         RETURN(err);
 }
 
 struct obd_ops lmv_obd_ops = {
-        o_owner:                THIS_MODULE,
-        o_attach:               lmv_attach,
-        o_detach:               lmv_detach,
-        o_setup:                lmv_setup,
-        o_cleanup:              lmv_cleanup,
-        o_connect:              lmv_connect_fake,
-        o_disconnect:           lmv_disconnect,
-        o_statfs:               lmv_statfs,
-        o_get_info:             lmv_get_info,
-        o_set_info:             lmv_set_info,
-        o_create:               lmv_obd_create,
-        o_packmd:               lmv_packmd,
-        o_unpackmd:             lmv_unpackmd,
-        o_brw:                  lmv_brw,
-        o_init_ea_size:         lmv_init_ea_size,
+        .o_owner                = THIS_MODULE,
+        .o_attach               = lmv_attach,
+        .o_detach               = lmv_detach,
+        .o_setup                = lmv_setup,
+        .o_cleanup              = lmv_cleanup,
+        .o_connect              = lmv_connect,
+        .o_disconnect           = lmv_disconnect,
+        .o_statfs               = lmv_statfs,
+        .o_get_info             = lmv_get_info,
+        .o_set_info             = lmv_set_info,
+        .o_create               = lmv_obd_create,
+        .o_packmd               = lmv_packmd,
+        .o_unpackmd             = lmv_unpackmd,
+        .o_brw                  = lmv_brw,
+        .o_init_ea_size         = lmv_init_ea_size,
+        .o_notify               = lmv_notify,
 };
 
 struct md_ops lmv_md_ops = {
-        m_getstatus:            lmv_getstatus,
-        m_getattr:              lmv_getattr,
-        m_change_cbdata:        lmv_change_cbdata,
-        m_change_cbdata_name:   lmv_change_cbdata_name,
-        m_close:                lmv_close,
-        m_create:               lmv_create,
-        m_done_writing:         lmv_done_writing,
-        m_enqueue:              lmv_enqueue,
-        m_getattr_name:         lmv_getattr_name,
-        m_intent_lock:          lmv_intent_lock,
-        m_link:                 lmv_link,
-        m_rename:               lmv_rename,
-        m_setattr:              lmv_setattr,
-        m_sync:                 lmv_sync,
-        m_readpage:             lmv_readpage,
-        m_unlink:               lmv_unlink,
-        m_get_real_obd:         lmv_get_real_obd,
-        m_valid_attrs:          lmv_valid_attrs,
+        .m_getstatus            = lmv_getstatus,
+        .m_getattr              = lmv_getattr,
+        .m_change_cbdata        = lmv_change_cbdata,
+        .m_change_cbdata_name   = lmv_change_cbdata_name,
+        .m_close                = lmv_close,
+        .m_create               = lmv_create,
+        .m_done_writing         = lmv_done_writing,
+        .m_enqueue              = lmv_enqueue,
+        .m_getattr_name         = lmv_getattr_name,
+        .m_intent_lock          = lmv_intent_lock,
+        .m_link                 = lmv_link,
+        .m_rename               = lmv_rename,
+        .m_setattr              = lmv_setattr,
+        .m_sync                 = lmv_sync,
+        .m_readpage             = lmv_readpage,
+        .m_unlink               = lmv_unlink,
+        .m_get_real_obd         = lmv_get_real_obd,
+        .m_valid_attrs          = lmv_valid_attrs,
 };
 
 int __init lmv_init(void)
index 2a179ac..1b1c9cd 100644 (file)
@@ -82,12 +82,12 @@ struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
         obj->fid = *fid;
         obj->obd = obd;
 
-        OBD_ALLOC(obj->objs, sizeof(struct lmv_inode) * lmv->count);
+        OBD_ALLOC(obj->objs, sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
         if (!obj->objs) {
                 OBD_FREE(obj, sizeof(*obj));
                 RETURN(NULL);
         }
-        memset(obj->objs, 0,  sizeof(struct lmv_inode) * lmv->count);
+        memset(obj->objs, 0,  sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
 
         spin_lock(&lmv_obj_list_lock);
         list_for_each(cur, &lmv_obj_list) {
@@ -96,7 +96,7 @@ struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
                                 obj2->fid.generation == fid->generation) {
                         /* someone created it already */
                         OBD_FREE(obj->objs,
-                                  sizeof(struct lmv_inode) * lmv->count);
+                                  sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
                         OBD_FREE(obj, sizeof(*obj));
 
                         atomic_inc(&obj2->count);
@@ -140,7 +140,7 @@ void lmv_cleanup_objs(struct obd_device *obd)
 
                 list_del(&obj->list);
                 OBD_FREE(obj->objs,
-                                sizeof(struct lmv_inode) * lmv->count);
+                         sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
                 OBD_FREE(obj, sizeof(*obj));
         }
         spin_unlock(&lmv_obj_list_lock);
@@ -172,7 +172,7 @@ int lmv_create_obj_from_attrs(struct obd_export *exp,
                 md.mea = NULL;
                 
                 valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
-                rc = md_getattr(lmv->tgts[fid->mds].exp, fid,
+                rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid,
                                 valid, mealen, &req);
                 if (rc) {
                         CERROR("md_getattr() failed, rc = %d\n", rc);
index 1190e4c..1f23936 100644 (file)
@@ -302,7 +302,7 @@ static int lov_set_osc_active(struct lov_obd *lov, struct obd_uuid *uuid,
         CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LOV idx %d\n",
                obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
                obd->obd_type->typ_name, i);
-        LASSERT(strcmp(obd->obd_type->typ_name, "osc") == 0);
+        LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0);
 
         if (tgt->active == activate) {
                 CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
@@ -325,12 +325,12 @@ static int lov_set_osc_active(struct lov_obd *lov, struct obd_uuid *uuid,
 }
 
 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
-                       int active)
+                      int active)
 {
         int rc;
         struct obd_uuid *uuid;
 
-        if (strcmp(watched->obd_type->typ_name, "osc")) {
+        if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
                 CERROR("unexpected notification of %s %s!\n",
                        watched->obd_type->typ_name,
                        watched->obd_name);
@@ -2703,7 +2703,7 @@ static int lov_set_info(struct obd_export *exp, obd_count keylen,
                         continue;
 
                 er = obd_set_info(lov->tgts[i].ltd_exp, keylen, key, vallen,
-                                   val);
+                                  val);
                 if (!rc)
                         rc = er;
         }
index 97ea846..dfdad07 100644 (file)
@@ -835,7 +835,7 @@ static int mds_getattr_name(int offset, struct ptlrpc_request *req,
         char *name;
         ENTRY;
 
-        LASSERT(!strcmp(obd->obd_type->typ_name, "mds"));
+        LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME));
 
         /* Swab now, before anyone looks inside the request */
 
index e1f09b8..9dca6e3 100644 (file)
@@ -673,7 +673,7 @@ int mds_choose_mdsnum(struct obd_device *obd, const char *name, int len, int fla
                 i = mds->mds_num;
         } else if (mds->mds_lmv_exp) {
                 lmv = &mds->mds_lmv_exp->exp_obd->u.lmv;
-                i = raw_name2idx(lmv->count, name, len);
+                i = raw_name2idx(lmv->desc.ld_tgt_count, name, len);
         }
         RETURN(i);
 }
index c9e0c21..64e7041 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/lustre_mds.h>
+#include <linux/obd_ost.h>
 #include <linux/lustre_idl.h>
 #include <linux/obd_class.h>
 #include <linux/obd_lov.h>
@@ -591,7 +592,7 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched, int active)
         if (!active)
                 RETURN(0);
 
-        if (strcmp(watched->obd_type->typ_name, "osc")) {
+        if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
                 CERROR("unexpected notification of %s %s!\n",
                        watched->obd_type->typ_name, watched->obd_name);
                 RETURN(-EINVAL);
index 8c1269d..0b2a370 100644 (file)
@@ -567,7 +567,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         ENTRY;
 
         LASSERT(offset == 0);
-        LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, "mds"));
+        LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, LUSTRE_MDS_NAME));
 
         DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u name %s mode %o",
                   rec->ur_fid1->id, rec->ur_fid1->generation,
index add9ae4..80894ce 100644 (file)
@@ -55,7 +55,7 @@ int obd_llog_setup(struct obd_device *obd, struct obd_llogs *llogs,
         if (op->lop_close == llog_lvfs_ops.lop_close) {
                 ctxt->loc_fsops = disk_obd->obd_fsops;
                 ctxt->loc_lvfs_ctxt = &disk_obd->obd_lvfs_ctxt;
-                if (!strcmp(disk_obd->obd_type->typ_name, "mds")) {
+                if (!strcmp(disk_obd->obd_type->typ_name, LUSTRE_MDS_NAME)) {
                         struct mds_obd *mds = &disk_obd->u.mds;
                         ctxt->loc_objects_dir = mds->mds_objects_dir;
                         ctxt->loc_logs_dir = mds->mds_logs_dir;
index ee07f05..3d5c86f 100644 (file)
@@ -464,8 +464,8 @@ int jt_lcfg_lmv_setup(int argc, char **argv)
 
         memset(&desc, 0, sizeof(desc));
         obd_str2uuid(&desc.ld_uuid, argv[1]);
-        desc.ld_count = argc - 2;
-        printf("LMV: %d uuids:\n", desc.ld_count);
+        desc.ld_tgt_count = argc - 2;
+        printf("LMV: %d uuids:\n", desc.ld_tgt_count);
 
         /* NOTE: it is possible to overwrite the default striping parameters,
          *       but EXTREME care must be taken when saving the OST UUID list.
@@ -473,10 +473,10 @@ int jt_lcfg_lmv_setup(int argc, char **argv)
          *       end of the list, or only overwrite individual OST entries
          *       that are restored from backups of the previous OST.
          */
-        uuidarray = calloc(desc.ld_count, sizeof(*uuidarray));
+        uuidarray = calloc(desc.ld_tgt_count, sizeof(*uuidarray));
         if (!uuidarray) {
                 fprintf(stderr, "error: %s: no memory for %d UUIDs\n",
-                        jt_cmdname(argv[0]), desc.ld_count);
+                        jt_cmdname(argv[0]), desc.ld_tgt_count);
                 rc = -ENOMEM;
                 goto out;
         }
@@ -493,7 +493,7 @@ int jt_lcfg_lmv_setup(int argc, char **argv)
 
         lcfg.lcfg_inllen1 = sizeof(desc);
         lcfg.lcfg_inlbuf1 = (char *)&desc;
-        lcfg.lcfg_inllen2 = desc.ld_count * sizeof(*uuidarray);
+        lcfg.lcfg_inllen2 = desc.ld_tgt_count * sizeof(*uuidarray);
         lcfg.lcfg_inlbuf2 = (char *)uuidarray;
 
         rc = lcfg_ioctl(argv[0], OBD_DEV_ID, &lcfg);