Whamcloud - gitweb
LU-6202 obd: replace OBD_IOC_NO_TRANSNO with sysfs file 93/35993/22
authorJames Simmons <jsimmons@infradead.org>
Wed, 25 Mar 2020 11:57:40 +0000 (07:57 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 9 Apr 2020 06:27:52 +0000 (06:27 +0000)
We can replace the ioctl OBD_IOC_NO_TRANSNO, which is server side
only, with a sysfs file. The original ioctl set an internal obd
device flags to simulate transactions not reaching the disk. The
new write only sysfs file behaves the exact same way.

Change-Id: Ie78feec61fab46a1982bd5caca3e89613356d2e8
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/35993
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/include/uapi/linux/lustre/lustre_ioctl.h
lustre/obdclass/class_obd.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_sysfs.c
lustre/utils/lctl.c
lustre/utils/obd.c

index a0f8f39..be44801 100644 (file)
@@ -610,7 +610,6 @@ struct obd_device {
                obd_abort_recovery:1,   /* recovery expired */
                obd_version_recov:1,    /* obd uses version checking */
                obd_replayable:1,       /* recovery enabled; inform clients */
-               obd_no_transno:1,       /* no committed-transno notification */
                obd_no_recov:1,         /* fail instead of retry messages */
                obd_stopping:1,         /* started cleanup */
                obd_starting:1,         /* started setup */
@@ -622,6 +621,10 @@ struct obd_device {
                obd_no_ir:1,            /* no imperative recovery. */
                obd_process_conf:1,     /* device is processing mgs config */
                obd_checksum_dump:1;    /* dump pages upon cksum error */
+#ifdef HAVE_SERVER_SUPPORT
+       /* no committed-transno notification */
+       unsigned long                   obd_no_transno:1;
+#endif
 
         /* use separate field as it is set in interrupt to don't mess with
          * protection of other bits using _bh lock */
index 424aebf..41410a2 100644 (file)
@@ -172,7 +172,7 @@ static inline __u32 obd_ioctl_packlen(struct obd_ioctl_data *data)
 /* was OBD_IOC_PING_TARGET     _IOW('f', 136, OBD_IOC_DATA_TYPE) until 2.11 */
 
 /*     OBD_IOC_DEC_FS_USE_COUNT _IO('f', 139) */
-#define OBD_IOC_NO_TRANSNO     _IOW('f', 140, OBD_IOC_DATA_TYPE)
+/* was OBD_IOC_NO_TRANSNO      _IOW('f', 140, OBD_IOC_DATA_TYPE) until 2.14 */
 #define OBD_IOC_SET_READONLY   _IOW('f', 141, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_ABORT_RECOVERY _IOR('f', 142, OBD_IOC_DATA_TYPE)
 /*     OBD_IOC_ROOT_SQUASH     _IOWR('f', 143, OBD_IOC_DATA_TYPE) */
index 8543769..3871d32 100644 (file)
@@ -464,29 +464,12 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 GOTO(out, err = -EINVAL);
         }
 
-        switch(cmd) {
-        case OBD_IOC_NO_TRANSNO: {
-                if (!obd->obd_attached) {
-                        CERROR("Device %d not attached\n", obd->obd_minor);
-                        GOTO(out, err = -ENODEV);
-                }
-                CDEBUG(D_HA, "%s: disabling committed-transno notification\n",
-                       obd->obd_name);
-                obd->obd_no_transno = 1;
-                GOTO(out, err = 0);
-        }
-
-        default: {
-                err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL);
-                if (err)
-                        GOTO(out, err);
-
-               if (copy_to_user((void __user *)arg, data, len))
-                        err = -EFAULT;
-                GOTO(out, err);
-        }
-        }
+       err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL);
+       if (err)
+               GOTO(out, err);
 
+       if (copy_to_user((void __user *)arg, data, len))
+               err = -EFAULT;
 out:
        OBD_FREE_LARGE(buf, len);
        RETURN(err);
index e7457ff..29986fb 100644 (file)
@@ -747,9 +747,13 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
                        case 'A':
                                LCONSOLE_WARN("Failing over %s\n",
                                              obd->obd_name);
+                               spin_lock(&obd->obd_dev_lock);
                                obd->obd_fail = 1;
+#ifdef HAVE_SERVER_SUPPORT
                                obd->obd_no_transno = 1;
+#endif
                                obd->obd_no_recov = 1;
+                               spin_unlock(&obd->obd_dev_lock);
                                if (OBP(obd, iocontrol)) {
                                        obd_iocontrol(OBD_IOC_SYNC,
                                                      obd->obd_self_export,
index 35e4cd5..d79bb63 100644 (file)
@@ -177,6 +177,34 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RW_ATTR(max_dirty_mb);
 
+#ifdef HAVE_SERVER_SUPPORT
+static ssize_t no_transno_store(struct kobject *kobj,
+                               struct attribute *attr,
+                               const char *buffer, size_t count)
+{
+       struct obd_device *obd;
+       unsigned int idx;
+       int rc;
+
+       rc = kstrtouint(buffer, 10, &idx);
+       if (rc)
+               return rc;
+
+       obd = class_num2obd(idx);
+       if (!obd || !obd->obd_attached) {
+               if (obd)
+                       CERROR("%s: not attached\n", obd->obd_name);
+               return -ENODEV;
+       }
+
+       spin_lock(&obd->obd_dev_lock);
+       obd->obd_no_transno = 1;
+       spin_unlock(&obd->obd_dev_lock);
+       return count;
+}
+LUSTRE_WO_ATTR(no_transno);
+#endif /* HAVE_SERVER_SUPPORT */
+
 static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
                            char *buf)
 {
@@ -390,6 +418,7 @@ static struct attribute *lustre_attrs[] = {
 #ifdef HAVE_SERVER_SUPPORT
        &lustre_sattr_ldlm_timeout.u.attr,
        &lustre_sattr_bulk_timeout.u.attr,
+       &lustre_attr_no_transno.attr,
 #endif
        &lustre_sattr_lbug_on_eviction.u.attr,
        NULL,
index 3ea4fdc..e15b082 100644 (file)
@@ -421,8 +421,10 @@ command_t cmdlist[] = {
         "usage: lookup <directory> <file>"},
        {"readonly", jt_obd_set_readonly, 0,
         "disable writes to the underlying device\n"},
+#ifdef HAVE_SERVER_SUPPORT
        {"notransno", jt_obd_no_transno, 0,
         "disable sending of committed-transno updates\n"},
+#endif
        {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a NID\n"
         "usage: add_uuid <uuid> <nid>"},
        {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
index db5bc12..c810f55 100644 (file)
@@ -838,19 +838,56 @@ int jt_opt_net(int argc, char **argv)
         return rc;
 }
 
+#ifdef HAVE_SERVER_SUPPORT
+/* Place this here so we can build tools that work with
+ * older Lustre versions
+ */
+#ifndef OBD_IOC_NO_TRANSNO
+#define OBD_IOC_NO_TRANSNO     _IOW('f', 140, OBD_IOC_DATA_TYPE)
+#endif
+
 int jt_obd_no_transno(int argc, char **argv)
 {
        struct obd_ioctl_data data;
        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+       glob_t path;
+       int count;
+       int fd;
        int rc;
 
-       memset(&data, 0, sizeof(data));
-       data.ioc_dev = cur_device;
-
        if (argc != 1)
                return CMD_HELP;
 
        memset(buf, 0, sizeof(rawbuf));
+
+       rc = cfs_get_param_paths(&path, "no_transno");
+       if (rc != 0)
+               goto old_ioctl;
+
+       fd = open(path.gl_pathv[0], O_WRONLY);
+       if (fd < 0) {
+               cfs_free_param_data(&path);
+               goto old_ioctl;
+       }
+
+       snprintf(rawbuf, sizeof(rawbuf), "%d", cur_device);
+
+       count = write(fd, rawbuf, strlen(rawbuf));
+       if (count < 0)
+               rc = errno;
+
+       cfs_free_param_data(&path);
+       close(fd);
+       if (rc)
+               goto old_ioctl;
+
+       return 0;
+
+old_ioctl:
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
+       memset(&data, 0, sizeof(data));
+       data.ioc_dev = cur_device;
+
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
        if (rc) {
                fprintf(stderr, "error: %s: invalid ioctl\n",
@@ -861,9 +898,10 @@ int jt_obd_no_transno(int argc, char **argv)
        if (rc < 0)
                fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
                        strerror(rc = errno));
-
+#endif
        return rc;
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 int jt_obd_set_readonly(int argc, char **argv)
 {