Why does devctl(DCMD_FSYS_STATISTICS) always return 0 for Disk I/O statistics?
I’m trying to make an utility for disk filesystem’s statistics like
QNX’s fsysinfo utility. But, I’m in trouble to get disk I/O write and
read information because devctl(DCMD_FSYS_STATISTICS) always returns 0
for the following disk I/O statistics.
// s_buf_rphys and s_buf_wphys become always 0 unexptedly
struct fs_stats {
...
/* Buffer/DiskIO statistics */
uint64_t s_buf_rphys; /*
uint64_t s_buf_wphys;
...
}
According to fsysinfo’s manual page, it is a front end of devctl(DCMD_FSYS_STATISTICS).
devctl(DCMD_FSYS_STATISTICS):
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.devctl%2Ftopic%2Ffsys%2Fdcmd_fsys_statistics.html
By using fsysinfo, you can get disk filesystem’s statistics as
follows.
$ fsysinfo /mnt/data
FILESYS /mnt/data/ [qnx6]
MOUNT mounted Sat Jan 1 00:00:00 2000 elapsed 1032 secs
DISK I/O write 4007 read 56 r/a 0
direct 0 bad 0
CACHE write 5578729 read 8799168 rate 99%
mfu 23732k mru 9036k ratio 72%
SYSCALL open 8032 stat 16038 namei 28540
write 281212 read 2733 devctl 29
create 4000 delete 4000
NAMES exist 148742 enoent 12507 misses 8000
unsuit 0 stale 276 rate 95%
BMAP hit 309693 miss 203 rate 99%
VNODES create 4000 hit 181282 rate 97%
lock 1302952 recycl 4373
SLAB map 608 unmap 285 active 323
THREADS create 60 destro 54 pool 6
The above’s DISK I/O write and read correspond to the following
devctl(DCMD_FSYS_STATISTICS)'s struct fs_stats.
struct fs_stats {
...
/* Buffer/DiskIO statistics */
uint64_t s_buf_rphys; /*
uint64_t s_buf_wphys;
...
}
So, I wrote a code as follows to get the DiskIO write and read information.
int fd = 0;
if((fd = open("/mnt/data", O_RDONLY)) == -1) {
return;
}
struct fs_stats data;
if (devctl(fd, DCMD_FSYS_STATISTICS, &data, sizeof(struct fs_stats), NULL) != EOK) {
return;
}
printf("DISK I/O write %llu read %llu\n", data.s_buf_wphys, data.s_buf_rphys);
But, data.s_buf_wphys(DISK IO write) and data.s_buf_rphys(DISK IO read) are always set as 0 even
when fsysinfo utility reports non-zero values for the DISK IO.
I found the following interesting description about fsysinfo’s ‘-m’ option in its manual.
So, it seems devctl(DCMD_FSYS_STATISTICS)'s default behavior is the
same as fsysinfo’s ‘-m’ option.
Is it possible to make devctl(DCMD_FSYS_STATISTICS) behave like
fsysinfo without -m option?