Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-03-2011, 03:26 PM
|
#1
|
LQ Newbie
Registered: Jun 2011
Distribution: Debian, Ubuntu, Enterprise stuff (at work...)
Posts: 4
Rep: 
|
why are 3 IOs produced by writing one byte via write()?
hi,
i play around with c for producing some io to a san-disk and struggle with basics here. :-(
if i'm using the write()-call to write 1 byte to a file on the disk iostat tells me i'm producing 3 writes. if i write 1 byte twice a second, it tells me i produce 6 writes (w/s).
of course i'm sure there's no other traffic to the disk. :-)
can anyone explain? i would expect iostat tells me 1w/s or 2w/s.
sorry if this is a dumb question...
|
|
|
06-03-2011, 06:33 PM
|
#2
|
LQ Newbie
Registered: Jan 2010
Location: Anacortes, WA
Distribution: Arch, Debian, CentOS
Posts: 27
Rep:
|
Might have something to do with the journaling for the file system? What kind of filesystem are you writing to?
|
|
1 members found this post helpful.
|
06-03-2011, 11:12 PM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,336
|
Try strace.
|
|
|
06-04-2011, 03:02 AM
|
#4
|
Senior Member
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070
|
What about file metadata?
|
|
1 members found this post helpful.
|
06-04-2011, 09:31 AM
|
#5
|
LQ Newbie
Registered: Jun 2011
Distribution: Debian, Ubuntu, Enterprise stuff (at work...)
Posts: 4
Original Poster
Rep: 
|
thanks for your replies. i'm using ext3 (so journaling could be the point?). strace does nothing strange / all works as expected:
Code:
[...]
# load glibc
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY) = 3
[...]
# open the file with sync-flag (got file-descriptor nr 3)
open("/mnt/testdevice/io", O_WRONLY|O_CREAT|O_TRUNC|O_DSYNC, 0644) = 3
[...]
# write 1 byte to fd nr 3
write(3, "\0", 1) = 1
[...]
# close the file
close(3) = 0
[...]
if it is the journaling/metadata-thing which produces the additional io, i should be able kick it by working directly on the device-node (e.g. /dev/mapper/<mydevice>) instead of opening a file on a journaling fs, right?
*nargh*, seems that loop-devices could not be monitored by
Code:
iostat -d <device-node> -x 1
 & i don't have a "real" device/partition to test it until monday...
any further ideas? can i track the behaviour by using the sources without being a guru? i tried to look inside the glibc source, but i'm a rookie in this stuff. even not sure if i got the right snippet, but if so, i don't understand it (seems to do nothing but checking for false arguments?)
Code:
# /usr/src/glibc/eglibc-2.13/io/write.c
[...]
/* Write NBYTES of BUF to FD. Return the number written, or -1. */
ssize_t __libc_write (int fd, const void *buf, size_t nbytes)
{
if (nbytes == 0)
return 0;
if (fd < 0)
{
__set_errno (EBADF);
return -1;
}
if (buf == NULL)
{
__set_errno (EINVAL);
return -1;
}
__set_errno (ENOSYS);
return -1;
}
libc_hidden_def (__libc_write)
stub_warning (write)
weak_alias (__libc_write, __write)
libc_hidden_weak (__write)
weak_alias (__libc_write, write)
#include <stub-tag.h>
|
|
|
06-04-2011, 09:43 AM
|
#6
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,464
|
Hi
Just a guess, but it could have to do with the updating of timestamps. When you write a character to a file, it has to update the timestamps - both in the inode of the directory entry of that file, as well as the directory itself.
|
|
1 members found this post helpful.
|
06-04-2011, 10:05 AM
|
#7
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,336
|
If you're putting (more) software block device drivers between the application and the "real" (FSVO "real") ,I/O block device drivers, all bets are off.
|
|
|
06-04-2011, 11:24 AM
|
#8
|
LQ Newbie
Registered: Jun 2011
Distribution: Debian, Ubuntu, Enterprise stuff (at work...)
Posts: 4
Original Poster
Rep: 
|
Quote:
Originally Posted by syg00
If you're putting (more) software block device drivers between the application and the "real" (FSVO "real") ,I/O block device drivers, all bets are off.
|
yupp, i just guessed loop-device-io would be measurable the same way other block-device-abstractions are. but you're right - iostat tells me, whatever i do, no io at all for loop-devices...
hope monday is far far away  but i will test "raw-access" to the dev-node itself then.
|
|
|
06-06-2011, 12:26 PM
|
#9
|
LQ Newbie
Registered: Jun 2011
Distribution: Debian, Ubuntu, Enterprise stuff (at work...)
Posts: 4
Original Poster
Rep: 
|
hi. just wanted to share the "results": it's definitely the metadata/journal-stuff. i tried writing the device-node itself and all works as expected (1 byte write -> 1 IO (using SYNC-flag of course)). mounting an ext3 with noatime etc. does not improve anything, using ext2 produces lesser IO as ext3. thanks for your input!
btw. if anyone has links which describe IO-related stuff in depth/detail (write() -> libc() -> kernel / fc-stuff) - i would like to read it.
|
|
|
All times are GMT -5. The time now is 09:23 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|