public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] readahead02: fix read_ahead_kb file not found
@ 2016-08-27 11:14 naresh.kamboju
  2016-08-30 12:21 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: naresh.kamboju @ 2016-08-27 11:14 UTC (permalink / raw)
  To: ltp

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


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

* [LTP] [PATCH] readahead02: fix read_ahead_kb file not found
  2016-08-27 11:14 [LTP] [PATCH] readahead02: fix read_ahead_kb file not found naresh.kamboju
@ 2016-08-30 12:21 ` Cyril Hrubis
  2016-08-31  9:14   ` Naresh Kamboju
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2016-08-30 12:21 UTC (permalink / raw)
  To: ltp

Hi!
> @@ -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);

So we clear lower five bits of the minor number here. Why exactly that amount?

Shouldn't we just pass zero as a minor number there anyway?

>  	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
>  
>  	return ra_kb * 1024;
> -- 
> 1.9.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] readahead02: fix read_ahead_kb file not found
@ 2016-08-31  9:11 naresh.kamboju
  0 siblings, 0 replies; 5+ messages in thread
From: naresh.kamboju @ 2016-08-31  9:11 UTC (permalink / raw)
  To: ltp

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/8:16/8:32/8:48). 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..d50c40a 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) & ~15);
 	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
 
 	return ra_kb * 1024;
-- 
1.9.1


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

* [LTP] [PATCH] readahead02: fix read_ahead_kb file not found
  2016-08-30 12:21 ` Cyril Hrubis
@ 2016-08-31  9:14   ` Naresh Kamboju
  0 siblings, 0 replies; 5+ messages in thread
From: Naresh Kamboju @ 2016-08-31  9:14 UTC (permalink / raw)
  To: ltp

On 30 August 2016 at 17:51, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
>> @@ -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);
>
> So we clear lower five bits of the minor number here. Why exactly that amount?
>
> Shouldn't we just pass zero as a minor number there anyway?

For block device like sda the read_ahead_kb is present in 8:0. if it
sdb it is present at 8:16. like wise
 8:0   sda
 8:16 sdb
 8:32 sdc
 8:48 sdd

I changed my patch to clear lower four bits of the minor number

  minor(st.st_dev) & ~15);

- Naresh

>
>>       SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
>>
>>       return ra_kb * 1024;
>> --
>> 1.9.1
>>
>
> --
> Cyril Hrubis
> chrubis@suse.cz

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

* [LTP] [PATCH] readahead02: fix read_ahead_kb file not found
@ 2016-09-01 13:14 naresh.kamboju
  0 siblings, 0 replies; 5+ messages in thread
From: naresh.kamboju @ 2016-09-01 13:14 UTC (permalink / raw)
  To: ltp

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/8:16/8:32/8:48). 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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 53278be..97ab0a8 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -192,8 +192,13 @@ 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));
+	if (minor(st.st_dev)) {
+		snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/../queue/read_ahead_kb",
+			major(st.st_dev), minor(st.st_dev));
+	} else {
+		snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/queue/read_ahead_kb",
+			major(st.st_dev), minor(st.st_dev));
+	}
 	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
 
 	return ra_kb * 1024;
-- 
1.9.1


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

end of thread, other threads:[~2016-09-01 13:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-27 11:14 [LTP] [PATCH] readahead02: fix read_ahead_kb file not found naresh.kamboju
2016-08-30 12:21 ` Cyril Hrubis
2016-08-31  9:14   ` Naresh Kamboju
  -- strict thread matches above, loose matches on Subject: below --
2016-08-31  9:11 naresh.kamboju
2016-09-01 13:14 naresh.kamboju

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