From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 5 17:08:04 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90615106567C for ; Wed, 5 Nov 2008 17:08:04 +0000 (UTC) (envelope-from mezz7@cox.net) Received: from eastrmmtao103.cox.net (eastrmmtao103.cox.net [68.230.240.9]) by mx1.freebsd.org (Postfix) with ESMTP id 261388FC21 for ; Wed, 5 Nov 2008 17:08:04 +0000 (UTC) (envelope-from mezz7@cox.net) Received: from eastrmimpo01.cox.net ([68.1.16.119]) by eastrmmtao103.cox.net (InterMail vM.7.08.02.01 201-2186-121-102-20070209) with ESMTP id <20081105170802.EVIC27754.eastrmmtao103.cox.net@eastrmimpo01.cox.net> for ; Wed, 5 Nov 2008 12:08:02 -0500 Received: from localhost ([68.103.35.214]) by eastrmimpo01.cox.net with bizsmtp id bV831a0024dCcn002V83t7; Wed, 05 Nov 2008 12:08:03 -0500 X-Authority-Analysis: v=1.0 c=1 a=BJYOUj_aXYIA:10 a=_ErIr5gE0BMA:10 a=e0E1ilLqAAAA:8 a=6I5d2MoRAAAA:8 a=LS5Y-Q-YuX6K_S6nM-8A:9 a=OwSUQDXHe8DwpwyDqAkjjXGe6akA:4 a=4vB-4DCPJfMA:10 a=SV7veod9ZcQA:10 a=b8hG5vVbyAkA:10 X-CM-Score: 0.00 Date: Wed, 05 Nov 2008 11:08:11 -0600 To: freebsd-hackers@freebsd.org From: "Jeremy Messenger" Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: User-Agent: Opera Mail/9.62 (Linux) Subject: preallocate files without (posix_)fallocate or fcntl's F_PREALLOCATE? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2008 17:08:04 -0000 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 -- mezz7@cox.net - mezz@FreeBSD.org FreeBSD GNOME Team http://www.FreeBSD.org/gnome/ - gnome@FreeBSD.org