Subject: Re: [linux-audio-dev] info point on linux hdr
From: Paul Barton-Davis (pbd_AT_Op.Net)
Date: Fri Apr 21 2000 - 23:34:58 EEST
>> also, in the code you show, the ftruncate is redundant, because it
>> doesn't allocate any blocks, and the point of preallocation (if there
>> is one) is to get the blocks allocated in a certain way.
>
>It depends on where in the block we write the data. If we write data to
>start of the block and without ftruncate() we get file size
>
>filesize = requested_file_size - blocksize + write_data_size
Do you think I'm that sloppy ?
I don't mean to sound sour about this, but for over a month, ardour
has had working code to do this kind of file preallocation. I do it by
writing the first byte of the file (*), jump by the fs blocksize, until i
reach the end, then i write the last byte if the filesize wasn't an
exact multiple of the fs blocksize.
>I got little better preallocation performance with
>ftruncate()/lseek()/write() compared to write() of full blocks.
Sure, because there is less copy_to_user action going on.
--p
(*) more precisely, since the function in ardour can be used to extend
existing files, the first byte beyond the current file size.
This archive was generated by hypermail 2b28 : Sat Apr 22 2000 - 00:08:03 EEST