Skip to contentSkip to conversation

readahead02: fix path for read_ahead_kb on raw partitions

PATCH New Jan Stancek 2 participants 3 messages Sep 14, 2016 – Sep 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 readahead02: fix path for read_ahead_kb on raw partitions

Path to read_ahead_kb is not consistent for all block devices, for example for LVM it's:
/sys/dev/block/$maj:$min/queue/read_ahead_kb
but for raw partitions "queue" is only in "parent" device:
/sys/dev/block/$maj:$min/../queue/read_ahead_kb

This patch checks both types and reads first one it can find. Tested on LVM and raw partitions with 4.7.3.

---
 testcases/kernel/syscalls/readahead/readahead02.c | 6 ++++++
 1 file changed, 6 insertions(+)
testcases/kernel/syscalls/readahead/readahead02.c +6 -0
index 53278be7d84c..2517a333680e 100644
@@ -194,6 +194,12 @@ static long get_device_readahead(const char *fname)
 		tst_brkm(TBROK | TERRNO, cleanup, "stat");
 	snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/queue/read_ahead_kb",
 		 major(st.st_dev), minor(st.st_dev));
+	if (access(buf, F_OK)) {
+		snprintf(buf, sizeof(buf),
+			"/sys/dev/block/%d:%d/../queue/read_ahead_kb",
+			major(st.st_dev), minor(st.st_dev));
+	}
+	tst_resm(TINFO, "Reading %s", buf);
 	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
 
 	return ra_kb * 1024;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 readahead02: fix path for read_ahead_kb on raw partitions

Hi!

Quoted 8 lines

Path to read_ahead_kb is not consistent for all block devices, for example for LVM it's:
/sys/dev/block/$maj:$min/queue/read_ahead_kb
but for raw partitions "queue" is only in "parent" device:
/sys/dev/block/$maj:$min/../queue/read_ahead_kb

This patch checks both types and reads first one it can find. Tested on LVM and raw partitions with 4.7.3.

Fixes the problem for me as well (minus the Btrfs anonymous block devices that has to be fixed).

Acked.

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 readahead02: fix path for read_ahead_kb on raw partitions

----- Original Message -----

Quoted 13 lines

From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Monday, 19 September, 2016 11:37:55 AM
Subject: Re: [LTP] [PATCH] readahead02: fix path for read_ahead_kb on raw partitions

Hi!

Quoted 6 lines

Path to read_ahead_kb is not consistent for all block devices, for example for LVM it's:
/sys/dev/block/$maj:$min/queue/read_ahead_kb
but for raw partitions "queue" is only in "parent" device:
/sys/dev/block/$maj:$min/../queue/read_ahead_kb

Quoted 7 lines
Quoted 2 lines

This patch checks both types and reads first one it can find. Tested on LVM and raw partitions with 4.7.3.

Fixes the problem for me as well (minus the Btrfs anonymous block devices that has to be fixed).

Acked.

Pushed.

Regards,
Jan

Quoted 5 lines

--
Cyril Hrubis
[email protected]