When does `write' return?



Hello,

As far as I know, the system call `write' is asynchronous, which
would leave the `data' in page cache. The `data' would be flushed in
the background, thus the `write' could return quickly, in order to
improve the performance.

My question is: when would the `write' return? For example:

write(fd, buf, 1GB)

The 1GB buf will be written in to disk file represented by `fd'. When
the `write' returns, how much of buf has been written? Does the kernel
cache the buf with copy-on-write or just making a full memory copy?


I am not so familiar with linux kernel, please forgive me if the
question is too silly.

Best Regards

Andrew Xue

.



Relevant Pages

  • Re: When does `write return?
    ... > leave the `data' in page cache. ... > The 1GB buf will be written in to disk file represented by `fd'. ... the write could return as soon as the data get to a memory buffer. ... It also depends if file fd is a raw file or not (if you are using raw file ...
    (comp.os.linux.misc)
  • Re: [9fans] cwfs
    ... yes, here is a console... ... outin("cwfscmd", buf, sizeof buf); ... pis our end of the pipe to cwfs stdin. ... garbage to the cache device, ...
    (comp.os.plan9)
  • Re: Minutes from 10/1 LSE Call
    ... > close to half the size of the L1 cache you end up pushing the memory at ... > `buf' out of CPU cache all the time. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Cached file read performance with 6.2-PRERELEASE
    ... Glancing at the 'top' man page, "150M Wired" seems to be the data file cache, while "111M Buf" is block-level caching... ... That should give you an idea as to how much RAM is being used for the buffer/block IO cache, and the VM disk cache. ... It might be worthwhile trying with a series of different file size to determine if there is a point where the caching performance drops... ...
    (freebsd-stable)
  • memory categories
    ... I'm trying to understand what FreeBSD uses its memory for. ... Cache: ... Buf, I get more memory than I have physically installed. ... find a sysctl that represents this value. ...
    (freebsd-questions)