Read directly from sysfs when checking the device size
authorHannes Reinecke <hare@suse.de>
Tue, 16 Jul 2013 07:13:05 +0000 (09:13 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 16 Jul 2013 19:50:42 +0000 (21:50 +0200)
Device sizes might change, so we need to be reading from sysfs
directly to avoid udev still caching the old value.

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

index 9137ed2..7ca7cf9 100644 (file)
@@ -320,7 +320,7 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
        struct udev_device *rport_dev = NULL;
        char value[11];
        char rport_id[32];
-       unsigned long long tmo;
+       unsigned long long tmo = 0;
 
        sprintf(rport_id, "rport-%d:%d-%d",
                pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
@@ -347,6 +347,7 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
         */
        value[0] = '\0';
        if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET &&
+           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",
@@ -362,8 +363,6 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
                }
                if (mpp->fast_io_fail >= tmo) {
                        snprintf(value, 11, "%u", mpp->fast_io_fail);
-               } else {
-                       tmo = 0;
                }
        } else if (mpp->dev_loss > 600) {
                condlog(3, "%s: limiting dev_loss_tmo to 600, since "
index 22b73b1..bab3837 100644 (file)
@@ -149,14 +149,13 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
 int
 sysfs_get_size (struct path *pp, unsigned long long * size)
 {
-       const char * attr;
+       char attr[255];
        int r;
 
        if (!pp->udev)
                return 1;
 
-       attr = udev_device_get_sysattr_value(pp->udev, "size");
-       if (!attr) {
+       if (sysfs_attr_get_value(pp->udev, "size", attr, 255) == 0) {
                condlog(3, "%s: No size attribute in sysfs", pp->dev);
                return 1;
        }
@@ -164,8 +163,7 @@ sysfs_get_size (struct path *pp, unsigned long long * size)
        r = sscanf(attr, "%llu\n", size);
 
        if (r != 1) {
-               condlog(3, "%s: Cannot parse size attribute '%s'",
-                       pp->dev, attr);
+               condlog(3, "%s: Cannot parse size attribute", pp->dev);
                return 1;
        }