Whamcloud - gitweb
- small changes to name2dev:
authorbraam <braam>
Mon, 22 Apr 2002 16:51:27 +0000 (16:51 +0000)
committerbraam <braam>
Mon, 22 Apr 2002 16:51:27 +0000 (16:51 +0000)
  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.

lustre/mdc/mdc_request.c
lustre/obdclass/class_obd.c
lustre/tests/runfailure-net
lustre/utils/obdctl.c

index d747d18..98b3973 100644 (file)
@@ -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;
 }
 
index a49c31a..b08ea30 100644 (file)
@@ -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);
         } 
index 8a84b47..a902bdf 100755 (executable)
@@ -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
index 9d60972..b59e28d 100644 (file)
@@ -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;
 }