TOENAL,
TCPNAL,
SCIMACNAL,
+ ROUTER,
NAL_ENUM_END_MARKER
};
return (val + 0xf) & (~0xf);
}
+static inline int size_round32(int val)
+{
+ return (val + 0x1f) & (~0x1f);
+}
+
static inline int size_round0(int val)
{
if (!val)
return (rc);
}
+static int
+kportal_router_cmd(struct portals_cfg *pcfg, void * private)
+{
+ int err;
+ ENTRY;
+
+ switch(pcfg->pcfg_command) {
+ case IOC_PORTAL_ADD_ROUTE:
+ CDEBUG(D_IOCTL, "Adding route: [%d] "LPU64" : "LPU64" - "LPU64"\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ err = kportal_add_route(pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ break;
+
+ case IOC_PORTAL_DEL_ROUTE:
+ CDEBUG (D_IOCTL, "Removing routes via [%d] "LPU64" : "LPU64" - "LPU64"\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ err = kportal_del_route (pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ break;
+
+ case IOC_PORTAL_NOTIFY_ROUTER: {
+ CDEBUG (D_IOCTL, "Notifying peer [%d] "LPU64" %s @ %ld\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_flags ? "Enabling" : "Disabling",
+ (time_t)pcfg->pcfg_nid3);
+
+ err = kportal_notify_router (pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_flags,
+ (time_t)pcfg->pcfg_nid3);
+ break;
+ }
+
+ case IOC_PORTAL_GET_ROUTE:
+ CDEBUG (D_IOCTL, "Getting route [%d]\n", pcfg->pcfg_count);
+ err = kportal_get_route(pcfg->pcfg_count, &pcfg->pcfg_nal,
+ &pcfg->pcfg_nid,
+ &pcfg->pcfg_nid2, &pcfg->pcfg_nid3,
+ &pcfg->pcfg_flags);
+ break;
+ }
+ RETURN(err);
+}
+
+static int
+kportal_register_router (void)
+{
+ int rc;
+ kpr_control_interface_t *ci;
+
+ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
+ if (ci == NULL)
+ return (0);
+
+ rc = kportal_nal_register(ROUTER, kportal_router_cmd, NULL);
+
+ PORTAL_SYMBOL_PUT(kpr_control_interface);
+ return (rc);
+}
+
+static int
+kportal_unregister_router (void)
+{
+ int rc;
+ kpr_control_interface_t *ci;
+
+ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
+ if (ci == NULL)
+ return (0);
+
+ rc = kportal_nal_unregister(ROUTER);
+
+ PORTAL_SYMBOL_PUT(kpr_control_interface);
+ return (rc);
+}
+
int
kportal_nal_cmd(struct portals_cfg *pcfg)
{
RETURN(0);
}
- case IOC_PORTAL_ADD_ROUTE:
- CDEBUG(D_IOCTL, "Adding route: [%d] "LPU64" : "LPU64" - "LPU64"\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- err = kportal_add_route(data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- break;
-
- case IOC_PORTAL_DEL_ROUTE:
- CDEBUG (D_IOCTL, "Removing routes via [%d] "LPU64" : "LPU64" - "LPU64"\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- err = kportal_del_route (data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- break;
-
- case IOC_PORTAL_NOTIFY_ROUTER: {
- CDEBUG (D_IOCTL, "Notifying peer [%d] "LPU64" %s @ %ld\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_flags ? "Enabling" : "Disabling",
- (time_t)data->ioc_nid3);
-
- err = kportal_notify_router (data->ioc_nal, data->ioc_nid,
- data->ioc_flags,
- (time_t)data->ioc_nid3);
- break;
- }
-
- case IOC_PORTAL_GET_ROUTE:
- CDEBUG (D_IOCTL, "Getting route [%d]\n", data->ioc_count);
- err = kportal_get_route(data->ioc_count, &data->ioc_nal,
- &data->ioc_nid,
- &data->ioc_nid2, &data->ioc_nid3,
- &data->ioc_flags);
- if (err == 0)
- if (copy_to_user((char *)arg, data, sizeof (*data)))
- err = -EFAULT;
- break;
-
case IOC_PORTAL_GET_NID: {
const ptl_handle_ni_t *nip;
ptl_process_id_t pid;
goto cleanup_fini;
}
+ rc = kportal_register_router();
+ if (rc) {
+ CERROR("kportals_register_router: error %d\n", rc);
+ goto cleanup_proc;
+ }
+
CDEBUG (D_OTHER, "portals setup OK\n");
return (0);
+ cleanup_proc:
+ remove_proc();
cleanup_fini:
PtlFini();
cleanup_deregister:
{
int rc;
+ kportal_unregister_router();
remove_proc();
PtlFini();
int
jt_ptl_add_route (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
ptl_nid_t nid1;
ptl_nid_t nid2;
ptl_nid_t gateway_nid;
return (-1);
}
- PORTAL_IOC_INIT(data);
- data.ioc_nid = gateway_nid;
- data.ioc_nal = g_nal;
- data.ioc_nid2 = MIN (nid1, nid2);
- data.ioc_nid3 = MAX (nid1, nid2);
+ PCFG_INIT(pcfg, IOC_PORTAL_ADD_ROUTE);
+ pcfg.pcfg_nid = gateway_nid;
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid2 = MIN (nid1, nid2);
+ pcfg.pcfg_nid3 = MAX (nid1, nid2);
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_ADD_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_ADD_ROUTE failed: %s\n", strerror (errno));
int
jt_ptl_del_route (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
ptl_nid_t nid;
ptl_nid_t nid1 = PTL_NID_ANY;
ptl_nid_t nid2 = PTL_NID_ANY;
}
}
- PORTAL_IOC_INIT(data);
- data.ioc_nal = g_nal;
- data.ioc_nid = nid;
- data.ioc_nid2 = nid1;
- data.ioc_nid3 = nid2;
+ PCFG_INIT(pcfg, IOC_PORTAL_DEL_ROUTE);
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid = nid;
+ pcfg.pcfg_nid2 = nid1;
+ pcfg.pcfg_nid3 = nid2;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_DEL_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_DEL_ROUTE ("LPX64") failed: %s\n", nid, strerror (errno));
int
jt_ptl_notify_router (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
int enable;
ptl_nid_t nid;
int rc;
return (-1);
}
- PORTAL_IOC_INIT(data);
- data.ioc_nal = g_nal;
- data.ioc_nid = nid;
- data.ioc_flags = enable;
+ PCFG_INIT(pcfg, IOC_PORTAL_NOTIFY_ROUTER);
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid = nid;
+ pcfg.pcfg_flags = enable;
/* Yeuch; 'cept I need a __u64 on 64 bit machines... */
- data.ioc_nid3 = (__u64)when;
+ pcfg.pcfg_nid3 = (__u64)when;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NOTIFY_ROUTER, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_NOTIFY_ROUTER ("LPX64") failed: %s\n",
jt_ptl_print_routes (int argc, char **argv)
{
char buffer[3][128];
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
int rc;
int index;
int gateway_nal;
for (index = 0;;index++)
{
- PORTAL_IOC_INIT(data);
- data.ioc_count = index;
+ PCFG_INIT(pcfg, IOC_PORTAL_GET_ROUTE);
+ pcfg.pcfg_count = index;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
break;
- gateway_nal = data.ioc_nal;
- gateway_nid = data.ioc_nid;
- nid1 = data.ioc_nid2;
- nid2 = data.ioc_nid3;
- alive = data.ioc_flags;
+ gateway_nal = pcfg.pcfg_nal;
+ gateway_nid = pcfg.pcfg_nid;
+ nid1 = pcfg.pcfg_nid2;
+ nid2 = pcfg.pcfg_nid3;
+ alive = pcfg.pcfg_flags;
printf ("%8s %18s : %s - %s, %s\n",
nal2name (gateway_nal),
/* ldlm_flock.c */
int ldlm_process_flock_lock(struct ldlm_lock *lock, int *flags, int first_enq,
ldlm_error_t *err);
+
+extern struct proc_dir_entry *ldlm_svc_proc_dir;
+
+struct ldlm_state {
+ struct ptlrpc_service *ldlm_cb_service;
+ struct ptlrpc_service *ldlm_cancel_service;
+ struct ptlrpc_client *ldlm_client;
+ struct ptlrpc_connection *ldlm_server_conn;
+ struct ldlm_bl_pool *ldlm_bl_pool;
+};
+
#else
# include <liblustre.h>
#endif
+#include <linux/obd.h>
#include <linux/obd_ost.h>
+#include <linux/lustre_mgmt.h>
#include <linux/lustre_dlm.h>
#include <linux/lustre_mds.h>
#include <linux/lustre_net.h>
+int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
+{
+ struct ptlrpc_connection *conn;
+ struct lustre_cfg* lcfg = buf;
+ struct client_obd *cli = &obddev->u.cli;
+ struct obd_import *imp;
+ struct obd_uuid server_uuid;
+ int rq_portal, rp_portal, connect_op;
+ char *name = obddev->obd_type->typ_name;
+ char *mgmt_name = NULL;
+ int rc = 0;
+ struct obd_device *mgmt_obd;
+ mgmtcli_register_for_events_t register_f;
+ ENTRY;
+
+ /* In a more perfect world, we would hang a ptlrpc_client off of
+ * obd_type and just use the values from there. */
+ if (!strcmp(name, LUSTRE_OSC_NAME)) {
+ rq_portal = OST_REQUEST_PORTAL;
+ rp_portal = OSC_REPLY_PORTAL;
+ connect_op = OST_CONNECT;
+ } else if (!strcmp(name, LUSTRE_MDC_NAME)) {
+ rq_portal = MDS_REQUEST_PORTAL;
+ rp_portal = MDC_REPLY_PORTAL;
+ connect_op = MDS_CONNECT;
+ } else if (!strcmp(name, LUSTRE_MGMTCLI_NAME)) {
+ rq_portal = MGMT_REQUEST_PORTAL;
+ rp_portal = MGMT_REPLY_PORTAL;
+ connect_op = MGMT_CONNECT;
+ } else {
+ CERROR("unknown client OBD type \"%s\", can't setup\n",
+ name);
+ RETURN(-EINVAL);
+ }
+
+ if (lcfg->lcfg_inllen1 < 1) {
+ CERROR("requires a TARGET UUID\n");
+ RETURN(-EINVAL);
+ }
+
+ if (lcfg->lcfg_inllen1 > 37) {
+ CERROR("client UUID must be less than 38 characters\n");
+ RETURN(-EINVAL);
+ }
+
+ if (lcfg->lcfg_inllen2 < 1) {
+ CERROR("setup requires a SERVER UUID\n");
+ RETURN(-EINVAL);
+ }
+
+ if (lcfg->lcfg_inllen2 > 37) {
+ CERROR("target UUID must be less than 38 characters\n");
+ RETURN(-EINVAL);
+ }
+
+ sema_init(&cli->cl_sem, 1);
+ cli->cl_conn_count = 0;
+ memcpy(server_uuid.uuid, lcfg->lcfg_inlbuf2, MIN(lcfg->lcfg_inllen2,
+ sizeof(server_uuid)));
+
+ init_MUTEX(&cli->cl_dirty_sem);
+ cli->cl_dirty = 0;
+ cli->cl_dirty_granted = 0;
+ cli->cl_dirty_max = 64*1024*1024; /* some default */
+ cli->cl_ost_can_grant = 1;
+ INIT_LIST_HEAD(&cli->cl_cache_waiters);
+ INIT_LIST_HEAD(&cli->cl_loi_ready_list);
+ spin_lock_init(&cli->cl_loi_list_lock);
+ cli->cl_brw_in_flight = 0;
+ spin_lock_init(&cli->cl_rpc_concurrency_oh.oh_lock);
+ spin_lock_init(&cli->cl_pages_per_rpc_oh.oh_lock);
+ cli->cl_max_pages_per_rpc = PTL_MD_MAX_IOV;
+ cli->cl_max_rpcs_in_flight = 8;
+
+ ldlm_get_ref();
+ if (rc) {
+ CERROR("ldlm_get_ref failed: %d\n", rc);
+ GOTO(err, rc);
+ }
+
+ conn = ptlrpc_uuid_to_connection(&server_uuid);
+ if (conn == NULL)
+ GOTO(err_ldlm, rc = -ENOENT);
+
+ ptlrpc_init_client(rq_portal, rp_portal, name,
+ &obddev->obd_ldlm_client);
+
+ imp = class_new_import();
+ if (imp == NULL) {
+ ptlrpc_put_connection(conn);
+ GOTO(err_ldlm, rc = -ENOENT);
+ }
+ imp->imp_connection = conn;
+ imp->imp_client = &obddev->obd_ldlm_client;
+ imp->imp_obd = obddev;
+ imp->imp_connect_op = connect_op;
+ imp->imp_generation = 0;
+ INIT_LIST_HEAD(&imp->imp_pinger_chain);
+ memcpy(imp->imp_target_uuid.uuid, lcfg->lcfg_inlbuf1,
+ lcfg->lcfg_inllen1);
+ class_import_put(imp);
+
+ cli->cl_import = imp;
+ cli->cl_max_mds_easize = sizeof(struct lov_mds_md);
+ cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
+ cli->cl_sandev = to_kdev_t(0);
+
+ if (lcfg->lcfg_inllen3 != 0) {
+ if (!strcmp(lcfg->lcfg_inlbuf3, "inactive")) {
+ CDEBUG(D_HA, "marking %s %s->%s as inactive\n",
+ name, obddev->obd_name,
+ imp->imp_target_uuid.uuid);
+ imp->imp_invalid = 1;
+
+ if (lcfg->lcfg_inllen4 != 0)
+ mgmt_name = lcfg->lcfg_inlbuf4;
+ } else {
+ mgmt_name = lcfg->lcfg_inlbuf3;
+ }
+ }
+
+ if (mgmt_name != NULL) {
+ /* Register with management client if we need to. */
+ CDEBUG(D_HA, "%s registering with %s for events about %s\n",
+ obddev->obd_name, mgmt_name, server_uuid.uuid);
+
+ mgmt_obd = class_name2obd(mgmt_name);
+ if (!mgmt_obd) {
+ CERROR("can't find mgmtcli %s to register\n",
+ mgmt_name);
+ GOTO(err_import, rc = -ENOSYS);
+ }
+
+ register_f = inter_module_get("mgmtcli_register_for_events");
+ if (!register_f) {
+ CERROR("can't i_m_g mgmtcli_register_for_events\n");
+ GOTO(err_import, rc = -ENOSYS);
+ }
+
+ rc = register_f(mgmt_obd, obddev, &imp->imp_target_uuid);
+ inter_module_put("mgmtcli_register_for_events");
+
+ if (!rc)
+ cli->cl_mgmtcli_obd = mgmt_obd;
+ }
+
+ RETURN(rc);
+
+err_import:
+ class_destroy_import(imp);
+err_ldlm:
+ ldlm_put_ref();
+err:
+ RETURN(rc);
+
+}
+
+int client_obd_cleanup(struct obd_device *obddev, int flags)
+{
+ struct client_obd *cli = &obddev->u.cli;
+
+ if (!cli->cl_import)
+ RETURN(-EINVAL);
+ if (cli->cl_mgmtcli_obd) {
+ mgmtcli_deregister_for_events_t dereg_f;
+
+ dereg_f = inter_module_get("mgmtcli_deregister_for_events");
+ dereg_f(cli->cl_mgmtcli_obd, obddev);
+ inter_module_put("mgmtcli_deregister_for_events");
+ }
+ class_destroy_import(cli->cl_import);
+ cli->cl_import = NULL;
+
+ ldlm_put_ref();
+
+ RETURN(0);
+}
+
int client_connect_import(struct lustre_handle *dlm_handle,
struct obd_device *obd,
struct obd_uuid *cluuid)
obd->obd_name);
obd->obd_recovering = 0;
- obd_postsetup(obd);
/* when recovering finished, cleanup orphans for mds */
if (OBT(obd) && OBP(obd, postrecov)) {
rc2 = OBP(obd, postrecov)(obd);
char *ll_read_opt(const char *opt, char *data);
int ll_set_opt(const char *opt, char *data, int fl);
void ll_options(char *options, char **ost, char **mds, char **zconf,
- char **mds_uuid, int *flags);
+ char **mds_uuid, char **mds_peer, int *flags);
void ll_lli_init(struct ll_inode_info *lli);
int ll_fill_super(struct super_block *sb, void *data, int silent);
void ll_put_super(struct super_block *sb);
void lov_free_memmd(struct lov_stripe_md **lsmp);
/* lov_log.c */
-int lov_llog_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count ,struct llog_logid *logids);
-int lov_llog_cleanup(struct obd_device *obd);
-int lov_llog_origin_add(struct obd_export *exp,
- int index,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies);
-int lov_llog_repl_cancel(struct obd_device *obd, struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies, int flags);
-
-
-#if 0
-int lov_get_catalogs(struct lov_obd *lov, struct llog_handle *cathandle);
-int lov_log_add(struct obd_export *exp,
- struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies);
-#endif
+int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
+ int count, struct llog_logid *logid);
+int lov_llog_finish(struct obd_device *obd, int count);
/* lov_pack.c */
int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmm,
#include "lov_internal.h"
-int lov_llog_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count ,struct llog_logid *logids)
+#if 0
+static int lov_logop_cleanup(struct llog_obd_ctxt *ctxt)
{
- struct lov_obd *lov = &obd->u.lov;
+ struct lov_obd *lov = &ctxt->loc_obd->u.lov;
int i, rc = 0;
- ENTRY;
- LASSERT(lov->desc.ld_tgt_count == count);
+ ENTRY;
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
struct obd_device *child = lov->tgts[i].ltd_exp->exp_obd;
- child->obd_log_exp = disk_obd->obd_log_exp;
- rc = obd_llog_setup(child, disk_obd, index, 1, logids + i);
+ struct llog_obd_ctxt *cctxt = child->obd_llog_ctxt[ctxt->loc_idx];
+ rc = llog_cleanup(cctxt);
if (rc) {
CERROR("error lov_llog_open %d\n", i);
break;
}
RETURN(rc);
}
-
-int lov_llog_cleanup(struct obd_device *obd)
-{
- struct lov_obd *lov = &obd->u.lov;
- int i, rc = 0;
-
- ENTRY;
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- struct obd_device *child = lov->tgts[i].ltd_exp->exp_obd;
- rc = obd_llog_cleanup(child);
- CERROR("error lov_llog_open %d\n", i);
- if (rc)
- break;
- }
- RETURN(rc);
-}
+#endif
/* Add log records for each OSC that this object is striped over, and return
* cookies for each one. We _would_ have nice abstraction here, except that
* we need to keep cookies in stripe order, even if some are NULL, so that
* the right cookies are passed back to the right OSTs at the client side.
* Unset cookies should be all-zero (which will never occur naturally). */
-int lov_llog_origin_add(struct obd_export *exp,
- int index,
+static int lov_llog_origin_add(struct llog_obd_ctxt *ctxt,
struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
struct llog_cookie *logcookies, int numcookies)
{
- struct obd_device *obd = class_exp2obd(exp);
+ struct obd_device *obd = ctxt->loc_obd;
struct lov_obd *lov = &obd->u.lov;
struct lov_oinfo *loi;
int i, rc = 0;
LASSERT(logcookies && numcookies >= lsm->lsm_stripe_count);
for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
- rc += obd_llog_origin_add(lov->tgts[loi->loi_ost_idx].ltd_exp, index,
- rec, NULL, logcookies + rc, numcookies - rc);
+ struct obd_device *child = lov->tgts[loi->loi_ost_idx].ltd_exp->exp_obd;
+ struct llog_obd_ctxt *cctxt = child->obd_llog_ctxt[ctxt->loc_idx];
+ rc += llog_add(cctxt, rec, NULL, logcookies + rc, numcookies - rc);
+
}
RETURN(rc);
}
/* the replicators commit callback */
-int lov_llog_repl_cancel(struct obd_device *obd, struct lov_stripe_md *lsm,
+static int lov_llog_repl_cancel(struct llog_obd_ctxt *ctxt, struct lov_stripe_md *lsm,
int count, struct llog_cookie *cookies, int flags)
{
struct lov_obd *lov;
+ struct obd_device *obd = ctxt->loc_obd;
struct lov_oinfo *loi;
int rc = 0, i;
ENTRY;
loi = lsm->lsm_oinfo;
lov = &obd->u.lov;
for (i = 0; i < count; i++, cookies++, loi++) {
+ struct obd_device *child = lov->tgts[loi->loi_ost_idx].ltd_exp->exp_obd;
+ struct llog_obd_ctxt *cctxt = child->obd_llog_ctxt[ctxt->loc_idx];
int err;
- err = obd_llog_repl_cancel(lov->tgts[loi->loi_ost_idx].ltd_exp->exp_obd,
- NULL, 1, cookies, flags);
-
+ err = llog_cancel(cctxt, NULL, 1, cookies, flags);
if (err && lov->tgts[loi->loi_ost_idx].active) {
CERROR("error: objid "LPX64" subobj "LPX64
" on OST idx %d: rc = %d\n", lsm->lsm_object_id,
}
RETURN(rc);
}
+
+static struct llog_operations lov_unlink_orig_logops = {
+// lop_cleanup: lov_logop_cleanup,
+ lop_add: lov_llog_origin_add,
+};
+
+static struct llog_operations lov_size_repl_logops = {
+// lop_cleanup: lov_logop_cleanup,
+ lop_cancel: lov_llog_repl_cancel
+};
+
+
+int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
+ int count, struct llog_logid *logid)
+{
+ struct lov_obd *lov = &obd->u.lov;
+ int i, rc = 0;
+ ENTRY;
+
+ rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, 0, NULL,
+ &lov_unlink_orig_logops);
+ if (rc)
+ RETURN(rc);
+
+ rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
+ &lov_size_repl_logops);
+ if (rc)
+ RETURN(rc);
+
+ LASSERT(lov->desc.ld_tgt_count == count);
+ for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+ struct obd_device *child = lov->tgts[i].ltd_exp->exp_obd;
+ rc = obd_llog_init(child, tgt, 1, logid + i);
+ if (rc) {
+ CERROR("error osc_llog_init %d\n", i);
+ break;
+ }
+ }
+ RETURN(rc);
+}
+
+int lov_llog_finish(struct obd_device *obd, int count)
+{
+ struct lov_obd *lov = &obd->u.lov;
+ int i, rc = 0;
+ ENTRY;
+
+ rc = llog_cleanup(obd->obd_llog_ctxt[LLOG_UNLINK_ORIG_CTXT]);
+ if (rc)
+ RETURN(rc);
+
+ rc = llog_cleanup(obd->obd_llog_ctxt[LLOG_SIZE_REPL_CTXT]);
+ if (rc)
+ RETURN(rc);
+
+ LASSERT(lov->desc.ld_tgt_count == count);
+ for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+ struct obd_device *child = lov->tgts[i].ltd_exp->exp_obd;
+ rc = obd_llog_finish(child, 1);
+ if (rc) {
+ CERROR("error osc_llog_finish %d\n", i);
+ break;
+ }
+ }
+ RETURN(rc);
+}
return &req->rq_export->exp_obd->u.mds;
}
-
-/* mds/mds_fs.c */
-struct llog_handle *mds_log_create(struct obd_device *obd, char *name);
-int mds_log_close(struct llog_handle *cathandle, struct llog_handle *loghandle);
-struct llog_handle *mds_log_open(struct obd_device *obd,
- struct llog_cookie *logcookie);
-#if 0
-struct llog_handle *mds_get_catalog(struct obd_device *obd);
-#endif
-void mds_put_catalog(struct obd_device *obd, struct llog_handle *cathandle);
-
-
/* mds/mds_reint.c */
void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error);
int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
/* mds/mds_log.c */
-int mds_llog_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count, struct llog_logid *logid);
-int mds_llog_cleanup(struct obd_device *obd);
-int mds_llog_origin_add(struct obd_export *exp,
- int index,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies);
-int mds_llog_repl_cancel(struct obd_device *obd, struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies, int flags);
int mds_log_op_unlink(struct obd_device *obd, struct inode *inode, struct lustre_msg *repmsg,
int offset);
+int mds_llog_init(struct obd_device *obd, struct obd_device *tgt,
+ int count, struct llog_logid *logid);
+int mds_llog_finish(struct obd_device *obd, int count);
/* mds/mds_lov.c */
-int mds_lov_connect(struct obd_device *obd);
+int mds_lov_connect(struct obd_device *obd, char * lov_name);
+int mds_lov_disconnect(struct obd_device *obd, int flags);
int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *);
int mds_lov_write_objids(struct obd_device *obd);
void mds_lov_update_objids(struct obd_device *obd, obd_id *ids);
int mds_lov_set_growth(struct mds_obd *mds, int count);
int mds_lov_set_nextid(struct obd_device *obd);
-int mds_set_lovdesc(struct obd_device *obd, struct lov_desc *desc,
- struct obd_uuid *uuidarray);
int mds_post_mds_lovconf(struct obd_device *obd);
int mds_notify(struct obd_device *obd, struct obd_device *watched, int active);
int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
/* mds/handler.c */
extern struct lvfs_callback_ops mds_lvfs_ops;
+int mds_lov_clean(struct obd_device *obd);
extern int mds_iocontrol(unsigned int cmd, struct obd_export *exp,
int len, void *karg, void *uarg);
#ifdef __KERNEL__
#include "mds_internal.h"
-int mds_llog_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count, struct llog_logid *logid)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(obd->u.mds.mds_osc_obd, llog_setup, 0);
- rc = OBP(obd->u.mds.mds_osc_obd, llog_setup)(obd->u.mds.mds_osc_obd,
- disk_obd, index, count,
- logid);
- RETURN(rc);
-}
-
-int mds_llog_cleanup(struct obd_device *obd)
+#if 0
+static int mds_logop_cleanup(struct llog_obd_ctxt *ctxt)
{
+ struct obd_device *obd = ctxt->loc_obd;
+ struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ struct llog_obd_ctxt *lctxt;
int rc;
ENTRY;
- OBD_CHECK_OP(obd->u.mds.mds_osc_obd, llog_cleanup, 0);
- rc = OBP(obd->u.mds.mds_osc_obd, llog_cleanup)(obd->u.mds.mds_osc_obd);
+ lctxt = lov_obd->obd_llog_ctxt[ctxt->loc_idx];
+ rc = llog_cleanup(lctxt);
RETURN(rc);
}
+#endif
-int mds_llog_origin_add(struct obd_export *exp, int index,
+static int mds_llog_origin_add(struct llog_obd_ctxt *ctxt,
struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
struct llog_cookie *logcookies, int numcookies)
{
+ struct obd_device *obd = ctxt->loc_obd;
+ struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ struct llog_obd_ctxt *lctxt;
int rc;
- struct obd_export *lov_exp = exp->exp_obd->u.mds.mds_osc_exp;
ENTRY;
- EXP_CHECK_OP(lov_exp, llog_origin_add);
-
- rc = OBP(lov_exp->exp_obd, llog_origin_add)(lov_exp, index, rec, lsm,
- logcookies, numcookies);
+ lctxt = lov_obd->obd_llog_ctxt[ctxt->loc_idx];
+ rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
RETURN(rc);
}
-int mds_llog_repl_cancel(struct obd_device *obd, struct lov_stripe_md *lsm,
+static int mds_llog_repl_cancel(struct llog_obd_ctxt *ctxt, struct lov_stripe_md *lsm,
int count, struct llog_cookie *cookies, int flags)
{
- int rc;
+ struct obd_device *obd = ctxt->loc_obd;
struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ struct llog_obd_ctxt *lctxt;
+ int rc;
ENTRY;
- OBD_CHECK_OP(obd, llog_repl_cancel, -EOPNOTSUPP);
-
- rc = OBP(lov_obd, llog_repl_cancel)(lov_obd, lsm, count, cookies,
- flags);
+ lctxt = lov_obd->obd_llog_ctxt[ctxt->loc_idx];
+ rc = llog_cancel(lctxt, lsm, count, cookies,flags);
RETURN(rc);
}
struct mds_obd *mds = &obd->u.mds;
struct lov_stripe_md *lsm = NULL;
struct llog_unlink_rec *lur;
+#ifdef ENABLE_ORPHANS
+ struct llog_obd_ctxt *ctxt;
+#endif
int rc;
ENTRY;
lur->lur_ogen = inode->i_generation;
#ifdef ENABLE_ORPHANS
- rc = obd_llog_origin_add(mds->mds_osc_exp, 0, &lur->lur_hdr,
+ ctxt = obd->obd_llog_ctxt[LLOG_UNLINK_ORIG_CTXT];
+ rc = llog_add(ctxt, &lur->lur_hdr,
lsm, lustre_msg_buf(repmsg, offset + 1, 0),
repmsg->buflens[offset + 1] /
sizeof(struct llog_cookie));
RETURN(rc);
}
+
+static struct llog_operations mds_unlink_orig_logops = {
+ //lop_cleanup: mds_logop_cleanup,
+ lop_add: mds_llog_origin_add,
+};
+
+static struct llog_operations mds_size_repl_logops = {
+ //lop_cleanup: mds_logop_cleanup,
+ lop_cancel: mds_llog_repl_cancel
+};
+
+int mds_llog_init(struct obd_device *obd, struct obd_device *tgt,
+ int count, struct llog_logid *logid)
+{
+ struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ int rc;
+ ENTRY;
+
+ rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, 0, NULL, &mds_unlink_orig_logops);
+ if (rc)
+ RETURN(rc);
+
+ rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL, &mds_size_repl_logops);
+ if (rc)
+ RETURN(rc);
+
+ rc = obd_llog_init(lov_obd, tgt, count, logid);
+ if (rc)
+ CERROR("error lov_llog_init\n");
+
+ RETURN(rc);
+}
+
+int mds_llog_finish(struct obd_device *obd, int count)
+{
+ struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ int rc;
+ ENTRY;
+
+ rc = llog_cleanup(obd->obd_llog_ctxt[LLOG_UNLINK_ORIG_CTXT]);
+ if (rc)
+ RETURN(rc);
+
+ rc = llog_cleanup(obd->obd_llog_ctxt[LLOG_SIZE_REPL_CTXT]);
+ if (rc)
+ RETURN(rc);
+
+ rc = obd_llog_finish(lov_obd, count);
+ if (rc)
+ CERROR("error lov_llog_finish\n");
+
+ RETURN(rc);
+}
mgmt_service = ptlrpc_init_svc(MGMT_NEVENTS, MGMT_NBUFS, MGMT_BUFSIZE,
MGMT_MAXREQSIZE, MGMT_REQUEST_PORTAL,
MGMT_REPLY_PORTAL, mgmt_handler,
- "mgmt", obd);
+ "mgmt", obd->obd_proc_entry);
if (!mgmt_service) {
CERROR("Failed to start mgmt service\n");
RETURN(-ENOMEM);
}
- for (i = 0; i < MGMT_NUM_THREADS; i++) {
- char name[32];
- sprintf(name, "mgmt_%02d", i);
- rc = ptlrpc_start_thread(obd, mgmt_service, name);
- if (rc) {
- CERROR("failed to start mgmt thread %d: %d\n", i, rc);
- LBUG();
- }
- }
-
+ rc = ptlrpc_start_n_threads(obd, mgmt_service, MGMT_NUM_THREADS,"mgmt");
+ if (rc)
+ GOTO(err, rc);
+
mgmt_initialized = 1;
RETURN(0);
+err:
+ ptlrpc_unregister_service(mgmt_service);
+ RETURN(rc):
}
static int mgmt_cleanup(struct obd_device *obd, int flags)
/* helper functions for calling the llog obd methods */
-int obd_llog_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count, struct llog_logid *logid)
+int llog_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
+ int count, struct llog_logid *logid, struct llog_operations *op)
{
- int rc;
+ int rc = 0;
+ struct llog_obd_ctxt *ctxt;
ENTRY;
- OBD_CHECK_OP(obd, llog_setup, 0);
- OBD_COUNTER_INCREMENT(obd, llog_setup);
+ if (index < 0 || index >= LLOG_MAX_CTXTS)
+ RETURN(-EFAULT);
+
+ OBD_ALLOC(ctxt, sizeof(*ctxt));
+ if (!ctxt)
+ RETURN(-ENOMEM);
+
+ obd->obd_llog_ctxt[index] = ctxt;
+ ctxt->loc_obd = obd;
+ ctxt->loc_exp = class_export_get(disk_obd->obd_self_export);
+ ctxt->loc_idx = index;
+ ctxt->loc_logops = op;
+ sema_init(&ctxt->loc_sem, 1);
+
+ if (op->lop_setup)
+ rc = op->lop_setup(obd, index, disk_obd, count, logid);
+ if (ctxt && rc)
+ OBD_FREE(ctxt, sizeof(*ctxt));
- rc = OBP(obd, llog_setup)(obd, disk_obd, index, count, logid);
RETURN(rc);
}
-EXPORT_SYMBOL(obd_llog_setup);
+EXPORT_SYMBOL(llog_setup);
-int obd_llog_cleanup(struct obd_device *obd)
+int llog_cleanup(struct llog_obd_ctxt *ctxt)
{
- int rc;
+ int rc = 0;
ENTRY;
- OBD_CHECK_OP(obd, llog_cleanup, 0);
- OBD_COUNTER_INCREMENT(obd, llog_cleanup);
+ LASSERT(ctxt);
+
+ if (CTXTP(ctxt, cleanup))
+ rc = CTXTP(ctxt, cleanup)(ctxt);
+
+ ctxt->loc_obd->obd_llog_ctxt[ctxt->loc_idx] = NULL;
+ class_export_put(ctxt->loc_exp);
+ ctxt->loc_exp = NULL;
+ OBD_FREE(ctxt, sizeof(*ctxt));
- rc = OBP(obd, llog_cleanup)(obd);
RETURN(rc);
}
-EXPORT_SYMBOL(obd_llog_cleanup);
+EXPORT_SYMBOL(llog_cleanup);
-int obd_llog_origin_add(struct obd_export *exp,
- int index,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies)
+int llog_add(struct llog_obd_ctxt *ctxt,
+ struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
+ struct llog_cookie *logcookies, int numcookies)
{
int rc;
ENTRY;
- EXP_CHECK_OP(exp, llog_origin_add);
- OBD_COUNTER_INCREMENT(exp->exp_obd, llog_origin_add);
+ LASSERT(ctxt);
+ CTXT_CHECK_OP(ctxt, add, -EOPNOTSUPP);
- rc = OBP(exp->exp_obd, llog_origin_add)
- (exp, index, rec, lsm, logcookies, numcookies);
+ rc = CTXTP(ctxt, add)(ctxt, rec, lsm, logcookies, numcookies);
RETURN(rc);
}
-EXPORT_SYMBOL(obd_llog_origin_add);
+EXPORT_SYMBOL(llog_add);
-int obd_llog_repl_cancel(struct obd_device *obd, struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies, int flags)
+int llog_cancel(struct llog_obd_ctxt *ctxt, struct lov_stripe_md *lsm,
+ int count, struct llog_cookie *cookies, int flags)
{
int rc;
ENTRY;
- OBD_CHECK_OP(obd, llog_repl_cancel, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, llog_repl_cancel);
-
- rc = OBP(obd, llog_repl_cancel)(obd, lsm, count, cookies, flags);
+ LASSERT(ctxt);
+ CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP);
+ rc = CTXTP(ctxt, cancel)(ctxt, lsm, count, cookies, flags);
RETURN(rc);
}
-EXPORT_SYMBOL(obd_llog_repl_cancel);
+EXPORT_SYMBOL(llog_cancel);
-/* now some implementations of these stubs useful on the OSC and OBDFILTER */
-int llog_obd_setup(struct obd_device *obd, struct obd_device *disk_obd,
- int index, int count, struct llog_logid *logid)
+
+/* lop_setup method for filter/osc */
+// XXX how to set exports
+int llog_obd_origin_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
+ int count, struct llog_logid *logid)
{
struct llog_obd_ctxt *ctxt;
struct llog_handle *handle;
struct obd_run_ctxt saved;
int rc;
+ ENTRY;
- LASSERT(count == 1);
-
- if (disk_obd->obd_llog_ctxt &&
- disk_obd->obd_llog_ctxt->loc_handles[index])
+ if (count == 0)
RETURN(0);
- if (index == 0) {
- if (disk_obd->obd_llog_ctxt) {
- CERROR("llog_ctxt already allocated\n");
- LBUG();
- }
-
- OBD_ALLOC(ctxt, sizeof(*ctxt));
- if (!ctxt)
- RETURN(-ENOMEM);
- disk_obd->obd_llog_ctxt = ctxt;
-
- sema_init(&disk_obd->obd_llog_ctxt->loc_sem, 1);
- } else
- ctxt = disk_obd->obd_llog_ctxt;
-
- if (index < 0 || index >= LLOG_OBD_MAX_HANDLES) {
- CERROR("llog_ctxt index out of range\n");
- LBUG();
- }
+ LASSERT(count == 1);
+
+ LASSERT(obd->obd_llog_ctxt[index]);
+ ctxt = obd->obd_llog_ctxt[index];
if (logid->lgl_oid)
- rc = llog_create(disk_obd, &handle, logid, NULL);
+ rc = llog_create(ctxt, &handle, logid, NULL);
else {
- rc = llog_create(disk_obd, &handle, NULL, NULL);
+ rc = llog_create(ctxt, &handle, NULL, NULL);
if (!rc)
*logid = handle->lgh_id;
}
if (rc)
GOTO(out, rc);
- disk_obd->obd_llog_ctxt->loc_handles[index] = handle;
+ ctxt->loc_handle = handle;
push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
rc = llog_init_handle(handle, LLOG_F_IS_CAT, NULL);
pop_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
out:
- if (ctxt && rc)
+ if (ctxt && rc) {
+ obd->obd_llog_ctxt[index] = NULL;
OBD_FREE(ctxt, sizeof(*ctxt));
+ }
RETURN(rc);
}
-EXPORT_SYMBOL(llog_obd_setup);
+EXPORT_SYMBOL(llog_obd_origin_setup);
-int llog_obd_cleanup(struct obd_device *obd)
+int llog_obd_origin_cleanup(struct llog_obd_ctxt *ctxt)
{
- int i;
- struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt;
-
if (!ctxt)
return 0;
- if (ctxt->loc_imp) {
- //class_destroy_import(ctxt->loc_imp);
- ctxt->loc_imp = NULL;
- }
-
- for (i=0 ; i < LLOG_OBD_MAX_HANDLES ;i++ )
- if (obd->obd_llog_ctxt->loc_handles[i])
- llog_cat_put(obd->obd_llog_ctxt->loc_handles[i]);
+ if (ctxt->loc_handle)
+ llog_cat_put(ctxt->loc_handle);
- OBD_FREE(obd->obd_llog_ctxt, sizeof(*obd->obd_llog_ctxt));
- obd->obd_llog_ctxt = NULL;
return 0;
}
-EXPORT_SYMBOL(llog_obd_cleanup);
+EXPORT_SYMBOL(llog_obd_origin_cleanup);
+
-int llog_obd_origin_add(struct obd_export *exp,
- int index,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies)
+/* add for obdfilter/sz and mds/unlink */
+int llog_obd_origin_add(struct llog_obd_ctxt *ctxt,
+ struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
+ struct llog_cookie *logcookies, int numcookies)
{
struct llog_handle *cathandle;
- struct obd_export *export = exp->exp_obd->obd_log_exp;
int rc;
ENTRY;
- if (index < 0 || index >= LLOG_OBD_MAX_HANDLES) {
- LBUG();
- RETURN(-EINVAL);
- }
-
- //cathandle = exp->exp_obd->obd_llog_ctxt->loc_handles[index];
- cathandle = export->exp_obd->obd_llog_ctxt->loc_handles[index];
+ cathandle = ctxt->loc_handle;
LASSERT(cathandle != NULL);
rc = llog_cat_add_rec(cathandle, rec, logcookies, NULL);
if (rc != 1)
}
EXPORT_SYMBOL(llog_obd_origin_add);
-/* initialize the local storage obd for the logs */
-int llog_initialize(struct obd_device *obd)
-{
- struct obd_export *exp;
- ENTRY;
-
- if (obd->obd_log_exp)
- RETURN(0);
-
- exp = class_new_export(obd);
- if (exp == NULL)
- RETURN(-ENOMEM);
- memcpy(&exp->exp_client_uuid, &obd->obd_uuid,
- sizeof(exp->exp_client_uuid));
- obd->obd_log_exp = exp;
- class_export_put(exp);
-
- obd->obd_logops = &llog_lvfs_ops;
- RETURN(0);
-}
-EXPORT_SYMBOL(llog_initialize);
-
-/* disconnect the local storage obd for the logs */
-int llog_disconnect(struct obd_device *obd)
-{
- struct obd_export *exp;
- ENTRY;
-
- LASSERT(obd->obd_log_exp);
- exp = obd->obd_log_exp;
-
- class_handle_unhash(&exp->exp_handle);
- spin_lock(&exp->exp_obd->obd_dev_lock);
- list_del_init(&exp->exp_obd_chain);
- exp->exp_obd->obd_num_exports--;
- spin_unlock(&exp->exp_obd->obd_dev_lock);
- OBD_FREE(exp, sizeof(*exp));
- if (obd->obd_set_up) {
- atomic_dec(&obd->obd_refcount);
- wake_up(&obd->obd_refcount_waitq);
- }
-
- obd->obd_log_exp = NULL;
- obd->obd_logops = NULL;
- RETURN(0);
-}
-EXPORT_SYMBOL(llog_disconnect);
-
int llog_cat_initialize(struct obd_device *obd, int count)
{
- int rc, i;
- char name[32];
struct llog_logid *idarray;
int size = sizeof(*idarray) * count;
+ char name[32] = "CATLIST";
+ int rc;
ENTRY;
- LASSERT(obd->obd_log_exp);
-
OBD_ALLOC(idarray, size);
if (!idarray)
RETURN(-ENOMEM);
- for (i = 0; i < LLOG_OBD_MAX_HANDLES; i++) {
- sprintf(name, "CATLIST-%d", i);
- memset(idarray, 0, size);
- rc = llog_get_cat_list(obd, obd, name, count, idarray);
- if (rc) {
- CERROR("rc: %d\n", rc);
- GOTO(out, rc);
- }
- rc = obd_llog_setup(obd, obd, i, count, idarray);
- if (rc) {
- CERROR("rc: %d\n", rc);
- GOTO(out, rc);
- }
- rc = llog_put_cat_list(obd, obd, name, count, idarray);
- if (rc) {
- CERROR("rc: %d\n", rc);
- GOTO(out, rc);
- }
+ memset(idarray, 0, size);
+
+ rc = llog_get_cat_list(obd, obd, name, count, idarray);
+ if (rc) {
+ CERROR("rc: %d\n", rc);
+ GOTO(out, rc);
+ }
+
+ rc = obd_llog_init(obd, obd, count, idarray);
+ if (rc) {
+ CERROR("rc: %d\n", rc);
+ GOTO(out, rc);
+ }
+
+ rc = llog_put_cat_list(obd, obd, name, count, idarray);
+ if (rc) {
+ CERROR("rc: %d\n", rc);
+ GOTO(out, rc);
}
out:
RETURN(rc);
}
EXPORT_SYMBOL(llog_cat_initialize);
+
+int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd,
+ int count, struct llog_logid *logid)
+{
+ int rc;
+ ENTRY;
+ OBD_CHECK_OP(obd, llog_init, 0);
+ OBD_COUNTER_INCREMENT(obd, llog_init);
+
+ rc = OBP(obd, llog_init)(obd, disk_obd, count, logid);
+ RETURN(rc);
+}
+EXPORT_SYMBOL(obd_llog_init);
+
+int obd_llog_finish(struct obd_device *obd, int count)
+{
+ int rc;
+ ENTRY;
+ OBD_CHECK_OP(obd, llog_finish, 0);
+ OBD_COUNTER_INCREMENT(obd, llog_finish);
+
+ rc = OBP(obd, llog_finish)(obd, count);
+ RETURN(rc);
+}
+EXPORT_SYMBOL(obd_llog_finish);
void *cb_data, int error)
{
struct llog_cookie *cookie = cb_data;
- llog_obd_repl_cancel(obd, NULL, 1, cookie, OBD_LLOG_FL_SENDNOW);
+ llog_obd_repl_cancel(obd->obd_llog_ctxt[LLOG_UNLINK_REPL_CTXT],
+ NULL, 1, cookie, OBD_LLOG_FL_SENDNOW);
OBD_FREE(cb_data, sizeof(struct llog_cookie));
}
TOENAL,
TCPNAL,
SCIMACNAL,
+ ROUTER,
NAL_ENUM_END_MARKER
};
return (val + 0xf) & (~0xf);
}
+static inline int size_round32(int val)
+{
+ return (val + 0x1f) & (~0x1f);
+}
+
static inline int size_round0(int val)
{
if (!val)
return (rc);
}
+static int
+kportal_router_cmd(struct portals_cfg *pcfg, void * private)
+{
+ int err;
+ ENTRY;
+
+ switch(pcfg->pcfg_command) {
+ case IOC_PORTAL_ADD_ROUTE:
+ CDEBUG(D_IOCTL, "Adding route: [%d] "LPU64" : "LPU64" - "LPU64"\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ err = kportal_add_route(pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ break;
+
+ case IOC_PORTAL_DEL_ROUTE:
+ CDEBUG (D_IOCTL, "Removing routes via [%d] "LPU64" : "LPU64" - "LPU64"\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ err = kportal_del_route (pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_nid2, pcfg->pcfg_nid3);
+ break;
+
+ case IOC_PORTAL_NOTIFY_ROUTER: {
+ CDEBUG (D_IOCTL, "Notifying peer [%d] "LPU64" %s @ %ld\n",
+ pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_flags ? "Enabling" : "Disabling",
+ (time_t)pcfg->pcfg_nid3);
+
+ err = kportal_notify_router (pcfg->pcfg_nal, pcfg->pcfg_nid,
+ pcfg->pcfg_flags,
+ (time_t)pcfg->pcfg_nid3);
+ break;
+ }
+
+ case IOC_PORTAL_GET_ROUTE:
+ CDEBUG (D_IOCTL, "Getting route [%d]\n", pcfg->pcfg_count);
+ err = kportal_get_route(pcfg->pcfg_count, &pcfg->pcfg_nal,
+ &pcfg->pcfg_nid,
+ &pcfg->pcfg_nid2, &pcfg->pcfg_nid3,
+ &pcfg->pcfg_flags);
+ break;
+ }
+ RETURN(err);
+}
+
+static int
+kportal_register_router (void)
+{
+ int rc;
+ kpr_control_interface_t *ci;
+
+ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
+ if (ci == NULL)
+ return (0);
+
+ rc = kportal_nal_register(ROUTER, kportal_router_cmd, NULL);
+
+ PORTAL_SYMBOL_PUT(kpr_control_interface);
+ return (rc);
+}
+
+static int
+kportal_unregister_router (void)
+{
+ int rc;
+ kpr_control_interface_t *ci;
+
+ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface);
+ if (ci == NULL)
+ return (0);
+
+ rc = kportal_nal_unregister(ROUTER);
+
+ PORTAL_SYMBOL_PUT(kpr_control_interface);
+ return (rc);
+}
+
int
kportal_nal_cmd(struct portals_cfg *pcfg)
{
RETURN(0);
}
- case IOC_PORTAL_ADD_ROUTE:
- CDEBUG(D_IOCTL, "Adding route: [%d] "LPU64" : "LPU64" - "LPU64"\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- err = kportal_add_route(data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- break;
-
- case IOC_PORTAL_DEL_ROUTE:
- CDEBUG (D_IOCTL, "Removing routes via [%d] "LPU64" : "LPU64" - "LPU64"\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- err = kportal_del_route (data->ioc_nal, data->ioc_nid,
- data->ioc_nid2, data->ioc_nid3);
- break;
-
- case IOC_PORTAL_NOTIFY_ROUTER: {
- CDEBUG (D_IOCTL, "Notifying peer [%d] "LPU64" %s @ %ld\n",
- data->ioc_nal, data->ioc_nid,
- data->ioc_flags ? "Enabling" : "Disabling",
- (time_t)data->ioc_nid3);
-
- err = kportal_notify_router (data->ioc_nal, data->ioc_nid,
- data->ioc_flags,
- (time_t)data->ioc_nid3);
- break;
- }
-
- case IOC_PORTAL_GET_ROUTE:
- CDEBUG (D_IOCTL, "Getting route [%d]\n", data->ioc_count);
- err = kportal_get_route(data->ioc_count, &data->ioc_nal,
- &data->ioc_nid,
- &data->ioc_nid2, &data->ioc_nid3,
- &data->ioc_flags);
- if (err == 0)
- if (copy_to_user((char *)arg, data, sizeof (*data)))
- err = -EFAULT;
- break;
-
case IOC_PORTAL_GET_NID: {
const ptl_handle_ni_t *nip;
ptl_process_id_t pid;
goto cleanup_fini;
}
+ rc = kportal_register_router();
+ if (rc) {
+ CERROR("kportals_register_router: error %d\n", rc);
+ goto cleanup_proc;
+ }
+
CDEBUG (D_OTHER, "portals setup OK\n");
return (0);
+ cleanup_proc:
+ remove_proc();
cleanup_fini:
PtlFini();
cleanup_deregister:
{
int rc;
+ kportal_unregister_router();
remove_proc();
PtlFini();
int
jt_ptl_add_route (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
ptl_nid_t nid1;
ptl_nid_t nid2;
ptl_nid_t gateway_nid;
return (-1);
}
- PORTAL_IOC_INIT(data);
- data.ioc_nid = gateway_nid;
- data.ioc_nal = g_nal;
- data.ioc_nid2 = MIN (nid1, nid2);
- data.ioc_nid3 = MAX (nid1, nid2);
+ PCFG_INIT(pcfg, IOC_PORTAL_ADD_ROUTE);
+ pcfg.pcfg_nid = gateway_nid;
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid2 = MIN (nid1, nid2);
+ pcfg.pcfg_nid3 = MAX (nid1, nid2);
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_ADD_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_ADD_ROUTE failed: %s\n", strerror (errno));
int
jt_ptl_del_route (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
ptl_nid_t nid;
ptl_nid_t nid1 = PTL_NID_ANY;
ptl_nid_t nid2 = PTL_NID_ANY;
}
}
- PORTAL_IOC_INIT(data);
- data.ioc_nal = g_nal;
- data.ioc_nid = nid;
- data.ioc_nid2 = nid1;
- data.ioc_nid3 = nid2;
+ PCFG_INIT(pcfg, IOC_PORTAL_DEL_ROUTE);
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid = nid;
+ pcfg.pcfg_nid2 = nid1;
+ pcfg.pcfg_nid3 = nid2;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_DEL_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_DEL_ROUTE ("LPX64") failed: %s\n", nid, strerror (errno));
int
jt_ptl_notify_router (int argc, char **argv)
{
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
int enable;
ptl_nid_t nid;
int rc;
return (-1);
}
- PORTAL_IOC_INIT(data);
- data.ioc_nal = g_nal;
- data.ioc_nid = nid;
- data.ioc_flags = enable;
+ PCFG_INIT(pcfg, IOC_PORTAL_NOTIFY_ROUTER);
+ pcfg.pcfg_nal = g_nal;
+ pcfg.pcfg_nid = nid;
+ pcfg.pcfg_flags = enable;
/* Yeuch; 'cept I need a __u64 on 64 bit machines... */
- data.ioc_nid3 = (__u64)when;
+ pcfg.pcfg_nid3 = (__u64)when;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NOTIFY_ROUTER, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
{
fprintf (stderr, "IOC_PORTAL_NOTIFY_ROUTER ("LPX64") failed: %s\n",
jt_ptl_print_routes (int argc, char **argv)
{
char buffer[3][128];
- struct portal_ioctl_data data;
+ struct portals_cfg pcfg;
int rc;
int index;
int gateway_nal;
for (index = 0;;index++)
{
- PORTAL_IOC_INIT(data);
- data.ioc_count = index;
+ PCFG_INIT(pcfg, IOC_PORTAL_GET_ROUTE);
+ pcfg.pcfg_count = index;
- rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_ROUTE, &data);
+ rc = pcfg_ioctl(&pcfg);
if (rc != 0)
break;
- gateway_nal = data.ioc_nal;
- gateway_nid = data.ioc_nid;
- nid1 = data.ioc_nid2;
- nid2 = data.ioc_nid3;
- alive = data.ioc_flags;
+ gateway_nal = pcfg.pcfg_nal;
+ gateway_nid = pcfg.pcfg_nid;
+ nid1 = pcfg.pcfg_nid2;
+ nid2 = pcfg.pcfg_nid3;
+ alive = pcfg.pcfg_flags;
printf ("%8s %18s : %s - %s, %s\n",
nal2name (gateway_nal),
#include <linux/lvfs.h>
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static int llog_net_create(struct obd_device *obd, struct llog_handle **res,
- struct llog_logid *logid, char *name)
-{
- struct llog_handle *handle;
- ENTRY;
-
- handle = llog_alloc_handle();
- if (handle == NULL)
- RETURN(-ENOMEM);
- *res = handle;
-
- if (!logid) {
- CERROR("llog_net_create: must pass logid\n");
- llog_free_handle(handle);
- RETURN(-EINVAL);
- }
-
- handle->lgh_file = NULL;
- handle->lgh_obd = obd;
- handle->lgh_id.lgl_ogr = 1;
- handle->lgh_id.lgl_oid =
- handle->lgh_file->f_dentry->d_inode->i_ino;
- handle->lgh_id.lgl_ogen =
- handle->lgh_file->f_dentry->d_inode->i_generation;
-
- RETURN(0);
-}
-
#ifdef ENABLE_ORPHANS
-int llog_origin_handle_cancel(struct obd_device *obd,
+int llog_origin_handle_cancel(struct llog_obd_ctxt *ctxt,
struct ptlrpc_request *req)
{
+ struct obd_device *obd = ctxt->loc_exp->exp_obd;
struct llog_cookie *logcookies;
int num_cookies, rc = 0;
struct obd_run_ctxt saved;
struct llog_handle *cathandle;
- int i;
ENTRY;
- LASSERT(obd->obd_llog_ctxt);
-
logcookies = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*logcookies));
num_cookies = req->rq_reqmsg->buflens[0]/sizeof(*logcookies);
if (logcookies == NULL || num_cookies == 0) {
DEBUG_REQ(D_HA, req, "no cookies sent");
RETURN(-EFAULT);
}
-#if 0
- /* workaround until we don't need to send replies */
- rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
- req->rq_repmsg->status = rc;
- if (rc)
- RETURN(rc);
- /* end workaround */
-#endif
- i = logcookies->lgc_subsys;
- if (i < 0 || i > LLOG_OBD_MAX_HANDLES) {
- LBUG();
- RETURN(-EINVAL);
- }
- cathandle = obd->obd_llog_ctxt->loc_handles[i];
+
+ cathandle = ctxt->loc_handle;
LASSERT(cathandle);
push_ctxt(&saved, &obd->obd_ctxt, NULL);
CERROR("cancel %d llog-records failed: %d\n", num_cookies, rc);
pop_ctxt(&saved, &obd->obd_ctxt, NULL);
- //req->rq_repmsg->status = rc;
RETURN(rc);
}
EXPORT_SYMBOL(llog_origin_handle_cancel);
#endif
-int llog_receptor_accept(struct obd_device *obd, struct obd_import *imp)
+int llog_receptor_accept(struct llog_obd_ctxt *ctxt, struct obd_import *imp)
{
ENTRY;
- LASSERT(obd->obd_llog_ctxt);
- obd->obd_llog_ctxt->loc_imp = imp;
+ LASSERT(ctxt);
+ ctxt->loc_imp = imp;
RETURN(0);
}
EXPORT_SYMBOL(llog_receptor_accept);
-int llog_initiator_connect(struct obd_device *obd)
+int llog_initiator_connect(struct llog_obd_ctxt *ctxt)
{
ENTRY;
- LASSERT(obd->obd_llog_ctxt);
- obd->obd_llog_ctxt->loc_imp = obd->u.cli.cl_import;
+ LASSERT(ctxt);
+ ctxt->loc_imp = ctxt->loc_obd->u.cli.cl_import;
RETURN(0);
}
EXPORT_SYMBOL(llog_initiator_connect);
-struct llog_operations llog_net_ops = {
- //lop_next_block: llog_lvfs_next_block,
- //lop_read_header: llog_lvfs_read_header,
- lop_create: llog_net_create,
-};
-
-EXPORT_SYMBOL(llog_lvfs_ops);
cli->cl_max_mds_easize = sizeof(struct lov_mds_md);
cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
cli->cl_sandev = to_kdev_t(0);
-
- obddev->obd_logops = &llogd_client_ops;
-
+
if (lcfg->lcfg_inllen3 == 0)
RETURN(0);
TIMEOUT=${TIMEOUT:-5}
STRIPE_BYTES=65536
-STRIPES_PER_OBJ=1
+STRIPES_PER_OBJ=0
gen_config() {
rm -f replay-single.xml
add_facet ost
add_facet client --lustre_upcall $UPCALL
do_lmc --add mds --node mds_facet --mds mds1 --dev $MDSDEV --size $MDSSIZE
+
do_lmc --add lov --mds mds1 --lov lov1 --stripe_sz $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
do_lmc --add ost --lov lov1 --node ost_facet --ost ost1 --dev $OSTDEV --size $OSTSIZE
do_lmc --add ost --lov lov1 --node ost_facet --ost ost2 --dev ${OSTDEV}-2 --size $OSTSIZE
do_lmc --add mtpt --node client_facet --path $MOUNT --mds mds1 --ost lov1
+
+# do_lmc --add ost --node ost_facet --ost ost1 --dev $OSTDEV --size $OSTSIZE
+# do_lmc --add mtpt --node client_facet --path $MOUNT --mds mds1 --ost ost1
}
build_test_filter
cleanup() {
- [ "$DAEMONFILE" ] && lctl debug_daemon stop
- umount $MOUNT || true
- rmmod llite || true
+ lconf --cleanup --zeroconf --mds_uuid mds1_UUID --mds_nid localhost \
+ --local_nid localhost --profile client_facet --mount $MOUNT
stop mds ${FORCE} $MDSLCONFARGS
stop ost ${FORCE} --dump cleanup.log
}
gen_config
+start mds --write_conf --reformat $MDSLCONFARGS -v
start ost --reformat $OSTLCONFARGS
[ "$DAEMONFILE" ] && lctl debug_daemon start $DAEMONFILE $DAEMONSIZE
-start mds --write_conf --reformat $MDSLCONFARGS
+start mds $MDSLCONFARGS --gdb
# 0-conf client
-insmod ../llite/llite.o || true
-[ -d /r ] && lctl modules > /r/tmp/ogdb-`hostname`
-[ -d $MOUNT ] || mkdir $MOUNT
-mount -t lustre_lite -o mds_uuid=mds1_UUID,profile=client_facet replay-single $MOUNT
+lconf --zeroconf --mds_uuid mds1_UUID --mds_nid localhost \
+ --local_nid localhost --profile client_facet --mount $MOUNT
if [ "$ONLY" == "setup" ]; then
exit 0
CHECK_MEMBER(llogd_body, lgd_saved_index);
CHECK_MEMBER(llogd_body, lgd_cur_offset);
- CHECK_VALUE(LLOGD_CREATE);
- CHECK_VALUE(LLOGD_NEXT_BLOCK);
- CHECK_VALUE(LLOGD_READ_HEADER);
- CHECK_VALUE(LLOGD_WRITE_REC);
- CHECK_VALUE(LLOGD_CLOSE);
+ CHECK_VALUE(LLOG_ORIGIN_HANDLE_CREATE);
+ CHECK_VALUE(LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
+ CHECK_VALUE(LLOG_ORIGIN_HANDLE_READ_HEADER);
+ CHECK_VALUE(LLOG_ORIGIN_HANDLE_WRITE_REC);
+ CHECK_VALUE(LLOG_ORIGIN_HANDLE_CLOSE);
}
int
CHECK_VALUE(MDS_DISCONNECT);
CHECK_VALUE(MDS_GETSTATUS);
CHECK_VALUE(MDS_STATFS);
- CHECK_VALUE(MDS_GETLOVINFO);
CHECK_VALUE(MDS_LAST_OPC);
CHECK_VALUE(MDS_FIRST_OPC);
LASSERT(MDS_DISCONNECT == 39);
LASSERT(MDS_GETSTATUS == 40);
LASSERT(MDS_STATFS == 41);
- LASSERT(MDS_GETLOVINFO == 42);
LASSERT(MDS_LAST_OPC == 46);
LASSERT(MDS_FIRST_OPC == 33);
LASSERT(REINT_SETATTR == 1);
LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_saved_index) == 4);
LASSERT(offsetof(struct llogd_body, lgd_cur_offset) == 32);
LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8);
- LASSERT(LLOGD_CREATE == 501);
- LASSERT(LLOGD_NEXT_BLOCK == 502);
- LASSERT(LLOGD_READ_HEADER == 503);
- LASSERT(LLOGD_WRITE_REC == 504);
- LASSERT(LLOGD_CLOSE == 505);
+ LASSERT(LLOG_ORIGIN_HANDLE_CREATE == 501);
+ LASSERT(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502);
+ LASSERT(LLOG_ORIGIN_HANDLE_READ_HEADER == 503);
+ LASSERT(LLOG_ORIGIN_HANDLE_WRITE_REC == 504);
+ LASSERT(LLOG_ORIGIN_HANDLE_CLOSE == 505);
}