question about file allocation for recording sound data to disk

Doug Karl karl-d at nisca.ircc.ohio-state.edu
Sat Jul 14 07:25:52 AEST 1990


I am in need of some advice on how to more efficently allocate a large file
(1 to 100 Mbytes) on Unix (BSD 4.3, NeXT, Sun/OS, Ultrix and System V).
What I do on a MAC, MS-DOS and VMS is to:

	1) open a new file.
	2) lseek to the last block in the new file.
	3) write out one block.
	4) fsync, close, and reopen

Now a file is created on disk with inodes, direct and indirect blocks (or the
equivelent there of) updated and all the blocks allocated.  On Unix that is
NOT what happens, there are direct and indirect mapping blocks that are full
of zeros (ie. file is not fully mapped on disk).

So on Unix I have to:
	1) open a new file.
	2) write out each block of the file (to fully map it)
	3) fsync, close, and reopen

Is there any trick or patch to get around this?  I guess that the idea of not
actually mapping the blocks of a file on Unix until the block is actually
written to has some merrit, but is bad for me, I need to have the file "fully"
allocated quickly.

FYI. What I am doing is recording CD quality sound on a generic SCSI disk
     attached to a BSD 4.3 system, NeXT, and SUN using a special SCSI disk
     controller.  The special SCSI disk controller bolts on top of a 5 1/4
     SCSI drive but logically sits between the SCSI bus on the CPU
     and the disk(s). This is so that the high speed data (sound in this case)
     can flow directly to the disk and not load down the CPU. It is operating
     system and file system independent and therefore works on Unix
     (assuming SCSI disks of course).  BUT it expects that a file is fully
     preallocated by the operating system (prior to recording) which takes
     less than a second on VMS, MS-DOS, and MAC/OS but takes several seconds
     on Unix depending on file size (because I have to write out each block of
     the file for it to be "fully" allocated).  After the file is allocated
     then I mearly write to the SCSI disk controller the files logical block
     mapping and it then can record the sound.  Playing or re-recording is no
     problem since the file is already allocated but recording a new file takes
     several seconds to "setup" due to the "write each block allocation
     restriction (feature) of Unix".

Please respond to me directly with ANY ideas:

karl-d at osu-20.ircc.ohio-state.edu

THANKS VERY MUCH,
Doug Karl, Instruction and Research Computer Center, Ohio State University.



More information about the Comp.unix mailing list