Whamcloud - gitweb
* Pass the connecting client's UUID (NB: not the _connection_'s UUID, the
authorshaver <shaver>
Wed, 7 Aug 2002 21:46:32 +0000 (21:46 +0000)
committershaver <shaver>
Wed, 7 Aug 2002 21:46:32 +0000 (21:46 +0000)
  _client_'s) through the various obd connection functions.
* Use this newfound UUID to match up the exports conjured up from reading
  last_rcvd with reattaching clients.

13 files changed:
lustre/include/linux/lustre_lib.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/lib/l_net.c
lustre/llite/super.c
lustre/lov/lov_obd.c
lustre/mds/handler.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/proc_lustre.c
lustre/obdecho/echo.c
lustre/obdfilter/filter.c
lustre/ost/ost_handler.c

index c309fc2..4d053cd 100644 (file)
@@ -39,7 +39,8 @@ struct ptlrpc_request;
 struct obd_device;
 int target_handle_connect(struct ptlrpc_request *req);
 int target_handle_disconnect(struct ptlrpc_request *req);
-int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd);
+int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
+                       char *cluuid);
 int client_obd_disconnect(struct lustre_handle *conn);
 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
 int client_obd_cleanup(struct obd_device * obddev);
index d2553bb..ae71fd8 100644 (file)
@@ -222,7 +222,8 @@ struct obd_ops {
         int (*o_detach)(struct obd_device *dev);
         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
         int (*o_cleanup)(struct obd_device *dev);
-        int (*o_connect)(struct lustre_handle *conn, struct obd_device *src);
+        int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
+                         char *cluuid);
         int (*o_disconnect)(struct lustre_handle *conn);
 
 
index 3963c3a..f76dd84 100644 (file)
@@ -70,19 +70,20 @@ extern int class_rconn2export(struct lustre_handle *conn,
 
 struct obd_export {
         __u64 exp_cookie;
-        struct lustre_handle exp_rconnh;        /* remote connection handle */
-        struct lustre_handle exp_impconnh;
-        struct list_head exp_chain;
-        struct obd_device *exp_obd;
+        struct lustre_handle      exp_rconnh;     /* remote connection handle */
+        struct lustre_handle      exp_impconnh;
+        struct list_head          exp_chain;
+        struct obd_device        *exp_obd;
         struct ptlrpc_connection *exp_connection;
-        struct mds_export_data exp_mds_data;
+        struct mds_export_data    exp_mds_data;
 #if NOTYET && 0
-        struct ldlm_export_data exp_ldlm_data;
-        struct ost_export_data exp_ost_data;
+        struct ldlm_export_data   exp_ldlm_data;
+        struct ost_export_data    exp_ost_data;
 #endif
-        void *exp_data; /* device specific data */
-        int exp_desclen;
-        char *exp_desc;
+        void                     *exp_data; /* device specific data */
+        int                       exp_desclen;
+        char                     *exp_desc;
+        uuid_t                    exp_uuid;
 };
 
 struct obd_import {
@@ -292,13 +293,14 @@ static inline int obd_setattr(struct lustre_handle *conn,
         RETURN(rc);
 }
 
-static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd)
+static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd,
+                              char *cluuid)
 {
         int rc;
         OBD_CHECK_DEVSETUP(obd);
         OBD_CHECK_OP(obd,connect);
 
-        rc = OBP(obd, connect)(conn, obd);
+        rc = OBP(obd, connect)(conn, obd, cluuid);
         RETURN(rc);
 }
 
@@ -708,7 +710,8 @@ int class_name2dev(char *name);
 int class_uuid2dev(char *name);
 struct obd_device *class_uuid2obd(char *name);
 struct obd_export *class_new_export(struct obd_device *obddev);
-int class_connect (struct lustre_handle *conn, struct obd_device *obd);
+int class_connect(struct lustre_handle *conn, struct obd_device *obd,
+                  char *cluuid);
 int class_disconnect(struct lustre_handle *conn);
 struct obd_export *class_conn2export(struct lustre_handle *);
 
index 27cd3ef..e1098b6 100644 (file)
@@ -129,7 +129,8 @@ int client_obd_cleanup(struct obd_device * obddev)
         return 0;
 }
 
-int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd)
+int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
+                       char *cluuid)
 {
         struct client_obd *cli = &obd->u.cli;
         struct ptlrpc_request *request;
@@ -141,7 +142,8 @@ int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd)
         ENTRY;
         down(&cli->cl_sem);
         MOD_INC_USE_COUNT;
-        rc = class_connect(conn, obd);
+#warning shaver: we might need a real cluuid here
+        rc = class_connect(conn, obd, NULL);
         if (!rc)
                 cli->cl_conn_count++;
         else {
@@ -277,7 +279,7 @@ int target_handle_connect(struct ptlrpc_request *req)
         if (rc)
                 RETURN(rc);
 
-        req->rq_status = obd_connect(&conn, target);
+        req->rq_status = obd_connect(&conn, target, cluuid);
         req->rq_repmsg->addr = conn.addr;
         req->rq_repmsg->cookie = conn.cookie;
 
index f49ae28..d6ab7d1 100644 (file)
@@ -128,7 +128,8 @@ static struct super_block * ll_read_super(struct super_block *sb,
         }
 #endif 
 
-        err = obd_connect(&sbi->ll_mdc_conn, obd);
+#warning shaver: might need a cluuid here
+        err = obd_connect(&sbi->ll_mdc_conn, obd, NULL);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
                 GOTO(out_free, sb = NULL);
@@ -140,7 +141,8 @@ static struct super_block * ll_read_super(struct super_block *sb,
                 CERROR("OSC %s: not setup or attached\n", osc);
                 GOTO(out_mdc, sb = NULL);
         }
-        err = obd_connect(&sbi->ll_osc_conn, obd);
+#warning shaver: might need a cluuid here
+        err = obd_connect(&sbi->ll_osc_conn, obd, NULL);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", osc, err);
                 GOTO(out_mdc, sb = NULL);
index a6cae4b..cb05eb3 100644 (file)
@@ -28,7 +28,8 @@
 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 /* obd methods */
-static int lov_connect(struct lustre_handle *conn, struct obd_device *obd)
+static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
+                       char *cluuid)
 {
         struct ptlrpc_request *req;
         struct lov_obd *lov = &obd->u.lov;
@@ -38,14 +39,14 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd)
         int i;
 
         MOD_INC_USE_COUNT;
-        rc = class_connect(conn, obd);
+        rc = class_connect(conn, obd, cluuid);
         if (rc) {
                 MOD_DEC_USE_COUNT;
                 RETURN(rc);
         }
 
         /* retrieve LOV metadata from MDS */
-        rc = obd_connect(&mdc_conn, lov->mdcobd);
+        rc = obd_connect(&mdc_conn, lov->mdcobd, NULL);
         if (rc) {
                 CERROR("cannot connect to mdc: rc = %d\n", rc);
                 GOTO(out, rc = -EINVAL);
@@ -96,7 +97,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd)
                         CERROR("Target %s not set up\n", uuidarray[i]);
                         GOTO(out_mem, rc = -EINVAL);
                 }            
-                rc = obd_connect(&lov->tgts[i].conn, tgt);
+                rc = obd_connect(&lov->tgts[i].conn, tgt, NULL);
                 if (rc) {
                         CERROR("Target %s connect error %d\n",
                                uuidarray[i], rc);
index 6303205..8b55d65 100644 (file)
@@ -221,13 +221,39 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
         return result;
 }
 
-static int mds_connect(struct lustre_handle *conn, struct obd_device *obd)
+static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
+                       char *cluuid)
 {
         int rc;
+        struct list_head *p, *n;
 
-#warning shaver: find existing export if there is one.
         MOD_INC_USE_COUNT;
-        rc = class_connect(conn, obd);
+        if (cluuid) {
+                list_for_each_safe(p, n, &obd->obd_exports) {
+                        struct obd_export *exp;
+                        struct mds_client_data *mcd;
+                        
+                        exp = list_entry(p, struct obd_export, exp_chain);
+                        mcd = exp->exp_mds_data.med_mcd;
+                        if (mcd && !memcmp(cluuid, mcd->mcd_uuid,
+                                           sizeof(mcd->mcd_uuid))) {
+                                CDEBUG(D_INFO, 
+                                       "existing export for UUID '%s' at %p\n",
+                                       cluuid, exp);
+                                if (exp->exp_obd != obd) 
+                                        LBUG();
+                                exp->exp_rconnh.addr = conn->addr;
+                                exp->exp_rconnh.cookie = conn->cookie;
+                                conn->addr = (__u64) (unsigned long)exp;
+                                conn->cookie = exp->exp_cookie;
+                                CDEBUG(D_IOCTL, "connect: addr %Lx cookie %Lx\n",
+                                       (long long)conn->addr,
+                                       (long long)conn->cookie);
+                                return 0;
+                        }
+                }
+        }
+        rc = class_connect(conn, obd, NULL);
 
         if (rc)
                 MOD_DEC_USE_COUNT;
index aa59bbf..fe9383e 100644 (file)
@@ -401,7 +401,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
         case OBD_IOC_CONNECT: {
                 obd_data2conn(&conn, data);
 
-                err = obd_connect(&conn, obd);
+                err = obd_connect(&conn, obd, NULL);
 
                 CDEBUG(D_IOCTL, "assigned export %Lx\n", conn.addr);
                 obd_conn2data(data, &conn);
index 4d7f91d..29cdbc1 100644 (file)
@@ -281,7 +281,8 @@ struct obd_export *class_new_export(struct obd_device *obddev)
 
 /* a connection defines an export context in which preallocation can
    be managed. */
-int class_connect (struct lustre_handle *conn, struct obd_device *obd)
+int class_connect (struct lustre_handle *conn, struct obd_device *obd,
+                   char *cluuid)
 {
         struct obd_export * export;
         if (conn == NULL) {
index 979467c..6224cfc 100644 (file)
@@ -19,6 +19,7 @@
  *   You should have received a copy of the GNU General Public License
  *   along with Lustre; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 
 /* OBD devices materialize in /proc as a directory:
  *              /proc/lustre/obd/<number>
index 3c0c33f..79e30d7 100644 (file)
@@ -11,8 +11,8 @@
  * by Peter Braam <braam@clusterfs.com>
  */
 
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.19 2002/07/31 20:49:37 braam Exp $";
-#define OBDECHO_VERSION "$Revision: 1.19 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.20 2002/08/07 21:46:32 shaver Exp $";
+#define OBDECHO_VERSION "$Revision: 1.20 $"
 
 #define EXPORT_SYMTAB
 
@@ -92,12 +92,13 @@ echo_proc_fini(void)
         remove_proc_entry(ECHO_PROC_STAT, 0);
 }
 
-static int echo_connect(struct lustre_handle *conn, struct obd_device *obd)
+static int echo_connect(struct lustre_handle *conn, struct obd_device *obd,
+                        char *cluuid)
 {
         int rc;
 
         MOD_INC_USE_COUNT;
-        rc = class_connect(conn, obd);
+        rc = class_connect(conn, obd, NULL);
 
         if (rc)
                 MOD_DEC_USE_COUNT;
index e2ceb0e..c45d715 100644 (file)
@@ -354,12 +354,13 @@ static struct inode *filter_inode_from_obj(struct obd_device *obddev,
 }
 
 /* obd methods */
-static int filter_connect(struct lustre_handle *conn, struct obd_device *obd)
+static int filter_connect(struct lustre_handle *conn, struct obd_device *obd,
+                          char *cluuid)
 {
         int rc;
         ENTRY;
         MOD_INC_USE_COUNT;
-        rc = class_connect(conn, obd);
+        rc = class_connect(conn, obd, cluuid);
         if (rc)
                 MOD_DEC_USE_COUNT;
         RETURN(rc);
index 9cdf336..bed58f1 100644 (file)
@@ -576,7 +576,7 @@ static int ost_setup(struct obd_device *obddev, obd_count len, void *buf)
                 GOTO(error_dec, err = -EINVAL);
         }
 
-        err = obd_connect(&ost->ost_conn, tgt);
+        err = obd_connect(&ost->ost_conn, tgt, NULL);
         if (err) {
                 CERROR("fail to connect to device %d\n", data->ioc_dev);
                 GOTO(error_dec, err = -EINVAL);