lseek/write



Greetings.

I have a question regarding disk IO performance. I would like to
understand why exactly writes to a disk are faster when I use lseek as
opposed to not using lseek. The snippet of code that I am using is as
follows:
I would imagine that the write keeps track of the pointer after each
write, but my test does not bear that out.

Ultimately, I am trying to determine why writes are faster to my local
disk than to my SAN storage (EMC w/ cache). When I use the fsync,
writes are slower to san. When I do not use the fsync, writes are
faster.

I would appreciate any information regarding t his topic.

Thanks in advance.


for(int i = 0; i < 10; i++)
{

if (write(fd, buf, bytes) != bytes)
{
printf("write: \n");
exit (1);
}

if ( dosync ) {
if (fsync(fd) != 0)
{
printf("fsync: \n");
exit (1);
}
}
if ( doSeek )
{
if (lseek(fd, (off_t)0, SEEK_SET) == -1)
{
printf("lseek: %s\n",
strerror(errno));
exit (1);
}
}

}
.



Relevant Pages

  • Re: Ext4 and the "30 second window of death"
    ... A - Writing data to disk immediately and lose no work at all, ... application uses fsync, right?). ... The problem comes when you have lots of applications open on the ... in order to save power. ...
    (Linux-Kernel)
  • Re: HardBound and SoftBound
    ... ext3 performance is extremely poor on fsync. ... Which as I said is an ext3 problem that has nothing to do with the quality of ext4. ... As long as you're happy with the consequences of not accessing the disk, then that's fine - but you don't like that, either. ... the state of the file system on disk reflects this in-order behavior. ...
    (comp.arch)
  • Re: True fsync() in Linux (on IDE)
    ... I have written the InnoDB backend to MySQL. ... Some notes on the fsync() ... to the disk in an order different from the order in which the fsync's were ... In a power outage this can cause database corruption. ...
    (Linux-Kernel)
  • Re: How to flush data to disk reliably?
    ... >> I am asking how to flush the data from these logs to disk. ... fdatasync doesn't write back all the metadata so depending on ... if log file is some block device both O_SYNC and fsync ... Also flushing should be slow because disk seeks ...
    (Linux-Kernel)
  • Re: Ext4 and the "30 second window of death"
    ... fsync() boundaries, or if we combine two writes to the same block ... meaning "Put my data on the disk please". ... laptop-mode isn't intended to ... Shouldn't applications have a mode to avoid spinning up the disk if it is ...
    (Linux-Kernel)