preallocate files without (posix_)fallocate or fcntl's F_PREALLOCATE?
Hello folks, At first, I don't really know C that well so... It's more of request or suggest if anyone is bored or interest to port on FreeBSD. :-) Recently, Transmission has added preallocate files to prevent disk fragmentation but FreeBSD does not has any of (posix_)fallocate or fcntl's F_PREALLOCATE (checked in RELENG_7's src/* and manpages). Here's what it looks like: static int preallocateFile( int fd UNUSED, uint64_t length UNUSED ) { #ifdef HAVE_FALLOCATE return fallocate( fd, 0, offset, length ); #elif defined(HAVE_POSIX_FALLOCATE) return posix_fallocate( fd, 0, length ); #elif defined(SYS_DARWIN) fstore_t fst; fst.fst_flags = F_ALLOCATECONTIG; fst.fst_posmode = F_PEOFPOSMODE; fst.fst_offset = 0; fst.fst_length = length; fst.fst_bytesalloc = 0; return fcntl( fd, F_PREALLOCATE, fst ); #else #warning no known method to preallocate files on this platform return -1; #endif } You can see a bit more over at http://trac.transmissionbt.com/changeset/7051 .. You can also point me to some sources if it exists for I can try do it by myself, but with lacking C knowledge is a bit hard for me at the most of time. I don't know if UFS does not need or does need it. If anyone is interesting to write simple one for FreeBSD will be cool. Thanks! Cheers, Mezz -- [EMAIL PROTECTED] - [EMAIL PROTECTED] FreeBSD GNOME Team http://www.FreeBSD.org/gnome/ - [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: preallocate files without (posix_)fallocate or fcntl's F_PREALLOCATE?
Hello, Not entirely related to this topic, but looking at the standards, it seems we don't implement posix_fadvise() either. It seems we could implement this as a no-op for now. It has no real advantage if we do, but say, one day we gain real posix_fadvise() support, we already have a bunch of binaries that have these performance optimisations compiled in. Any comments? -- Ed Schouten [EMAIL PROTECTED] WWW: http://80386.nl/ pgp0WOOLvWPl6.pgp Description: PGP signature
Re: preallocate files without (posix_)fallocate or fcntl's F_PREALLOCATE?
On Wednesday 05 November 2008 12:08:11 pm Jeremy Messenger wrote: Hello folks, At first, I don't really know C that well so... It's more of request or suggest if anyone is bored or interest to port on FreeBSD. :-) Recently, Transmission has added preallocate files to prevent disk fragmentation but FreeBSD does not has any of (posix_)fallocate or fcntl's F_PREALLOCATE (checked in RELENG_7's src/* and manpages). Here's what it looks like: static int preallocateFile( int fd UNUSED, uint64_t length UNUSED ) { #ifdef HAVE_FALLOCATE return fallocate( fd, 0, offset, length ); #elif defined(HAVE_POSIX_FALLOCATE) return posix_fallocate( fd, 0, length ); #elif defined(SYS_DARWIN) fstore_t fst; fst.fst_flags = F_ALLOCATECONTIG; fst.fst_posmode = F_PEOFPOSMODE; fst.fst_offset = 0; fst.fst_length = length; fst.fst_bytesalloc = 0; return fcntl( fd, F_PREALLOCATE, fst ); #else #warning no known method to preallocate files on this platform return -1; #endif } You can see a bit more over at http://trac.transmissionbt.com/changeset/7051 .. You can also point me to some sources if it exists for I can try do it by myself, but with lacking C knowledge is a bit hard for me at the most of time. I don't know if UFS does not need or does need it. If anyone is interesting to write simple one for FreeBSD will be cool. Thanks! UFS would benefit. See the notes on MAP_NOSYNC in mmap(2). Peter Wemm (peter@) probably can give a more detailed suggestion of what you would need to do. Doing it efficiently would probably require a new VOP_ALLOCATE() or some such. -- John Baldwin ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]