readahead02: fix read_ahead_kb file not found
PATCH v2 1/1 readahead02: fix read_ahead_kb file not found
From: Naresh Kamboju <[email protected]>
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 holds the partition can be found at 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.
--- testcases/kernel/syscalls/readahead/readahead02.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/readahead/readahead02.c +7 -2
@@ -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 ;
Signature · 1 line
1.9.1
PATCH v2 1/1 readahead02: fix read_ahead_kb file not found
----- Original Message -----
Quoted 28 lines
From: "naresh kamboju" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>, "milosz wasilewski" <[email protected]>
Sent: Friday, 2 September, 2016 12:42:33 PM
Subject: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundFrom: Naresh Kamboju <[email protected]>
Test case is looking for
read_ahead_kbfile on a partition device (8:2) and not on block device (8:0/8:16/8:32/8:48). The appropriate block device that holds the partition can be found at 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 directoryAfter 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
Quoted 8 lines
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
This doesn't seem to be true for all entries under /sys/dev/block. If I ran your patch on lvm, testcase fails:
# ./readahead02 readahead02 0 TINFO : creating test file of size: 67108864 readahead02 1 TBROK : safe_file_ops.c:144: Failed to open FILE '/sys/dev/block/253:1/../queue/read_ahead_kb' for reading at readahead02.c:202: errno=ENOENT(2): No such file or directory readahead02 2 TBROK : safe_file_ops.c:144: Remaining cases broken
# ll /sys/dev/block/253:1 lrwxrwxrwx. 1 root root 0 Sep 5 09:21 /sys/dev/block/253:1 -> ../../devices/virtual/block/dm-1
# ll /sys/dev/block/253:1/ total 0 -r--r--r--. 1 root root 4096 Sep 5 09:25 alignment_offset -rw-r--r--. 1 root root 4096 Sep 5 09:25 badblocks lrwxrwxrwx. 1 root root 0 Sep 5 09:21 bdi -> ../../bdi/253:1 -r--r--r--. 1 root root 4096 Sep 5 09:25 capability -r--r--r--. 1 root root 4096 Sep 5 09:25 dev -r--r--r--. 1 root root 4096 Sep 5 09:25 discard_alignment drwxr-xr-x. 2 root root 0 Sep 5 09:25 dm -r--r--r--. 1 root root 4096 Sep 5 09:25 ext_range drwxr-xr-x. 2 root root 0 Sep 5 09:25 holders -r--r--r--. 1 root root 4096 Sep 5 09:25 inflight drwxr-xr-x. 2 root root 0 Sep 5 09:25 integrity drwxr-xr-x. 2 root root 0 Sep 5 09:25 power drwxr-xr-x. 2 root root 0 Sep 5 09:25 queue -r--r--r--. 1 root root 4096 Sep 5 09:25 range -r--r--r--. 1 root root 4096 Sep 5 09:25 removable -r--r--r--. 1 root root 4096 Sep 5 09:25 ro -r--r--r--. 1 root root 4096 Sep 5 09:25 size drwxr-xr-x. 2 root root 0 Sep 5 09:25 slaves -r--r--r--. 1 root root 4096 Sep 5 09:25 stat lrwxrwxrwx. 1 root root 0 Sep 5 09:21 subsystem -> ../../../../class/block drwxr-xr-x. 2 root root 0 Sep 5 09:25 trace -rw-r--r--. 1 root root 4096 Sep 5 09:25 uevent
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 35G 0 disk ├─vda1 252:1 0 500M 0 part /boot └─vda2 252:2 0 34.5G 0 part ├─rhel_dhcp--27--118-swap 253:0 0 2G 0 lvm [SWAP] └─rhel_dhcp--27--118-root 253:1 0 32.5G 0 lvm /
# uname -r 4.7.0-rc7+
Regards,
Jan
PATCH v2 1/1 readahead02: fix read_ahead_kb file not found
Hi Jan,
Quoted 40 lines · Jan Stancek
----- Original Message -----
Quoted 28 lines
From: "naresh kamboju" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>, "milosz wasilewski" <[email protected]>
Sent: Friday, 2 September, 2016 12:42:33 PM
Subject: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundFrom: Naresh Kamboju <[email protected]>
Test case is looking for
read_ahead_kbfile on a partition device (8:2) and not on block device (8:0/8:16/8:32/8:48). The appropriate block device that holds the partition can be found at 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 directoryAfter 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 usecQuoted 8 lines
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
Quoted 2 lines
This doesn't seem to be true for all entries under
/sys/dev/block. If I ran your patch on lvm, testcase fails:
Thanks for your findings.
I have tested on Ubuntu and Debian.
We have to refactor this test case to work on multi distribution. I have to find a machine running CentOS and debug this case.
Quoted 17 lines
# ./readahead02 readahead02 0 TINFO : creating test file of size: 67108864 readahead02 1 TBROK : safe_file_ops.c:144: Failed to open FILE '/sys/dev/block/253:1/../queue/read_ahead_kb' for reading at readahead02.c:202: errno=ENOENT(2): No such file or directory readahead02 2 TBROK : safe_file_ops.c:144: Remaining cases broken# ll /sys/dev/block/253:1 lrwxrwxrwx. 1 root root 0 Sep 5 09:21 /sys/dev/block/253:1 -> ../../devices/virtual/block/dm-1# ll /sys/dev/block/253:1/ total 0(quoted diff) +0
-2-r--r--r--. 1 root root 4096 Sep 5 09:25 alignment_offset -rw-r--r--. 1 root root 4096 Sep 5 09:25 badblockslrwxrwxrwx. 1 root root 0 Sep 5 09:21 bdi -> ../../bdi/253:1
(quoted diff) +0
-3-r--r--r--. 1 root root 4096 Sep 5 09:25 capability -r--r--r--. 1 root root 4096 Sep 5 09:25 dev -r--r--r--. 1 root root 4096 Sep 5 09:25 discard_alignment
Quoted 7 lines
drwxr-xr-x. 2 root root 0 Sep 5 09:25 dm -r--r--r--. 1 root root 4096 Sep 5 09:25 ext_range drwxr-xr-x. 2 root root 0 Sep 5 09:25 holders -r--r--r--. 1 root root 4096 Sep 5 09:25 inflight drwxr-xr-x. 2 root root 0 Sep 5 09:25 integrity drwxr-xr-x. 2 root root 0 Sep 5 09:25 power drwxr-xr-x. 2 root root 0 Sep 5 09:25 queue
read_ahead_kb file should present in queue folder. Is this test case pass on this machine *without* my patch ? /sys/dev/block/253:1/queue/read_ahead_kb
Quoted 10 lines
(quoted diff) +0
-4-r--r--r--. 1 root root 4096 Sep 5 09:25 range -r--r--r--. 1 root root 4096 Sep 5 09:25 removable -r--r--r--. 1 root root 4096 Sep 5 09:25 ro -r--r--r--. 1 root root 4096 Sep 5 09:25 sizedrwxr-xr-x. 2 root root 0 Sep 5 09:25 slaves -r--r--r--. 1 root root 4096 Sep 5 09:25 stat lrwxrwxrwx. 1 root root 0 Sep 5 09:21 subsystem -> ../../../../class/block drwxr-xr-x. 2 root root 0 Sep 5 09:25 trace -rw-r--r--. 1 root root 4096 Sep 5 09:25 uevent
Quoted 7 lines
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 35G 0 disk ├─vda1 252:1 0 500M 0 part /boot └─vda2 252:2 0 34.5G 0 part ├─rhel_dhcp--27--118-swap 253:0 0 2G 0 lvm [SWAP] └─rhel_dhcp--27--118-root 253:1 0 32.5G 0 lvm /
Is it a physical drive or Virtual drive ?
In general I use vda for KVM.
Quoted 3 lines
# uname -r 4.7.0-rc7+
Thank you.
Best regards
Naresh Kamboju
Quoted 3 lines
Regards,
Jan
PATCH v2 1/1 readahead02: fix read_ahead_kb file not found
----- Original Message -----
Quoted 54 lines
From: "Naresh Kamboju" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: "chrubis" <[email protected]>, [email protected], [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>, "milosz wasilewski" <[email protected]>
Sent: Tuesday, 6 September, 2016 2:33:58 PM
Subject: Re: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundHi Jan,
Quoted 43 lines · Jan Stancek
----- Original Message -----
Quoted 39 lines
From: "naresh kamboju" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>,
"milosz wasilewski" <[email protected]>
Sent: Friday, 2 September, 2016 12:42:33 PM
Subject: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundFrom: Naresh Kamboju <[email protected]>
Test case is looking for
read_ahead_kbfile on a partition device (8:2) and
not on block device (8:0/8:16/8:32/8:48). The appropriate block device that
holds the partition can be found at 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 directoryAfter 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
Quoted 8 lines
Quoted 2 lines
This doesn't seem to be true for all entries under
/sys/dev/block. If I ran your patch on lvm, testcase fails:Thanks for your findings.
I have tested on Ubuntu and Debian.We have to refactor this test case to work on multi distribution. I have to find a machine running CentOS and debug this case.
I think it should be enough to setup LVM volume, and point LTP's TMPDIR to it to reproduce.
Quoted 23 lines
Quoted 23 lines
# ./readahead02 readahead02 0 TINFO : creating test file of size: 67108864 readahead02 1 TBROK : safe_file_ops.c:144: Failed to open FILE '/sys/dev/block/253:1/../queue/read_ahead_kb' for reading at readahead02.c:202: errno=ENOENT(2): No such file or directory readahead02 2 TBROK : safe_file_ops.c:144: Remaining cases broken# ll /sys/dev/block/253:1 lrwxrwxrwx. 1 root root 0 Sep 5 09:21 /sys/dev/block/253:1 -> ../../devices/virtual/block/dm-1# ll /sys/dev/block/253:1/ total 0(quoted diff) +0
-2-r--r--r--. 1 root root 4096 Sep 5 09:25 alignment_offset -rw-r--r--. 1 root root 4096 Sep 5 09:25 badblockslrwxrwxrwx. 1 root root 0 Sep 5 09:21 bdi -> ../../bdi/253:1
(quoted diff) +0
-3-r--r--r--. 1 root root 4096 Sep 5 09:25 capability -r--r--r--. 1 root root 4096 Sep 5 09:25 dev -r--r--r--. 1 root root 4096 Sep 5 09:25 discard_alignmentdrwxr-xr-x. 2 root root 0 Sep 5 09:25 dm
-r--r--r--. 1 root root 4096 Sep 5 09:25ext_range
Quoted 8 lines
Quoted 5 lines
drwxr-xr-x. 2 root root 0 Sep 5 09:25 holders -r--r--r--. 1 root root 4096 Sep 5 09:25 inflight drwxr-xr-x. 2 root root 0 Sep 5 09:25 integrity drwxr-xr-x. 2 root root 0 Sep 5 09:25 power drwxr-xr-x. 2 root root 0 Sep 5 09:25 queue
read_ahead_kbfile should present in queue folder. Is this test case pass on this machine *without* my patch ?
Yes, it does pass without the patch. Since there doesn't seem to be a reliable pattern depending on value of $min number, I'm thinking we should try both and take first present:
/sys/dev/block/$maj:$min/queue/read_ahead_kb /sys/dev/block/$maj:$min/../queue/read_ahead_kb
Quoted 14 lines
/sys/dev/block/253:1/queue/read_ahead_kb
Quoted 11 lines
(quoted diff) +0
-4-r--r--r--. 1 root root 4096 Sep 5 09:25 range -r--r--r--. 1 root root 4096 Sep 5 09:25 removable -r--r--r--. 1 root root 4096 Sep 5 09:25 ro -r--r--r--. 1 root root 4096 Sep 5 09:25 sizedrwxr-xr-x. 2 root root 0 Sep 5 09:25 slaves -r--r--r--. 1 root root 4096 Sep 5 09:25 stat lrwxrwxrwx. 1 root root 0 Sep 5 09:21 subsystem ->../../../../class/block
drwxr-xr-x. 2 root root 0 Sep 5 09:25 trace
-rw-r--r--. 1 root root 4096 Sep 5 09:25 uevent
Quoted 10 lines
Quoted 7 lines
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 35G 0 disk ├─vda1 252:1 0 500M 0 part /boot └─vda2 252:2 0 34.5G 0 part ├─rhel_dhcp--27--118-swap 253:0 0 2G 0 lvm [SWAP] └─rhel_dhcp--27--118-root 253:1 0 32.5G 0 lvm /Is it a physical drive or Virtual drive ?
In general I use vda for KVM.
It's virtual, from host point of view it's a qcow2 file.
Regards,
Jan
Quoted 14 lines
Quoted 4 lines
# uname -r 4.7.0-rc7+Thank you.
Best regards
Naresh KambojuQuoted 3 lines
Regards,
Jan
PATCH v2 1/1 readahead02: fix read_ahead_kb file not found
----- Original Message -----
Quoted 11 lines
From: "Jan Stancek" <[email protected]>
To: "Naresh Kamboju" <[email protected]>
Cc: "graeme gregory" <[email protected]>, "milosz wasilewski" <[email protected]>, [email protected], "fengguang wu" <[email protected]>, [email protected]
Sent: Tuesday, 6 September, 2016 4:22:00 PM
Subject: Re: [LTP] [v2] readahead02: fixread_ahead_kbfile not found
Quoted 32 lines
----- Original Message -----
Quoted 31 lines
From: "Naresh Kamboju" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: "chrubis" <[email protected]>, [email protected], [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>, "milosz wasilewski"
<[email protected]>
Sent: Tuesday, 6 September, 2016 2:33:58 PM
Subject: Re: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundHi Jan,
Quoted 18 lines · Jan Stancek
----- Original Message -----
Quoted 15 lines
From: "naresh kamboju" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "fengguang wu" <[email protected]>, "graeme gregory" <[email protected]>,
"milosz wasilewski" <[email protected]>
Sent: Friday, 2 September, 2016 12:42:33 PM
Subject: [LTP] [v2] readahead02: fixread_ahead_kbfile not foundFrom: Naresh Kamboju <[email protected]>
Test case is looking for
read_ahead_kbfile on a partition device (8:2) and
not on block device (8:0/8:16/8:32/8:48). The appropriate block device that
holds the partition can be found at queue/read_ahead_kb entry.
Just fyi, there is a patch proposed to change this limit again:
https://lkml.org/lkml/2016/7/25/308
Regards,
Jan