+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
#ifndef _LUSTRE_HA_H
#define _LUSTRE_HA_H
+#include <linux/lustre_net.h>
+
#define MGR_STOPPING 1
#define MGR_RUNNING 2
#define MGR_STOPPED 4
extern struct connmgr_obd *ptlrpc_connmgr;
-struct connmgr_thread {
+struct connmgr_thread {
struct connmgr_obd *mgr;
char *name;
};
+struct connmgr_body {
+ __u64 conn;
+ __u64 conn_token;
-struct connmgr_body {
__u32 generation;
};
-int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *cn);
+int connmgr_connect(struct connmgr_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);
#endif
-/* object based disk file system
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * object based disk file system
*
* This code is issued under the GNU General Public License.
* See the file COPYING in this distribution
*
*
*
- *
#ifndef _LL_H
#define _LL_H
+#include <linux/fs.h>
#include <linux/ext2_fs.h>
#include <linux/lustre_net.h>
void ll_sysctl_clean(void);
#endif
-
#include <linux/obd_class.h>
#include <portals/p30.h>
#include <linux/lustre_idl.h>
-#include <linux/lustre_ha.h>
/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
* FOO_REPLY_PORTAL is for incoming replies on the FOO
struct osc_obd {
struct obd_device *osc_tgt;
struct ptlrpc_client *osc_client;
+ struct ptlrpc_client *osc_ldlm_client;
struct ptlrpc_connection *osc_conn;
};
*/
#define EXPORT_SYMTAB
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <asm/unistd.h>
-
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
#include <linux/lustre_dlm.h>
/* This function will be called to judge if the granted queue of another child
*/
#define EXPORT_SYMTAB
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <asm/unistd.h>
-
#define DEBUG_SUBSYSTEM S_LDLM
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-
+#include <linux/slab.h>
#include <linux/lustre_dlm.h>
-kmem_cache_t *ldlm_resource_slab;
-kmem_cache_t *ldlm_lock_slab;
+kmem_cache_t *ldlm_resource_slab, *ldlm_lock_slab;
struct list_head ldlm_namespaces;
spinlock_t ldlm_spinlock;
if (!PageLocked(page))
LBUG();
- if ( ((inode->i_size + PAGE_CACHE_SIZE -1)>>PAGE_SHIFT)
- <= page->index) {
+ if (((inode->i_size + PAGE_CACHE_SIZE -1)>>PAGE_SHIFT) <= page->index) {
memset(kmap(page), 0, PAGE_CACHE_SIZE);
kunmap(page);
GOTO(readpage_out, rc);
#include <linux/config.h>
#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/locks.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <asm/uaccess.h>
-#include <asm/segment.h>
#define DEBUG_SUBSYSTEM S_LLITE
#include <linux/lustre_lite.h>
+#include <linux/lustre_ha.h>
kmem_cache_t *ll_file_data_slab;
extern struct address_space_operations ll_aops;
ENTRY;
CDEBUG(D_INFO, "option: %s, data %s\n", opt, data);
- if ( strncmp(opt, data, strlen(opt)) ) {
- EXIT;
- return NULL;
- }
- if ( (value = strchr(data, '=')) == NULL ) {
- EXIT;
- return NULL;
- }
+ if ( strncmp(opt, data, strlen(opt)) )
+ RETURN(NULL);
+ if ( (value = strchr(data, '=')) == NULL )
+ RETURN(NULL);
value++;
OBD_ALLOC(retval, strlen(value) + 1);
if ( !retval ) {
CERROR("out of memory!\n");
- return NULL;
+ RETURN(NULL);
}
memcpy(retval, value, strlen(value)+1);
CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
- EXIT;
- return retval;
+ RETURN(retval);
}
static void ll_options(char *options, char **dev, char **vers)
GOTO(out_free, sb = NULL);
}
- ptlrpc_init_client(ptlrpc_connmgr,
- MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
+ ptlrpc_init_client(ptlrpc_connmgr, MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
&sbi->ll_mds_client);
sbi->ll_mds_conn = ptlrpc_uuid_to_connection("mds");
ptlrpc_free_req(request);
- EXIT;
- return err;
+ RETURN(err);
}
int ll_setattr(struct dentry *de, struct iattr *attr)
{
struct statfs tmp;
int err;
-
ENTRY;
err = obd_statfs(ID(sb), &tmp);
if ( err ) {
CERROR("obd_statfs fails (%d)\n", err);
- return err;
+ RETURN(err);
}
memcpy(buf, &tmp, sizeof(*buf));
CDEBUG(D_SUPER, "statfs returns avail %ld\n", tmp.f_bavail);
- EXIT;
- return err;
+ RETURN(err);
}
static void inline ll_to_inode(struct inode *dst, struct mds_body *body)
} else {
init_special_inode(inode, inode->i_mode,
((int *)ll_i2info(inode)->lli_inline)[0]);
+ EXIT;
}
- EXIT;
return;
}
static int request_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- int err;
+ int err = 0;
struct ptlrpc_client cl;
struct ptlrpc_connection *conn;
struct ptlrpc_request *request;
OBD_ALLOC(buf, PAGE_SIZE);
if (!buf) {
err = -ENOMEM;
- break;
+ GOTO(out, err);
}
CERROR("-- readpage 0 for ino %lu\n", arg);
err = mdc_readpage(&cl, conn, arg, S_IFDIR, 0, buf, &request);
#ifdef CONFIG_DEV_RDONLY
dev_clear_rdonly(2);
#endif
+ if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2)
+ RETURN(-EINVAL);
+
mds->mds_fstype = strdup(data->ioc_inlbuf2);
if (!strcmp(mds->mds_fstype, "ext3"))
int err = 0;
ENTRY;
+ if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2)
+ RETURN(-EINVAL);
+
MOD_INC_USE_COUNT;
mnt = do_kern_mount(data->ioc_inlbuf2, 0, data->ioc_inlbuf1, NULL);
err = PTR_ERR(mnt);
return 0;
}
-
/* mount the file system (secretly) */
-static int ost_setup(struct obd_device *obddev, obd_count len,
- void *buf)
-
+static int ost_setup(struct obd_device *obddev, obd_count len, void *buf)
{
struct obd_ioctl_data* data = buf;
struct ost_obd *ost = &obddev->u.ost;
int err;
ENTRY;
- if (data->ioc_dev < 0 || data->ioc_dev > MAX_OBD_DEVICES)
+ if (data->ioc_dev < 0 || data->ioc_dev > MAX_OBD_DEVICES)
RETURN(-ENODEV);
MOD_INC_USE_COUNT;
tgt = &obd_dev[data->ioc_dev];
ost->ost_tgt = tgt;
- if ( ! (tgt->obd_flags & OBD_ATTACHED) ||
- ! (tgt->obd_flags & OBD_SET_UP) ){
+ if (!(tgt->obd_flags & OBD_ATTACHED) ||
+ !(tgt->obd_flags & OBD_SET_UP)) {
CERROR("device not attached or not set up (%d)\n",
data->ioc_dev);
GOTO(error_dec, err = -EINVAL);
}
err = ptlrpc_start_thread(obddev, ost->ost_service, "lustre_ost");
- if (err) {
+ if (err)
GOTO(error_disc, err = -EINVAL);
- }
RETURN(0);
#define DEBUG_SUBSYSTEM S_RPC
-#include <linux/lustre_net.h>
-
+#include <linux/lustre_ha.h>
void ptlrpc_init_client(struct connmgr_obd *mgr, int req_portal,
int rep_portal, struct ptlrpc_client *cl)
*/
#define EXPORT_SYMTAB
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/locks.h>
-#include <linux/kmod.h>
-#include <linux/quotaops.h>
-#include <asm/unistd.h>
-#include <asm/uaccess.h>
-
#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/kmod.h>
#include <linux/lustre_lite.h>
#include <linux/lustre_ha.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_net.h>
-struct connmgr_obd *ptlrpc_connmgr;
+struct connmgr_obd *ptlrpc_connmgr;
void connmgr_cli_manage(struct connmgr_obd *mgr, 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);
+ list_add(&cli->cli_ha_item, &mgr->mgr_connections_lh);
+ spin_unlock(&mgr->mgr_lock);
EXIT;
}
-
void connmgr_cli_fail(struct ptlrpc_client *cli)
{
ENTRY;
- spin_lock(&cli->cli_ha_mgr->mgr_lock);
+ spin_lock(&cli->cli_ha_mgr->mgr_lock);
cli->cli_ha_mgr->mgr_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);
+ 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);
EXIT;
}
-int connmgr_upcall(void)
+static int connmgr_upcall(void)
{
char *argv[2];
char *envp[3];
b->generation = NTOH__u32(b->generation);
}
-int connmgr_connect(struct connmgr_obd *mgr,
- struct ptlrpc_connection *conn)
+int connmgr_connect(struct connmgr_obd *mgr, struct ptlrpc_connection *conn)
{
struct ptlrpc_request *req;
struct ptlrpc_client *cl;
int rc, size = sizeof(*body);
ENTRY;
- if (!mgr) {
- CERROR("no manager\n");
+ if (!mgr) {
+ CERROR("no manager\n");
LBUG();
}
cl = mgr->mgr_client;
body = lustre_msg_buf(req->rq_reqmsg, 0);
body->generation = HTON__u32(conn->c_generation);
+ body->conn = (__u64)(unsigned long)conn;
+ body->conn_token = conn->c_token;
req->rq_replen = lustre_msg_size(1, &size);
rc = ptlrpc_queue_wait(req);
rc = ptlrpc_check_status(req, rc);
-
if (!rc) {
connmgr_unpack_body(req);
body = lustre_msg_buf(req->rq_repmsg, 0);
CDEBUG(D_NET, "mode: %o\n", body->generation);
+ conn->c_remote_conn = body->conn;
+ conn->c_remote_token = body->conn_token;
}
+ ptlrpc_free_req(req);
EXIT;
out:
return rc;
}
-
-int connmgr_handle_connect(struct ptlrpc_request *req)
+static int connmgr_handle_connect(struct ptlrpc_request *req)
{
struct connmgr_body *body;
int rc, size = sizeof(*body);
}
body = lustre_msg_buf(req->rq_reqmsg, 0);
- connmgr_unpack_body(req);
+ connmgr_unpack_body(req);
+
+ req->rq_connection->c_remote_conn = body->conn;
+ req->rq_connection->c_remote_token = body->conn_token;
- printk("incoming generation %d\n", body->generation);
+ CERROR("incoming generation %d\n", body->generation);
body = lustre_msg_buf(req->rq_repmsg, 0);
body->generation = 4711;
+ body->conn = (__u64)(unsigned long)req->rq_connection;
+ body->conn_token = req->rq_connection->c_token;
+
RETURN(0);
}
-int connmgr_handle(struct obd_device *dev,
- struct ptlrpc_service *svc,
+int connmgr_handle(struct obd_device *dev, struct ptlrpc_service *svc,
struct ptlrpc_request *req)
{
int rc;
ENTRY;
rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen);
- if (rc) {
- CERROR("lustre_mds: Invalid request\n");
+ if (rc) {
+ CERROR("Invalid request\n");
GOTO(out, rc);
}
if (req->rq_reqmsg->type != PTL_RPC_REQUEST) {
- CERROR("lustre_mds: wrong packet type sent %d\n",
+ 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, "getattr\n");
+ CDEBUG(D_INODE, "connect\n");
OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
rc = connmgr_handle_connect(req);
break;
return 0;
}
-
static int recovd_check_event(struct connmgr_obd *mgr)
{
- int rc = 0;
+ int rc = 0;
ENTRY;
spin_lock(&mgr->mgr_lock);
- if (!(mgr->mgr_flags & MGR_WORKING) &&
- !list_empty(&mgr->mgr_troubled_lh) ) {
+ if (!(mgr->mgr_flags & MGR_WORKING) &&
+ !list_empty(&mgr->mgr_troubled_lh)) {
- CERROR("connection in trouble - state: WORKING, upcall\n");
+ CERROR("connection in trouble - state: WORKING, upcall\n");
mgr->mgr_flags = MGR_WORKING;
- mgr->mgr_waketime = CURRENT_TIME;
+ mgr->mgr_waketime = CURRENT_TIME;
mgr->mgr_timeout = 5 * HZ;
- schedule_timeout(mgr->mgr_timeout);
+ schedule_timeout(mgr->mgr_timeout);
}
if (mgr->mgr_flags & MGR_WORKING &&
- CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout ) {
+ CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout) {
CERROR("WORKING: new event\n");
- mgr->mgr_waketime = CURRENT_TIME;
- schedule_timeout(mgr->mgr_timeout);
+ mgr->mgr_waketime = CURRENT_TIME;
+ schedule_timeout(mgr->mgr_timeout);
}
- if (mgr->mgr_flags & MGR_STOPPING) {
+ if (mgr->mgr_flags & MGR_STOPPING) {
CERROR("ha mgr stopping\n");
rc = 1;
}
- spin_unlock(&mgr->mgr_lock);
+ spin_unlock(&mgr->mgr_lock);
RETURN(rc);
}
-int recovd_handle_event(struct connmgr_obd *mgr)
+static int recovd_handle_event(struct connmgr_obd *mgr)
{
-
spin_lock(&mgr->mgr_lock);
- if (!(mgr->mgr_flags & MGR_WORKING) &&
- !list_empty(&mgr->mgr_troubled_lh) ) {
+ if (!(mgr->mgr_flags & MGR_WORKING) &&
+ !list_empty(&mgr->mgr_troubled_lh)) {
- CERROR("connection in trouble - state: WORKING, upcall\n");
+ CERROR("connection in trouble - state: WORKING, upcall\n");
mgr->mgr_flags = MGR_WORKING;
connmgr_upcall();
- mgr->mgr_waketime = CURRENT_TIME;
+ mgr->mgr_waketime = CURRENT_TIME;
mgr->mgr_timeout = 5 * HZ;
- schedule_timeout(mgr->mgr_timeout);
-
+ schedule_timeout(mgr->mgr_timeout);
}
if (mgr->mgr_flags & MGR_WORKING &&
- CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout ) {
+ CURRENT_TIME <= mgr->mgr_waketime + mgr->mgr_timeout) {
CERROR("WORKING: new event\n");
- mgr->mgr_waketime = CURRENT_TIME;
- schedule_timeout(mgr->mgr_timeout);
+ mgr->mgr_waketime = CURRENT_TIME;
+ schedule_timeout(mgr->mgr_timeout);
}
spin_unlock(&mgr->mgr_lock);
/* And now, loop forever on requests */
while (1) {
- wait_event_interruptible(mgr->mgr_waitq,
+ wait_event_interruptible(mgr->mgr_waitq,
recovd_check_event(mgr));
spin_lock(&mgr->mgr_lock);
if (mgr->mgr_flags & MGR_STOPPING) {
spin_unlock(&mgr->mgr_lock);
- CERROR("lustre_hamgr quitting\n");
+ CERROR("lustre_hamgr quitting\n");
EXIT;
break;
}
- recovd_handle_event(mgr);
+ recovd_handle_event(mgr);
spin_unlock(&mgr->mgr_lock);
}
INIT_LIST_HEAD(&mgr->mgr_connections_lh);
INIT_LIST_HEAD(&mgr->mgr_troubled_lh);
- spin_lock_init(&mgr->mgr_lock);
+ spin_lock_init(&mgr->mgr_lock);
d.mgr = mgr;
d.name = "lustre_recovd";
}
wait_event(mgr->mgr_ctl_waitq, mgr->mgr_flags & MGR_RUNNING);
- RETURN(0);
+ RETURN(0);
}
-
int recovd_cleanup(struct connmgr_obd *mgr)
{
mgr->mgr_flags = MGR_STOPPING;
#define DEBUG_SUBSYSTEM S_RPC
-#include <linux/lustre_net.h>
-
-extern int connmgr_handle(struct obd_device *dev,
- struct ptlrpc_service *svc,
- struct ptlrpc_request *req);
+#include <linux/lustre_ha.h>
extern int ptlrpc_init_portals(void);
extern void ptlrpc_exit_portals(void);
-extern int recovd_setup(struct connmgr_obd *mgr);
-extern int recovd_cleanup(struct connmgr_obd *mgr);
-
-
int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
{
struct connmgr_obd *mgr = &obddev->u.mgr;
if (err)
GOTO(err_free, err);
- mgr->mgr_service = ptlrpc_init_svc
- (128 * 1024,CONNMGR_REQUEST_PORTAL, CONNMGR_REPLY_PORTAL,
- "self", connmgr_handle);
+ mgr->mgr_service =
+ ptlrpc_init_svc(128 * 1024,CONNMGR_REQUEST_PORTAL,
+ CONNMGR_REPLY_PORTAL, "self", connmgr_handle);
if (!mgr->mgr_service) {
CERROR("failed to start service\n");
GOTO(err_recovd, err = -EINVAL);
RETURN(err);
}
-
int connmgr_cleanup(struct obd_device *dev)
{
struct connmgr_obd *mgr = &dev->u.mgr;
OBD_FREE(mgr->mgr_service, sizeof(*mgr->mgr_service));
mgr->mgr_flags = MGR_STOPPING;
- PORTAL_FREE(mgr->mgr_client, sizeof(*mgr->mgr_client));
+ OBD_FREE(mgr->mgr_client, sizeof(*mgr->mgr_client));
MOD_DEC_USE_COUNT;
RETURN(0);
}
*/
#define EXPORT_SYMTAB
-
#define DEBUG_SUBSYSTEM S_RPC
#include <linux/lustre_net.h>
extern int request_in_callback(ptl_event_t *ev, void *data);
extern int ptl_handled_rpc(struct ptlrpc_service *service, void *start);
-extern int connmgr_handle_event(struct obd_device *dev, struct ptlrpc_service *);
static int ptlrpc_check_event(struct ptlrpc_service *svc)
{
int rc = 0;
+ ENTRY;
spin_lock(&svc->srv_lock);
if (sigismember(&(current->pending.signal), SIGKILL) ||
int err;
int rc, i;
struct ptlrpc_service *service;
+ ENTRY;
OBD_ALLOC(service, sizeof(*service));
if (!service) {
service->srv_id.nid = PTL_ID_ANY;
service->srv_id.pid = PTL_ID_ANY;
- rc = PtlEQAlloc(service->srv_self.peer_ni, 128,
- request_in_callback,
+ rc = PtlEQAlloc(service->srv_self.peer_ni, 128, request_in_callback,
service, &(service->srv_eq_h));
if (rc != PTL_OK) {
CDEBUG(D_NET, "Starting service listening on portal %d\n",
service->srv_req_portal);
- return service;
+ RETURN(service);
err_ring:
service->srv_ring_length = i;
rpc_unregister_service(service); // XXX verify this is right
* We don't know how to find that from here. */
peer.peer_ni = svc->srv_self.peer_ni;
- /* FIXME: rq_reqmsg->conn should be, if nonzero, the local connection
- * structure. Until we have the HA connect messages that we talked
- * about, however, we don't have a way to exchange that address/token
- * pair and this will always be zero. */
if (request.rq_reqmsg->conn) {
request.rq_connection =
(void *)(unsigned long)request.rq_reqmsg->conn;
$OBDCTL <<EOF
device 0
+attach ptlrpc
+setup
+device 1
+attach ldlm
+setup
+device 2
attach osc
setup -1
quit
EOF
-mount -t lustre_lite -o device=0 none /mnt/lustre
+mount -t lustre_lite -o device=2 none /mnt/lustre
device 2
attach ost
setup 1
+device 3
+attach ptlrpc
+setup
+device 4
+attach ldlm
+setup
quit
EOF
attach ost
setup 1
device 3
-attach osc
-setup -1
-device 4
attach ptlrpc
setup
+device 4
+attach ldlm
+setup
+device 5
+attach osc
+setup -1
quit
EOF
-mount -t lustre_lite -o device=3 none /mnt/lustre
+mount -t lustre_lite -o device=5 none /mnt/lustre
rmmod mdc
$OBDCTL <<EOF
+device 5
+cleanup
+detach
device 4
cleanup
detach
attach ost
setup 1
device 3
-attach osc
-setup -1
-device 4
attach ptlrpc
setup
+device 4
+attach ldlm
+setup
+device 5
+attach osc
+setup -1
quit
EOF
-mount -t lustre_lite -o device=3 none /mnt/lustre
+mount -t lustre_lite -o device=5 none /mnt/lustre