All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Straub <lukasstraub2@web.de>
To: "axboe@kernel.dk" <axboe@kernel.dk>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>
Subject: [PATCH 4/8] linux-dev-lookup.c: Put the check for replay_redirect in the beginning
Date: Wed, 19 Jan 2022 21:14:26 +0000	[thread overview]
Message-ID: <0dd4b6407f7b7f5f15f1fcad409554ff339ffca1.1642626314.git.lukasstraub2@web.de> (raw)
In-Reply-To: <cover.1642626314.git.lukasstraub2@web.de>

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

The machine may not have any block device nodes (like my dev container)
which makes this function fail despite replay_redirect being set.

Move the check to the beginning to fix this.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 oslib/linux-dev-lookup.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/oslib/linux-dev-lookup.c b/oslib/linux-dev-lookup.c
index 1dda93f2..4335faf9 100644
--- a/oslib/linux-dev-lookup.c
+++ b/oslib/linux-dev-lookup.c
@@ -16,6 +16,16 @@ int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj,
 	int found = 0;
 	DIR *D;
 
+	/*
+	 * If replay_redirect is set then always return this device
+	 * upon lookup which overrides the device lookup based on
+	 * major minor in the actual blktrace
+	 */
+	if (redirect) {
+		strcpy(path, redirect);
+		return 1;
+	}
+
 	D = opendir(path);
 	if (!D)
 		return 0;
@@ -44,17 +54,6 @@ int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj,
 		if (!S_ISBLK(st.st_mode))
 			continue;
 
-		/*
-		 * If replay_redirect is set then always return this device
-		 * upon lookup which overrides the device lookup based on
-		 * major minor in the actual blktrace
-		 */
-		if (redirect) {
-			strcpy(path, redirect);
-			found = 1;
-			break;
-		}
-
 		if (maj == major(st.st_rdev) && min == minor(st.st_rdev)) {
 			strcpy(path, full_path);
 			found = 1;
-- 
2.34.1


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2022-01-19 21:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19 21:14 [PATCH 0/8] blktrace: Add support for read_iolog_chunked and fixes Lukas Straub
2022-01-19 21:14 ` [PATCH 1/8] blktrace.c: Use file stream interface instead of fifo Lukas Straub
2022-01-19 21:14 ` [PATCH 2/8] iolog.c: Make iolog_items_to_fetch public Lukas Straub
2022-01-19 21:14 ` [PATCH 3/8] blktrace.c: Add support for read_iolog_chunked Lukas Straub
2022-01-19 21:14 ` Lukas Straub [this message]
2022-01-19 21:14 ` [PATCH 5/8] blktrace.c: Don't hardcode direct-io Lukas Straub
2022-01-19 21:14 ` [PATCH 6/8] blktrace.c: Don't sleep indefinitely if there is a wrong timestamp Lukas Straub
2022-01-19 21:14 ` [PATCH 7/8] blktrace.c: Make thread-safe by removing local static variables Lukas Straub
2022-01-19 21:14 ` [PATCH 8/8] iolog.c: Fix memory leak for blkparse case Lukas Straub
2022-01-20 18:41 ` [PATCH 0/8] blktrace: Add support for read_iolog_chunked and fixes Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0dd4b6407f7b7f5f15f1fcad409554ff339ffca1.1642626314.git.lukasstraub2@web.de \
    --to=lukasstraub2@web.de \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.