Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: peter@nmti.com (Peter da Silva)
Subject: Re: Sparse files take up more space when copied
Date: Tue, 15 Nov 1994 16:08:01 GMT	[thread overview]
Message-ID: <id.5CRE1.UA8@nmti.com> (raw)
In-Reply-To: 3aaj2f$qql@xdm084.ccc.cranfield.ac.uk

In article <3aaj2f$qql@xdm084.ccc.cranfield.ac.uk>,
Peter Lister <p.lister@cranfield.ac.uk> wrote:
> I tarred the directory and gzip managed 94% compression on the tar
> file (yes, that's right, reduced the size by 94%), so these files are
> obviously pretty sparse. It would seem that I-DEAS can take advantage
> of some pretty good file compression in the OSF1 filesystem when it
> writes it's files, but tar,cp,etc don't manage this. My guess is that
> I-DEAS uses mmap(3) and that that virtual memory paging writes the file
> blocks more efficiently than stream I/O as used by cp, tar, etc.

To be precise... if you seek to a point beyond the end of a file then write,
blocks between the end of the file and the new seek point will not be
allocated until they are written to, and will read as blocks of zeros.

A database program will tend to do this, producting what's called a "sparse
file".

If you write a block of zeros, it will be allocated, so tar and cp and so on
will populate a sparse file.

The fix is to have a program that seeks (on output) over blocks of zeroes (on
input) as it writes. It's not a complex program... I wrote one that does this
and also retries reads (I wrote it to recover data from a flakey Xenix disk,
originally) but I don't know if I can post it (work stuff). In any case, as
I said, it's not a complex program.

	while(read block)

		if (block is empty)

			seek end of file + blocksize

		else

			write block
-- 
Peter da Silva                                            `-_-'
Network Management Technology Incorporated                 'U`
1601 Industrial Blvd.     Sugar Land, TX  77478  USA
+1 713 274 5180                       "Hast Du heute schon Deinen Wolf umarmt?"


  reply	other threads:[~1994-11-15 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-15 15:11 Sparse files take up more space when copied Peter Lister
1994-11-15 16:08 ` Peter da Silva [this message]
1994-11-15 16:30   ` Peter da Silva
1994-11-16  0:56     ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
1994-11-16  0:08   ` John Hascall
1994-11-17 20:35     ` Peter da Silva
1994-11-15 19:52 ` Torbj|rn Lindgren
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox