public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] readahead02: fix path for read_ahead_kb on raw partitions
@ 2016-09-14 13:50 Jan Stancek
  2016-09-19  9:37 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2016-09-14 13:50 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/readahead/readahead02.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 53278be7d84c..2517a333680e 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-19 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-14 13:50 [LTP] [PATCH] readahead02: fix path for read_ahead_kb on raw partitions Jan Stancek
2016-09-19  9:37 ` Cyril Hrubis
2016-09-19 12:46   ` Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox