diff options
author | Volker Lendecke <vl@samba.org> | 2012-08-08 00:32:35 +0200 |
---|---|---|
committer | Christian Ambach <ambi@samba.org> | 2012-08-17 18:25:53 +0200 |
commit | 2c3a58db9e2149785486e6b6398615f2d226dc23 (patch) | |
tree | 931eccb4ee41c565291a8fb3825a3c38d4882383 /source3/modules/vfs_gpfs.c | |
parent | 2e1ab13f6ebb2c2cf746457d4783fe9bc5e86de0 (diff) | |
download | samba-2c3a58db9e2149785486e6b6398615f2d226dc23.tar.gz samba-2c3a58db9e2149785486e6b6398615f2d226dc23.tar.xz samba-2c3a58db9e2149785486e6b6398615f2d226dc23.zip |
s3: Merge vfs_gpfs_hsm_notify into vfs_gpfs.c
It was separated out because formerly our async I/O was not properly
stackable. aio_fork could for example catch aio and not get aio_return
get through to vfs_gpfs
Signed-off-by: Christian Ambach <ambi@samba.org>
Diffstat (limited to 'source3/modules/vfs_gpfs.c')
-rw-r--r-- | source3/modules/vfs_gpfs.c | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index a988c09164..7a012573f0 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -34,6 +34,7 @@ #include "vfs_gpfs.h" #include "system/filesys.h" #include "auth.h" +#include "lib/util/tevent_unix.h" struct gpfs_config_data { bool sharemodes; @@ -1691,6 +1692,189 @@ static int vfs_gpfs_open(struct vfs_handle_struct *handle, return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); } +static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp, + void *data, size_t n, off_t offset) +{ + ssize_t ret; + + ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); + + DEBUG(10, ("vfs_private = %x\n", + (unsigned int)fsp->fsp_name->st.vfs_private)); + + if ((ret != -1) && + ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) { + fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE; + notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name->base_name); + } + + return ret; +} + +struct vfs_gpfs_pread_state { + struct files_struct *fsp; + ssize_t ret; + int err; +}; + +static void vfs_gpfs_pread_done(struct tevent_req *subreq); + +static struct tevent_req *vfs_gpfs_pread_send(struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp, + void *data, size_t n, + off_t offset) +{ + struct tevent_req *req, *subreq; + struct vfs_gpfs_pread_state *state; + + req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pread_state); + if (req == NULL) { + return NULL; + } + state->fsp = fsp; + subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data, + n, offset); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, vfs_gpfs_pread_done, req); + return req; +} + +static void vfs_gpfs_pread_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct vfs_gpfs_pread_state *state = tevent_req_data( + req, struct vfs_gpfs_pread_state); + + state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err); + TALLOC_FREE(subreq); + tevent_req_done(req); +} + +static ssize_t vfs_gpfs_pread_recv(struct tevent_req *req, int *err) +{ + struct vfs_gpfs_pread_state *state = tevent_req_data( + req, struct vfs_gpfs_pread_state); + struct files_struct *fsp = state->fsp; + + if (tevent_req_is_unix_error(req, err)) { + return -1; + } + *err = state->err; + + DEBUG(10, ("vfs_private = %x\n", + (unsigned int)fsp->fsp_name->st.vfs_private)); + + if ((state->ret != -1) && + ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) { + fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE; + DEBUG(10, ("sending notify\n")); + notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name->base_name); + } + + return state->ret; +} + +static ssize_t vfs_gpfs_pwrite(vfs_handle_struct *handle, files_struct *fsp, + const void *data, size_t n, off_t offset) +{ + ssize_t ret; + + ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); + + DEBUG(10, ("vfs_private = %x\n", + (unsigned int)fsp->fsp_name->st.vfs_private)); + + if ((ret != -1) && + ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) { + fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE; + notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name->base_name); + } + + return ret; +} + +struct vfs_gpfs_pwrite_state { + struct files_struct *fsp; + ssize_t ret; + int err; +}; + +static void vfs_gpfs_pwrite_done(struct tevent_req *subreq); + +static struct tevent_req *vfs_gpfs_pwrite_send( + struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp, + const void *data, size_t n, + off_t offset) +{ + struct tevent_req *req, *subreq; + struct vfs_gpfs_pwrite_state *state; + + req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pwrite_state); + if (req == NULL) { + return NULL; + } + state->fsp = fsp; + subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data, + n, offset); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, vfs_gpfs_pwrite_done, req); + return req; +} + +static void vfs_gpfs_pwrite_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct vfs_gpfs_pwrite_state *state = tevent_req_data( + req, struct vfs_gpfs_pwrite_state); + + state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err); + TALLOC_FREE(subreq); + tevent_req_done(req); +} + +static ssize_t vfs_gpfs_pwrite_recv(struct tevent_req *req, int *err) +{ + struct vfs_gpfs_pwrite_state *state = tevent_req_data( + req, struct vfs_gpfs_pwrite_state); + struct files_struct *fsp = state->fsp; + + if (tevent_req_is_unix_error(req, err)) { + return -1; + } + *err = state->err; + + DEBUG(10, ("vfs_private = %x\n", + (unsigned int)fsp->fsp_name->st.vfs_private)); + + if ((state->ret != -1) && + ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) { + fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE; + DEBUG(10, ("sending notify\n")); + notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_ATTRIBUTES, + fsp->fsp_name->base_name); + } + + return state->ret; +} + static struct vfs_fn_pointers vfs_gpfs_fns = { .connect_fn = vfs_gpfs_connect, @@ -1721,6 +1905,12 @@ static struct vfs_fn_pointers vfs_gpfs_fns = { .sendfile_fn = vfs_gpfs_sendfile, .fallocate_fn = vfs_gpfs_fallocate, .open_fn = vfs_gpfs_open, + .pread_fn = vfs_gpfs_pread, + .pread_send_fn = vfs_gpfs_pread_send, + .pread_recv_fn = vfs_gpfs_pread_recv, + .pwrite_fn = vfs_gpfs_pwrite, + .pwrite_send_fn = vfs_gpfs_pwrite_send, + .pwrite_recv_fn = vfs_gpfs_pwrite_recv, .ftruncate_fn = vfs_gpfs_ftruncate }; |