The branch, master has been updated via 52dc959 s3: smbd: Remove unused counters for outstanding aio calls. via f0e6453 vfs_ceph: add fake async pwrite/pread send/recv hooks from bc2beed libcli: remove unused se_create_child_secdesc_buf()
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 52dc959bb21a102a14437812418bbb75b0bb231f Author: Jeremy Allison <j...@samba.org> Date: Wed May 9 09:32:45 2018 -0700 s3: smbd: Remove unused counters for outstanding aio calls. Only a debug message used this. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Böhme <s...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Wed May 9 22:24:38 CEST 2018 on sn-devel-144 commit f0e6453b0420fe9d062936d4ddc05f44b40cf2ba Author: David Disseldorp <dd...@samba.org> Date: Wed May 9 16:51:34 2018 +0200 vfs_ceph: add fake async pwrite/pread send/recv hooks As found by Jeremy, VFS modules that don't provide pread_send() or pwrite_send() hooks result in vfs_default fallback, which is catastrophic for VFS modules with non-mounted filesystems such as vfs_ceph. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13425 Reported-by: Jeremy Allison <j...@samba.org> Signed-off-by: David Disseldorp <dd...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_ceph.c | 109 ++++++++++++++++++++++++++++++++++++++++++++- source3/smbd/aio.c | 41 ++--------------- source3/smbd/proto.h | 3 -- source3/smbd/smb2_flush.c | 3 -- 4 files changed, 112 insertions(+), 44 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 87df83e..bac8858 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -470,6 +470,57 @@ static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fs WRAP_RETURN(result); } +struct cephwrap_pread_state { + ssize_t bytes_read; + struct vfs_aio_state vfs_aio_state; +}; + +/* + * Fake up an async ceph read by calling the synchronous API. + */ +static struct tevent_req *cephwrap_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 = NULL; + struct cephwrap_pread_state *state = NULL; + int ret = -1; + + DBG_DEBUG("[CEPH] %s\n", __func__); + req = tevent_req_create(mem_ctx, &state, struct cephwrap_pread_state); + if (req == NULL) { + return NULL; + } + + ret = ceph_read(handle->data, fsp->fh->fd, data, n, offset); + if (ret < 0) { + /* ceph returns -errno on error. */ + tevent_req_error(req, -ret); + return tevent_req_post(req, ev); + } + + state->bytes_read = ret; + tevent_req_done(req); + /* Return and schedule the completion of the call. */ + return tevent_req_post(req, ev); +} + +static ssize_t cephwrap_pread_recv(struct tevent_req *req, + struct vfs_aio_state *vfs_aio_state) +{ + struct cephwrap_pread_state *state = + tevent_req_data(req, struct cephwrap_pread_state); + + DBG_DEBUG("[CEPH] %s\n", __func__); + if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { + return -1; + } + *vfs_aio_state = state->vfs_aio_state; + return state->bytes_read; +} static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, off_t offset) @@ -482,6 +533,58 @@ static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *f WRAP_RETURN(result); } +struct cephwrap_pwrite_state { + ssize_t bytes_written; + struct vfs_aio_state vfs_aio_state; +}; + +/* + * Fake up an async ceph write by calling the synchronous API. + */ +static struct tevent_req *cephwrap_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 = NULL; + struct cephwrap_pwrite_state *state = NULL; + int ret = -1; + + DBG_DEBUG("[CEPH] %s\n", __func__); + req = tevent_req_create(mem_ctx, &state, struct cephwrap_pwrite_state); + if (req == NULL) { + return NULL; + } + + ret = ceph_write(handle->data, fsp->fh->fd, data, n, offset); + if (ret < 0) { + /* ceph returns -errno on error. */ + tevent_req_error(req, -ret); + return tevent_req_post(req, ev); + } + + state->bytes_written = ret; + tevent_req_done(req); + /* Return and schedule the completion of the call. */ + return tevent_req_post(req, ev); +} + +static ssize_t cephwrap_pwrite_recv(struct tevent_req *req, + struct vfs_aio_state *vfs_aio_state) +{ + struct cephwrap_pwrite_state *state = + tevent_req_data(req, struct cephwrap_pwrite_state); + + DBG_DEBUG("[CEPH] %s\n", __func__); + if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { + return -1; + } + *vfs_aio_state = state->vfs_aio_state; + return state->bytes_written; +} + static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence) { off_t result = 0; @@ -535,7 +638,7 @@ static int cephwrap_rename(struct vfs_handle_struct *handle, } /* - * Fake up an async ceph fsync by calling the sychronous API. + * Fake up an async ceph fsync by calling the synchronous API. */ static struct tevent_req *cephwrap_fsync_send(struct vfs_handle_struct *handle, @@ -1443,7 +1546,11 @@ static struct vfs_fn_pointers ceph_fns = { .open_fn = cephwrap_open, .close_fn = cephwrap_close, .pread_fn = cephwrap_pread, + .pread_send_fn = cephwrap_pread_send, + .pread_recv_fn = cephwrap_pread_recv, .pwrite_fn = cephwrap_pwrite, + .pwrite_send_fn = cephwrap_pwrite_send, + .pwrite_recv_fn = cephwrap_pwrite_recv, .lseek_fn = cephwrap_lseek, .sendfile_fn = cephwrap_sendfile, .recvfile_fn = cephwrap_recvfile, diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 4fc1132..abf8858 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -26,27 +26,6 @@ #include "lib/tevent_wait.h" /**************************************************************************** - Statics plus accessor functions. -*****************************************************************************/ - -static int outstanding_aio_calls; - -int get_outstanding_aio_calls(void) -{ - return outstanding_aio_calls; -} - -void increment_outstanding_aio_calls(void) -{ - outstanding_aio_calls++; -} - -void decrement_outstanding_aio_calls(void) -{ - outstanding_aio_calls--; -} - -/**************************************************************************** The buffer we keep around whilst an aio request is in process. *****************************************************************************/ @@ -69,12 +48,6 @@ bool aio_write_through_requested(struct aio_extra *aio_ex) return aio_ex->write_through; } -static int aio_extra_destructor(struct aio_extra *aio_ex) -{ - decrement_outstanding_aio_calls(); - return 0; -} - /**************************************************************************** Create the extended aio struct we must keep around for the lifetime of the aio call. @@ -101,9 +74,7 @@ static struct aio_extra *create_aio_extra(TALLOC_CTX *mem_ctx, return NULL; } } - talloc_set_destructor(aio_ex, aio_extra_destructor); aio_ex->fsp = fsp; - increment_outstanding_aio_calls(); return aio_ex; } @@ -523,11 +494,9 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn, } DEBUG(10,("schedule_aio_write_and_X: scheduled aio_write for file " - "%s, offset %.0f, len = %u (mid = %u) " - "outstanding_aio_calls = %d\n", + "%s, offset %.0f, len = %u (mid = %u)\n", fsp_str_dbg(fsp), (double)startpos, (unsigned int)numtowrite, - (unsigned int)aio_ex->smbreq->mid, - get_outstanding_aio_calls() )); + (unsigned int)aio_ex->smbreq->mid)); return NT_STATUS_OK; } @@ -906,13 +875,11 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn, */ DEBUG(10,("smb2: scheduled aio_write for file " - "%s, offset %.0f, len = %u (mid = %u) " - "outstanding_aio_calls = %d\n", + "%s, offset %.0f, len = %u (mid = %u)\n", fsp_str_dbg(fsp), (double)in_offset, (unsigned int)in_data.length, - (unsigned int)aio_ex->smbreq->mid, - get_outstanding_aio_calls() )); + (unsigned int)aio_ex->smbreq->mid)); return NT_STATUS_OK; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 2f315ce..778561c 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -66,9 +66,6 @@ void srv_set_signing(struct smbXsrv_connection *conn, /* The following definitions come from smbd/aio.c */ -int get_outstanding_aio_calls(void); -void increment_outstanding_aio_calls(void); -void decrement_outstanding_aio_calls(void); struct aio_extra; bool aio_write_through_requested(struct aio_extra *aio_ex); NTSTATUS schedule_aio_read_and_X(connection_struct *conn, diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index d1ab3a0..f7d9e96 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -184,7 +184,6 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - increment_outstanding_aio_calls(); return req; } @@ -196,8 +195,6 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq) int ret; struct vfs_aio_state vfs_aio_state; - decrement_outstanding_aio_calls(); - ret = SMB_VFS_FSYNC_RECV(subreq, &vfs_aio_state); TALLOC_FREE(subreq); if (ret == -1) { -- Samba Shared Repository