1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3:vfs:syncops make it possible to specify syncops:onclose per share

convert the onclose option of the vfs_syncops module from a
global option to a service-specific one

as preparation for further flags, use a struct to store in the VFS handle
instead of just the onclose flag
This commit is contained in:
Christian Ambach 2010-10-07 16:09:52 +02:00 committed by Volker Lendecke
parent 5954e7173a
commit c1dad16ede

View File

@ -31,13 +31,17 @@
On those filesystems this module provides a way to perform those
operations safely.
most of the performance loss with this module is in fsync on close().
You can disable that with
syncops:onclose = no
that can be set either globally or per share.
*/
/*
most of the performance loss with this module is in fsync on close().
You can disable that with syncops:onclose = no
*/
static bool sync_onclose;
struct syncops_config_data {
bool onclose;
};
/*
given a filename, find the parent directory
@ -191,7 +195,13 @@ static int syncops_rmdir(vfs_handle_struct *handle, const char *fname)
/* close needs to be handled specially */
static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
{
if (fsp->can_write && sync_onclose) {
struct syncops_config_data *config;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct syncops_config_data,
return -1);
if (fsp->can_write && config->onclose) {
/* ideally we'd only do this if we have written some
data, but there is no flag for that in fsp yet. */
fsync(fsp->fh->fd);
@ -199,8 +209,36 @@ static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
return SMB_VFS_NEXT_CLOSE(handle, fsp);
}
int syncops_connect(struct vfs_handle_struct *handle, const char *service,
const char *user)
{
struct syncops_config_data *config;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
config = talloc_zero(handle->conn, struct syncops_config_data);
if (!config) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0, ("talloc_zero() failed\n"));
return -1;
}
config->onclose = lp_parm_bool(SNUM(handle->conn), "syncops",
"onclose", true);
SMB_VFS_HANDLE_SET_DATA(handle, config,
NULL, struct syncops_config_data,
return -1);
return 0;
}
static struct vfs_fn_pointers vfs_syncops_fns = {
.connect_fn = syncops_connect,
.mkdir = syncops_mkdir,
.rmdir = syncops_rmdir,
.open = syncops_open,
@ -222,7 +260,5 @@ NTSTATUS vfs_syncops_init(void)
if (!NT_STATUS_IS_OK(ret))
return ret;
sync_onclose = lp_parm_bool(-1, "syncops", "onclose", true);
return ret;
}