From patchwork Mon Jul 15 13:00:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 2827465 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A0E509F7D6 for ; Mon, 15 Jul 2013 13:05:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E50A52015F for ; Mon, 15 Jul 2013 13:04:55 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id B25E420155 for ; Mon, 15 Jul 2013 13:04:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD0fmD005968; Mon, 15 Jul 2013 09:00:42 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD0cfY028935 for ; Mon, 15 Jul 2013 09:00:38 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FD0cPY011114 for ; Mon, 15 Jul 2013 09:00:38 -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 r6FD0apu025968 for ; Mon, 15 Jul 2013 09:00:37 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1F722A538C; Mon, 15 Jul 2013 15:00:35 +0200 (CEST) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 15 Jul 2013 15:00:15 +0200 Message-Id: <1373893230-26077-15-git-send-email-hare@suse.de> In-Reply-To: <1373893230-26077-1-git-send-email-hare@suse.de> References: <1373893230-26077-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.69 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 14/29] 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; }