[SCM] Samba Shared Repository - branch v3-5-test updated

Björn Jacke bjacke at samba.org
Wed Dec 2 16:04:19 MST 2009


The branch, v3-5-test has been updated
       via  a1991b1... s3: prefer posix_fallocate for doing "strict allocate"
       via  7d53a5f... s3:build: fix shared library build on QNX
      from  e0904e2... Ensure check_parent_acl_common() only looks at stored blobs - returns NT_STATUS_OK if there aren't any. Jeremy. (cherry picked from commit 148e79d156d92b41dfe7d6ae6f8cd2e571a3bee6)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-test


- Log -----------------------------------------------------------------
commit a1991b17cdb38b1bffa32d2386132ae01f827cd0
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Dec 2 15:13:37 2009 +0100

    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.

commit 7d53a5f728430013c7daca5b1301dc9271c29680
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Dec 3 00:02:44 2009 +0100

    s3:build: fix shared library build on QNX
    
    Fixes #6860. Thanks to Matt Kraai!

-----------------------------------------------------------------------

Summary of changes:
 source3/configure.in          |    9 +++++----
 source3/include/proto.h       |    1 +
 source3/lib/system.c          |   14 ++++++++++++++
 source3/modules/vfs_default.c |   25 +++++++++++++++++++++----
 4 files changed, 41 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/configure.in b/source3/configure.in
index 2f92a02..5f5cef9 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1007,7 +1007,7 @@ AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
-AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64)
+AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
 AC_CHECK_FUNCS(getpwent_r)
@@ -1491,9 +1491,10 @@ DSO_EXPORTS=""
 
   # and these are for particular systems
   case "$host_os" in
-		*linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
-			case "$host_os" in *linux*)
-				AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
+		*linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
+			case "$host_os" in
+				*linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
+				*qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
 			esac
 			BLDSHARED="true"
 			LDSHFLAGS="-shared -Wl,-Bsymbolic"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 52808f6..e3311ed 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -934,6 +934,7 @@ int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
 	      bool fake_dir_create_times);
 int sys_ftruncate(int fd, SMB_OFF_T offset);
+int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len);
 SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
 int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
 SMB_OFF_T sys_ftell(FILE *fp);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 86802d0..b18358d 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.
 ********************************************************************/
 
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 9abf792..da775d1 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -922,8 +922,6 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 	if (SMB_VFS_FSTAT(fsp, &st) == -1)
 		return -1;
 
-	space_to_write = len - st.st_ex_size;
-
 #ifdef S_ISFIFO
 	if (S_ISFIFO(st.st_ex_mode))
 		return 0;
@@ -936,7 +934,28 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 	if (st.st_ex_size > len)
 		return sys_ftruncate(fsp->fh->fd, len);
 
+	/* for allocation try posix_fallocate first. This can fail on some
+	   platforms e.g. when the filesystem doesn't support it and no
+	   emulation is being done by the libc (like on AIX with JFS1). In that
+	   case we do our own emulation. posix_fallocate implementations can
+	   return ENOTSUP or EINVAL in cases like that. */
+#if defined(HAVE_POSIX_FALLOCATE)
+	{
+		int ret = sys_posix_fallocate(fsp->fh->fd, 0, len);
+		if (ret == ENOSPC) {
+			errno = ENOSPC;
+			return -1;
+		}
+		if (ret == 0) {
+			return 0;
+		}
+		DEBUG(10,("strict_allocate_ftruncate: sys_posix_fallocate "
+			"failed with error %d. "
+			"Falling back to slow manual allocation\n", ret));
+	}
+#endif
 	/* available disk space is enough or not? */
+	space_to_write = len - st.st_ex_size;
 	if (lp_strict_allocate(SNUM(fsp->conn))){
 		uint64_t space_avail;
 		uint64_t bsize,dfree,dsize;
@@ -956,8 +975,6 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 	if (SMB_VFS_LSEEK(fsp, st.st_ex_size, SEEK_SET) != st.st_ex_size)
 		return -1;
 
-	space_to_write = len - st.st_ex_size;
-
 	memset(zero_space, '\0', sizeof(zero_space));
 	while ( space_to_write > 0) {
 		SMB_OFF_T retlen;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list