summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-12-17 23:08:01 -0800
committerJeremy Allison <jra@samba.org>2010-12-18 08:59:27 +0100
commit716ea734e4cd83a2030ca2cac10056bdaab1a021 (patch)
tree8caf80f6c76f5de768896e6d0aebaf3fadbc3116 /source3/smbd
parent7157221da5bc6787b08ab26c9e83c08208b41d8a (diff)
downloadsamba-716ea734e4cd83a2030ca2cac10056bdaab1a021.tar.gz
samba-716ea734e4cd83a2030ca2cac10056bdaab1a021.tar.bz2
samba-716ea734e4cd83a2030ca2cac10056bdaab1a021.zip
Rename vfs operation posix_fallocate to just fallocate and add the vfs_fallocate_mode parameter.
It turns out we need the fallocate operations to be able to both allocate and extend filesize, and to allocate and not extend filesize, and posix_fallocate can only do the former. So by defining the vfs op as posix_fallocate we lose the opportunity to use any underlying syscalls (like Linux fallocate) that can do the latter as well. We don't currently use the non-extending filesize call, but now I've changed the vfs op definition we can in the future. For the moment simply map the fallocate op onto posix_fallocate for the VFS_FALLOCATE_EXTEND_SIZE case and return ENOSYS for the VFS_FALLOCATE_KEEP_SIZE case. Jeremy. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Dec 18 08:59:27 CET 2010 on sn-devel-104
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/vfs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 3055e37663..ee70a3d583 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -559,9 +559,10 @@ int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len)
}
/****************************************************************************
- A slow version of posix_fallocate. Fallback code if SMB_VFS_POSIX_FALLOCATE
- fails. Needs to be outside of the default version of SMB_VFS_POSIX_FALLOCATE
+ A slow version of fallocate. Fallback code if SMB_VFS_FALLOCATE
+ fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE
as this is also called from the default SMB_VFS_FTRUNCATE code.
+ Always extends the file size.
Returns 0 on success, errno on failure.
****************************************************************************/
@@ -639,12 +640,13 @@ int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
/* Only do this on non-stream file handles. */
if (fsp->base_fsp == NULL) {
- /* for allocation try posix_fallocate first. This can fail on some
+ /* for allocation try 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
+ * case we do our own emulation. fallocate implementations can
* return ENOTSUP or EINVAL in cases like that. */
- ret = SMB_VFS_POSIX_FALLOCATE(fsp, offset, num_to_write);
+ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
+ offset, num_to_write);
if (ret == ENOSPC) {
errno = ENOSPC;
ret = -1;
@@ -653,7 +655,7 @@ int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
if (ret == 0) {
goto out;
}
- DEBUG(10,("vfs_fill_sparse: SMB_VFS_POSIX_FALLOCATE failed with "
+ DEBUG(10,("vfs_fill_sparse: SMB_VFS_FALLOCATE failed with "
"error %d. Falling back to slow manual allocation\n", ret));
}
@@ -1451,13 +1453,14 @@ int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
return handle->fns->ftruncate(handle, fsp, offset);
}
-int smb_vfs_call_posix_fallocate(struct vfs_handle_struct *handle,
+int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
struct files_struct *fsp,
+ enum vfs_fallocate_mode mode,
SMB_OFF_T offset,
SMB_OFF_T len)
{
- VFS_FIND(posix_fallocate);
- return handle->fns->posix_fallocate(handle, fsp, offset, len);
+ VFS_FIND(fallocate);
+ return handle->fns->fallocate(handle, fsp, mode, offset, len);
}
int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,