summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_aio_posix.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-07-13 13:53:39 +0200
committerJeremy Allison <jra@samba.org>2012-07-18 15:51:43 -0700
commite3f3c09504f1c6bdeeeea685b073762170f00e33 (patch)
treebee3ade93f48d194488cb872a6f5a1f8f987b2d0 /source3/modules/vfs_aio_posix.c
parented31e201158591b480404f0b197923751551bc40 (diff)
downloadsamba-e3f3c09504f1c6bdeeeea685b073762170f00e33.tar.gz
samba-e3f3c09504f1c6bdeeeea685b073762170f00e33.tar.bz2
samba-e3f3c09504f1c6bdeeeea685b073762170f00e33.zip
s3: Add aio_fsync to the aio_posix module
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/modules/vfs_aio_posix.c')
-rw-r--r--source3/modules/vfs_aio_posix.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/source3/modules/vfs_aio_posix.c b/source3/modules/vfs_aio_posix.c
index 97b102b5e4..3629541e61 100644
--- a/source3/modules/vfs_aio_posix.c
+++ b/source3/modules/vfs_aio_posix.c
@@ -209,6 +209,61 @@ static ssize_t aio_posix_recv(struct tevent_req *req, int *err)
return state->ret;
}
+static struct tevent_req *aio_posix_fsync_send(
+ struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev, struct files_struct *fsp)
+{
+ struct tevent_req *req;
+ struct aio_posix_state *state;
+ struct aiocb *a;
+ int ret;
+
+ req = tevent_req_create(mem_ctx, &state, struct aio_posix_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ a = &state->acb;
+
+ a->aio_fildes = fsp->fh->fd;
+ a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+ a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO;
+ a->aio_sigevent.sigev_value.sival_ptr = req;
+
+ ret = aio_fsync(O_SYNC, a);
+ if (ret == 0) {
+ talloc_set_destructor(state, aio_posix_state_destructor);
+ return req;
+ }
+
+ if (errno == EAGAIN) {
+ /*
+ * aio overloaded, do the sync fallback
+ */
+ state->ret = fsync(fsp->fh->fd);
+ if (state->ret == -1) {
+ state->err = errno;
+ }
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
+ }
+
+ tevent_req_error(req, errno);
+ return tevent_req_post(req, ev);
+}
+
+static int aio_posix_int_recv(struct tevent_req *req, int *err)
+{
+ struct aio_posix_state *state = tevent_req_data(
+ req, struct aio_posix_state);
+
+ if (tevent_req_is_unix_error(req, err)) {
+ return -1;
+ }
+ *err = state->err;
+ return state->ret;
+}
+
static int aio_posix_connect(vfs_handle_struct *handle, const char *service,
const char *user)
{
@@ -233,6 +288,8 @@ static struct vfs_fn_pointers vfs_aio_posix_fns = {
.pread_recv_fn = aio_posix_recv,
.pwrite_send_fn = aio_posix_pwrite_send,
.pwrite_recv_fn = aio_posix_recv,
+ .fsync_send_fn = aio_posix_fsync_send,
+ .fsync_recv_fn = aio_posix_int_recv,
};
NTSTATUS vfs_aio_posix_init(void);