diff options
author | Björn Jacke <bj@sernet.de> | 2009-12-08 10:30:03 +0100 |
---|---|---|
committer | Björn Jacke <bj@sernet.de> | 2009-12-08 10:33:26 +0100 |
commit | c8615b6a0c053c178dfcf9b4e755b896993e397e (patch) | |
tree | 2251e0b41d2918379695cc0f0b06d774f46dc569 /source3 | |
parent | ed5c3372de4d0815e482cf29a41729c212552153 (diff) | |
download | samba-c8615b6a0c053c178dfcf9b4e755b896993e397e.tar.gz samba-c8615b6a0c053c178dfcf9b4e755b896993e397e.tar.bz2 samba-c8615b6a0c053c178dfcf9b4e755b896993e397e.zip |
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.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/modules/vfs_default.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 3691fb0e7e..9b842df93f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -936,6 +936,8 @@ 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 @@ -943,7 +945,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs return ENOTSUP or EINVAL in cases like that. */ #if defined(HAVE_POSIX_FALLOCATE) { - int ret = sys_posix_fallocate(fsp->fh->fd, 0, len); + int ret = sys_posix_fallocate(fsp->fh->fd, st.st_ex_size, space_to_write); if (ret == ENOSPC) { errno = ENOSPC; return -1; @@ -957,7 +959,6 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs } #endif /* 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); |