#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
* - ioctl's
*/
+#define PTL_RPC_MSG_REQUEST 4711
+#define PTL_RPC_MSG_ERR 4712
+
struct lustre_msg {
__u64 conn;
__u64 token;
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:
/* -*- 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
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;
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 *);
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 *,
#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 */
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 */
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);
struct mds_fs_operations *mds_fsops;
struct file *mds_last_rcvd;
__u64 mds_mount_count;
+ struct ll_fid mds_rootfid;
};
struct ldlm_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 {
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;
#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
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);
#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);
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)
}
/* 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);
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)
{
char *version = NULL;
int devno;
int err;
+ struct ll_fid rootfid;
struct ptlrpc_request *request = NULL;
ENTRY;
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;
#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;
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;
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);
}
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;
}
GOTO(out, rc);
}
- mds_unpack_body(req);
+ mds_unpack_rep_body(req);
EXIT;
out:
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);
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);
}
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;
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);
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");
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);
}
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));
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);
#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;
}
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);
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;
}
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);
}
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);
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);
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;
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");
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);
{
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);
}
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;
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);
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);
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();
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;
/* -*- 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;
}
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;
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)
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;
}
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);
}
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);
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;
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;
recalc_sigpending(current);
spin_unlock_irq(¤t->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);
}
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,
};
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;
}
}
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();