summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_syncops.c
diff options
context:
space:
mode:
authorChristian Ambach <christian.ambach@de.ibm.com>2010-10-07 16:09:52 +0200
committerVolker Lendecke <vlendec@samba.org>2010-10-13 12:53:16 +0000
commitc1dad16edecae8474dfa68110da6492cd19f2f51 (patch)
treed095a0e618b4c80224de3d0040f9d90d76a57d97 /source3/modules/vfs_syncops.c
parent5954e7173a5aecb0998e359c2eff97e75fbe57f4 (diff)
downloadsamba-c1dad16edecae8474dfa68110da6492cd19f2f51.tar.gz
samba-c1dad16edecae8474dfa68110da6492cd19f2f51.tar.bz2
samba-c1dad16edecae8474dfa68110da6492cd19f2f51.zip
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
Diffstat (limited to 'source3/modules/vfs_syncops.c')
-rw-r--r--source3/modules/vfs_syncops.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c
index c098159ff6..3f52741009 100644
--- a/source3/modules/vfs_syncops.c
+++ b/source3/modules/vfs_syncops.c
@@ -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
+ You can disable that with
+ syncops:onclose = no
+ that can be set either globally or per share.
+
*/
-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;
}