#include <linux/lustre_net.h>
#include <portals/list.h>
-int llog_origin_handle_create(struct ptlrpc_request *req)
+int llog_origin_handle_create(struct llog_obd_ctxt * lctxt,
+ struct ptlrpc_request *req)
{
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct llogd_body *body;
struct obd_run_ctxt saved;
struct llog_logid *logid = NULL;
- struct llog_obd_ctxt *ctxt;
char * name = NULL;
int size = sizeof (*body);
int rc, rc2;
push_ctxt(&saved, &obd->obd_ctxt, NULL);
- ctxt = obd->obd_llog_ctxt[LLOG_CONFIG_ORIG_CTXT];
- rc = llog_create(ctxt, &loghandle, logid, name);
+ rc = llog_create(lctxt, &loghandle, logid, name);
if (rc)
GOTO(out_pop, rc);
RETURN(rc);
}
-int llog_origin_handle_next_block(struct ptlrpc_request *req)
+int llog_origin_handle_next_block(struct llog_obd_ctxt *lctxt,
+ struct ptlrpc_request *req)
{
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct llog_handle *loghandle;
struct llogd_body *body;
struct obd_run_ctxt saved;
- struct llog_obd_ctxt *ctxt;
__u8 *buf;
void * ptr;
int size[] = {sizeof (*body),
GOTO(out, rc = -ENOMEM);
push_ctxt(&saved, &obd->obd_ctxt, NULL);
-
- ctxt = obd->obd_llog_ctxt[LLOG_CONFIG_ORIG_CTXT];
- rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
+ rc = llog_create(lctxt, &loghandle, &body->lgd_logid, NULL);
if (rc)
GOTO(out_pop, rc);
RETURN(rc);
}
-int llog_origin_handle_read_header(struct ptlrpc_request *req)
+int llog_origin_handle_read_header(struct llog_obd_ctxt *lctxt,
+ struct ptlrpc_request *req)
{
struct obd_export *exp = req->rq_export;
struct obd_device *obd = exp->exp_obd;
struct llogd_body *body;
struct llog_log_hdr *hdr;
struct obd_run_ctxt saved;
- struct llog_obd_ctxt *ctxt;
__u8 *buf;
int size[] = {sizeof (*hdr)};
int rc, rc2;
GOTO(out, rc = -ENOMEM);
push_ctxt(&saved, &obd->obd_ctxt, NULL);
-
- ctxt = obd->obd_llog_ctxt[LLOG_CONFIG_ORIG_CTXT];
- rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
+ rc = llog_create(lctxt, &loghandle, &body->lgd_logid, NULL);
if (rc)
GOTO(out_pop, rc);
RETURN(rc);
}
-int llog_origin_handle_close(struct ptlrpc_request *req)
+int llog_origin_handle_close(struct llog_obd_ctxt *lctxt,
+ struct ptlrpc_request *req)
{
int rc;
#include <sys/mount.h>
#include <mntent.h>
+#include "obdctl.h"
+#include <portals/ptlctl.h>
+
+int debug = 0;
int verbose = 0;
int nomtab = 0;
-
static void
update_mtab_entry(char *spec, char *node, char *type, char *opts,
int flags, int freq, int pass)
}
}
+
+int
+parse_options(char * options, struct lustre_mount_data *lmd)
+{
+ ptl_nid_t nid = 0;
+ int val;
+ char *opt;
+ char * opteq;
+
+ /* parsing ideas here taken from util-linux/mount/nfsmount.c */
+ for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
+ if ((opteq = strchr(opt, '='))) {
+ val = atoi(opteq + 1);
+ *opteq = '\0';
+ if (!strcmp(opt, "nettype")) {
+ lmd->lmd_nal = ptl_name2nal(opteq+1);
+ } else if(!strcmp(opt, "local_nid")) {
+ if (ptl_parse_nid(&nid, opteq+1) != 0) {
+ fprintf (stderr, "mount: "
+ "can't parse NID %s\n",
+ opteq+1);
+ return (-1);
+ }
+ lmd->lmd_local_nid = nid;
+ } else if(!strcmp(opt, "server_nid")) {
+ if (ptl_parse_nid(&nid, opteq+1) != 0) {
+ fprintf (stderr, "mount: "
+ "can't parse NID %s\n",
+ opteq+1);
+ return (-1);
+ }
+ lmd->lmd_server_nid = nid;
+ } else if (!strcmp(opt, "port")) {
+ lmd->lmd_port = val;
+ }
+
+ } else {
+ val = 1;
+ if (!strncmp(opt, "no", 2)) {
+ val = 0;
+ opt += 2;
+ }
+ if (!strcmp(opt, "debug")) {
+ debug = val;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+set_peer(char *hostname, struct lustre_mount_data *lmd)
+{
+ ptl_nid_t nid = 0;
+
+ if (lmd->lmd_server_nid == 0) {
+ if (ptl_parse_nid (&nid, hostname) != 0) {
+ fprintf (stderr, "mount: can't parse NID %s\n",
+ hostname);
+ return (-1);
+ }
+ }
+
+ if (!lmd->lmd_nal)
+ lmd->lmd_nal = ptl_name2nal("tcp");
+
+ if (lmd->lmd_nal == SOCKNAL) {
+ if (!lmd->lmd_port)
+ lmd->lmd_port = 988;
+ if (ptl_parse_ipaddr(&lmd->lmd_server_ipaddr, hostname) != 0) {
+ fprintf (stderr, "mount: can't parse host %s\n",
+ hostname);
+ return (-1);
+ }
+ }
+
+ if (verbose)
+ printf("nal %d\n", lmd->lmd_nal);
+
+
+ lmd->lmd_server_nid = nid;
+
+ return 0;
+}
+
+int
+build_data(char *source, char *options, struct lustre_mount_data *lmd)
+{
+ char target[1024];
+ char *hostname = NULL;
+ char *mds = NULL;
+ char *profile = NULL;
+ char *s;
+ int rc;
+
+ if (strlen(source) > sizeof(target) + 1) {
+ fprintf(stderr, "mount: "
+ "exessively long host:/mds/profile argument\n");
+ return -EINVAL;
+ }
+ strcpy(target, source);
+ if ((s = strchr(target, ':'))) {
+ hostname = target;
+ *s = '\0';
+
+ while (*++s == '/')
+ ;
+ mds = s;
+ if ((s = strchr(mds, '/'))) {
+ *s = '\0';
+ profile = s + 1;
+ } else {
+ fprintf(stderr, "mount: "
+ "directory to mount not in "
+ "host:/mds/profile format\n");
+ return(-1);
+ }
+ } else {
+ fprintf(stderr, "mount: "
+ "directory to mount not in host:/mds/profile format\n");
+ return(-1);
+ }
+ if (verbose)
+ printf("host: %s\nmds: %s\nprofile: %s\n", hostname, mds,
+ profile);
+
+ rc = parse_options(options, lmd);
+ if (rc)
+ return rc;
+
+ rc = set_peer(hostname, lmd);
+ if (rc)
+ return rc;
+ if (strlen(mds) > sizeof(lmd->lmd_mds) + 1) {
+ fprintf(stderr, "mount: mds name too long\n");
+ return(-1);
+ }
+ strcpy(lmd->lmd_mds, mds);
+
+ if (strlen(profile) > sizeof(lmd->lmd_profile) + 1) {
+ fprintf(stderr, "mount: profile name too long\n");
+ return(-1);
+ }
+ strcpy(lmd->lmd_profile, profile);
+
+ return 0;
+}
+
int
main(int argc, char * const argv[])
{
char * options = NULL;
int opt;
int i;
+ struct lustre_mount_data lmd;
+
int rc;
- for (i = 0; i < argc; i++) {
- printf("arg[%d] = %s\n", i, argv[i]);
- }
while ((opt = getopt(argc, argv, "vno:")) != EOF) {
switch (opt) {
case 'v':
verbose = 1;
+ printf("verbose: %d\n", verbose);
break;
case 'n':
nomtab = 1;
+ printf("nomtab: %d\n", nomtab);
break;
case 'o':
options = optarg;
break;
default:
- printf("default\n");
+ break;
}
}
-
- if (optind < argc) {
- printf("optind %d\n", optind);
-/*
- while(optind < argc)
-*/
+
+ if (verbose)
+ for (i = 0; i < argc; i++) {
+ printf("arg[%d] = %s\n", i, argv[i]);
+ }
+
+ memset(&lmd, 0, sizeof(lmd));
+
+ rc = build_data(source, options, &lmd);
+ if (rc) {
+ exit(1);
}
- rc = mount(source, target, "lustre_lite", 0, options);
+
+ if (debug) {
+ printf("mount: debug mode, not mounting\n");
+ exit(0);
+ }
+
+ rc = mount(source, target, "lustre", 0, (void *)&lmd);
if (rc) {
- perror("mount.lustre_lite:");
+ perror(argv[0]);
} else {
- update_mtab_entry(source, target, "lustre_lite", options,
+ update_mtab_entry(source, target, "lustre", options,
0, 0, 0);
}
return rc;