Suppose I have a sparse file F on a Linux ext4 filesystem, and process P1 is writing to a disjoint 50% subset of F while P2 writes to the other 50% of F. I would like to minimize fragmentation while the file "grows". (I put "grows" in quotes because the file is pre-allocated as a sparse file, but as the blocks get written they fill in phantom blocks with actual data.)
I realize since P1 and P2 are running in parallel that one may get ahead of the other, but barring this, is it best to have P1 write blocks 1,3,5,7,... while P2 writes 2,4,6,...? Or better to have P1 write 1,2,3,4,...n/2 and P2 write n/2+1, ...., n?
fallocate(orposix_fallocate) will take too long on some OSes, but I'll look into this; cheers. – Fixee Oct 21 '11 at 18:04