[SCM] Samba Shared Repository - branch v3-5-test updated
Björn Jacke
bjacke at samba.org
Tue Dec 8 13:19:13 MST 2009
The branch, v3-5-test has been updated
via 39be2d1... s3: make sys_posix_fallocate more generic
via e9fb280... s3: allocate only "new" space, not "old" sparse space in the posix_fallocate path
from a2c4f88... WHATSNEW: Add changes since 3.5.0pre1.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-test
- Log -----------------------------------------------------------------
commit 39be2d18a24176b9300834a0552180cdfb11ca5f
Author: Björn Jacke <bj at sernet.de>
Date: Tue Dec 8 21:13:19 2009 +0100
s3: make sys_posix_fallocate more generic
this is in preparation for other preallocation methods to be introduced.
commit e9fb2807037919a598e17d24def4897e0cbfe19c
Author: Björn Jacke <bj at sernet.de>
Date: Tue Dec 8 10:30:03 2009 +0100
s3: allocate only "new" space, not "old" sparse space in the posix_fallocate path
this makes the posix_fallocate path work analogous to the manual allocate path.
-----------------------------------------------------------------------
Summary of changes:
source3/lib/system.c | 8 ++++----
source3/modules/vfs_default.c | 28 +++++++++++++---------------
2 files changed, 17 insertions(+), 19 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/lib/system.c b/source3/lib/system.c
index a2dd899..a58d903 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -621,16 +621,16 @@ 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)) && !defined(HAVE_BROKEN_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)
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_POSIX_FALLOCATE64) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
return posix_fallocate64(fd, offset, len);
-#else
+#elif defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
return posix_fallocate(fd, offset, len);
+#else
+ return ENOSYS;
#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 3691fb0..ded4b1a 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -917,6 +917,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
SMB_OFF_T space_to_write;
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
+ int ret;
if (currpos == -1)
return -1;
@@ -936,28 +937,25 @@ 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);
+ space_to_write = len - st.st_ex_size;
+
/* 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));
+ ret = sys_posix_fallocate(fsp->fh->fd, st.st_ex_size, space_to_write);
+ if (ret == ENOSPC) {
+ errno = ENOSPC;
+ return -1;
}
-#endif
+ 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));
+
/* available disk space is enough or not? */
- space_to_write = len - st.st_ex_size;
space_avail = get_dfree_info(fsp->conn,
fsp->fsp_name->base_name, false,
&bsize,&dfree,&dsize);
--
Samba Shared Repository
More information about the samba-cvs
mailing list