Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!ukc!reading!riddle!domo From: domo@riddle.UUCP (Dominic Dunlop) Newsgroups: comp.unix.wizards Subject: Re: Record-access libraries (with query on NFS) Summary: Raw device goes direct to disk -- unless controller's ``intelligent'' Message-ID: <931@riddle.UUCP> Date: 21 Oct 88 13:36:56 GMT References: <287@cvbnet2.UUCP> <107@minya.UUCP> Reply-To: domo@riddle.UUCP (Dominic Dunlop) Organization: Sphinx Ltd., Maidenhead, England Lines: 49 In article <107@minya.UUCP> jc@minya.UUCP (John Chambers) writes: >> If you access the raw disk device do you disable that read-ahead and >> write-behind aspect of the UNIX filesystem abstraction? > >Oh, wow! A question with a simple answer: Yes. According to several >manuals, the main difference between /dev/dsk* and /dev/rdsk* is that >there is no buffering for the latter. Reads always delay for physical >I/O, and writes always go immediately to disk (though with DMA, the >write may not be complete when write() returns). Worse, the disk controller hardware may be ``intelligent'', buffering write data in its private memory for an indeterminate time before actually writing it onto the physical disk medium. >Of course, this is all at the whim of the driver, so some vendors >could have screwed it up... Quite. A clued-up, socially-responsible, driver writer might take the trouble to disable buffering in an intelligent controller for raw writes, or to wait for a ``local buffer empty'' condition before returning. My bet is that this level of attention to detail is rare. UNIX System V, release 3 and later (but not the POSIX standard, IEEE 1003.1, or, as an example of a BSD-derived system, SunOS) has a synchronous write facility (enabled with the O_SYNC flag to open() or fcntl()), under which, to quote from the SVID, issue 2, volume 3, ``each write should wait for both the file data and file status [the inode, that is] to be physically updated.'' (You can bet that the 1003 working groups will tighten up that wording if they decide to put O_SYNC in a future standard.) I see no reason that synchronous writes should be immune to the invidious effect of ``intelligence'' either. This is where I get to admit my ignorance: maybe five years ago, intelligent controllers which defeated the ``write straight to disk'' characteristic of raw devices were dismayingly commonplace. Since that time, I'm glad to say that I've become less involved with such nitty-gritty characteristics of particular types of system. Would any current hardware jockey (please take the term as a compliment) care to comment on whether today's disk controllers exhibit similar behaviour? One thing that makes me think that the problem may still be around is this: there has been recent discussion elsewhere about the ability to do single byte reads and writes to raw disks on certain computers. Hmmm. Sounds as though the controllers have their own buffers, doesn't it? Has the data actually hit the disk by the time a raw write returns? Would anybody like to comment specifically on this? -- Dominic Dunlop domo@sphinx.co.uk domo@riddle.uucp