Whamcloud - gitweb
- rename ha_mgr to recovd
authorbraam <braam>
Mon, 22 Apr 2002 05:57:35 +0000 (05:57 +0000)
committerbraam <braam>
Mon, 22 Apr 2002 05:57:35 +0000 (05:57 +0000)
- rename connmgr_obd to recovd_obd
- pack fids as part of body_pack/body_unpack
- do body_pack/unpack for both requests and replies
- clean up 3 different groups of constants:
 - PTL_RPC_MSG_ERR/REQUEST -- into _idl: part of lustre_msg
 - PTL_RPC_FL_{TIMEOUT,REPLY...,} -- bitmask part of request->rq_flags
      will control the state machine for recovery somewhat
 - PTL_RPC_TYPE_REQUEST/REPLY -- request->rq_type:
      to determine what kind of packet is being sent
- ptlrpc_error: set the msg type field to an error message, otherwise
  the reply body is accidentally unpacked
- add a c_level field to the connection: the level will control what
  RPC's will go out during recovery and which ones are held up until
  recovery completes. This will be compared with an rq_level field
  (still to be added).
- mdc_connect further finished:
 - it gets the fid of ROOT on the MDS and
 - llite/super.c now uses that as the root inode. Didn't see major
   havoc.
 - the mds has a mds_rootfid field accordingly. This is set in
   mds_prep.

21 files changed:
lustre/include/linux/lustre_ha.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_lite.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/lustre_net.h
lustre/include/linux/obd.h
lustre/include/linux/obd_support.h
lustre/ldlm/ldlm_lockd.c
lustre/lib/mds_updates.c
lustre/llite/super.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlrpc/client.c
lustre/ptlrpc/connection.c
lustre/ptlrpc/events.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/recovd.c
lustre/ptlrpc/rpc.c
lustre/ptlrpc/service.c

index ba61536..f23d1a7 100644 (file)
 
 #define CONNMGR_CONNECT 1
 
-extern struct connmgr_obd *ptlrpc_connmgr;
+extern struct recovd_obd *ptlrpc_connmgr;
 
 struct connmgr_thread {
-        struct connmgr_obd *mgr;
+        struct recovd_obd *mgr;
         char *name;
 };
 
 struct connmgr_body {
         __u64 conn;
         __u64 conn_token;
-
         __u32 generation;
 };
 
-int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *conn);
+int connmgr_connect(struct recovd_obd *mgr, struct ptlrpc_connection *conn);
 int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc,
                    struct ptlrpc_request *req);
 void connmgr_cli_fail(struct ptlrpc_client *cli);
-void connmgr_cli_manage(struct connmgr_obd *mgr, struct ptlrpc_client *cli);
-int recovd_setup(struct connmgr_obd *mgr);
-int recovd_cleanup(struct connmgr_obd *mgr);
+void connmgr_cli_manage(struct recovd_obd *mgr, struct ptlrpc_client *cli);
+int recovd_setup(struct recovd_obd *mgr);
+int recovd_cleanup(struct recovd_obd *mgr);
 
 #endif
index 7c1a274..260a26c 100644 (file)
@@ -42,6 +42,9 @@
  * - ioctl's
  */
 
+#define PTL_RPC_MSG_REQUEST 4711
+#define PTL_RPC_MSG_ERR 4712
+
 struct lustre_msg {
         __u64 conn;
         __u64 token;
@@ -256,23 +259,6 @@ struct mds_rec_rename {
         struct ll_fid   rn_fid2;
 };
 
-#ifdef __KERNEL__
-
-static inline void ll_ino2fid(struct ll_fid *fid, ino_t ino, __u32 generation,
-                              int type)
-{
-        fid->id = HTON__u64((__u64)ino);
-        fid->generation = HTON__u32(generation);
-        fid->f_type = HTON__u32(type);
-}
-
-static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
-{
-        ll_ino2fid(fid, inode->i_ino, inode->i_generation,
-                   inode->i_mode & S_IFMT);
-}
-
-#endif
 
 /*
  *   LDLM requests:
index bc43dc4..6cd5e57 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * object based disk file system
+ * lustre lite cluster file system
  * 
  * This code is issued under the GNU General Public License.
  * See the file COPYING in this distribution
@@ -80,6 +80,20 @@ static inline struct obd_conn *ll_i2obdconn(struct inode *inode)
         return &(ll_i2sbi(inode))->ll_conn;
 }
 
+static inline void ll_ino2fid(struct ll_fid *fid, ino_t ino, __u32 generation,
+                              int type)
+{
+        fid->id = (__u64)ino;
+        fid->generation = generation;
+        fid->f_type = type;
+}
+
+static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
+{
+        ll_ino2fid(fid, inode->i_ino, inode->i_generation,
+                   inode->i_mode & S_IFMT);
+}
+
 /* dir.c */
 extern struct file_operations ll_dir_operations;
 extern struct inode_operations ll_dir_inode_operations;
index b9d08be..84f7aed 100644 (file)
@@ -62,8 +62,10 @@ struct mds_update_record {
 int mds_reint_rec(struct mds_update_record *r, struct ptlrpc_request *req); 
 
 /* lib/mds_updates.c */
-void mds_pack_body(struct ptlrpc_request *);
-void mds_unpack_body(struct ptlrpc_request *);
+void mds_pack_req_body(struct ptlrpc_request *);
+void mds_pack_rep_body(struct ptlrpc_request *);
+void mds_unpack_req_body(struct ptlrpc_request *);
+void mds_unpack_rep_body(struct ptlrpc_request *);
 int mds_update_unpack(struct ptlrpc_request *, struct mds_update_record *);
 
 void mds_setattr_pack(struct mds_rec_setattr *, struct inode *, struct iattr *);
@@ -79,6 +81,8 @@ void mds_rename_pack(struct mds_rec_rename *, struct inode *srcdir,
 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt);
 
 /* llight/request.c */
+int mdc_connect(struct ptlrpc_client *, struct ptlrpc_connection *, 
+                struct ll_fid *rootfid, struct ptlrpc_request **);
 int mdc_getattr(struct ptlrpc_client *, struct ptlrpc_connection *, ino_t ino,
                 int type, int valid, struct ptlrpc_request **);
 int mdc_setattr(struct ptlrpc_client *, struct ptlrpc_connection *,
index 3dea905..85bf1a7 100644 (file)
 #define SVC_HA_EVENT 32
 #define SVC_SIGNAL   64
 
+
+#define LUSTRE_CONN_NEW    1
+#define LUSTRE_CONN_CON    2
+#define LUSTRE_CONN_RECOVD 3
+#define LUSTRE_CONN_FULL   4
+
 struct ptlrpc_connection {
         struct list_head c_link;
         struct lustre_peer c_peer;
 
+        int c_level;
         __u32 c_generation;  /* changes upon new connection */
         __u32 c_epoch;       /* changes when peer changes */
         __u32 c_bootcount;   /* peer's boot count */ 
@@ -94,18 +101,21 @@ struct ptlrpc_client {
         struct list_head cli_sent_head;
         struct list_head cli_ha_item; 
 
-        struct connmgr_obd *cli_ha_mgr;
+        struct recovd_obd *cli_recovd;
 };
 
-/* These do double-duty in rq_type and rq_flags */
-#define PTL_RPC_INTR    1
-#define PTL_RPC_REQUEST 2
-#define PTL_RPC_REPLY   3
-#define PTL_RPC_BULK    4
-#define PTL_RPC_SENT    5
-#define PTL_BULK_SENT   6
-#define PTL_BULK_RCVD   7
-#define PTL_RPC_ERR     8
+/* packet types */
+#define PTL_RPC_TYPE_REQUEST 2
+#define PTL_RPC_TYPE_REPLY   3
+
+/* state flags of requests */
+#define PTL_RPC_FL_INTR    1
+#define PTL_RPC_FL_REPLY   2
+#define PTL_RPC_FL_SENT    4
+#define PTL_BULK_FL_SENT   8
+#define PTL_BULK_FL_RCVD   16
+#define PTL_RPC_FL_ERR     32
+#define PTL_RPC_FL_TIMEOUT 64
 
 struct ptlrpc_request { 
         int rq_type; /* one of PTL_RPC_REQUEST, PTL_RPC_REPLY, PTL_RPC_BULK */
@@ -217,7 +227,7 @@ int ptl_send_rpc(struct ptlrpc_request *request);
 void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i);
 
 /* rpc/client.c */
-void ptlrpc_init_client(struct connmgr_obd *, int req_portal, int rep_portal,
+void ptlrpc_init_client(struct recovd_obd *, int req_portal, int rep_portal,
                         struct ptlrpc_client *);
 struct ptlrpc_connection *ptlrpc_uuid_to_connection(char *uuid);
 int ptlrpc_queue_wait(struct ptlrpc_request *req);
index c2e5d4b..6604d53 100644 (file)
@@ -77,6 +77,7 @@ struct mds_obd {
         struct mds_fs_operations *mds_fsops;
         struct file *mds_last_rcvd;
         __u64 mds_mount_count;
+        struct ll_fid mds_rootfid;
 };
 
 struct ldlm_obd {
@@ -97,18 +98,19 @@ struct echo_obd {
         struct address_space_operations *eo_aops;
 };
 
-struct connmgr_obd {
-        time_t                mgr_waketime;
-        time_t                mgr_timeout;
-        struct ptlrpc_service *mgr_service;
-        struct ptlrpc_client  *mgr_client;
-        __u32                  mgr_flags; 
-        spinlock_t             mgr_lock;
-        struct list_head      mgr_connections_lh; /* connections managed by the mgr */
-        struct list_head      mgr_troubled_lh; /* connections in trouble */
-        wait_queue_head_t     mgr_ctl_waitq;
-        wait_queue_head_t     mgr_waitq;
-        struct task_struct    *mgr_thread;
+struct recovd_obd {
+        time_t                recovd_waketime;
+        time_t                recovd_timeout;
+        struct ptlrpc_service *recovd_service;
+        struct ptlrpc_client  *recovd_client;
+        __u32                  recovd_flags; 
+        spinlock_t             recovd_lock;
+        struct list_head      recovd_connections_lh; /* connections managed by the mgr */
+        struct list_head      recovd_troubled_lh; /* connections in trouble */
+        wait_queue_head_t     recovd_recovery_waitq;
+        wait_queue_head_t     recovd_ctl_waitq;
+        wait_queue_head_t     recovd_waitq;
+        struct task_struct    *recovd_thread;
 };
 
 struct trace_obd {
@@ -169,7 +171,7 @@ struct obd_device {
                 struct osc_obd osc;
                 struct ldlm_obd ldlm;
                 struct echo_obd echo;
-                struct connmgr_obd mgr;
+                struct recovd_obd recovd;
                 struct trace_obd trace;
 #if 0
                 struct raid1_obd raid1;
index 6e57009..f92b817 100644 (file)
@@ -54,6 +54,8 @@ extern unsigned long obd_fail_loc;
 #define OBD_FAIL_MDS_OPEN_PACK           0x114
 #define OBD_FAIL_MDS_CLOSE_NET           0x115
 #define OBD_FAIL_MDS_CLOSE_PACK          0x116
+#define OBD_FAIL_MDS_CONNECT_NET         0x117
+#define OBD_FAIL_MDS_CONNECT_PACK       0x118
 
 #define OBD_FAIL_OST                     0x200
 #define OBD_FAIL_OST_CONNECT_NET         0x201
index b259286..4e97c14 100644 (file)
@@ -184,7 +184,7 @@ static int ldlm_handle(struct obd_device *dev, struct ptlrpc_service *svc,
                 GOTO(out, rc);
         }
 
-        if (req->rq_reqmsg->type != PTL_RPC_REQUEST) {
+        if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
                 CERROR("lustre_ldlm: wrong packet type sent %d\n",
                        req->rq_reqmsg->type);
                 GOTO(out, rc = -EINVAL);
index 3580370..0285002 100644 (file)
 #include <linux/obd_support.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_mds.h>
+#include <linux/lustre_lite.h>
 
-void mds_pack_body(struct ptlrpc_request *req)
+void mds_pack_fid(struct ll_fid *fid)
+{
+        fid->id = HTON__u64(fid->id);
+        fid->generation = HTON__u32(fid->generation);
+        fid->f_type = HTON__u32(fid->f_type);
+}
+
+static void mds_pack_body(struct mds_body *b)
 {
-        struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, 0);
         if (b == NULL)
                 LBUG();
 
-        /* fid1/fid2 are already packed by another function */
+        mds_pack_fid(&b->fid1);
+        mds_pack_fid(&b->fid2);
         b->objid = HTON__u64(b->objid);
         b->size = HTON__u64(b->size);
         b->valid = HTON__u32(b->valid);
@@ -59,6 +67,19 @@ void mds_pack_body(struct ptlrpc_request *req)
         b->generation = HTON__u32(b->generation);
 }
 
+void mds_pack_req_body(struct ptlrpc_request *req) 
+{
+        struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, 0);
+        mds_pack_body(b);
+}
+
+void mds_pack_rep_body(struct ptlrpc_request *req) 
+{
+        struct mds_body *b = lustre_msg_buf(req->rq_repmsg, 0);
+        mds_pack_body(b);
+}
+
+
 /* packing of MDS records */
 void mds_create_pack(struct mds_rec_create *rec, struct inode *inode,
                      __u32 mode, __u64 id, __u32 uid, __u32 gid, __u64 time)
@@ -115,12 +136,20 @@ void mds_rename_pack(struct mds_rec_rename *rec, struct inode *srcdir,
 }
 
 /* unpacking */
-void mds_unpack_body(struct ptlrpc_request *req)
+void mds_unpack_fid(struct ll_fid *fid)
+{
+        fid->id = NTOH__u64(fid->id);
+        fid->generation = NTOH__u32(fid->generation);
+        fid->f_type = NTOH__u32(fid->f_type);
+}
+
+static void mds_unpack_body(struct mds_body *b)
 {
-        struct mds_body *b = lustre_msg_buf(req->rq_repmsg, 0);
         if (b == NULL)
                 LBUG();
 
+        mds_unpack_fid(&b->fid1);
+        mds_unpack_fid(&b->fid2);
         b->objid = NTOH__u64(b->objid);
         b->size = NTOH__u64(b->size);
         b->valid = NTOH__u32(b->valid);
@@ -138,6 +167,19 @@ void mds_unpack_body(struct ptlrpc_request *req)
         b->generation = NTOH__u32(b->generation);
 }
 
+
+void mds_unpack_req_body(struct ptlrpc_request *req) 
+{
+        struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, 0);
+        mds_unpack_body(b);
+}
+
+void mds_unpack_rep_body(struct ptlrpc_request *req) 
+{
+        struct mds_body *b = lustre_msg_buf(req->rq_repmsg, 0);
+        mds_unpack_body(b);
+}
+
 static int mds_setattr_unpack(struct ptlrpc_request *req,
                               struct mds_update_record *r)
 {
index 6bc188c..148c096 100644 (file)
@@ -83,6 +83,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
         char *version = NULL;
         int devno;
         int err;
+        struct ll_fid rootfid;
         struct ptlrpc_request *request = NULL;
 
         ENTRY;
@@ -131,7 +132,16 @@ static struct super_block * ll_read_super(struct super_block *sb,
                 GOTO(out_disc, sb = NULL);
         }
 
-        sbi->ll_rootino = 2;
+        sbi->ll_mds_conn->c_level = LUSTRE_CONN_FULL;
+
+        err= mdc_connect(&sbi->ll_mds_client, sbi->ll_mds_conn, 
+                    &rootfid, &request); 
+        CERROR("rootfid %Ld\n", rootfid.id);
+        if (err) { 
+                CERROR("cannot mds_connect %d\n", err);
+                GOTO(out_disc, sb = NULL);
+        }
+        sbi->ll_rootino = rootfid.id;
 
         sb->s_maxbytes = 1LL << 36;
         sb->s_blocksize = PAGE_SIZE;
index 17a8ee1..d747d18 100644 (file)
 #define DEBUG_SUBSYSTEM S_MDC
 
 #include <linux/lustre_mds.h>
+#include <linux/lustre_lite.h>
 
 #define REQUEST_MINOR 244
 
 extern int mds_queue_req(struct ptlrpc_request *);
 
 int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
-                ino_t ino, int type, int valid, struct ptlrpc_request **request)
+                struct ll_fid *rootfid, struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
@@ -46,18 +47,19 @@ int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
                 GOTO(out, rc = -ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, 0);
-        ll_ino2fid(&body->fid1, ino, 0, type);
-        body->valid = valid;
-
         req->rq_replen = lustre_msg_size(1, &size);
 
+        mds_pack_req_body(req); 
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
 
         if (!rc) {
-                mds_unpack_body(req);
+                mds_unpack_rep_body(req);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
-                CDEBUG(D_NET, "mode: %o\n", body->mode);
+                memcpy(rootfid, &body->fid1, sizeof(*rootfid)); 
+
+                CDEBUG(D_NET, "root ino: %Ld\n", rootfid->id);
+                
         }
 
         EXIT;
@@ -89,7 +91,7 @@ int mdc_getattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         rc = ptlrpc_check_status(req, rc);
 
         if (!rc) {
-                mds_unpack_body(req);
+                mds_unpack_rep_body(req);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
                 CDEBUG(D_NET, "mode: %o\n", body->mode);
         }
@@ -122,7 +124,7 @@ int mdc_open(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         rc = ptlrpc_check_status(req, rc);
 
         if (!rc) {
-                mds_unpack_body(req);
+                mds_unpack_rep_body(req);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
                 *fh = body->objid;
         }
@@ -210,7 +212,7 @@ int mdc_readpage(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
                 GOTO(out, rc);
         }
 
-        mds_unpack_body(req);
+        mds_unpack_rep_body(req);
         EXIT;
 
  out:
@@ -363,11 +365,12 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
 MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0");
 MODULE_LICENSE("GPL");
 
+EXPORT_SYMBOL(mdc_connect);
+EXPORT_SYMBOL(mdc_getattr);
 EXPORT_SYMBOL(mdc_create);
 EXPORT_SYMBOL(mdc_unlink);
 EXPORT_SYMBOL(mdc_rename);
 EXPORT_SYMBOL(mdc_link);
-EXPORT_SYMBOL(mdc_getattr);
 EXPORT_SYMBOL(mdc_readpage);
 EXPORT_SYMBOL(mdc_setattr);
 EXPORT_SYMBOL(mdc_close);
index 8b5792c..721e443 100644 (file)
@@ -78,7 +78,7 @@ int mds_sendpage(struct ptlrpc_request *req, struct file *file,
         wait_event_interruptible(bulk->b_waitq,
                                  ptlrpc_check_bulk_sent(bulk));
 
-        if (bulk->b_flags == PTL_RPC_INTR) {
+        if (bulk->b_flags & PTL_RPC_FL_INTR) {
                 rc = -EINTR;
                 GOTO(cleanup_buf, rc);
         }
@@ -155,6 +155,30 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
         return result;
 }
 
+int mds_connect(struct ptlrpc_request *req)
+{
+        struct mds_body *body;
+        struct mds_obd *mds = &req->rq_obd->u.mds;
+        int rc, size = sizeof(*body);
+        ENTRY;
+
+        rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
+        if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_CONNECT_PACK)) {
+                CERROR("mds: out of memory\n");
+                req->rq_status = -ENOMEM;
+                RETURN(0);
+        }
+
+        body = lustre_msg_buf(req->rq_reqmsg, 0);
+        mds_unpack_req_body(req); 
+        /* Anything we need to do here with the client's trans no or so? */
+
+        body = lustre_msg_buf(req->rq_repmsg, 0);
+        memcpy(&body->fid1, &mds->mds_rootfid  , sizeof(body->fid1)); 
+        mds_pack_rep_body(req);
+        RETURN(0);
+}
+
 int mds_getattr(struct ptlrpc_request *req)
 {
         struct dentry *de;
@@ -340,13 +364,19 @@ int mds_handle(struct obd_device *dev, struct ptlrpc_service *svc,
                 GOTO(out, rc);
         }
 
-        if (req->rq_reqmsg->type != PTL_RPC_REQUEST) {
+        if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
                 CERROR("lustre_mds: wrong packet type sent %d\n",
                        req->rq_reqmsg->type);
                 GOTO(out, rc = -EINVAL);
         }
 
         switch (req->rq_reqmsg->opc) {
+        case MDS_CONNECT:
+                CDEBUG(D_INODE, "getattr\n");
+                OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
+                rc = mds_connect(req);
+                break;
+
         case MDS_GETATTR:
                 CDEBUG(D_INODE, "getattr\n");
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
@@ -428,6 +458,22 @@ static int mds_prep(struct obd_device *obddev)
                 CERROR("cannot create ROOT directory\n");
                 GOTO(err_svc, rc);
         }
+        f = filp_open("ROOT", O_RDONLY, 0); 
+        if (!f || IS_ERR(f)) { 
+                CERROR("cannot open ROOT\n"); 
+                LBUG();
+        }
+        
+        mds->mds_rootfid.id = f->f_dentry->d_inode->i_ino;
+        mds->mds_rootfid.generation = f->f_dentry->d_inode->i_generation;
+        mds->mds_rootfid.f_type = S_IFDIR;
+
+        rc = filp_close(f, 0);
+        if (rc) { 
+                CERROR("cannot close ROOT\n"); 
+                LBUG();
+        }
+
         rc = simple_mkdir(current->fs->pwd, "FH", 0700);
         if (rc && rc != -EEXIST) {
                 CERROR("cannot create FH directory\n");
index 93923de..ac951c3 100644 (file)
@@ -374,7 +374,7 @@ int osc_sendpage(struct obd_conn *conn, struct ptlrpc_request *req,
                 wait_event_interruptible(bulk->b_waitq,
                                          ptlrpc_check_bulk_sent(bulk));
 
-                if (bulk->b_flags == PTL_RPC_INTR) {
+                if (bulk->b_flags & PTL_RPC_FL_INTR) {
                         ptlrpc_free_bulk(bulk);
                         RETURN(-EINTR);
                 }
index 1a70c99..ec2c30e 100644 (file)
@@ -325,7 +325,7 @@ static int ost_brw_read(struct ost_obd *obddev, struct ptlrpc_request *req)
                 wait_event_interruptible(bulk->b_waitq,
                                          ptlrpc_check_bulk_sent(bulk));
 
-                if (bulk->b_flags == PTL_RPC_INTR)
+                if (bulk->b_flags & PTL_RPC_FL_INTR)
                         GOTO(out, 0);
 
                 OBD_FREE(bulk, sizeof(*bulk));
@@ -486,7 +486,7 @@ static int ost_handle(struct obd_device *obddev, struct ptlrpc_service *svc,
                 GOTO(out, rc);
         }
 
-        if (req->rq_reqmsg->type != PTL_RPC_REQUEST) {
+        if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
                 CERROR("lustre_mds: wrong packet type sent %d\n",
                        req->rq_reqmsg->type);
                 GOTO(out, rc = -EINVAL);
index 33020fe..d79886b 100644 (file)
 
 #include <linux/lustre_ha.h>
 
-void ptlrpc_init_client(struct connmgr_obd *mgr, int req_portal,
+void ptlrpc_init_client(struct recovd_obd *recovd, int req_portal,
                         int rep_portal, struct ptlrpc_client *cl)
 {
         memset(cl, 0, sizeof(*cl));
-        cl->cli_ha_mgr = mgr;
-        if (mgr)
-                connmgr_cli_manage(mgr, cl);
+        cl->cli_recovd = recovd;
+        if (recovd)
+                connmgr_cli_manage(recovd, cl);
         cl->cli_obd = NULL;
         cl->cli_request_portal = req_portal;
         cl->cli_reply_portal = rep_portal;
@@ -107,13 +107,13 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
         }
 
         request->rq_time = CURRENT_TIME;
-        request->rq_type = PTL_RPC_REQUEST;
+        request->rq_type = PTL_RPC_TYPE_REQUEST;
         request->rq_connection = ptlrpc_connection_addref(conn);
 
         request->rq_reqmsg->conn = (__u64)(unsigned long)conn->c_remote_conn;
         request->rq_reqmsg->token = conn->c_remote_token;
         request->rq_reqmsg->opc = HTON__u32(opcode);
-        request->rq_reqmsg->type = HTON__u32(request->rq_type);
+        request->rq_reqmsg->type = HTON__u32(PTL_RPC_MSG_REQUEST);
         INIT_LIST_HEAD(&request->rq_list);
 
         spin_lock(&conn->c_lock);
@@ -150,13 +150,14 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req)
 
         schedule_timeout(3 * HZ);  /* 3 second timeout */
         if (req->rq_repmsg != NULL) {
-                req->rq_flags = PTL_RPC_REPLY;
+                req->rq_flags |= PTL_RPC_FL_REPLY;
                 GOTO(out, rc = 1);
         }
 
         if (CURRENT_TIME - req->rq_time >= 3) {
                 CERROR("-- REQ TIMEOUT --\n");
-                if (req->rq_client && req->rq_client->cli_ha_mgr)
+                req->rq_flags |= PTL_RPC_FL_TIMEOUT;
+                if (req->rq_client && req->rq_client->cli_recovd)
                         connmgr_cli_fail(req->rq_client);
                 return 0;
         }
@@ -164,7 +165,7 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req)
         if (sigismember(&(current->pending.signal), SIGKILL) ||
             sigismember(&(current->pending.signal), SIGTERM) ||
             sigismember(&(current->pending.signal), SIGINT)) {
-                req->rq_flags = PTL_RPC_INTR;
+                req->rq_flags |= PTL_RPC_FL_INTR;
                 GOTO(out, rc = 1);
         }
 
@@ -191,6 +192,11 @@ int ptlrpc_check_status(struct ptlrpc_request *req, int err)
                 RETURN(-ENOMEM);
         }
 
+        if (req->rq_repmsg->type == NTOH__u32(PTL_RPC_MSG_ERR)) {
+                CERROR("req->rq_repmsg->type == PTL_RPC_MSG_ERR\n");
+                RETURN(-EINVAL);
+        }
+
         if (req->rq_repmsg->status != 0) {
                 CERROR("req->rq_repmsg->status is %d\n",
                        req->rq_repmsg->status);
@@ -240,13 +246,13 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
         CDEBUG(D_OTHER, "-- done\n");
         ptlrpc_cleanup_request_buf(req);
         up(&req->rq_client->cli_rpc_sem);
-        if (req->rq_flags == PTL_RPC_INTR) {
+        if (req->rq_flags & PTL_RPC_FL_INTR) {
                 /* Clean up the dangling reply buffers */
                 ptlrpc_abort(req);
                 GOTO(out, rc = -EINTR);
         }
 
-        if (req->rq_flags != PTL_RPC_REPLY) {
+        if (! (req->rq_flags & PTL_RPC_FL_REPLY)) {
                 CERROR("Unknown reason for wakeup\n");
                 /* XXX Phil - I end up here when I kill obdctl */
                 ptlrpc_abort(req);
index 7ed2e9b..78c320c 100644 (file)
@@ -61,6 +61,7 @@ struct ptlrpc_connection *ptlrpc_get_connection(struct lustre_peer *peer)
         if (c == NULL)
                 GOTO(out, c);
 
+        c->c_level = LUSTRE_CONN_NEW;
         c->c_xid_in = 1;
         c->c_xid_out = 1;
         c->c_generation = 1;
index 4bfec2c..eb49df4 100644 (file)
@@ -154,7 +154,7 @@ static int bulk_source_callback(ptl_event_t *ev, void *data)
                 CDEBUG(D_NET, "got SENT event\n");
         } else if (ev->type == PTL_EVENT_ACK) {
                 CDEBUG(D_NET, "got ACK event\n");
-                bulk->b_flags = PTL_BULK_SENT;
+                bulk->b_flags |= PTL_BULK_FL_SENT;
                 wake_up_interruptible(&bulk->b_waitq);
         } else {
                 CERROR("Unexpected event type!\n");
@@ -174,7 +174,7 @@ static int bulk_sink_callback(ptl_event_t *ev, void *data)
         if (ev->type == PTL_EVENT_PUT) {
                 if (bulk->b_buf != ev->mem_desc.start + ev->offset)
                         CERROR("bulkbuf != mem_desc -- why?\n");
-                bulk->b_flags = PTL_BULK_RCVD;
+                bulk->b_flags |= PTL_BULK_FL_RCVD;
                 if (bulk->b_cb != NULL)
                         bulk->b_cb(bulk, data);
                 wake_up_interruptible(&bulk->b_waitq);
index af8465b..25503bf 100644 (file)
@@ -38,12 +38,12 @@ int ptlrpc_check_bulk_sent(struct ptlrpc_bulk_desc *bulk)
 {
         ENTRY;
 
-        if (bulk->b_flags == PTL_BULK_SENT)
+        if (bulk->b_flags & PTL_BULK_FL_SENT)
                 RETURN(1);
 
         if (sigismember(&(current->pending.signal), SIGKILL) ||
             sigismember(&(current->pending.signal), SIGINT)) {
-                bulk->b_flags = PTL_RPC_INTR;
+                bulk->b_flags |= PTL_RPC_FL_INTR;
                 RETURN(1);
         }
 
@@ -62,21 +62,14 @@ static int ptl_send_buf(struct ptlrpc_request *request,
         request->rq_req_md.user_ptr = request;
 
         switch (request->rq_type) {
-        case PTL_RPC_BULK:
-                request->rq_req_md.start = request->rq_bulkbuf;
-                request->rq_req_md.length = request->rq_bulklen;
-                request->rq_req_md.eventq = bulk_source_eq;
-                request->rq_req_md.threshold = 2; /* SENT and ACK events */
-                ack = PTL_ACK_REQ;
-                break;
-        case PTL_RPC_REQUEST:
+        case PTL_RPC_TYPE_REQUEST:
                 request->rq_req_md.start = request->rq_reqmsg;
                 request->rq_req_md.length = request->rq_reqlen;
                 request->rq_req_md.eventq = request_out_eq;
                 request->rq_req_md.threshold = 1;
                 ack = PTL_NOACK_REQ;
                 break;
-        case PTL_RPC_REPLY:
+        case PTL_RPC_TYPE_REPLY:
                 request->rq_req_md.start = request->rq_repmsg;
                 request->rq_req_md.length = request->rq_replen;
                 request->rq_req_md.eventq = reply_out_eq;
@@ -206,7 +199,7 @@ int ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *bulk)
 int ptlrpc_reply(struct ptlrpc_service *svc, struct ptlrpc_request *req)
 {
         /* FIXME: we need to increment the count of handled events */
-        req->rq_type = PTL_RPC_REPLY;
+        req->rq_type = PTL_RPC_TYPE_REPLY;
         req->rq_repmsg->conn = req->rq_connection->c_remote_conn;
         req->rq_repmsg->token = req->rq_connection->c_remote_token;
         req->rq_repmsg->xid = HTON__u32(req->rq_reqmsg->xid);
@@ -229,7 +222,7 @@ int ptlrpc_error(struct ptlrpc_service *svc, struct ptlrpc_request *req)
         if (rc)
                 RETURN(rc);
 
-        req->rq_repmsg->type = HTON__u32(PTL_RPC_ERR);
+        req->rq_repmsg->type = HTON__u32(PTL_RPC_MSG_ERR);
 
         rc = ptlrpc_reply(svc, req);
         RETURN(rc);
@@ -243,7 +236,7 @@ int ptl_send_rpc(struct ptlrpc_request *request)
 
         ENTRY;
 
-        if (NTOH__u32(request->rq_reqmsg->type) != PTL_RPC_REQUEST) {
+        if (NTOH__u32(request->rq_reqmsg->type) != PTL_RPC_MSG_REQUEST) {
                 CERROR("wrong packet type sent %d\n",
                        NTOH__u32(request->rq_reqmsg->type));
                 LBUG();
@@ -275,7 +268,7 @@ int ptl_send_rpc(struct ptlrpc_request *request)
                 GOTO(cleanup, rc);
         }
 
-        request->rq_type = PTL_RPC_REQUEST;
+        request->rq_type = PTL_RPC_TYPE_REQUEST;
         request->rq_reply_md.start = repbuf;
         request->rq_reply_md.length = request->rq_replen;
         request->rq_reply_md.threshold = 1;
index cd7f4a2..4a84101 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  linux/mds/handler.c
+ *  obd/rpc/recovd.c
  *
  *  Lustre High Availability Daemon
  *
 #include <linux/lustre_lite.h>
 #include <linux/lustre_ha.h>
 
-struct connmgr_obd *ptlrpc_connmgr;
+struct recovd_obd *ptlrpc_connmgr;
 
-void connmgr_cli_manage(struct connmgr_obd *mgr, struct ptlrpc_client *cli)
+void connmgr_cli_manage(struct recovd_obd *recovd, struct ptlrpc_client *cli)
 {
         ENTRY;
-        cli->cli_ha_mgr = mgr;
-        spin_lock(&mgr->mgr_lock);
-        list_add(&cli->cli_ha_item, &mgr->mgr_connections_lh);
-        spin_unlock(&mgr->mgr_lock);
+        cli->cli_recovd = recovd;
+        spin_lock(&recovd->recovd_lock);
+        list_add(&cli->cli_ha_item, &recovd->recovd_connections_lh);
+        spin_unlock(&recovd->recovd_lock);
         EXIT;
 }
 
 void connmgr_cli_fail(struct ptlrpc_client *cli)
 {
         ENTRY;
-        spin_lock(&cli->cli_ha_mgr->mgr_lock);
-        cli->cli_ha_mgr->mgr_flags |= SVC_HA_EVENT;
+        spin_lock(&cli->cli_recovd->recovd_lock);
+        cli->cli_recovd->recovd_flags |= SVC_HA_EVENT;
         list_del(&cli->cli_ha_item);
-        list_add(&cli->cli_ha_item, &cli->cli_ha_mgr->mgr_troubled_lh);
-        spin_unlock(&cli->cli_ha_mgr->mgr_lock);
-        wake_up(&cli->cli_ha_mgr->mgr_waitq);
+        list_add(&cli->cli_ha_item, &cli->cli_recovd->recovd_troubled_lh);
+        spin_unlock(&cli->cli_recovd->recovd_lock);
+        wake_up(&cli->cli_recovd->recovd_waitq);
         EXIT;
 }
 
@@ -69,7 +69,7 @@ static void connmgr_unpack_body(struct ptlrpc_request *req)
         b->generation = NTOH__u32(b->generation);
 }
 
-int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *conn)
+int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn)
 {
         struct ptlrpc_request *req;
         struct ptlrpc_client *cl;
@@ -77,11 +77,11 @@ int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *conn)
         int rc, size = sizeof(*body);
         ENTRY;
 
-        if (!mgr) {
+        if (!recovd) {
                 CERROR("no manager\n");
                 LBUG();
         }
-        cl = mgr->mgr_client;
+        cl = recovd->recovd_client;
 
         req = ptlrpc_prep_req(cl, conn, CONNMGR_CONNECT, 1, &size, NULL);
         if (!req)
@@ -99,7 +99,8 @@ int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *conn)
         if (!rc) {
                 connmgr_unpack_body(req);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
-                CDEBUG(D_NET, "mode: %o\n", body->generation);
+                CDEBUG(D_NET, "remote generation: %o\n", body->generation);
+                conn->c_level = LUSTRE_CONN_CON;
                 conn->c_remote_conn = body->conn;
                 conn->c_remote_token = body->conn_token;
         }
@@ -135,6 +136,7 @@ static int connmgr_handle_connect(struct ptlrpc_request *req)
         body->conn = (__u64)(unsigned long)req->rq_connection;
         body->conn_token = req->rq_connection->c_token;
 
+        req->rq_connection->c_level = LUSTRE_CONN_CON;
         RETURN(0);
 }
 
@@ -150,7 +152,7 @@ int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc,
                 GOTO(out, rc);
         }
 
-        if (req->rq_reqmsg->type != PTL_RPC_REQUEST) {
+        if (req->rq_reqmsg->type != NTOH__u32(PTL_RPC_MSG_REQUEST)) {
                 CERROR("wrong packet type sent %d\n",
                        req->rq_reqmsg->type);
                 GOTO(out, rc = -EINVAL);
@@ -158,8 +160,7 @@ int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc,
 
         switch (req->rq_reqmsg->opc) {
         case CONNMGR_CONNECT:
-                CDEBUG(D_INODE, "connect\n");
-                OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
+                CDEBUG(D_INODE, "connmgr connect\n");
                 rc = connmgr_handle_connect(req);
                 break;
 
@@ -180,75 +181,73 @@ out:
         return 0;
 }
 
-static int recovd_check_event(struct connmgr_obd *mgr)
+static int recovd_check_event(struct recovd_obd *recovd)
 {
         int rc = 0;
         ENTRY;
 
-        spin_lock(&mgr->mgr_lock);
+        spin_lock(&recovd->recovd_lock);
 
-        if (!(mgr->mgr_flags & MGR_WORKING) &&
-            !list_empty(&mgr->mgr_troubled_lh)) {
+        if (!(recovd->recovd_flags & MGR_WORKING) &&
+            !list_empty(&recovd->recovd_troubled_lh)) {
 
                 CERROR("connection in trouble - state: WORKING, upcall\n");
-                mgr->mgr_flags = MGR_WORKING;
-
-                mgr->mgr_waketime = CURRENT_TIME;
-                mgr->mgr_timeout = 5 * HZ;
-                schedule_timeout(mgr->mgr_timeout);
+                recovd->recovd_flags = MGR_WORKING;
 
+                recovd->recovd_waketime = CURRENT_TIME;
+                recovd->recovd_timeout = 5 * HZ;
+                schedule_timeout(recovd->recovd_timeout);
         }
 
-        if (mgr->mgr_flags & MGR_WORKING &&
-            CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout) {
+        if (recovd->recovd_flags & MGR_WORKING &&
+            CURRENT_TIME <= recovd->recovd_waketime + recovd->recovd_timeout) {
                 CERROR("WORKING: new event\n");
 
-                mgr->mgr_waketime = CURRENT_TIME;
-                schedule_timeout(mgr->mgr_timeout);
+                recovd->recovd_waketime = CURRENT_TIME;
+                schedule_timeout(recovd->recovd_timeout);
         }
 
-        if (mgr->mgr_flags & MGR_STOPPING) {
+        if (recovd->recovd_flags & MGR_STOPPING) {
                 CERROR("ha mgr stopping\n");
                 rc = 1;
         }
 
-        spin_unlock(&mgr->mgr_lock);
+        spin_unlock(&recovd->recovd_lock);
         RETURN(rc);
 }
 
-static int recovd_handle_event(struct connmgr_obd *mgr)
+static int recovd_handle_event(struct recovd_obd *recovd)
 {
-        spin_lock(&mgr->mgr_lock);
+        spin_lock(&recovd->recovd_lock);
 
-        if (!(mgr->mgr_flags & MGR_WORKING) &&
-            !list_empty(&mgr->mgr_troubled_lh)) {
+        if (!(recovd->recovd_flags & MGR_WORKING) &&
+            !list_empty(&recovd->recovd_troubled_lh)) {
 
                 CERROR("connection in trouble - state: WORKING, upcall\n");
-                mgr->mgr_flags = MGR_WORKING;
+                recovd->recovd_flags = MGR_WORKING;
 
 
                 connmgr_upcall();
-                mgr->mgr_waketime = CURRENT_TIME;
-                mgr->mgr_timeout = 5 * HZ;
-                schedule_timeout(mgr->mgr_timeout);
+                recovd->recovd_waketime = CURRENT_TIME;
+                recovd->recovd_timeout = 5 * HZ;
+                schedule_timeout(recovd->recovd_timeout);
         }
 
-        if (mgr->mgr_flags & MGR_WORKING &&
-            CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout) {
+        if (recovd->recovd_flags & MGR_WORKING &&
+            CURRENT_TIME <= recovd->recovd_waketime + recovd->recovd_timeout) {
                 CERROR("WORKING: new event\n");
 
-                mgr->mgr_waketime = CURRENT_TIME;
-                schedule_timeout(mgr->mgr_timeout);
+                recovd->recovd_waketime = CURRENT_TIME;
+                schedule_timeout(recovd->recovd_timeout);
         }
 
-        spin_unlock(&mgr->mgr_lock);
+        spin_unlock(&recovd->recovd_lock);
         return 0;
 }
 
 static int recovd_main(void *arg)
 {
-        struct connmgr_thread *data = (struct connmgr_thread *)arg;
-        struct connmgr_obd *mgr = data->mgr;
+        struct recovd_obd *recovd = (struct recovd_obd *)arg;
 
         ENTRY;
 
@@ -259,70 +258,67 @@ static int recovd_main(void *arg)
         recalc_sigpending(current);
         spin_unlock_irq(&current->sigmask_lock);
 
-        sprintf(current->comm, data->name);
+        sprintf(current->comm, "lustre_recovd");
 
         /* Record that the  thread is running */
-        mgr->mgr_thread = current;
-        mgr->mgr_flags = MGR_RUNNING;
-        wake_up(&mgr->mgr_ctl_waitq);
+        recovd->recovd_thread = current;
+        recovd->recovd_flags = MGR_RUNNING;
+        wake_up(&recovd->recovd_ctl_waitq);
 
         /* And now, loop forever on requests */
         while (1) {
-                wait_event_interruptible(mgr->mgr_waitq,
-                                         recovd_check_event(mgr));
+                wait_event_interruptible(recovd->recovd_waitq,
+                                         recovd_check_event(recovd));
 
-                spin_lock(&mgr->mgr_lock);
-                if (mgr->mgr_flags & MGR_STOPPING) {
-                        spin_unlock(&mgr->mgr_lock);
+                spin_lock(&recovd->recovd_lock);
+                if (recovd->recovd_flags & MGR_STOPPING) {
+                        spin_unlock(&recovd->recovd_lock);
                         CERROR("lustre_hamgr quitting\n");
                         EXIT;
                         break;
                 }
 
-                recovd_handle_event(mgr);
-                spin_unlock(&mgr->mgr_lock);
+                recovd_handle_event(recovd);
+                spin_unlock(&recovd->recovd_lock);
         }
 
-        mgr->mgr_thread = NULL;
-        mgr->mgr_flags = MGR_STOPPED;
-        wake_up(&mgr->mgr_ctl_waitq);
+        recovd->recovd_thread = NULL;
+        recovd->recovd_flags = MGR_STOPPED;
+        wake_up(&recovd->recovd_ctl_waitq);
         CDEBUG(D_NET, "mgr exiting process %d\n", current->pid);
         RETURN(0);
 }
 
-int recovd_setup(struct connmgr_obd *mgr)
+int recovd_setup(struct recovd_obd *recovd)
 {
-        struct connmgr_thread d;
         int rc;
         ENTRY;
 
-        INIT_LIST_HEAD(&mgr->mgr_connections_lh);
-        INIT_LIST_HEAD(&mgr->mgr_troubled_lh);
-        spin_lock_init(&mgr->mgr_lock);
-
-        d.mgr = mgr;
-        d.name = "lustre_recovd";
+        INIT_LIST_HEAD(&recovd->recovd_connections_lh);
+        INIT_LIST_HEAD(&recovd->recovd_troubled_lh);
+        spin_lock_init(&recovd->recovd_lock);
 
-        init_waitqueue_head(&mgr->mgr_waitq);
-        init_waitqueue_head(&mgr->mgr_ctl_waitq);
+        init_waitqueue_head(&recovd->recovd_waitq);
+        init_waitqueue_head(&recovd->recovd_recovery_waitq);
+        init_waitqueue_head(&recovd->recovd_ctl_waitq);
 
-        rc = kernel_thread(recovd_main, (void *) &d,
+        rc = kernel_thread(recovd_main, (void *)recovd,
                            CLONE_VM | CLONE_FS | CLONE_FILES);
         if (rc < 0) {
                 CERROR("cannot start thread\n");
                 RETURN(-EINVAL);
         }
-        wait_event(mgr->mgr_ctl_waitq, mgr->mgr_flags & MGR_RUNNING);
+        wait_event(recovd->recovd_ctl_waitq, recovd->recovd_flags & MGR_RUNNING);
 
         RETURN(0);
 }
 
-int recovd_cleanup(struct connmgr_obd *mgr)
+int recovd_cleanup(struct recovd_obd *recovd)
 {
-        mgr->mgr_flags = MGR_STOPPING;
+        recovd->recovd_flags = MGR_STOPPING;
 
-        wake_up(&mgr->mgr_waitq);
-        wait_event_interruptible(mgr->mgr_ctl_waitq,
-                                 (mgr->mgr_flags & MGR_STOPPED));
+        wake_up(&recovd->recovd_waitq);
+        wait_event_interruptible(recovd->recovd_ctl_waitq,
+                                 (recovd->recovd_flags & MGR_STOPPED));
         RETURN(0);
 }
index e1bc4fc..0d783c7 100644 (file)
@@ -33,77 +33,77 @@ extern void ptlrpc_exit_portals(void);
 
 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
 {
-        struct connmgr_obd *mgr = &obddev->u.mgr;
+        struct recovd_obd *recovd = &obddev->u.recovd;
         int err;
         ENTRY;
 
-        memset(mgr, 0, sizeof(*mgr));
+        memset(recovd, 0, sizeof(*recovd));
 
-        OBD_ALLOC(mgr->mgr_client, sizeof(*mgr->mgr_client));
-        if (!mgr)
+        OBD_ALLOC(recovd->recovd_client, sizeof(*recovd->recovd_client));
+        if (!recovd)
                 RETURN(-ENOMEM);
 
-        err = recovd_setup(mgr);
+        err = recovd_setup(recovd);
         if (err)
                 GOTO(err_free, err);
 
-        mgr->mgr_service =
+        recovd->recovd_service =
                 ptlrpc_init_svc(128 * 1024,CONNMGR_REQUEST_PORTAL,
                                 CONNMGR_REPLY_PORTAL, "self", connmgr_handle);
-        if (!mgr->mgr_service) {
+        if (!recovd->recovd_service) {
                 CERROR("failed to start service\n");
                 GOTO(err_recovd, err = -EINVAL);
         }
 
         ptlrpc_init_client(NULL, CONNMGR_REQUEST_PORTAL, 
-                           CONNMGR_REPLY_PORTAL, mgr->mgr_client);
+                           CONNMGR_REPLY_PORTAL, recovd->recovd_client);
 
-        err = ptlrpc_start_thread(obddev, mgr->mgr_service, "lustre_connmgr");
+        err = ptlrpc_start_thread(obddev, recovd->recovd_service, "lustre_connmgr");
         if (err) {
                 CERROR("cannot start thread\n");
                 GOTO(err_svc, err);
         }
 
         MOD_INC_USE_COUNT;
-        ptlrpc_connmgr = mgr;
+        ptlrpc_connmgr = recovd;
         RETURN(0);
 
  err_svc: 
-        rpc_unregister_service(mgr->mgr_service);
+        rpc_unregister_service(recovd->recovd_service);
  err_recovd: 
-        recovd_cleanup(mgr); 
+        recovd_cleanup(recovd); 
  err_free:
-        if (mgr->mgr_client)
-                OBD_FREE(mgr->mgr_client, sizeof(*mgr->mgr_client));
+        if (recovd->recovd_client)
+                OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
         RETURN(err);
 }
 
 int connmgr_cleanup(struct obd_device *dev)
 {
-        struct connmgr_obd *mgr = &dev->u.mgr;
+        struct recovd_obd *recovd = &dev->u.recovd;
         int err;
 
-        err = recovd_cleanup(mgr); 
+        err = recovd_cleanup(recovd); 
         if (err) 
                 LBUG();
 
-        ptlrpc_stop_thread(mgr->mgr_service);
-        rpc_unregister_service(mgr->mgr_service);
-        if (!list_empty(&mgr->mgr_service->srv_reqs)) {
+        ptlrpc_stop_thread(recovd->recovd_service);
+        rpc_unregister_service(recovd->recovd_service);
+        if (!list_empty(&recovd->recovd_service->srv_reqs)) {
                 // XXX reply with errors and clean up
                 CERROR("Request list not empty!\n");
         }
 
-        OBD_FREE(mgr->mgr_service, sizeof(*mgr->mgr_service));
-        mgr->mgr_flags = MGR_STOPPING;
+        OBD_FREE(recovd->recovd_service, sizeof(*recovd->recovd_service));
+        recovd->recovd_flags = MGR_STOPPING;
 
-        OBD_FREE(mgr->mgr_client, sizeof(*mgr->mgr_client));
+        OBD_FREE(recovd->recovd_client, sizeof(*recovd->recovd_client));
         MOD_DEC_USE_COUNT;
         RETURN(0);
 }
 
 /* use obd ops to offer management infrastructure */
-static struct obd_ops connmgr_obd_ops = {
+static struct obd_ops recovd_obd_ops = {
         o_setup:       connmgr_setup,
         o_cleanup:     connmgr_cleanup,
 };
@@ -115,7 +115,7 @@ static int __init ptlrpc_init(void)
         if (rc) 
                 RETURN(rc);
         ptlrpc_init_connection();
-        obd_register_type(&connmgr_obd_ops, LUSTRE_HA_NAME);
+        obd_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
         return 0;
 }
 
index d81767a..712cbf4 100644 (file)
@@ -181,6 +181,10 @@ static int handle_incoming_request(struct obd_device *obddev,
                 }
                 ptlrpc_connection_addref(request.rq_connection);
         } else {
+                /*
+                  PHIL? should we perhaps only do this when 
+                   we get an incoming connmgr_connect request? 
+                */
                 request.rq_connection = ptlrpc_get_connection(&peer);
                 if (!request.rq_connection)
                         LBUG();