diff mbox series

[v4,7/7] nfsrahead: retry getting the device if it fails.

Message ID 20220404121308.14228-1-tbecker@redhat.com (mailing list archive)
State New, archived
Headers show
Series Intruduce nfsrahead | expand

Commit Message

Thiago Becker April 4, 2022, 12:13 p.m. UTC
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 <tbecker@redhat.com>
---
 tools/nfsrahead/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

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;
 	}