[LTP] [PATCH] readahead02: fix read_ahead_kb file not found

naresh.kamboju@linaro.org naresh.kamboju@linaro.org
Sat Aug 27 13:14:19 CEST 2016


From: Naresh Kamboju <naresh.kamboju@linaro.org>

Test case is looking for read_ahead_kb file on a partition device (8:2) and
not on block device (8:0). The appropriate block device that hold the
partition can see the corrent queue/read_ahead_kb entry.

Before patch readahead02 test broken,
readahead02    1  TBROK  :  safe_file_ops.c:144: Failed to open FILE
'/sys/dev/block/8:2/queue/read_ahead_kb' for reading at
readahead02.c:197: errno=ENOENT(2): No such file or directory

After applying patch,
readahead02    0  TINFO  :  creating test file of size: 67108864
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    0  TINFO  :  read_testfile(0)
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    0  TINFO  :  read_testfile(1)
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    1  TPASS  :  expected ret success - returned value = 0
readahead02    2  TPASS  :  offset is still at 0 as expected
readahead02    0  TINFO  :  read_testfile(0) took: 1437202 usec
readahead02    0  TINFO  :  read_testfile(1) took: 1361915 usec
readahead02    0  TINFO  :  read_testfile(0) read: 67108864 bytes
readahead02    0  TINFO  :  read_testfile(1) read: 0 bytes
readahead02    3  TPASS  :  readahead saved some I/O
readahead02    0  TINFO  :  cache can hold at least: 157404 kB
readahead02    0  TINFO  :  read_testfile(0) used cache: 65332 kB
readahead02    0  TINFO  :  read_testfile(1) used cache: 65636 kB
readahead02    4  TPASS  :  using cache as expected

Patch tested on aarch64 and x86_64.

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
---
 testcases/kernel/syscalls/readahead/readahead02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 53278be..70d918d 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -193,7 +193,7 @@ static long get_device_readahead(const char *fname)
 	if (stat(fname, &st) == -1)
 		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));
+		 major(st.st_dev), minor(st.st_dev) & ~31);
 	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
 
 	return ra_kb * 1024;
-- 
1.9.1



More information about the ltp mailing list