Messages in this thread | | | Date | Thu, 11 Dec 2003 12:43:12 -0700 | From | Andreas Dilger <> | Subject | Re: Is there a "make hole" (truncate in middle) syscall? |
| |
On Dec 11, 2003 11:15 -0800, Hua Zhong wrote: > > The abstract interface for make_hole() is simple, but it turns into a > > pretty expensive filesystem operation, I think. After many cycles of > > free/allocate, your file would be badly fragmented across the > > filesystem. > > Understood. Two filesystems we are using: tmpfs and ext3. For the > former, fragmentation doesn't matter. > > Hey, I think when I get some cycles I can try to implement this for > tmpfs (since it's simpler) myself, and post a patch. :-) But before > that, I want to make sure it's doable.
At distant times in the past (i.e. 2.2 days), we had implemented a "punch" syscall which did what you wanted for ext3. I've looked at this for 2.4 at least, and it should be relatively straightforward to implement vmpunch from vmtruncate, since most of the VM routines that vmtruncate calls allow both a start and end parameter. For tmpfs that should be enough. Then, vmtruncate could just be a special case of vmpunch which punches from start = i_size to end = -1ULL.
Presumably, if a filesystem didn't support a punch filesystem method (either because it is unimplemented or because the filesystem doesn't support holes) it would be implemented as either a truncate (if end is beyond i_size) or a series of zero writes instead.
At some point we may want to update punch for ext3 again, because it is useful for various things (e.g. cache or heirarchical filesystems, etc).
Cheers, Andreas -- Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |