From patchwork Tue Jul 16 07:13:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 2827940 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14DFAC0AB2 for ; Tue, 16 Jul 2013 07:18:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 133D820187 for ; Tue, 16 Jul 2013 07:18:45 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id E9F4A20184 for ; Tue, 16 Jul 2013 07:18:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6G7E48e030489; Tue, 16 Jul 2013 03:14:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6G7DTPx027857 for ; Tue, 16 Jul 2013 03:13:29 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r6G7DTx8032101 for ; Tue, 16 Jul 2013 03:13:29 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6G7DRwG007279 for ; Tue, 16 Jul 2013 03:13:27 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7CC3BA554C; Tue, 16 Jul 2013 09:13:24 +0200 (CEST) From: Hannes Reinecke To: Christophe Varoqui Date: Tue, 16 Jul 2013 09:13:05 +0200 Message-Id: <1373958801-103613-15-git-send-email-hare@suse.de> In-Reply-To: <1373958801-103613-1-git-send-email-hare@suse.de> References: <1373958801-103613-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.29 (BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 14/30] Read directly from sysfs when checking the device size X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- libmultipath/discovery.c | 5 ++--- libmultipath/sysfs.c | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 96fe985..82f086b 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -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 " diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index 22b73b1..bab3837 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -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; }