summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_gpfs.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@us.ibm.com>2012-03-08 13:57:12 -0800
committerChristian Ambach <ambi@samba.org>2012-03-22 18:41:22 +0100
commit0a896094c61fa1eec7dbb5bb35485747cdc1549d (patch)
treeeb63f518b3742eefe802acf0fc987937c0a9a508 /source3/modules/vfs_gpfs.c
parent62616784ae5460bfd8f68ccfe596f80f55727b87 (diff)
downloadsamba-0a896094c61fa1eec7dbb5bb35485747cdc1549d.tar.gz
samba-0a896094c61fa1eec7dbb5bb35485747cdc1549d.tar.bz2
samba-0a896094c61fa1eec7dbb5bb35485747cdc1549d.zip
s3:vfs_gpfs: Implement fallocate callback for GPFS
GPFS provides the gpfs_prealloc call. Implement the fallocate callback with mode VFS_FALLOCATE_EXTEND_SIZE using this call. There is no support for VFS_FALLOCATE_KEEP_SIZE, so report this mode as not available.
Diffstat (limited to 'source3/modules/vfs_gpfs.c')
-rw-r--r--source3/modules/vfs_gpfs.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 9597999232..65cd33a394 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -44,6 +44,7 @@ struct gpfs_config_data {
bool ftruncate;
bool getrealfilename;
bool dfreequota;
+ bool prealloc;
};
@@ -1263,6 +1264,42 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
}
+int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
+ struct files_struct *fsp, enum vfs_fallocate_mode mode,
+ SMB_OFF_T offset, SMB_OFF_T len)
+{
+ int ret;
+ struct gpfs_config_data *config;
+
+ SMB_VFS_HANDLE_GET_DATA(handle, config,
+ struct gpfs_config_data,
+ return -1);
+
+ if (!config->prealloc) {
+ /* you should better not run fallocate() on GPFS at all */
+ errno = ENOTSUP;
+ return -1;
+ }
+
+ if (mode == VFS_FALLOCATE_KEEP_SIZE) {
+ DEBUG(10, ("Unsupported VFS_FALLOCATE_KEEP_SIZE\n"));
+ errno = ENOTSUP;
+ return -1;
+ }
+
+ ret = smbd_gpfs_prealloc(fsp->fh->fd, offset, len);
+
+ if (ret == -1 && errno != ENOSYS) {
+ DEBUG(0, ("GPFS prealloc failed: %s\n", strerror(errno)));
+ } else if (ret == -1 && errno == ENOSYS) {
+ DEBUG(10, ("GPFS prealloc not supported.\n"));
+ } else {
+ DEBUG(10, ("GPFS prealloc succeeded.\n"));
+ }
+
+ return ret;
+}
+
static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
SMB_OFF_T len)
{
@@ -1390,6 +1427,9 @@ int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
config->dfreequota = lp_parm_bool(SNUM(handle->conn), "gpfs",
"dfreequota", false);
+ config->prealloc = lp_parm_bool(SNUM(handle->conn), "gpfs",
+ "prealloc", true);
+
SMB_VFS_HANDLE_SET_DATA(handle, config,
NULL, struct gpfs_config_data,
return -1);
@@ -1582,6 +1622,7 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
.is_offline_fn = vfs_gpfs_is_offline,
.aio_force_fn = vfs_gpfs_aio_force,
.sendfile_fn = vfs_gpfs_sendfile,
+ .fallocate_fn = vfs_gpfs_fallocate,
.open_fn = vfs_gpfs_open,
.ftruncate_fn = vfs_gpfs_ftruncate
};