summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2009-12-02 15:13:37 +0100
committerBjörn Jacke <bj@sernet.de>2009-12-02 21:21:43 +0100
commit95c18626107484d5d1d475e34fc4dde03cfe6ff5 (patch)
tree508651f48665b308ec49ef600f7b58de0916c2a2 /source3/lib
parent486c8d57ec5a9aa63aff275621ff45c22b8cde61 (diff)
downloadsamba-95c18626107484d5d1d475e34fc4dde03cfe6ff5.tar.gz
samba-95c18626107484d5d1d475e34fc4dde03cfe6ff5.tar.bz2
samba-95c18626107484d5d1d475e34fc4dde03cfe6ff5.zip
s3: prefer posix_fallocate for doing "strict allocate"
posix_fallocate is more efficient than manual zero'ing the file. When preallocation in kernel space is supported it's extremely fast. Support for preallocation at fs layer via posix_fallocate and fallocate at kernel site can be found in Linux kernel 2.6.23/glibc 2.10 with ext4, XFS and OCFS2. Other systems that I know of which support fast preallocation in kernel space are AIX 6.1 with JFS2 and recent Solaris versions with ZFS maybe UFS2, too. People who have a system with preallocation in kernel space might want to set "strict allocate = yes". This reduces file fragentation and it's also safer for setups with quota being turned on. As of today most systems still don't have preallocation in kernel space, and that's why "strict allocate = no" will stay the default for now.
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 86802d0c8d..b18358d8b2 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -610,6 +610,20 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
}
/*******************************************************************
+ An posix_fallocate() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+#if defined(HAVE_POSIX_FALLOCATE64) || defined(HAVE_POSIX_FALLOCATE)
+int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len)
+{
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_POSIX_FALLOCATE64)
+ return posix_fallocate64(fd, offset, len);
+#else
+ return posix_fallocate(fd, offset, len);
+#endif
+}
+#endif
+
+/*******************************************************************
An ftruncate() wrapper that will deal with 64 bit filesizes.
********************************************************************/