Bug 525532 - RFE: fallocate (preallocation) support
Summary: RFE: fallocate (preallocation) support
Alias: None
Product: Fedora
Classification: Fedora
Component: samba
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Guenther Deschner
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2009-09-24 17:53 UTC by Eric Sandeen
Modified: 2011-04-04 16:35 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-04-04 16:35:47 UTC

Attachments (Terms of Use)

Description Eric Sandeen 2009-09-24 17:53:07 UTC
Windows samba clients do a poor-man's preallocation by doing 1 byte writes on 64k boundaries (or something like that) which NTFS interprets to mean "preallocate space"

We have a generic interface to filesystem preallocation now, with the fallocate syscall.

A very, very simple patch to implement this looks something like:

--- a/source/configure.in
+++ b/source/configure.in
@@ -1052,6 +1052,7 @@ AC_CHECK_FUNCS(setlocale nl_langinfo)
 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open)Index: samba-3.3.2/source/modules/vfs_default.c
--- samba-3.3.2.orig/source/modules/vfs_default.c
+++ samba-3.3.2/source/modules/vfs_default.c
@@ -714,6 +714,14 @@ static int strict_allocate_ftruncate(vfs
 	if (st.st_size > len)
 		return sys_ftruncate(fsp->fh->fd, len);
+	/* Growing */
+#if defined(HAVE_FALLOCATE)
+#include <linux/falloc.h>
+	if (!fallocate(fsp->fh->fd, 0, st.st_size, space_to_write))
+		return 0;
+	/* if glibc has fallocate but failed on this fs, go back to old way */
 	/* available disk space is enough or not? */
 	if (lp_strict_allocate(SNUM(fsp->conn))){
 		SMB_BIG_UINT space_avail;

but this is a little suboptimal; at least on xfs, this multitude of fallocate calls actually has a lot of overhead.  If it were possible to batch up these instances into 1 big fallocate call, it could be a win.

Comment 1 Guenther Deschner 2010-10-08 14:27:08 UTC
Can you check this isnt already adressed upstream ? I see there is a vfs_prealloc module at least.

Comment 2 Fedora Admin XMLRPC Client 2010-10-08 14:42:38 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 3 Eric Sandeen 2010-12-09 16:37:41 UTC
vfs_prealloc was specific to xfs, last time I looked.

In any case, I see there is movement upstream now,

Comment 4 Eric Sandeen 2010-12-09 16:38:54 UTC
oh and FWIW, vfs_prealloc does:

Preallocate all files with the extension EXT to the size specified by BYTES. 

which is not really what we're after (one single preallocated size for all files...)

Comment 5 Simo Sorce 2011-04-04 16:35:47 UTC
Upstream has changed to do some fallocate() work already.
Closing this one as I think it does not apply anymore in this form. Please reopen if it still applies.

Note You need to log in before you can comment on or make changes to this bug.