summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_default.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-07-13 10:22:25 +0200
committerJeremy Allison <jra@samba.org>2012-07-18 15:48:04 -0700
commit5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3 (patch)
treeb1438456ff31f7e522089f6569f67c078d6eadc4 /source3/modules/vfs_default.c
parent3882113e6f44d0adbc321d97931a6e9a37a149b8 (diff)
downloadsamba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.tar.gz
samba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.tar.bz2
samba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.zip
s3-vfs: async fsync
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/modules/vfs_default.c')
-rw-r--r--source3/modules/vfs_default.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index c79eed0b97..002a5501fd 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -737,6 +737,36 @@ static struct tevent_req *vfswrap_pwrite_send(struct vfs_handle_struct *handle,
return req;
}
+static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct files_struct *fsp)
+{
+ struct tevent_req *req;
+ struct vfswrap_asys_state *state;
+ int ret;
+
+ req = tevent_req_create(mem_ctx, &state, struct vfswrap_asys_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ if (!vfswrap_init_asys_ctx(handle->conn->sconn->conn)) {
+ tevent_req_oom(req);
+ return tevent_req_post(req, ev);
+ }
+ state->asys_ctx = handle->conn->sconn->conn->asys_ctx;
+ state->req = req;
+
+ ret = asys_fsync(state->asys_ctx, fsp->fh->fd, req);
+ if (ret != 0) {
+ tevent_req_error(req, ret);
+ return tevent_req_post(req, ev);
+ }
+ talloc_set_destructor(state, vfswrap_asys_state_destructor);
+
+ return req;
+}
+
static void vfswrap_asys_finished(struct tevent_context *ev,
struct tevent_fd *fde,
uint16_t flags, void *p)
@@ -785,6 +815,18 @@ static ssize_t vfswrap_asys_ssize_t_recv(struct tevent_req *req, int *err)
return state->ret;
}
+static int vfswrap_asys_int_recv(struct tevent_req *req, int *err)
+{
+ struct vfswrap_asys_state *state = tevent_req_data(
+ req, struct vfswrap_asys_state);
+
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
+ }
+ *err = state->err;
+ return state->ret;
+}
+
static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)
{
off_t result = 0;
@@ -2314,6 +2356,8 @@ static struct vfs_fn_pointers vfs_default_fns = {
.recvfile_fn = vfswrap_recvfile,
.rename_fn = vfswrap_rename,
.fsync_fn = vfswrap_fsync,
+ .fsync_send_fn = vfswrap_fsync_send,
+ .fsync_recv_fn = vfswrap_asys_int_recv,
.stat_fn = vfswrap_stat,
.fstat_fn = vfswrap_fstat,
.lstat_fn = vfswrap_lstat,