From patchwork Fri Apr 1 15:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C20AC433F5 for ; Fri, 1 Apr 2022 16:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346417AbiDAQLc (ORCPT ); Fri, 1 Apr 2022 12:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349535AbiDAQI4 (ORCPT ); Fri, 1 Apr 2022 12:08:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7586DFFB48 for ; Fri, 1 Apr 2022 08:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u/gwv7Px62VyAEaIFavhsWYpeXfWia3hAQmD6wryrDw=; b=flSAWbSWbjJQtbs+e1hcCu7IDRdE5HCW5o+AxTTf1kCQlPJB5A4ujgGac5wFSvlEqjPxJy gwnKA29XF1u1C8wiXRq2FsDF2iPJw9jE/Vgyo3azJd5OOTt4pfHdTu/sVEr6A583obC77s 6ufIMuYTtMrJOVpP2+0UQgRpGHYlAQU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-sKmpgSICO2KJdfI8dTOPqg-1; Fri, 01 Apr 2022 11:32:31 -0400 X-MC-Unique: sKmpgSICO2KJdfI8dTOPqg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9895380418E; Fri, 1 Apr 2022 15:32:28 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6227F7C30; Fri, 1 Apr 2022 15:32:24 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 1/7] Create nfsrahead Date: Fri, 1 Apr 2022 12:32:02 -0300 Message-Id: <20220401153208.3120851-2-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Kernel commit c128e575514c ("NFS: Optimise the default readahead size") changed the calculation for NFS readahead from a multiple of rsize to the system default, 128 kiB. This setting has been causing read heavy workloads to underperform by at least 30%, as show below. $ cat /sys/class/bdi/0\:55/read_ahead_kb 128 $ for i in {0..3} ; do dd if=/mnt/testfile.bin of=/dev/null bs=1M 2>&1 \ | grep copied ; echo 3 > /proc/sys/vm/drop_caches ; done 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 17.056 s, 252 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 17.1258 s, 251 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 16.5981 s, 259 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 16.5487 s, 260 MB/s $ echo 15360 > /sys/class/bdi/0\:55/read_ahead_kb $ for i in {0..3} ; do dd if=/mnt/testfile.bin of=/dev/null bs=1M 2>&1 \ | grep copied ; echo 3 > /proc/sys/vm/drop_caches ; done 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 12.3855 s, 347 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 11.2528 s, 382 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 11.9849 s, 358 MB/s 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 11.2953 s, 380 MB/s This patch and the following create a tool for automatically setting NFS readahead during the mount, nfsrahead. The tool is invoked from udev when the NFS backing device is created in kernel, and sets the readahead using the sysfs interface. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- .gitignore | 1 + configure.ac | 1 + tools/Makefile.am | 2 +- tools/nfsrahead/Makefile.am | 3 +++ tools/nfsrahead/main.c | 7 +++++++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tools/nfsrahead/Makefile.am create mode 100644 tools/nfsrahead/main.c diff --git a/.gitignore b/.gitignore index c89d1cd2..38ab1d39 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ utils/statd/statd tools/locktest/testlk tools/getiversion/getiversion tools/nfsconf/nfsconf +tools/nfsrahead/nfsrahead support/export/mount.h support/export/mount_clnt.c support/export/mount_xdr.c diff --git a/configure.ac b/configure.ac index e0f5a930..3e1c183b 100644 --- a/configure.ac +++ b/configure.ac @@ -737,6 +737,7 @@ AC_CONFIG_FILES([ tools/rpcgen/Makefile tools/mountstats/Makefile tools/nfs-iostat/Makefile + tools/nfsrahead/Makefile tools/rpcctl/Makefile tools/nfsdclnts/Makefile tools/nfsconf/Makefile diff --git a/tools/Makefile.am b/tools/Makefile.am index c3feabbe..40c17c37 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -12,6 +12,6 @@ if CONFIG_NFSDCLD OPTDIRS += nfsdclddb endif -SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat rpcctl nfsdclnts $(OPTDIRS) +SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat rpcctl nfsdclnts nfsrahead $(OPTDIRS) MAINTAINERCLEANFILES = Makefile.in diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am new file mode 100644 index 00000000..edff7921 --- /dev/null +++ b/tools/nfsrahead/Makefile.am @@ -0,0 +1,3 @@ +libexec_PROGRAMS = nfsrahead +nfsrahead_SOURCES = main.c + diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c new file mode 100644 index 00000000..0359aced --- /dev/null +++ b/tools/nfsrahead/main.c @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) +{ + unsigned int readahead = 128; + printf("%d\n", readahead); +} From patchwork Fri Apr 1 15:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8031EC433EF for ; Fri, 1 Apr 2022 16:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345613AbiDAQLa (ORCPT ); Fri, 1 Apr 2022 12:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349490AbiDAQI4 (ORCPT ); Fri, 1 Apr 2022 12:08:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABDE61A2A30 for ; Fri, 1 Apr 2022 08:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oxpdjddWsu965voiUt3RDLYE0ZMWuHvFAPmZcNyp+BY=; b=LwMTD6tf+Olbxp+GZRS/yrgHB7fEuWZ2nFIEzlNPyAp0VkrDWr5eYfu+nt+pqmGafywtrc +wDWu+5/twcxoO+30s9g64bpp8q/+uzMdf0lImFS5n8C3mSHTUQJzxi9vqwAhkS9pcVLg0 hSYCnLJWEpWYC/ph3UBBTtZKKdRe8Ao= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-07JyOUMpM-eQM4ODuZ56Pw-1; Fri, 01 Apr 2022 11:32:33 -0400 X-MC-Unique: 07JyOUMpM-eQM4ODuZ56Pw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E34A10AF627; Fri, 1 Apr 2022 15:32:32 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EA277ADD; Fri, 1 Apr 2022 15:32:29 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 2/7] nfsrahead: configure udev Date: Fri, 1 Apr 2022 12:32:03 -0300 Message-Id: <20220401153208.3120851-3-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Set the udev rule to call the readahead utility. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- .gitignore | 1 + tools/nfsrahead/99-nfs.rules.in | 1 + tools/nfsrahead/Makefile.am | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 tools/nfsrahead/99-nfs.rules.in diff --git a/.gitignore b/.gitignore index 38ab1d39..df791a83 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ tools/locktest/testlk tools/getiversion/getiversion tools/nfsconf/nfsconf tools/nfsrahead/nfsrahead +tools/nfsrahead/99-nfs_bdi.rules support/export/mount.h support/export/mount_clnt.c support/export/mount_xdr.c diff --git a/tools/nfsrahead/99-nfs.rules.in b/tools/nfsrahead/99-nfs.rules.in new file mode 100644 index 00000000..7d55b407 --- /dev/null +++ b/tools/nfsrahead/99-nfs.rules.in @@ -0,0 +1 @@ +SUBSYSTEM=="bdi", ACTION=="add", PROGRAM="_libexecdir_/nfsrahead", ATTR{read_ahead_kb}="%c" diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am index edff7921..58a2ea29 100644 --- a/tools/nfsrahead/Makefile.am +++ b/tools/nfsrahead/Makefile.am @@ -1,3 +1,11 @@ libexec_PROGRAMS = nfsrahead nfsrahead_SOURCES = main.c +udev_rulesdir = /usr/lib/udev/rules.d/ +udev_rules_DATA = 99-nfs.rules + +99-nfs.rules: 99-nfs.rules.in $(builddefs) + $(SED) "s|_libexecdir_|@libexecdir@|g" 99-nfs.rules.in > $@ + +clean-local: + $(RM) 99-nfs.rules From patchwork Fri Apr 1 15:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D141C433EF for ; Fri, 1 Apr 2022 16:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346814AbiDAQLh (ORCPT ); Fri, 1 Apr 2022 12:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349537AbiDAQI5 (ORCPT ); Fri, 1 Apr 2022 12:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 36D441A2A35 for ; Fri, 1 Apr 2022 08:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hT1eCpJ2y59hfRLRGJ/ytsvTYn8oYfO+eHH4/oNgNVI=; b=issB8I64MhI8oM/2arN1DtEbieinCSSV948gLD4gxegp5eZYndpq/4S3pOnF/8uXWJLPL8 VcI/io3VjSEVvGlJya6XuIUQyfG5GTYUwg/TgO7fHZVxHkd3LaohyTVUWnQE6ByV0TLJLI wRSEdNUBbeFrmI78QFpw9nanam0ev9I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-GIzMUgl5O_6BRUW9WOEnjg-1; Fri, 01 Apr 2022 11:32:43 -0400 X-MC-Unique: GIzMUgl5O_6BRUW9WOEnjg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E53848517C3; Fri, 1 Apr 2022 15:32:38 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 749847ADD; Fri, 1 Apr 2022 15:32:33 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 3/7] nfsrahead: only set readahead for nfs devices. Date: Fri, 1 Apr 2022 12:32:04 -0300 Message-Id: <20220401153208.3120851-4-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Limit setting the readahead for nfs devices. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- tools/nfsrahead/99-nfs.rules.in | 2 +- tools/nfsrahead/Makefile.am | 1 + tools/nfsrahead/main.c | 128 ++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) diff --git a/tools/nfsrahead/99-nfs.rules.in b/tools/nfsrahead/99-nfs.rules.in index 7d55b407..648813c5 100644 --- a/tools/nfsrahead/99-nfs.rules.in +++ b/tools/nfsrahead/99-nfs.rules.in @@ -1 +1 @@ -SUBSYSTEM=="bdi", ACTION=="add", PROGRAM="_libexecdir_/nfsrahead", ATTR{read_ahead_kb}="%c" +SUBSYSTEM=="bdi", ACTION=="add", PROGRAM="_libexecdir_/nfsrahead %k", ATTR{read_ahead_kb}="%c" diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am index 58a2ea29..0daddc4b 100644 --- a/tools/nfsrahead/Makefile.am +++ b/tools/nfsrahead/Makefile.am @@ -1,5 +1,6 @@ libexec_PROGRAMS = nfsrahead nfsrahead_SOURCES = main.c +nfsrahead_LDFLAGS= -lmount udev_rulesdir = /usr/lib/udev/rules.d/ udev_rules_DATA = 99-nfs.rules diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index 0359aced..8fe6d648 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -1,7 +1,135 @@ #include +#include +#include +#include + +#include +#include + +#ifndef MOUNTINFO_PATH +#define MOUNTINFO_PATH "/proc/self/mountinfo" +#endif + +/* Device information from the system */ +struct device_info { + char *device_number; + dev_t dev; + char *mountpoint; + char *fstype; +}; + +/* Convert a string in the format n:m to a device number */ +static dev_t dev_from_arg(const char *device_number) +{ + char *s = strdup(device_number), *p; + char *maj_s, *min_s; + unsigned int maj, min; + dev_t dev; + + maj_s = p = s; + for ( ; *p != ':'; p++) + ; + + *p = '\0'; + min_s = p + 1; + + maj = strtol(maj_s, NULL, 10); + min = strtol(min_s, NULL, 10); + + dev = makedev(maj, min); + + free(s); + return dev; +} + +#define sfree(ptr) if (ptr) free(ptr) + +/* device_info maintenance */ +static void init_device_info(struct device_info *di, const char *device_number) +{ + di->device_number = strdup(device_number); + di->dev = dev_from_arg(device_number); + di->mountpoint = NULL; + di->fstype = NULL; +} + + +static void free_device_info(struct device_info *di) +{ + sfree(di->mountpoint); + sfree(di->fstype); + sfree(di->device_number); +} + +static int get_mountinfo(const char *device_number, struct device_info *device_info, const char *mountinfo_path) +{ + int ret = 0; + struct libmnt_table *mnttbl; + struct libmnt_fs *fs; + char *target; + + init_device_info(device_info, device_number); + + mnttbl = mnt_new_table(); + + if ((ret = mnt_table_parse_file(mnttbl, mountinfo_path)) < 0) + goto out_free_tbl; + + if ((fs = mnt_table_find_devno(mnttbl, device_info->dev, MNT_ITER_FORWARD)) == NULL) { + ret = ENOENT; + goto out_free_tbl; + } + + if ((target = (char *)mnt_fs_get_target(fs)) == NULL) { + ret = ENOENT; + goto out_free_fs; + } + + device_info->mountpoint = strdup(target); + target = (char *)mnt_fs_get_fstype(fs); + if (target) + device_info->fstype = strdup(target); + +out_free_fs: + mnt_free_fs(fs); +out_free_tbl: + mnt_free_table(mnttbl); + free(device_info->device_number); + device_info->device_number = NULL; + return ret; +} + +static int get_device_info(const char *device_number, struct device_info *device_info) +{ + int ret = ENOENT; + for (int retry_count = 0; retry_count < 10 && ret != 0; retry_count++) + ret = get_mountinfo(device_number, device_info, MOUNTINFO_PATH); + + return ret; +} int main(int argc, char **argv) { + int ret = 0; + struct device_info device; unsigned int readahead = 128; + + if (argc != 2) { + return -EINVAL; + } + + if ((ret = get_device_info(argv[1], &device)) != 0) { + goto out; + } + + if (strncmp("nfs", device.fstype, 3) != 0) { + ret = -EINVAL; + goto out; + } + printf("%d\n", readahead); + +out: + free_device_info(&device); + return ret; } From patchwork Fri Apr 1 15:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63502C43219 for ; Fri, 1 Apr 2022 16:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345171AbiDAQL3 (ORCPT ); Fri, 1 Apr 2022 12:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349668AbiDAQI5 (ORCPT ); Fri, 1 Apr 2022 12:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16BDD1A2A36 for ; Fri, 1 Apr 2022 08:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sYqGNoeKyNfXy/k1csUcqU5ZARls3XYh8BgaVvO+Lk4=; b=FL8tzJyIBt9QdbFqoRS9kYtGpxbBt6Nj3Nqc4//F+2l16On3QUiUF1OgM32BaeeWmlybrj 3GREP3NK9A2ayxv5hsbDFz0REnsPPWDtc4bYfNGJLJMa5diDThpje5KMLLULc38dEDImRB KLPcBo68f7XWGbvWRi9SIN6dN21ucuk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-1tWw3ybWMZGZM0SwzAzn9g-1; Fri, 01 Apr 2022 11:32:43 -0400 X-MC-Unique: 1tWw3ybWMZGZM0SwzAzn9g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 109192A2AD70; Fri, 1 Apr 2022 15:32:43 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4ADC9D45; Fri, 1 Apr 2022 15:32:39 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 4/7] nfsrahead: add logging Date: Fri, 1 Apr 2022 12:32:05 -0300 Message-Id: <20220401153208.3120851-5-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- tools/nfsrahead/Makefile.am | 1 + tools/nfsrahead/main.c | 40 ++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am index 0daddc4b..60a1102a 100644 --- a/tools/nfsrahead/Makefile.am +++ b/tools/nfsrahead/Makefile.am @@ -1,6 +1,7 @@ libexec_PROGRAMS = nfsrahead nfsrahead_SOURCES = main.c nfsrahead_LDFLAGS= -lmount +nfsrahead_LDADD = ../../support/nfs/libnfsconf.la udev_rulesdir = /usr/lib/udev/rules.d/ udev_rules_DATA = 99-nfs.rules diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index 8fe6d648..b630b92f 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -2,14 +2,19 @@ #include #include #include +#include #include #include +#include "xlog.h" + #ifndef MOUNTINFO_PATH #define MOUNTINFO_PATH "/proc/self/mountinfo" #endif +#define CONF_NAME "nfsrahead" + /* Device information from the system */ struct device_info { char *device_number; @@ -108,25 +113,50 @@ static int get_device_info(const char *device_number, struct device_info *device return ret; } +#define L_DEFAULT (L_WARNING | L_ERROR | L_FATAL) + int main(int argc, char **argv) { int ret = 0; struct device_info device; - unsigned int readahead = 128; - - if (argc != 2) { - return -EINVAL; + unsigned int readahead = 128, verbose = 0, log_stderr = 0; + char opt; + + while((opt = getopt(argc, argv, "dF")) != -1) { + switch (opt) { + case 'd': + verbose = 1; + break; + case 'F': + log_stderr = 1; + break; + } } - if ((ret = get_device_info(argv[1], &device)) != 0) { + xlog_stderr(log_stderr); + xlog_syslog(~log_stderr); + xlog_config(L_DEFAULT | (L_NOTICE & verbose), 1); + xlog_open(CONF_NAME); + + // xlog_err causes the system to exit + if ((argc - optind) != 1) + xlog_err("expected the device number of a BDI; is udev ok?"); + + if ((ret = get_device_info(argv[optind], &device)) != 0) { + xlog(L_ERROR, "unable to find device %s\n", argv[optind]); goto out; } if (strncmp("nfs", device.fstype, 3) != 0) { + xlog(L_NOTICE, + "not setting readahead for non supported fstype %s on device %s\n", + device.fstype, argv[optind]); ret = -EINVAL; goto out; } + xlog(L_WARNING, "setting %s readahead to %d\n", device.mountpoint, readahead); + printf("%d\n", readahead); out: From patchwork Fri Apr 1 15:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 363AAC433FE for ; Fri, 1 Apr 2022 16:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243299AbiDAQL2 (ORCPT ); Fri, 1 Apr 2022 12:11:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349633AbiDAQI5 (ORCPT ); Fri, 1 Apr 2022 12:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DCD8FFB4B for ; Fri, 1 Apr 2022 08:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vESb3x633QWbvnEi4e9pu9J78HVNlcN3PfpVYmVC8kk=; b=Crn68SC0xmOxLHNknJu3+E+vsWBsYsQ7i1hnyuEMEZouvWDKI9lTdIZXsv01HSY0qEGa7q dhnPSUgff+k04bS+s826c7XWhJa/J9uS6h9pZPoIwxnGS2FqUI7rgTdWNvNuhI8zTtN+51 pAtwMiZFqHEQXohAjoGskgjTjFCZyTA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-yNXldqTgNFS5xX0OwZhsHA-1; Fri, 01 Apr 2022 11:32:47 -0400 X-MC-Unique: yNXldqTgNFS5xX0OwZhsHA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 207E12A2AD45; Fri, 1 Apr 2022 15:32:47 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E45909D42; Fri, 1 Apr 2022 15:32:43 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 5/7] nfsrahead: get the information from the config file. Date: Fri, 1 Apr 2022 12:32:06 -0300 Message-Id: <20220401153208.3120851-6-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- tools/nfsrahead/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index b630b92f..1a312ac9 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -8,12 +8,14 @@ #include #include "xlog.h" +#include "conffile.h" #ifndef MOUNTINFO_PATH #define MOUNTINFO_PATH "/proc/self/mountinfo" #endif #define CONF_NAME "nfsrahead" +#define NFS_DEFAULT_READAHEAD 128 /* Device information from the system */ struct device_info { @@ -113,6 +115,14 @@ static int get_device_info(const char *device_number, struct device_info *device return ret; } +static int conf_get_readahead(const char *kind) { + int readahead = 0; + + if((readahead = conf_get_num(CONF_NAME, kind, -1)) == -1) + readahead = conf_get_num(CONF_NAME, "default", NFS_DEFAULT_READAHEAD); + + return readahead; +} #define L_DEFAULT (L_WARNING | L_ERROR | L_FATAL) int main(int argc, char **argv) @@ -133,6 +143,8 @@ int main(int argc, char **argv) } } + conf_init_file(NFS_CONFFILE); + xlog_stderr(log_stderr); xlog_syslog(~log_stderr); xlog_config(L_DEFAULT | (L_NOTICE & verbose), 1); @@ -155,6 +167,8 @@ int main(int argc, char **argv) goto out; } + readahead = conf_get_readahead(device.fstype); + xlog(L_WARNING, "setting %s readahead to %d\n", device.mountpoint, readahead); printf("%d\n", readahead); From patchwork Fri Apr 1 15:32:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12798466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C731C433EF for ; Fri, 1 Apr 2022 16:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237129AbiDAQL1 (ORCPT ); Fri, 1 Apr 2022 12:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349657AbiDAQI5 (ORCPT ); Fri, 1 Apr 2022 12:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8A35AFFB4C for ; Fri, 1 Apr 2022 08:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pdeAVoT8WrUyzro2PiZcbaPSqi9ISMyf0NB3t0SMW6U=; b=QU2xvgezHd9YYkY5KAuyxDzltk1KtGErqyFDctfXAsvT0US+Ka4U+fN2bFUFGnfXQ/dZr0 UgrT87Yt5a2iNjHuwKVVVwTGa0+MlKcnEXouD5hsrbs3uMGqRfeYh2tKX2HTAiGIL/gcMr INAFKRc6fJqcj1RtbTeVyK7QWIM6h4M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-f1SZsWzrO9u-FqfNpxy4BA-1; Fri, 01 Apr 2022 11:32:51 -0400 X-MC-Unique: f1SZsWzrO9u-FqfNpxy4BA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3725F80281D; Fri, 1 Apr 2022 15:32:51 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3FA47C4E; Fri, 1 Apr 2022 15:32:47 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 6/7] nfsrahead: User documentation Date: Fri, 1 Apr 2022 12:32:07 -0300 Message-Id: <20220401153208.3120851-7-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add the man page for nfsrahead, and add the new section to nfs.conf. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- systemd/nfs.conf.man | 11 ++++++ tools/nfsrahead/Makefile.am | 3 ++ tools/nfsrahead/nfsrahead.man | 72 +++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tools/nfsrahead/nfsrahead.man diff --git a/systemd/nfs.conf.man b/systemd/nfs.conf.man index be487a11..e74083e9 100644 --- a/systemd/nfs.conf.man +++ b/systemd/nfs.conf.man @@ -294,6 +294,17 @@ Only .B debug= is recognized. +.TP +.B nfsrahead +Recognized values: +.BR nfs , +.BR nfsv4 , +.BR default . + +See +.BR nfsrahead (5) +for deatils. + .SH FILES .TP 10n .I /etc/nfs.conf diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am index 60a1102a..845ea0d5 100644 --- a/tools/nfsrahead/Makefile.am +++ b/tools/nfsrahead/Makefile.am @@ -3,6 +3,9 @@ nfsrahead_SOURCES = main.c nfsrahead_LDFLAGS= -lmount nfsrahead_LDADD = ../../support/nfs/libnfsconf.la +man5_MANS = nfsrahead.man +EXTRA_DIST = $(man5_MANS) + udev_rulesdir = /usr/lib/udev/rules.d/ udev_rules_DATA = 99-nfs.rules diff --git a/tools/nfsrahead/nfsrahead.man b/tools/nfsrahead/nfsrahead.man new file mode 100644 index 00000000..5488f633 --- /dev/null +++ b/tools/nfsrahead/nfsrahead.man @@ -0,0 +1,72 @@ +.\" Manpage for nfsrahead. +.nh +.ad l +.TH man 5 "08 Mar 2022" "1.0" "nfsrahead man page" +.SH NAME + +nfsrahead \- Configure the readahead for NFS mounts + +.SH SYNOPSIS + +nfsrahead [-F] [-d] + +.SH DESCRIPTION + +\fInfsrahead\fR is a tool intended to be used with udev to set the \fIread_ahead_kb\fR parameter of NFS mounts, according to the configuration file (see \fICONFIGURATION\fR). \fIdevice\fR is the device number for the NFS backing device as provided by the kernel. + +.SH OPTIONS +.TP +.B -F +Send messages to +.I stderr +instead of +.I syslog + +.TP +.B -d +Increase the debugging level. + +.SH CONFIGURATION +.I nfsrahead +is configured in +.IR /etc/nfs.conf , +in the section titled +.IR nfsrahead . +It accepts the following configurations. + +.TP +.B nfs= +The readahead value applied to NFSv3 mounts. + +.TP +.B nfs4= +The readahead value applied to NFSv4 mounts. + +.TP +.B default= +The default configuration when none of the configurations above is set. + +.SH EXAMPLE CONFIGURATION +[nfsrahead] +.br +nfs=15000 # readahead of 15000 for NFSv3 mounts +.br +nfs4=16000 # readahead of 16000 for NFSv4 mounts +.br +default=128 # default is 128 + +.SH SEE ALSO + +.BR mount.nfs (8), +.BR nfs (5), +.BR nfs.conf (5), +.BR udev (7), +.BR bcc-readahead (8) + +.SH BUGS + +No known bugs. + +.SH AUTHOR + +Thiago Rafael Becker From patchwork Mon Apr 4 12:13:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 12800140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A85BCC433F5 for ; Mon, 4 Apr 2022 12:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237187AbiDDMQP (ORCPT ); Mon, 4 Apr 2022 08:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239706AbiDDMQO (ORCPT ); Mon, 4 Apr 2022 08:16:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABE93273F for ; Mon, 4 Apr 2022 05:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649074457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=60796q+R66q6PScXM7sZ0KwUoDSRalaBUU99w2DeJQA=; b=WOvPq1Z3GbFAG5nmyvnVyYkitaS/tCPWn4M6Mi10JRGV0X0qKnHy2fOb7Vy3bz082cZUyG J7KPu6iuNnRubJ8/6vLE8PyOZLeCNuk8Zx4Bff1a+F3KvEpD3byoevgG1OZpjCqg3D6yp2 pdR7RlJGPqN+ni6sFt9PqA7bOiwUot4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-r7hPr-VDPTe8ifEvNlpAEA-1; Mon, 04 Apr 2022 08:14:14 -0400 X-MC-Unique: r7hPr-VDPTe8ifEvNlpAEA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81F911C068D1; Mon, 4 Apr 2022 12:14:13 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-103.gru2.redhat.com [10.97.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEDB64428E8; Mon, 4 Apr 2022 12:14:07 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 7/7] nfsrahead: retry getting the device if it fails. Date: Mon, 4 Apr 2022 09:13:08 -0300 Message-Id: <20220404121308.14228-1-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Sometimes the mountinfo entry is not available when nfsrahead is called, leading to failure to set the readahead. Retry getting the device before failing. Signed-off-by: Thiago Becker --- tools/nfsrahead/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index 1a312ac9..b3af3aa8 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -127,7 +127,7 @@ static int conf_get_readahead(const char *kind) { int main(int argc, char **argv) { - int ret = 0; + int ret = 0, retry; struct device_info device; unsigned int readahead = 128, verbose = 0, log_stderr = 0; char opt; @@ -154,7 +154,11 @@ int main(int argc, char **argv) if ((argc - optind) != 1) xlog_err("expected the device number of a BDI; is udev ok?"); - if ((ret = get_device_info(argv[optind], &device)) != 0) { + for (retry = 0; retry <= 10; retry++ ) + if ((ret = get_device_info(argv[optind], &device)) == 0) + break; + + if (ret != 0) { xlog(L_ERROR, "unable to find device %s\n", argv[optind]); goto out; }