The branch, master has been updated
       via  bc71cd0 s3: VFS: Remove fsync_fn() from the VFS and all modules. 
VFS ABI change.
       via  cf44420 s3: vfs: Use the new smb_vfs_fsync_sync() call in place of 
SMB_VFS_FSYNC().
       via  a0482b9 s3: VFS: Add a synchronous smb_vfs_fsync_sync() call, built 
from async primitives.
      from  c6c67d9 ctdb-scripts: Remove function rewrite_ctdb_options()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bc71cd035c816de4ca98002860496bf8f5d50fe3
Author: Jeremy Allison <[email protected]>
Date:   Fri Apr 27 17:06:10 2018 -0700

    s3: VFS: Remove fsync_fn() from the VFS and all modules. VFS ABI change.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Wed May  2 01:06:28 CEST 2018 on sn-devel-144

commit cf4442090e979bca1fc93d00f51b5d4fc99e59e2
Author: Jeremy Allison <[email protected]>
Date:   Fri Apr 27 16:59:42 2018 -0700

    s3: vfs: Use the new smb_vfs_fsync_sync() call in place of SMB_VFS_FSYNC().
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit a0482b9d8daa4f8a1ff2e3011fa9a2fcc370c3a1
Author: Jeremy Allison <[email protected]>
Date:   Fri Apr 27 16:59:02 2018 -0700

    s3: VFS: Add a synchronous smb_vfs_fsync_sync() call, built from async 
primitives.
    
    Will be used in the next commit.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 examples/VFS/skel_opaque.c          |  7 ------
 examples/VFS/skel_transparent.c     |  6 -----
 source3/include/vfs.h               |  8 +++----
 source3/modules/vfs_catia.c         | 18 ---------------
 source3/modules/vfs_ceph.c          |  9 --------
 source3/modules/vfs_default.c       | 15 ------------
 source3/modules/vfs_full_audit.c    | 13 -----------
 source3/modules/vfs_glusterfs.c     |  7 ------
 source3/modules/vfs_streams_xattr.c | 13 -----------
 source3/modules/vfs_time_audit.c    | 19 ---------------
 source3/smbd/fileio.c               |  2 +-
 source3/smbd/vfs.c                  | 46 +++++++++++++++++++++++++++++++------
 source3/torture/cmd_vfs.c           |  3 +--
 13 files changed, 45 insertions(+), 121 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index e6c066d..41215cc 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -311,12 +311,6 @@ static int skel_rename(vfs_handle_struct *handle,
        return -1;
 }
 
-static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       errno = ENOSYS;
-       return -1;
-}
-
 static struct tevent_req *skel_fsync_send(struct vfs_handle_struct *handle,
                                          TALLOC_CTX *mem_ctx,
                                          struct tevent_context *ev,
@@ -967,7 +961,6 @@ struct vfs_fn_pointers skel_opaque_fns = {
        .sendfile_fn = skel_sendfile,
        .recvfile_fn = skel_recvfile,
        .rename_fn = skel_rename,
-       .fsync_fn = skel_fsync,
        .fsync_send_fn = skel_fsync_send,
        .fsync_recv_fn = skel_fsync_recv,
        .stat_fn = skel_stat,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 59d1634..7a82a55 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -388,11 +388,6 @@ static int skel_rename(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
 }
 
-static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       return SMB_VFS_NEXT_FSYNC(handle, fsp);
-}
-
 struct skel_fsync_state {
        int ret;
        struct vfs_aio_state vfs_aio_state;
@@ -1140,7 +1135,6 @@ struct vfs_fn_pointers skel_transparent_fns = {
        .sendfile_fn = skel_sendfile,
        .recvfile_fn = skel_recvfile,
        .rename_fn = skel_rename,
-       .fsync_fn = skel_fsync,
        .fsync_send_fn = skel_fsync_send,
        .fsync_recv_fn = skel_fsync_recv,
        .stat_fn = skel_stat,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index bb4a135..6f940ed 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -245,8 +245,10 @@
 /* Version 37 - Rename SMB_VFS_STRICT_LOCK to
                 SMB_VFS_STRICT_LOCK_CHECK */
 /* Version 38 - Remove SMB_VFS_INIT_SEARCH_OP */
+/* Version 39 - Remove SMB_VFS_FSYNC
+               Only implement async versions. */
 
-#define SMB_VFS_INTERFACE_VERSION 38
+#define SMB_VFS_INTERFACE_VERSION 39
 
 /*
     All intercepted VFS operations must be declared as static functions inside 
module source
@@ -707,7 +709,6 @@ struct vfs_fn_pointers {
        int (*rename_fn)(struct vfs_handle_struct *handle,
                         const struct smb_filename *smb_fname_src,
                         const struct smb_filename *smb_fname_dst);
-       int (*fsync_fn)(struct vfs_handle_struct *handle, struct files_struct 
*fsp);
        struct tevent_req *(*fsync_send_fn)(struct vfs_handle_struct *handle,
                                            TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
@@ -1208,8 +1209,6 @@ ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct 
*handle, int fromfd,
 int smb_vfs_call_rename(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname_src,
                        const struct smb_filename *smb_fname_dst);
-int smb_vfs_call_fsync(struct vfs_handle_struct *handle,
-                      struct files_struct *fsp);
 
 struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
                                           TALLOC_CTX *mem_ctx,
@@ -1217,6 +1216,7 @@ struct tevent_req *smb_vfs_call_fsync_send(struct 
vfs_handle_struct *handle,
                                           struct files_struct *fsp);
 int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct vfs_aio_state *state);
 
+int smb_vfs_fsync_sync(files_struct *fsp);
 int smb_vfs_call_stat(struct vfs_handle_struct *handle,
                      struct smb_filename *smb_fname);
 int smb_vfs_call_fstat(struct vfs_handle_struct *handle,
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 6f90c4d..b8c61e2 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -2078,23 +2078,6 @@ static off_t catia_lseek(vfs_handle_struct *handle,
        return result;
 }
 
-static int catia_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       struct catia_cache *cc = NULL;
-       int ret;
-
-       ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
-       if (ret != 0) {
-               return -1;
-       }
-
-       ret = SMB_VFS_NEXT_FSYNC(handle, fsp);
-
-       CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
-
-       return ret;
-}
-
 struct catia_fsync_state {
        int ret;
        struct vfs_aio_state vfs_aio_state;
@@ -2495,7 +2478,6 @@ static struct vfs_fn_pointers vfs_catia_fns = {
        .pwrite_recv_fn = catia_pwrite_recv,
        .lseek_fn = catia_lseek,
        .rename_fn = catia_rename,
-       .fsync_fn = catia_fsync,
        .fsync_send_fn = catia_fsync_send,
        .fsync_recv_fn = catia_fsync_recv,
        .stat_fn = catia_stat,
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 656ce57..2062fe4 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -562,14 +562,6 @@ static int cephwrap_rename(struct vfs_handle_struct 
*handle,
        WRAP_RETURN(result);
 }
 
-static int cephwrap_fsync(struct vfs_handle_struct *handle, files_struct *fsp)
-{
-       int result;
-       DBG_DEBUG("[CEPH] cephwrap_fsync\n");
-       result = ceph_fsync(handle->data, fsp->fh->fd, false);
-       WRAP_RETURN(result);
-}
-
 /*
  * Fake up an async ceph fsync by calling the sychronous API.
  */
@@ -1490,7 +1482,6 @@ static struct vfs_fn_pointers ceph_fns = {
        .sendfile_fn = cephwrap_sendfile,
        .recvfile_fn = cephwrap_recvfile,
        .rename_fn = cephwrap_rename,
-       .fsync_fn = cephwrap_fsync,
        .fsync_send_fn = cephwrap_fsync_send,
        .fsync_recv_fn = cephwrap_fsync_recv,
        .stat_fn = cephwrap_stat,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index e2efdab..6de0329 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1127,20 +1127,6 @@ static int vfswrap_rename(vfs_handle_struct *handle,
        return result;
 }
 
-static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-#ifdef HAVE_FSYNC
-       int result;
-
-       START_PROFILE(syscall_fsync);
-       result = fsync(fsp->fh->fd);
-       END_PROFILE(syscall_fsync);
-       return result;
-#else
-       return 0;
-#endif
-}
-
 static int vfswrap_stat(vfs_handle_struct *handle,
                        struct smb_filename *smb_fname)
 {
@@ -3036,7 +3022,6 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .sendfile_fn = vfswrap_sendfile,
        .recvfile_fn = vfswrap_recvfile,
        .rename_fn = vfswrap_rename,
-       .fsync_fn = vfswrap_fsync,
        .fsync_send_fn = vfswrap_fsync_send,
        .fsync_recv_fn = vfswrap_fsync_recv,
        .stat_fn = vfswrap_stat,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index fbe1715..45d6544 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -1286,18 +1286,6 @@ static int smb_full_audit_rename(vfs_handle_struct 
*handle,
        return result;    
 }
 
-static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       int result;
-       
-       result = SMB_VFS_NEXT_FSYNC(handle, fsp);
-
-       do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
-              fsp_str_do_log(fsp));
-
-       return result;    
-}
-
 struct smb_full_audit_fsync_state {
        vfs_handle_struct *handle;
        files_struct *fsp;
@@ -2531,7 +2519,6 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .sendfile_fn = smb_full_audit_sendfile,
        .recvfile_fn = smb_full_audit_recvfile,
        .rename_fn = smb_full_audit_rename,
-       .fsync_fn = smb_full_audit_fsync,
        .fsync_send_fn = smb_full_audit_fsync_send,
        .fsync_recv_fn = smb_full_audit_fsync_recv,
        .stat_fn = smb_full_audit_stat,
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 38abb78..5878c14 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -931,12 +931,6 @@ static int vfs_gluster_rename(struct vfs_handle_struct 
*handle,
                           smb_fname_dst->base_name);
 }
 
-static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
-                            files_struct *fsp)
-{
-       return glfs_fsync(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp));
-}
-
 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
                                                 *handle, TALLOC_CTX *mem_ctx,
                                                 struct tevent_context *ev,
@@ -1471,7 +1465,6 @@ static struct vfs_fn_pointers glusterfs_fns = {
        .sendfile_fn = vfs_gluster_sendfile,
        .recvfile_fn = vfs_gluster_recvfile,
        .rename_fn = vfs_gluster_rename,
-       .fsync_fn = vfs_gluster_fsync,
        .fsync_send_fn = vfs_gluster_fsync_send,
        .fsync_recv_fn = vfs_gluster_fsync_recv,
 
diff --git a/source3/modules/vfs_streams_xattr.c 
b/source3/modules/vfs_streams_xattr.c
index c653656..5355dd8 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -1323,18 +1323,6 @@ static int streams_xattr_fchmod(vfs_handle_struct 
*handle,
        return 0;
 }
 
-static int streams_xattr_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       struct stream_io *sio =
-               (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
-
-       if (sio == NULL) {
-               return SMB_VFS_NEXT_FSYNC(handle, fsp);
-       }
-
-       return 0;
-}
-
 static ssize_t streams_xattr_fgetxattr(struct vfs_handle_struct *handle,
                                       struct files_struct *fsp,
                                       const char *name,
@@ -1683,7 +1671,6 @@ static struct vfs_fn_pointers vfs_streams_xattr_fns = {
 
        .fchown_fn = streams_xattr_fchown,
        .fchmod_fn = streams_xattr_fchmod,
-       .fsync_fn = streams_xattr_fsync,
 
        .fgetxattr_fn = streams_xattr_fgetxattr,
        .flistxattr_fn = streams_xattr_flistxattr,
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 4a0ec89..383f49b 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -938,24 +938,6 @@ static int smb_time_audit_rename(vfs_handle_struct *handle,
        return result;
 }
 
-static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
-{
-       int result;
-       struct timespec ts1,ts2;
-       double timediff;
-
-       clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_FSYNC(handle, fsp);
-       clock_gettime_mono(&ts2);
-       timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
-       if (timediff > audit_timeout) {
-               smb_time_audit_log_fsp("fsync", timediff, fsp);
-       }
-
-       return result;
-}
-
 struct smb_time_audit_fsync_state {
        struct files_struct *fsp;
        int ret;
@@ -2707,7 +2689,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .sendfile_fn = smb_time_audit_sendfile,
        .recvfile_fn = smb_time_audit_recvfile,
        .rename_fn = smb_time_audit_rename,
-       .fsync_fn = smb_time_audit_fsync,
        .fsync_send_fn = smb_time_audit_fsync_send,
        .fsync_recv_fn = smb_time_audit_fsync_recv,
        .stat_fn = smb_time_audit_stat,
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index ec6333e..7b17889 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -1057,7 +1057,7 @@ NTSTATUS sync_file(connection_struct *conn, files_struct 
*fsp, bool write_throug
                if (ret == -1) {
                        return map_nt_error_from_unix(errno);
                }
-               ret = SMB_VFS_FSYNC(fsp);
+               ret = smb_vfs_fsync_sync(fsp);
                if (ret == -1) {
                        return map_nt_error_from_unix(errno);
                }
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 5970220..f659c8f 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1921,13 +1921,6 @@ int smb_vfs_call_rename(struct vfs_handle_struct *handle,
        return handle->fns->rename_fn(handle, smb_fname_src, smb_fname_dst);
 }
 
-int smb_vfs_call_fsync(struct vfs_handle_struct *handle,
-                      struct files_struct *fsp)
-{
-       VFS_FIND(fsync);
-       return handle->fns->fsync_fn(handle, fsp);
-}
-
 struct smb_vfs_call_fsync_state {
        int (*recv_fn)(struct tevent_req *req, struct vfs_aio_state 
*vfs_aio_state);
        int retval;
@@ -1988,6 +1981,45 @@ int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct 
vfs_aio_state *vfs_aio_sta
        return state->retval;
 }
 
+/*
+ * Synchronous version of fsync, built from backend
+ * async VFS primitives. Uses a temporary sub-event
+ * context (NOT NESTED).
+ */
+
+int smb_vfs_fsync_sync(files_struct *fsp)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_req *req = NULL;
+       struct vfs_aio_state aio_state = { 0 };
+       int ret = -1;
+       bool ok;
+       struct tevent_context *ev = samba_tevent_context_init(frame);
+
+       if (ev == NULL) {
+               goto out;
+       }
+
+       req = SMB_VFS_FSYNC_SEND(talloc_tos(), ev, fsp);
+       if (req == NULL) {
+               goto out;
+       }
+
+       ok = tevent_req_poll(req, ev);
+       if (!ok) {
+               goto out;
+       }
+
+       ret = SMB_VFS_FSYNC_RECV(req, &aio_state);
+
+  out:
+
+       TALLOC_FREE(frame);
+       if (aio_state.error != 0) {
+               errno = aio_state.error;
+       }
+       return ret;
+}
 
 int smb_vfs_call_stat(struct vfs_handle_struct *handle,
                      struct smb_filename *smb_fname)
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 034136f..3ae788e 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -640,7 +640,6 @@ static NTSTATUS cmd_rename(struct vfs_state *vfs, 
TALLOC_CTX *mem_ctx, int argc,
        return NT_STATUS_OK;
 }
 
-
 static NTSTATUS cmd_fsync(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int 
argc, const char **argv)
 {
        int ret, fd;
@@ -650,7 +649,7 @@ static NTSTATUS cmd_fsync(struct vfs_state *vfs, TALLOC_CTX 
*mem_ctx, int argc,
        }
 
        fd = atoi(argv[1]);
-       ret = SMB_VFS_FSYNC(vfs->files[fd]);
+       ret = smb_vfs_fsync_sync(vfs->files[fd]);
        if (ret == -1) {
                printf("fsync: error=%d (%s)\n", errno, strerror(errno));
                return NT_STATUS_UNSUCCESSFUL;


-- 
Samba Shared Repository

Reply via email to