Do not print error when rport is blocked
authorHannes Reinecke <hare@suse.de>
Tue, 16 Jul 2013 07:13:14 +0000 (09:13 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 16 Jul 2013 19:52:04 +0000 (21:52 +0200)
When an rport is blocked any write to the dev_loss_tmo
attribute will fail with EBUSY. But that's perfectly
normal and nothing to worry about, so decrease the
logging priority for these cases.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/discovery.c
libmultipath/sysfs.c

index f305aa7..558c2bd 100644 (file)
@@ -323,6 +323,7 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
        char value[11];
        char rport_id[32];
        unsigned long long tmo = 0;
+       int ret;
 
        sprintf(rport_id, "rport-%d:%d-%d",
                pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
@@ -352,15 +353,16 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
            mpp->fast_io_fail != MP_FAST_IO_FAIL_ZERO &&
            mpp->fast_io_fail != MP_FAST_IO_FAIL_OFF) {
                /* Check if we need to temporarily increase dev_loss_tmo */
-               if (sysfs_attr_get_value(rport_dev, "dev_loss_tmo",
-                                        value, 16) <= 0) {
+               ret = sysfs_attr_get_value(rport_dev, "dev_loss_tmo",
+                                          value, 16);
+               if (ret <= 0) {
                        condlog(0, "%s: failed to read dev_loss_tmo value, "
-                               "error %d", pp->dev, errno);
+                               "error %d", rport_id, -ret);
                        goto out;
                }
                if (sscanf(value, "%llu\n", &tmo) != 1) {
                        condlog(0, "%s: Cannot parse dev_loss_tmo "
-                               "attribute '%s'",pp->dev, value);
+                               "attribute '%s'", rport_id, value);
                        goto out;
                }
                if (mpp->fast_io_fail >= tmo) {
@@ -368,16 +370,21 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
                }
        } else if (mpp->dev_loss > 600) {
                condlog(3, "%s: limiting dev_loss_tmo to 600, since "
-                       "fast_io_fail is not set", pp->dev);
+                       "fast_io_fail is not set", rport_id);
                snprintf(value, 11, "%u", 600);
        } else {
                snprintf(value, 11, "%u", mpp->dev_loss);
        }
-       if (strlen(value) &&
-           sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, 11) <= 0) {
-               condlog(0, "%s failed to set dev_loss_tmo",
-                       mpp->alias);
-               goto out;
+       if (strlen(value)) {
+               ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, 11);
+               if (ret <= 0) {
+                       if (ret == -EBUSY)
+                               condlog(3, "%s: rport blocked", rport_id);
+                       else
+                               condlog(0, "%s: failed to set dev_loss_tmo to %s, error %d",
+                                       rport_id, value, -ret);
+                       goto out;
+               }
        }
        if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) {
                if (mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF)
@@ -386,18 +393,27 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
                        sprintf(value, "0");
                else
                        snprintf(value, 11, "%u", mpp->fast_io_fail);
-               if (sysfs_attr_set_value(rport_dev, "fast_io_fail_tmo",
-                                        value, 11) <= 0) {
-                       condlog(0, "%s failed to set fast_io_fail_tmo",
-                               mpp->alias);
+               ret = sysfs_attr_set_value(rport_dev, "fast_io_fail_tmo",
+                                          value, 11);
+               if (ret <= 0) {
+                       if (ret == -EBUSY)
+                               condlog(3, "%s: rport blocked", rport_id);
+                       else
+                               condlog(0, "%s: failed to set fast_io_fail_tmo to %s, error %d",
+                                       rport_id, value, -ret);
                }
        }
        if (tmo > 0) {
                snprintf(value, 11, "%u", mpp->dev_loss);
-               if (sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
-                                        value, 11) <= 0)
-                       condlog(0, "%s failed to set dev_loss_tmo",
-                               mpp->alias);
+               ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
+                                          value, 11);
+               if (ret <= 0) {
+                       if (ret == -EBUSY)
+                               condlog(3, "%s: rport blocked", rport_id);
+                       else
+                               condlog(0, "%s: failed to set dev_loss_tmo to %s, error %d",
+                                       rport_id, value, -ret);
+               }
        }
 out:
        udev_device_unref(rport_dev);
index bab3837..0670e0a 100644 (file)
@@ -59,19 +59,19 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
        condlog(4, "open '%s'", devpath);
        if (stat(devpath, &statbuf) != 0) {
                condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
-               return 0;
+               return -errno;
        }
 
        /* skip directories */
        if (S_ISDIR(statbuf.st_mode)) {
                condlog(4, "%s is a directory", devpath);
-               return 0;
+               return -EISDIR;
        }
 
        /* skip non-writeable files */
        if ((statbuf.st_mode & S_IRUSR) == 0) {
                condlog(4, "%s is not readable", devpath);
-               return 0;
+               return -EPERM;
        }
 
        /* read attribute value */
@@ -79,12 +79,12 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
        if (fd < 0) {
                condlog(4, "attribute '%s' can not be opened: %s",
                        devpath, strerror(errno));
-               return 0;
+               return -errno;
        }
        size = read(fd, value, value_len);
        if (size < 0) {
                condlog(4, "read from %s failed: %s", devpath, strerror(errno));
-               size = 0;
+               size = -errno;
        } else if (size == value_len) {
                condlog(4, "overflow while reading from %s", devpath);
                size = 0;
@@ -110,19 +110,19 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
        condlog(4, "open '%s'", devpath);
        if (stat(devpath, &statbuf) != 0) {
                condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
-               return 0;
+               return -errno;
        }
 
        /* skip directories */
        if (S_ISDIR(statbuf.st_mode)) {
                condlog(4, "%s is a directory", devpath);
-               return 0;
+               return -EISDIR;
        }
 
        /* skip non-writeable files */
        if ((statbuf.st_mode & S_IWUSR) == 0) {
                condlog(4, "%s is not writeable", devpath);
-               return 0;
+               return -EPERM;
        }
 
        /* write attribute value */
@@ -130,12 +130,12 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
        if (fd < 0) {
                condlog(4, "attribute '%s' can not be opened: %s",
                        devpath, strerror(errno));
-               return 0;
+               return -errno;
        }
        size = write(fd, value, value_len);
        if (size < 0) {
                condlog(4, "write to %s failed: %s", devpath, strerror(errno));
-               size = 0;
+               size = -errno;
        } else if (size < value_len) {
                condlog(4, "tried to write %ld to %s. Wrote %ld",
                        (long)value_len, devpath, (long)size);