Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Sat, 7 Jan 2006 00:58:36 +0000 (00:58 +0000)
committernathan <nathan>
Sat, 7 Jan 2006 00:58:36 +0000 (00:58 +0000)
b=4482
live ost add of an old ost

13 files changed:
lustre/include/linux/lustre_idl.h
lustre/include/linux/obd.h
lustre/lov/lov_log.c
lustre/lov/lov_obd.c
lustre/mds/handler.c
lustre/mds/mds_internal.h
lustre/mds/mds_lov.c
lustre/mgc/mgc_request.c
lustre/obdclass/genops.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/obdfilter/filter.c
lustre/osc/osc_request.c

index ac47fdb..339e86c 100644 (file)
@@ -788,7 +788,6 @@ extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
  * array of UUIDs returned by the MDS.  With the current
  * protocol, this will limit the max number of OSTs per LOV */
 
-#define LOV_IDX_MAGIC  0x80000000
 #define LOV_DESC_MAGIC 0xB0CCDE5C
 
 struct lov_desc {
index cd0d417..ad45929 100644 (file)
@@ -373,11 +373,11 @@ struct mds_obd {
         struct obd_uuid                  mds_lov_uuid;
         char                            *mds_profile;
         struct obd_export               *mds_osc_exp; /* XXX lov_exp */
-        int                              mds_has_lov_desc;
         struct lov_desc                  mds_lov_desc;
+        struct semaphore                 mds_lov_sem;
         obd_id                          *mds_lov_objids;
         int                              mds_lov_objids_size;
-        int                              mds_lov_objids_red;
+        __u32                            mds_lov_objids_red;
         int                              mds_lov_nextid_set;
         struct file                     *mds_lov_objid_filp;
         struct file                     *mds_health_check_filp;
@@ -826,4 +826,8 @@ static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
         }
 }
 
+/* get/set_info keys */
+#define KEY_MDS_CONN "mds_conn"
+#define KEY_NEXT_ID  "next_id"
+
 #endif /* __OBD_H */
index 8d3bda2..4f51a97 100644 (file)
@@ -101,10 +101,10 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, int count,
         int i, rc = 0;
         ENTRY;
 
-        if (lov->desc.ld_tgt_count != count)
-                CERROR("Origin connect %d != %d\n",
-                       lov->desc.ld_tgt_count, count);
-        for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
+        if (count != lov->desc.ld_tgt_count )
+                CERROR("Origin connect mds cnt %d != lov cnt %d\n", count,
+                       lov->desc.ld_tgt_count);
+        for (i = 0, tgt = lov->tgts; i < count; i++, tgt++) {
                 struct obd_device *child;
                 struct llog_ctxt *cctxt;
                 
index 95bb93b..abd97db 100644 (file)
@@ -433,7 +433,7 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen)
 {
         struct lov_obd *lov = &obd->u.lov;
         struct lov_tgt_desc *tgt;
-        __u32 bufsize;
+        __u32 bufsize, idx;
         int rc;
         ENTRY;
 
@@ -508,11 +508,9 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen)
         if (rc)
                 GOTO(out, rc);
 
-        /* Crazy high index, catch collision with flag here */
-        LASSERT((index & LOV_IDX_MAGIC) == 0);
-
+        idx = index;
         rc = lov_notify(obd, tgt->ltd_exp->exp_obd, OBD_NOTIFY_ACTIVE,
-                        (void *)(index | LOV_IDX_MAGIC));
+                        (void *)&idx);
 
  out:
         if (rc) {
@@ -2194,7 +2192,7 @@ static int lov_set_info(struct obd_export *exp, obd_count keylen,
         int i, rc = 0, err;
         ENTRY;
 
-        if (KEY_IS("next_id")) {
+        if (KEY_IS(KEY_NEXT_ID)) {
                 if (vallen != lov->desc.ld_tgt_count)
                         RETURN(-EINVAL);
                 vallen = sizeof(obd_id);
@@ -2202,7 +2200,7 @@ static int lov_set_info(struct obd_export *exp, obd_count keylen,
 
         lov_getref(obddev);
 
-        if (KEY_IS("next_id") || KEY_IS("checksum")) {
+        if (KEY_IS(KEY_NEXT_ID) || KEY_IS("checksum")) {
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                         /* OST was disconnected */
                         if (!lov->tgts[i].ltd_exp)
@@ -2231,7 +2229,7 @@ static int lov_set_info(struct obd_export *exp, obd_count keylen,
                 GOTO(out, rc);
         }
 
-        if (KEY_IS("mds_conn") || KEY_IS("unlinked")) {
+        if (KEY_IS(KEY_MDS_CONN) || KEY_IS("unlinked")) {
                 if (vallen != 0)
                         GOTO(out, rc = -EINVAL);
         } else {
index 196f0cb..227a643 100644 (file)
@@ -1528,6 +1528,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 
         sema_init(&mds->mds_orphan_recovery_sem, 1);
         sema_init(&mds->mds_epoch_sem, 1);
+        sema_init(&mds->mds_lov_sem, 1);
         spin_lock_init(&mds->mds_transno_lock);
         mds->mds_max_mdsize = sizeof(struct lov_mds_md);
         mds->mds_max_cookiesize = sizeof(struct llog_cookie);
@@ -1752,13 +1753,11 @@ int mds_postrecov(struct obd_device *obd)
         LASSERT(!obd->obd_recovering);
         LASSERT(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT) != NULL);
 
+        /* FIXME just put this in the synchronize, why not? */
         /* set nextid first, so we are sure it happens */
         rc = mds_lov_set_nextid(obd);
-        if (rc) {
-                CERROR ("%s: mds_lov_set_nextid failed\n",
-                        obd->obd_name);
+        if (rc) 
                 GOTO(out, rc);
-        }
 
         /* clean PENDING dir */
         rc = mds_cleanup_pending(obd);
@@ -1768,8 +1767,8 @@ int mds_postrecov(struct obd_device *obd)
                 item = rc;
         }
 
-        /* Does anyone need this to be synchronous ever? */
-        mds_lov_start_synchronize(obd, NULL, obd->obd_async_recov);
+        /* Does target_finish_recovery really need this to be synchronous? */
+        mds_lov_start_synchronize(obd, NULL, NULL, obd->obd_async_recov);
 
 out:
         RETURN(rc < 0 ? rc : item);
@@ -2226,61 +2225,6 @@ static int mds_health_check(struct obd_device *obd)
         return rc;
 }
 
-#if 0
-static int mds_set_info(struct obd_export *exp, obd_count keylen,
-                        void *key, obd_count vallen, void *val)
-{
-        struct obd_device *obd = exp->exp_obd;
-        struct mds_obd *mds = &obd->u.mds;
-        int rc = -EINVAL;
-        ENTRY;
-
-        if (KEY_IS("next_id")) {
-                int idx = (int)*((obd_id*)val);
-                obd_id id = *(((obd_id*)val) + 1);
-                
-                if (vallen != sizeof(obd_id) * 2)
-                        RETURN(-EINVAL);
-                if (idx >= mds->mds_lov_desc.ld_tgt_count) 
-                        RETURN(-EINVAL);
-
-                if (idx >= mds->mds_lov_desc.ld_tgt_count) {
-                        obd_id *ids;
-                        int     size;
-
-                        size = mds->mds_lov_desc.ld_tgt_count * sizeof(*ids);
-                        OBD_ALLOC(ids, size);
-                        if (ids == NULL)
-                                RETURN(-ENOMEM);
-
-                        memset(ids, 0, size);
-
-                        if (mds->mds_lov_objids != NULL) {
-                                int oldsize = mds->mds_lov_desc.ld_tgt_count * 
-                                        sizeof(*ids);
-                                memcpy(ids, mds->mds_lov_objids, oldsize);
-                                OBD_FREE(mds->mds_lov_objids, oldsize);
-                        }
-                        mds->mds_lov_objids = ids;
-                        mds->mds_lov_desc.ld_tgt_count = 
-                                mds->mds_lov_desc.ld_tgt_count;
-                }
-                
-                mds->mds_lov_objids[idx] = id;
-
-                CWARN("got last object "LPU64" from OST %d\n",
-                      mds->mds_lov_objids[idx], idx);
-
-                rc = mds_lov_write_objids(obd);
-                if (rc)
-                        CERROR("got last objids from OSTs, but error "
-                               "writing objids file: %d\n", rc);
-        }
-        
-        RETURN(rc);
-}
-#endif
-
 struct lvfs_callback_ops mds_lvfs_ops = {
         l_fid2dentry:     mds_lvfs_fid2dentry,
 };
index 8ba49b2..f7b9da2 100644 (file)
@@ -151,8 +151,9 @@ int mds_lov_write_objids(struct obd_device *obd);
 void mds_lov_update_objids(struct obd_device *obd, obd_id *ids);
 int mds_lov_set_nextid(struct obd_device *obd);
 int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
-int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid,
-                              int nonblock);
+int mds_lov_start_synchronize(struct obd_device *obd, 
+                              struct obd_device *watched,
+                              void *data, int nonblock);
 int mds_post_mds_lovconf(struct obd_device *obd);
 int mds_notify(struct obd_device *obd, struct obd_device *watched,
                enum obd_notify_event ev, void *data);
index db777e9..225b809 100644 (file)
@@ -69,6 +69,8 @@ static int mds_lov_read_objids(struct obd_device *obd)
            has fewer targets. Old targets not in the lov descriptor 
            during mds setup may still have valid objids. */
         size = mds->mds_lov_objid_filp->f_dentry->d_inode->i_size;
+
+        CERROR("objid file size: %d\n", size);
         if (size == 0)
                 RETURN(0);
 
@@ -87,7 +89,8 @@ static int mds_lov_read_objids(struct obd_device *obd)
         }
 
         for (i = 0; i < mds->mds_lov_objids_red; i++)
-                CDEBUG(D_INFO, "read last object "LPU64" for idx %d\n",
+                //FIXME D_ERROR
+                CDEBUG(D_INFO|D_ERROR, "read last object "LPU64" for idx %d\n",
                        mds->mds_lov_objids[i], i);
 
         RETURN(rc);
@@ -97,18 +100,22 @@ int mds_lov_write_objids(struct obd_device *obd)
 {
         struct mds_obd *mds = &obd->u.mds;
         loff_t off = 0;
-        int i, rc, size = mds->mds_lov_desc.ld_tgt_count * sizeof(obd_id);
+        int i, rc, tgts; 
         ENTRY;
 
-        if (!mds->mds_lov_desc.ld_tgt_count)
+        tgts = max(mds->mds_lov_desc.ld_tgt_count, mds->mds_lov_objids_red);
+
+        if (!tgts)
                 RETURN(0);
 
-        for (i = 0; i < mds->mds_lov_desc.ld_tgt_count; i++)
-                CDEBUG(D_INFO, "writing last object "LPU64" for idx %d\n",
+        for (i = 0; i < tgts; i++)
+                //FIXME D_ERROR
+                CDEBUG(D_INFO|D_ERROR, "writing last object "LPU64" for idx %d\n",
                        mds->mds_lov_objids[i], i);
 
         rc = fsfilt_write_record(obd, mds->mds_lov_objid_filp,
-                                 mds->mds_lov_objids, size, &off, 0);
+                                 mds->mds_lov_objids, tgts * sizeof(obd_id),
+                                 &off, 0);
         RETURN(rc);
 }
 
@@ -148,8 +155,12 @@ int mds_lov_set_nextid(struct obd_device *obd)
 
         LASSERT(mds->mds_lov_objids != NULL);
 
-        rc = obd_set_info(mds->mds_osc_exp, strlen("next_id"), "next_id",
+        rc = obd_set_info(mds->mds_osc_exp, strlen(KEY_NEXT_ID), KEY_NEXT_ID,
                           mds->mds_lov_desc.ld_tgt_count, mds->mds_lov_objids);
+        
+        if (rc) 
+                CERROR ("%s: mds_lov_set_nextid failed (%d)\n", 
+                        obd->obd_name, rc);
         RETURN(rc);
 }
 
@@ -194,8 +205,6 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov)
                 mds->mds_lov_objids_size = size;
         }
 
-        /* Only update the tgt count after we have an objid ready.
-           The objid may invalidly be 0 right now - is that a problem? */
         mds->mds_lov_desc = *ld;
 
         i = lov_mds_md_size(mds->mds_lov_desc.ld_tgt_count);
@@ -203,12 +212,61 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov)
                 mds->mds_max_mdsize = i;
         mds->mds_max_cookiesize = mds->mds_lov_desc.ld_tgt_count *
                                   sizeof(struct llog_cookie);
-        mds->mds_has_lov_desc = 1;
 out:
         OBD_FREE(ld, sizeof(*ld));
         RETURN(rc);
 }
 
+/* Tell the mds_lov about the new target */
+static int mds_lov_add_ost(struct obd_device *obd, struct obd_device *watched, 
+                           __u32 idx)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        int old_count;
+        int rc = 0;
+        ENTRY;
+
+        //FIXME remove D_ERROR
+        CDEBUG(D_CONFIG|D_ERROR, "Updating mds lov for OST idx %d\n", idx);
+
+        old_count = mds->mds_lov_desc.ld_tgt_count;
+        rc = mds_lov_update_desc(obd, mds->mds_osc_exp);
+        if (rc)
+                RETURN(rc);
+
+        if (idx >= mds->mds_lov_desc.ld_tgt_count) {
+                CERROR("index %d > count %d!\n", idx, 
+                       mds->mds_lov_desc.ld_tgt_count);
+                RETURN(-EINVAL);
+        }
+        
+        if (idx >= mds->mds_lov_objids_red) {
+                /* We never read this lastid; ask the osc */
+                obd_id lastid;
+                __u32 size = sizeof(lastid);
+                rc = obd_get_info(watched->obd_self_export,
+                                  strlen("last_id"), 
+                                  "last_id", &size, &lastid);
+                if (rc)
+                        RETURN(rc);
+                mds->mds_lov_objids[idx] = lastid;
+                CWARN("got last object "LPU64" from OST %d\n",
+                      mds->mds_lov_objids[idx], idx);
+                mds_lov_write_objids(obd);
+        } else {
+                /* We did read this lastid; tell the osc */ 
+                rc = mds_lov_set_nextid(obd);
+        }
+
+        CWARN("last object "LPU64" from OST %d\n",
+              mds->mds_lov_objids[idx], idx);
+        
+        obd_llog_finish(obd, old_count);
+        llog_cat_initialize(obd, mds->mds_lov_desc.ld_tgt_count);
+        
+        RETURN(rc);
+}
+
 int mds_lov_connect(struct obd_device *obd, char * lov_name)
 {
         struct mds_obd *mds = &obd->u.mds;
@@ -482,8 +540,8 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 rc = llog_ioctl(ctxt, cmd, data);
                 pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
                 llog_cat_initialize(obd, mds->mds_lov_desc.ld_tgt_count);
-                rc2 = obd_set_info(mds->mds_osc_exp, strlen("mds_conn"),
-                                   "mds_conn", 0, NULL);
+                rc2 = obd_set_info(mds->mds_osc_exp, strlen(KEY_MDS_CONN),
+                                   KEY_MDS_CONN, 0, NULL);
                 if (!rc)
                         rc = rc2;
                 RETURN(rc);
@@ -513,34 +571,54 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
 }
 
+#define MLSI_NO_INDEX -1
+
 struct mds_lov_sync_info {
-        struct obd_device *mlsi_obd; /* the lov device to sync */
-        struct obd_uuid   *mlsi_uuid;  /* target to sync */
+        struct obd_device *mlsi_obd;     /* the lov device to sync */
+        struct obd_device *mlsi_watched; /* target osc */
+        __u32              mlsi_index;   /* index of target */
 };
 
 static int __mds_lov_synchronize(void *data)
 {
         struct mds_lov_sync_info *mlsi = data;
-        struct obd_device *obd;
-        struct obd_uuid *uuid;
+        struct obd_device *obd, *watched;
+        struct mds_obd *mds;
+        struct obd_uuid *uuid = NULL;
+        __u32  idx;
         int rc = 0;
         ENTRY;
 
         obd = mlsi->mlsi_obd;
-        uuid = mlsi->mlsi_uuid;
+        mds = &obd->u.mds;
+        watched = mlsi->mlsi_watched;
+        idx = mlsi->mlsi_index;
+        if (watched) 
+                uuid = &watched->u.cli.cl_import->imp_target_uuid;
 
         OBD_FREE(mlsi, sizeof(*mlsi));
 
         LASSERT(obd != NULL);
 
-        rc = obd_set_info(obd->u.mds.mds_osc_exp, strlen("mds_conn"),
-                          "mds_conn", 0, uuid);
+        /* Hold this throughout a synchronize, and wherever we
+           reference the contents of mds_lov_desc */
+        down(&mds->mds_lov_sem);
+
+        rc = obd_set_info(mds->mds_osc_exp, strlen(KEY_MDS_CONN),
+                          KEY_MDS_CONN, 0, uuid);
         if (rc != 0)
                 GOTO(out, rc);
 
+        if (idx != MLSI_NO_INDEX) {
+                rc = mds_lov_add_ost(obd, watched, idx);
+                if (rc != 0)
+                        GOTO(out, rc);
+        }
+
         rc = llog_connect(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT),
-                          obd->u.mds.mds_lov_desc.ld_tgt_count,
+                          mds->mds_lov_desc.ld_tgt_count,
                           NULL, NULL, uuid);
+        
         if (rc != 0) {
                 CERROR("%s: failed at llog_origin_connect: %d\n",
                        obd->obd_name, rc);
@@ -552,12 +630,12 @@ static int __mds_lov_synchronize(void *data)
                       obd->obd_name, (char *)uuid->uuid);
         else
                 CWARN("MDS %s: All %d OSC's now active, resetting orphans\n",
-                      obd->obd_name, obd->u.mds.mds_lov_desc.ld_tgt_count);
+                      obd->obd_name, mds->mds_lov_desc.ld_tgt_count);
 
         if (obd->obd_stopping)
                 GOTO(out, rc = -ENODEV);
 
-        rc = mds_lov_clearorphans(&obd->u.mds, uuid);
+        rc = mds_lov_clearorphans(mds, uuid);
         if (rc != 0) {
                 CERROR("%s: failed at mds_lov_clearorphans: %d\n",
                        obd->obd_name, rc);
@@ -565,6 +643,7 @@ static int __mds_lov_synchronize(void *data)
         }
 
 out:
+        up(&mds->mds_lov_sem);
         class_decref(obd);
         RETURN(rc);
 }
@@ -572,6 +651,7 @@ out:
 int mds_lov_synchronize(void *data)
 {
         unsigned long flags;
+        ENTRY;
 
         lock_kernel();
         ptlrpc_daemonize();
@@ -582,11 +662,12 @@ int mds_lov_synchronize(void *data)
         SIGNAL_MASK_UNLOCK(current, flags);
         unlock_kernel();
 
-        return (__mds_lov_synchronize(data));
+        RETURN(__mds_lov_synchronize(data));
 }
 
-int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid,
-                              int nonblock)
+int mds_lov_start_synchronize(struct obd_device *obd, 
+                              struct obd_device *watched,
+                              void *data, int nonblock)
 {
         struct mds_lov_sync_info *mlsi;
         int rc;
@@ -598,7 +679,11 @@ int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid,
                 RETURN(-ENOMEM);
 
         mlsi->mlsi_obd = obd;
-        mlsi->mlsi_uuid = uuid;
+        mlsi->mlsi_watched = watched;
+        if (data) 
+                mlsi->mlsi_index = *(__u32 *)data;
+        else
+                mlsi->mlsi_index = MLSI_NO_INDEX;
 
         /* Although class_export_get(obd->obd_self_export) would lock
            the MDS in place, since it's only a self-export
@@ -611,8 +696,9 @@ int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid,
         atomic_inc(&obd->obd_refcount);
 
         if (nonblock) {
-                /* Syncronize in the background */
-                rc = kernel_thread(mds_lov_synchronize, mlsi, CLONE_VM | CLONE_FILES);
+                /* Synchronize in the background */
+                rc = kernel_thread(mds_lov_synchronize, mlsi,
+                                   CLONE_VM | CLONE_FILES);
                 if (rc < 0) {
                         CERROR("%s: error starting mds_lov_synchronize: %d\n",
                                obd->obd_name, rc);
@@ -632,8 +718,6 @@ int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid,
 int mds_notify(struct obd_device *obd, struct obd_device *watched,
                enum obd_notify_event ev, void *data)
 {
-        struct obd_uuid *uuid;
-        int idx = (int)data;
         int rc = 0;
         ENTRY;
 
@@ -646,60 +730,16 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
                 RETURN(-EINVAL);
         }
 
-        uuid = &watched->u.cli.cl_import->imp_target_uuid;
-
         if (obd->obd_recovering) {
                 CWARN("MDS %s: in recovery, not resetting orphans on %s\n",
-                      obd->obd_name, uuid->uuid);
+                      obd->obd_name,
+                      watched->u.cli.cl_import->imp_target_uuid.uuid);
+                /* mds_postrecov will handle the sync later */
                 RETURN(rc);
         } 
 
-        /* FIXME Put all this in the sync, so that we don't change the
-           tgt_count out from under it.  We also can't run multiple 
-           sync threads simultaneously.  This means we need a single 
-           permanent sync thread that we occationally wake to re-sync.
-           Sigh, but for a single uuid or a whole lov? */
-        /* Tell the mds_lov about the new target */
-        if (idx & LOV_IDX_MAGIC) {
-                struct mds_obd *mds = &obd->u.mds;
-                int old_count = mds->mds_lov_desc.ld_tgt_count;
-
-                idx &= ~LOV_IDX_MAGIC;
-                //FIXME remove D_ERROR
-                CDEBUG(D_CONFIG|D_ERROR, "Updating mds lov for OST idx %d\n", idx);
-
-                rc = mds_lov_update_desc(obd, mds->mds_osc_exp);
-                if (rc)
-                        RETURN(rc);
-        
-                if (idx >= mds->mds_lov_desc.ld_tgt_count) {
-                        CERROR("index %d > count %d!\n", idx, 
-                               mds->mds_lov_desc.ld_tgt_count);
-                        RETURN(-EINVAL);
-                }
-                
-                /* Don't get_info unless we never read it -- this will
-                   block on a missing OST */
-                if (idx >= mds->mds_lov_objids_red) {
-                        obd_id lastid;
-                        __u32 size = sizeof(lastid);
-                        rc = obd_get_info(watched->obd_self_export,
-                                          strlen("last_id"), 
-                                          "last_id", &size, &lastid);
-                        if (rc)
-                                RETURN(rc);
-                        mds->mds_lov_objids[idx] = lastid;
-                        CWARN("got last object "LPU64" from OST %d\n",
-                              mds->mds_lov_objids[idx], idx);
-                        rc = mds_lov_write_objids(obd);
-                }
-                
-                obd_llog_finish(obd, old_count);
-                llog_cat_initialize(obd, mds->mds_lov_desc.ld_tgt_count);
-        }
-
         LASSERT(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT) != NULL);
-        rc = mds_lov_start_synchronize(obd, uuid, 1);
+        rc = mds_lov_start_synchronize(obd, watched, data, 1);
         RETURN(rc);
 }
 
index c755c6d..914599e 100644 (file)
@@ -390,7 +390,11 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                    (we get called from client_disconnect_export) */
                 if (!lock->l_conn_export ||
                     !lock->l_conn_export->exp_obd->u.cli.cl_conn_count) {
-                        CERROR("Disconnecting, don't requeue\n");
+                        CDEBUG(D_MGC, "Disconnecting, don't requeue\n");
+                        break;
+                }
+                if (lock->l_req_mode != lock->l_granted_mode) {
+                        CERROR("original grant failed, don't requeue\n");
                         break;
                 }
 
@@ -444,6 +448,13 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
                               type, NULL, mode, flags, 
                               mgc_blocking_ast, ldlm_completion_ast, NULL,
                               data, NULL, 0, NULL, lockh);
+        if (rc == 0) {
+                /* Allow matches for other clients mounted on this host */
+                struct ldlm_lock *lock = ldlm_handle2lock(lockh);
+                LASSERT(lock);
+                ldlm_lock_allow_match(lock);
+                LDLM_LOCK_PUT(lock);
+        }
 
         RETURN(rc);
 }
index dfbabe9..b8daa18 100644 (file)
@@ -85,13 +85,15 @@ struct obd_type *class_get_type(char *name)
 
 #ifdef CONFIG_KMOD
         if (!type) {
-                if (strcmp(name, LUSTRE_MDT_NAME) == 0) 
-                        name = LUSTRE_MDS_NAME;
-                if (!request_module(name)) {
-                        CDEBUG(D_INFO, "Loaded module '%s'\n", name);
+                char *modname = name;
+                if (strcmp(modname, LUSTRE_MDT_NAME) == 0) 
+                        modname = LUSTRE_MDS_NAME;
+                if (!request_module(modname)) {
+                        CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
                         type = class_search_type(name);
-                } else
-                        CDEBUG(D_INFO, "Can't load module '%s'\n", name);
+                } else {
+                        LCONSOLE_ERROR("Can't load module '%s'\n", modname);
+                }
         }
 #endif
         if (type)
index 4735dfe..03069a4 100644 (file)
@@ -233,6 +233,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         RETURN(0);
 
 err_exp:
+        CERROR("setup %s failed (%d)\n", obd->obd_name, err);
         class_unlink_export(obd->obd_self_export);
         obd->obd_self_export = NULL;
         obd->obd_starting = 0;
index b56fbf0..5ac4bc2 100644 (file)
@@ -194,6 +194,8 @@ static void unlock_mntput(struct vfsmount *mnt)
         }
 }
 
+static int lustre_put_lsi(struct super_block *sb);
+
 /* to be called from obd_cleanup methods */
 int server_put_mount(char *name, struct vfsmount *mnt)
 {
@@ -211,7 +213,12 @@ int server_put_mount(char *name, struct vfsmount *mnt)
         lsi = s2lsi(lmi->lmi_sb);
         LASSERT(lmi->lmi_mnt == mnt);
         unlock_mntput(lmi->lmi_mnt);
-        if (atomic_dec_and_test(&lsi->lsi_mounts)) {
+
+        CDEBUG(D_MOUNT, "put_mnt %p from %s, refs=%d, vfscount=%d\n", 
+               lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts),
+               atomic_read(&lmi->lmi_mnt->mnt_count));
+
+        if (lustre_put_lsi(lmi->lmi_sb)) {
                 CDEBUG(D_MOUNT, "Last put of mnt %p from %s, vfscount=%d\n", 
                        lmi->lmi_mnt, name, 
                        atomic_read(&lmi->lmi_mnt->mnt_count));
@@ -222,10 +229,6 @@ int server_put_mount(char *name, struct vfsmount *mnt)
         }
         up(&lustre_mount_info_lock);
 
-        CDEBUG(D_MOUNT, "put_mnt %p from %s, refs=%d, vfscount=%d\n", 
-               lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts),
-               atomic_read(&lmi->lmi_mnt->mnt_count));
-
         /* this obd should never need the mount again */
         server_deregister_mount(name);
         
@@ -997,7 +1000,8 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
         }
 
         s2lsi_nocast(sb) = lsi;
-        atomic_set(&lsi->lsi_mounts, 0);
+        /* we take 1 extra ref for our setup */
+        atomic_set(&lsi->lsi_mounts, 1);
         RETURN(lsi);
 }
 
@@ -1009,12 +1013,11 @@ static int lustre_free_lsi(struct super_block *sb)
         if (!lsi)
                 RETURN(0);
                 
-        if (atomic_read(&lsi->lsi_mounts) > 0) {
-                /* someone didn't call server_put_mount */
-                /* FIXME this should assert */
-                CERROR("There are still mounts on this sb!\n");
-                RETURN(-EBUSY);
-        }
+        CDEBUG(D_MOUNT, "Freeing lsi\n");
+        
+        /* someone didn't call server_put_mount. */
+        LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
+
         if (lsi->lsi_ldd != NULL) 
                 OBD_FREE(lsi->lsi_ldd, sizeof(*lsi->lsi_ldd));
         
@@ -1038,6 +1041,21 @@ static int lustre_free_lsi(struct super_block *sb)
         RETURN(0);
 }
            
+static int lustre_put_lsi(struct super_block *sb)
+{
+        struct lustre_sb_info *lsi = s2lsi(sb);
+        ENTRY;
+
+        LASSERT(lsi);
+        
+        CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts));
+
+        if (atomic_dec_and_test(&lsi->lsi_mounts)) {
+                lustre_free_lsi(sb);
+                RETURN(1);
+        }
+        RETURN(0);
+}
 
 /*************** server mount ******************/
 
@@ -1174,6 +1192,8 @@ static void server_put_super(struct super_block *sb)
 
         /* drop the One True Mount */
         unlock_mntput(mnt);
+
+        CDEBUG(D_MOUNT, "umount done\n");
         EXIT;
 }
 
@@ -1359,7 +1379,7 @@ int lustre_common_put_super(struct super_block *sb)
                    needs the mgc.  Let him clean it up. */
                 CDEBUG(D_MOUNT, "MGC busy, will stop later\n");
         }
-        rc = lustre_free_lsi(sb);
+        lustre_put_lsi(sb);
         RETURN(rc);
 }      
 
@@ -1520,7 +1540,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
 
         /* Figure out the lmd from the mount options */
         if (lmd_parse((char *)data, lmd)) {
-                lustre_free_lsi(sb);
+                lustre_put_lsi(sb);
                 RETURN(-EINVAL);
         }
 
@@ -1537,22 +1557,23 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
                         /* Connect and start */
                         /* (should always be ll_fill_super) */
                         rc = (*client_fill_super)(sb);
+                        if (rc) 
+                                lustre_common_put_super(sb);
                 }
         } else {
                 CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev);
+                lsi->lsi_flags |= LSI_SERVER;
                 rc = server_fill_super(sb);
                 /* s_f_s calls lustre_start_mgc after the mount because we need
                    the MGS nids which are stored on disk.  Plus, we may
                    need to start the MGS first. */
+                /* s_f_s will call server_put_super on failure */
         }
                                                                                 
 out:
         if (rc){
-                /* s_f_s will call server_put_super on failure */
                 CERROR("Unable to mount %s\n", 
                        s2lsi(sb) ? lmd->lmd_dev : "");
-                lustre_stop_mgc(sb);
-                lustre_free_lsi(sb);
         } else {
                 CDEBUG(D_MOUNT, "Successfully mounted %s\n", lmd->lmd_dev);
         }
index 7a56d18..19bdb9f 100644 (file)
@@ -2736,8 +2736,8 @@ static int filter_set_info(struct obd_export *exp, __u32 keylen,
                 RETURN(-EINVAL);
         }
 
-        if (keylen < strlen("mds_conn") ||
-            memcmp(key, "mds_conn", keylen) != 0)
+        if (keylen < strlen(KEY_MDS_CONN) ||
+            memcmp(key, KEY_MDS_CONN, keylen) != 0)
                 RETURN(-EINVAL);
 
         CWARN("%s: received MDS connection from %s\n", obd->obd_name,
index 8f26e8c..5cce3e8 100644 (file)
@@ -3034,7 +3034,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10);
 
-        if (KEY_IS("next_id")) {
+        if (KEY_IS(KEY_NEXT_ID)) {
                 if (vallen != sizeof(obd_id))
                         RETURN(-EINVAL);
                 obd->u.cli.cl_oscc.oscc_next_id = *((obd_id*)val) + 1;
@@ -3072,7 +3072,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (!KEY_IS("mds_conn") && !KEY_IS("evict_by_nid"))
+        if (!KEY_IS(KEY_MDS_CONN) && !KEY_IS("evict_by_nid"))
                 RETURN(-EINVAL);