View topic - How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
9 posts
• Page 1 of 1
How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
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.
According to fsysinfo's manual page, it is a front end of devctl(DCMD_FSYS_STATISTICS).
fsysinfo:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.utilities%2Ftopic%2Ff%2Ffsysinfo.html
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.
The above's DISK I/O write and read correspond to the following
devctl(DCMD_FSYS_STATISTICS)'s struct fs_stats.
So, I wrote a code as follows to get the DiskIO write and read information.
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?
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.
- Code: Select all
// 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).
fsysinfo:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.utilities%2Ftopic%2Ff%2Ffsysinfo.html
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.
- Code: Select all
$ 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.
- Code: Select all
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.
- Code: Select all
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.
If you specify the -m option, fsysinfo doesn't combine disk I/O statistics from the specified filesystem and its host device/partition
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?
- Hiroki Watanabe
- New Member
- Posts: 9
- Joined: Sun Jan 24, 2016 11:25 pm
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
You should try with io_devctl() function. Search for "DCMD_FSYS_STATISTICS" in QNX help.
Beware that QNX documentation states that : "There is no supported utility which obtains this, the fs_stats is completely undocumented, and may/will change in the future, and certainly has changed in the past."
Beware that QNX documentation states that : "There is no supported utility which obtains this, the fs_stats is completely undocumented, and may/will change in the future, and certainly has changed in the past."
- nico04
- Senior Member
- Posts: 171
- Joined: Wed Sep 29, 2010 9:59 am
- Location: France
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
Hi, nico
Thank you.
Now, I'm trying to understand the io_devctl()'s usage with
DCMD_FSYS_STATISTICS by reffering the following pages.
The io_devctl() function:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.cookbook%2Ftopic%2Fs2_ramdisk_io_devctl.html
io_devctl():
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.getting_started%2Ftopic%2Fs1_resmgr_io_devctl.html
The io_devctl()'s usage seems not so straightforward. Anyway, I'll try
to find how to do that.
Best regards,
Thank you.
Now, I'm trying to understand the io_devctl()'s usage with
DCMD_FSYS_STATISTICS by reffering the following pages.
The io_devctl() function:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.cookbook%2Ftopic%2Fs2_ramdisk_io_devctl.html
io_devctl():
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.getting_started%2Ftopic%2Fs1_resmgr_io_devctl.html
The io_devctl()'s usage seems not so straightforward. Anyway, I'll try
to find how to do that.
Best regards,
- Hiroki Watanabe
- New Member
- Posts: 9
- Joined: Sun Jan 24, 2016 11:25 pm
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
Just realised that io_devctl() is not what you need. I've been too fast analysing the search result.
io_devctl() function is for managing devctl() calls to a resource manager you write. Definitively not what you need.
Sorry for this mistake.
io_devctl() function is for managing devctl() calls to a resource manager you write. Definitively not what you need.
Sorry for this mistake.
- nico04
- Senior Member
- Posts: 171
- Joined: Wed Sep 29, 2010 9:59 am
- Location: France
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
Hi, nico
OK, understood. Anyway, thank you
A relationship between fsysinfo's -m option and devctl(DCMD_FSYS_STATISTICS) is very mysterious.
OK, understood. Anyway, thank you

A relationship between fsysinfo's -m option and devctl(DCMD_FSYS_STATISTICS) is very mysterious.
- Hiroki Watanabe
- New Member
- Posts: 9
- Joined: Sun Jan 24, 2016 11:25 pm
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
I tried the following code on my system :
Each time a file is written, s_buf_wphys is incremented by one and each time a file is read, s_buf_rphys is incremented by one.
It does not work with /tmp.
- Code: Select all
int fd = -1;
struct fs_stats data;
int err;
fd = open("/mnt/sdhc-user-up/", O_RDONLY);
if(fd == -1)
{
perror("open()");
return;
}
err = devctl(fd, DCMD_FSYS_STATISTICS, &data, sizeof(struct fs_stats), NULL);
if (err != EOK)
{
printf("devctl() -> %d", err);
return;
}
printf("DISK I/O write %llu read %llu\n", data.s_buf_wphys, data.s_buf_rphys);
Each time a file is written, s_buf_wphys is incremented by one and each time a file is read, s_buf_rphys is incremented by one.
It does not work with /tmp.
- nico04
- Senior Member
- Posts: 171
- Joined: Wed Sep 29, 2010 9:59 am
- Location: France
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
Umm, I'll check my code and system again tomorrow. Maybe, I overlooked sth.
- Hiroki Watanabe
- New Member
- Posts: 9
- Joined: Sun Jan 24, 2016 11:25 pm
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
In your code, you want to get stats for /mnt/data. What is /mnt/data ? USB drive ? SD card ? ...
- nico04
- Senior Member
- Posts: 171
- Joined: Wed Sep 29, 2010 9:59 am
- Location: France
Re: How to get Disk I/O stat by devctl(DCMD_FSYS_STATISTICS)
Sorry for too late reply.
/mnt/data is a hard disk drive partition formatted with QNX6's Power-Safe filesystem. Still, I'm in the title's trouble. I assume I overlook a something trivial. I'm totally stuck.
nico04 wrote:In your code, you want to get stats for /mnt/data. What is /mnt/data ? USB drive ? SD card ? ...
/mnt/data is a hard disk drive partition formatted with QNX6's Power-Safe filesystem. Still, I'm in the title's trouble. I assume I overlook a something trivial. I'm totally stuck.
- Hiroki Watanabe
- New Member
- Posts: 9
- Joined: Sun Jan 24, 2016 11:25 pm
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 1 guest