Re: When does `write' return?




Jean-David Beyer wrote:
> Andrew Xue wrote:
> > Jean-David Beyer 写道:
> >
> >
> >> It depends on a coupla things. If you have much more than 1GBytes of
> >> ram, the write could return as soon as the data get to a memory buffer.
> >> Possibly some of the cache would have to be paged out, but not
> >> necessarily.
> >>
> >
> > My ram is a little bit large, 4GB. And my biggest test file is 1.8GB, so
> > I think it's cached entirely.
> >
> >
> >> It also depends if file fd is a raw file or not (if you are using raw
> >> file systems, you probably already know enough to answer your
> >> questions; so probably not a raw file). If it is, I believe you must
> >> wait until the write completes, but OTOH, you do not need to take the
> >> time to find system buffer space and copy from user space to system
> >> space, and you might be able to do it in a giant "spiral write" as DEC
> >> used to call it. Depends on hardware and the low level driver, I would
> >> expect.
> >
> > Could you please explain it in more details? I could not find anything
> > about "spiral write" by google. Does it mean something of copy-on-write?
> >
> Sorry. That was a DEC thing on their hard drives in the very late 1960s, at
> least on the PDP-11 and VAX-11 series machines. It has nothing to do with
> copy-on-write.
>
> Their disks had 512-byte sectors and UNIX at the time normally read in one
> sector at a time, and if it detected sequential reading, it might read the
> next block as well.
>
> But the hardware controller for the disk drives allowed you to read any
> multiple of 512 bytes you wanted. I do not remember the numbers, so I will
> make them up here, but you will get the idea. Imagine there are 19 tracks
> per cylinder and 20 sectors per track. If you started at block zero and read
> 512 * 20 * 19 bytes, you would read the whole cylinder.
> But if you read 512 * 20 * 29 bytes, the controller would accept that, read
> the whole cylinder and do an automatic seek with no intervention from the OS
> and read about half the next cylinder as well. You could go as much as you
> wanted, up to almost 65536 bytes (which would use up all the data space in
> any one process).
Thank you so much for the useful information. However, I am still
confused whether
the kernel write some data to the disk while it's buffering them? If
so, how much is
written?
>
>
> --
> .~. Jean-David Beyer Registered Linux User 85642.
> /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
> /( )\ Shrewsbury, New Jersey http://counter.li.org
> ^^-^^ 22:35:00 up 14 days, 13:21, 3 users, load average: 4.19, 4.28, 4.21

.



Relevant Pages

  • Re: Disk geometry from /sys
    ... Many compact flash cards will report 16 heads, and 16 or 32 sectors ... Simplest way to find out what geometry a disk pretents to have is to ask ... Why do you want to know what cylinder size the hard disk pretents to ...
    (Linux-Kernel)
  • disktab for VPC Disk
    ... I'm trying to optimize the disk access of NEXTSTEP on Virtual PC 5.0.4. ... Maximum size of NeXT file system is 2GB. ... programs in the initial 8 sectors of the device. ... The number of cylinders per cylinder group in a file system. ...
    (microsoft.public.mac.virtualpc)
  • Re: fmthard and misallignment issues
    ... this seemed to match up the partitions for me then at this point I can ... the rest of the disk. ... You'd need to massage the data so that your slices are on cylinder ... size (the number of sectors in a cylinder). ...
    (comp.unix.solaris)
  • Re: why I told dd command to write but it reads in first?
    ... >> I am using `dd` command to measure raw disk write speed. ... > Linux uses the buffer cache by default. ... Instead of 512-byte sectors, it is individual bytes. ...
    (comp.os.linux.development.system)
  • Re: XP Partition size
    ... >> The very first sector of a disk is reserved for its Master Boot Record ... As Partitions are made to be aligned on Cylinder ... With some Un*x OS's you can use sectors, ...
    (microsoft.public.windowsxp.general)