From: braam Date: Mon, 22 Apr 2002 16:51:27 +0000 (+0000) Subject: - small changes to name2dev: X-Git-Tag: v1_7_100~5744 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=193a00fe39a31c25dcc480be6ca7be2b4eeed0ed;p=fs%2Flustre-release.git - small changes to name2dev: Usage: obdctl > attach osc THEOSC obdctl > quit mount -t lustre_lite -o device=`obdctl name2dev THEOSC` none /mnt/lustre - free a tiny leak - temporary fix to runfailure-net - also add to obdctl the setting of an environment variable when setting the name of a device. Not clear yet if this is useful. --- diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index d747d18..98b3973 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -64,7 +64,7 @@ int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, EXIT; out: - *request = req; + ptlrpc_free_req(req); return rc; } diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index a49c31a..b08ea30 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -158,7 +158,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, memset(buf, 0, sizeof(buf)); - if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS) { + if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS + && cmd != OBD_IOC_NAME2DEV) { CERROR("OBD ioctl: No device\n"); RETURN(-EINVAL); } diff --git a/lustre/tests/runfailure-net b/lustre/tests/runfailure-net index 8a84b47..a902bdf 100755 --- a/lustre/tests/runfailure-net +++ b/lustre/tests/runfailure-net @@ -10,8 +10,8 @@ test_fail() { kill -9 $! echo 0 > /proc/sys/lustre/fail_loc - umount /mnt/lustre - mount -t lustre_lite -o device=3 none /mnt/lustre + umount /mnt/lustre || exit 1 + mount -t lustre_lite -o device=5 none /mnt/lustre || exit 1 } [ -c /dev/request ] || mknod /dev/request c 10 244 diff --git a/lustre/utils/obdctl.c b/lustre/utils/obdctl.c index 9d60972d..b59e28d 100644 --- a/lustre/utils/obdctl.c +++ b/lustre/utils/obdctl.c @@ -467,6 +467,18 @@ static int jt_attach(int argc, char **argv) if (rc < 0) fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), OBD_IOC_ATTACH, strerror(rc = errno)); + else if (argc == 3) { + char name[1024]; + if (strlen(argv[2]) > 128) { + printf("Name too long to set environment\n"); + return -EINVAL; + } + snprintf(name, 512, "LUSTRE-dev-%s", argv[2]); + rc = setenv(name, argv[1], 1); + if (rc) { + printf("error setting env variable %s\n", name); + } + } return rc; } @@ -476,6 +488,14 @@ static int jt_name2dev(int argc, char **argv) struct obd_ioctl_data data; int rc; + if (fd == -1) + fd = open("/dev/obd", O_RDWR); + if (fd == -1) { + fprintf(stderr, "error: %s: opening /dev/obd: %s\n", + cmdname(argv[0]), strerror(errno)); + return errno; + } + IOCINIT(data); if (argc != 2) { @@ -486,25 +506,17 @@ static int jt_name2dev(int argc, char **argv) data.ioc_inllen1 = strlen(argv[1]) + 1; data.ioc_inlbuf1 = argv[1]; - printf("%s: len %d addr %p name %s\n", - cmdname(argv[0]), data.ioc_len, buf, - MKSTR(data.ioc_inlbuf1)); if (obd_ioctl_pack(&data, &buf, max)) { fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0])); return -2; } - printf("%s: len %d addr %p raw %p name %s and %s\n", - cmdname(argv[0]), data.ioc_len, buf, rawbuf, - MKSTR(data.ioc_inlbuf1), &buf[516]); - rc = ioctl(fd, OBD_IOC_NAME2DEV , buf); if (rc < 0) fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), OBD_IOC_NAME2DEV, strerror(rc = errno)); memcpy((char *)(&data), buf, sizeof(data)); - printf("device set to %d (name %s)\n", data.ioc_dev, argv[1]); - + printf("%d\n", data.ioc_dev); return rc; }