The Samba-Bugzilla – Attachment 18597 Details for
Bug 15810
Add async io API from libcephfs to ceph_new VFS module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch from master for v4-21-test
v4.21.patch (text/plain), 23.96 KB, created by
Anoop C S
on 2025-03-07 09:54:42 UTC
(
hide
)
Description:
patch from master for v4-21-test
Filename:
MIME Type:
Creator:
Anoop C S
Created:
2025-03-07 09:54:42 UTC
Size:
23.96 KB
patch
obsolete
>From af85176953187041ce261a4bebb5df6abb5c63b1 Mon Sep 17 00:00:00 2001 >From: Anoop C S <anoopcs@samba.org> >Date: Mon, 5 Aug 2024 18:51:49 +0530 >Subject: [PATCH 1/3] source3/wscript: Introduce auto mode to build ceph vfs > modules > >Use 'auto' mode as the default for building ceph vfs modules so that an >explicit --enable-cephfs can reliably fail in the absence of required >dependencies. > >ref: https://lists.samba.org/archive/samba/2024-August/249569.html > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15810 > >Signed-off-by: Anoop C S <anoopcs@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> > >Autobuild-User(master): Anoop C S <anoopcs@samba.org> >Autobuild-Date(master): Tue Aug 27 06:18:51 UTC 2024 on atb-devel-224 > >(cherry picked from commit 232ab02faf9615c55c362c60e06381ea02421794) >--- > source3/wscript | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > >diff --git a/source3/wscript b/source3/wscript >index 2cf537704b2..f746a67b800 100644 >--- a/source3/wscript >+++ b/source3/wscript >@@ -87,7 +87,7 @@ def options(opt): > help=("Include AFS fake-kaserver support"), default=False) > > opt.samba_add_onoff_option('glusterfs', with_name="enable", without_name="disable", default=True) >- opt.samba_add_onoff_option('cephfs', with_name="enable", without_name="disable", default=True) >+ opt.samba_add_onoff_option('cephfs', with_name="enable", without_name="disable", default=None) > > opt.add_option('--enable-vxfs', > help=("enable support for VxFS (default=no)"), >@@ -1619,17 +1619,27 @@ int main(void) { > > conf.env['CFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64" > >- if (Options.options.with_cephfs and >+ if (Options.options.with_cephfs is not False and > conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and > conf.CHECK_LIB('cephfs', shlib=True)): > if (Options.options.with_acl_support and > conf.CHECK_FUNCS_IN('ceph_statx ceph_openat', 'cephfs', > headers='cephfs/libcephfs.h')): > conf.DEFINE('HAVE_CEPH', '1') >+ >+ if conf.CONFIG_SET('HAVE_CEPH'): >+ Logs.info("building ceph vfs modules") >+ else: >+ if Options.options.with_cephfs == False: >+ Logs.info("not building ceph vfs modules(--disable-cephfs)") >+ elif Options.options.with_cephfs == True: >+ Logs.error("acl support disabled or ceph_statx/ceph_openat not " >+ "available, cannot build ceph vfs modules") >+ conf.fatal("acl support disabled or ceph_statx/ceph_openat not " >+ "available, but --enable-cephfs was specified") > else: >- Logs.warn('''Ceph support disabled due to --without-acl-support >- or lack of ceph_statx/ceph_openat support''') >- conf.undefine('HAVE_CEPH') >+ Logs.warn("acl support disabled or ceph_statx/ceph_openat not " >+ "available, not building ceph vfs modules") > > if Options.options.with_glusterfs: > conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs', >-- >2.48.1 > > >From 4c98a4c8dec03cf5ab4182ebf927857811c7dd5b Mon Sep 17 00:00:00 2001 >From: Anoop C S <anoopcs@samba.org> >Date: Mon, 28 Oct 2024 11:13:10 +0530 >Subject: [PATCH 2/3] vfs_ceph_new: Remove unused symbol for ceph_readdir > >ce459ddbcd0f32252858a7640f6871057eb14645 recently switched the readdir >implementation to use ceph_readdir_r(). Thus ceph_readdir() is >unnecessarily loaded which is no longer used. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15810 > >Signed-off-by: Anoop C S <anoopcs@samba.org> >Reviewed-by: John Mulligan <jmulligan@redhat.com> > >Autobuild-User(master): Anoop C S <anoopcs@samba.org> >Autobuild-Date(master): Sun Nov 3 11:07:23 UTC 2024 on atb-devel-224 > >(cherry picked from commit e3d35ca69446606b557f20e5faec2e76354eaaa4) >--- > source3/modules/vfs_ceph_new.c | 2 -- > 1 file changed, 2 deletions(-) > >diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c >index 1cb04f1f9ee..c7a4cc9d05e 100644 >--- a/source3/modules/vfs_ceph_new.c >+++ b/source3/modules/vfs_ceph_new.c >@@ -155,7 +155,6 @@ struct vfs_ceph_config { > CEPH_FN(ceph_userperm_destroy); > CEPH_FN(ceph_userperm_new); > CEPH_FN(ceph_version); >- CEPH_FN(ceph_readdir); > CEPH_FN(ceph_rewinddir); > CEPH_FN(ceph_readdir_r); > }; >@@ -442,7 +441,6 @@ static bool vfs_cephfs_load_lib(struct vfs_ceph_config *config) > CHECK_CEPH_FN(libhandle, ceph_userperm_destroy); > CHECK_CEPH_FN(libhandle, ceph_userperm_new); > CHECK_CEPH_FN(libhandle, ceph_version); >- CHECK_CEPH_FN(libhandle, ceph_readdir); > CHECK_CEPH_FN(libhandle, ceph_rewinddir); > CHECK_CEPH_FN(libhandle, ceph_readdir_r); > >-- >2.48.1 > > >From 4b79a1ff69c99628902ffe96c7c563a0becc6db1 Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Tue, 1 Oct 2024 12:09:40 +0300 >Subject: [PATCH 3/3] vfs_ceph_new: use libcephfs nonblocking API for async-io > ops >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Use libcephfs non-blocking API (ceph_ll_nonblocking_readv_writev[1]) in >combination with smb VFS async hooks ({pread,pwrite,fsync}_send/_recv). >Fills libcephfs' struct ceph_ll_io_info with single iovec and >submit/complete the operation asynchronously on libcephfs side, with >corresponding tevent schedule-immediate upon completion on smbd side. > >Control nonblocking/normal I/O mode via config parameter. The common >parts of async I/O (with/without HAVE_CEPH_ASYNCIO) are united. >Specifically, use same struct vfs_ceph_aio_state and common code via >helper function for all async I/O hooks. When HAVE_CEPH_ASYNCIO >is True _and_ config option 'asyncio = yes' use libcephfs asynchronous >I/O API. Otherwise, fake async operation using normal blocking APIs. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15810 > >[1] https://github.com/ceph/ceph/commit/b4e39f3eccd6734f1ed13c700c136e3aef1777f8 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> > >Autobuild-User(master): Günther Deschner <gd@samba.org> >Autobuild-Date(master): Tue Mar 4 16:53:21 UTC 2025 on atb-devel-224 > >(cherry picked from commit 4ae9224138449fe7b8dd1e8ce8141aedd014efc4) >--- > source3/modules/vfs_ceph_new.c | 430 ++++++++++++++++++++++++++------- > source3/wscript | 4 + > 2 files changed, 349 insertions(+), 85 deletions(-) > >diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c >index c7a4cc9d05e..1f9d9b4c3b0 100644 >--- a/source3/modules/vfs_ceph_new.c >+++ b/source3/modules/vfs_ceph_new.c >@@ -102,6 +102,9 @@ static const struct enum_list enum_vfs_cephfs_proxy_vals[] = { > #define CEPH_FN(_name) typeof(_name) *_name ## _fn > > struct vfs_ceph_config { >+#if HAVE_CEPH_ASYNCIO >+ struct tevent_threaded_context *tctx; >+#endif > const char *conf_file; > const char *user_id; > const char *fsname; >@@ -157,6 +160,9 @@ struct vfs_ceph_config { > CEPH_FN(ceph_version); > CEPH_FN(ceph_rewinddir); > CEPH_FN(ceph_readdir_r); >+#if HAVE_CEPH_ASYNCIO >+ CEPH_FN(ceph_ll_nonblocking_readv_writev); >+#endif > }; > > /* >@@ -443,6 +449,9 @@ static bool vfs_cephfs_load_lib(struct vfs_ceph_config *config) > CHECK_CEPH_FN(libhandle, ceph_version); > CHECK_CEPH_FN(libhandle, ceph_rewinddir); > CHECK_CEPH_FN(libhandle, ceph_readdir_r); >+#if HAVE_CEPH_ASYNCIO >+ CHECK_CEPH_FN(libhandle, ceph_ll_nonblocking_readv_writev); >+#endif > > config->libhandle = libhandle; > >@@ -1795,6 +1804,30 @@ static int vfs_ceph_ll_fremovexattr(const struct vfs_handle_struct *handle, > cfh->uperm); > } > >+#if HAVE_CEPH_ASYNCIO >+static int64_t vfs_ceph_ll_nonblocking_readv_writev( >+ const struct vfs_handle_struct *handle, >+ const struct vfs_ceph_fh *cfh, >+ struct ceph_ll_io_info *io_info) >+{ >+ struct vfs_ceph_config *config = NULL; >+ >+ SMB_VFS_HANDLE_GET_DATA(handle, >+ config, >+ struct vfs_ceph_config, >+ return -EINVAL); >+ >+ DBG_DEBUG("[CEPH] ceph_ll_nonblocking_readv_writev: ino=%" PRIu64 >+ " fd=%d off=%jd\n", >+ cfh->iref.ino, >+ cfh->fd, >+ io_info->off); >+ >+ return config->ceph_ll_nonblocking_readv_writev_fn(config->mount, >+ io_info); >+} >+#endif >+ > /* Ceph Inode-refernce get/put wrappers */ > static int vfs_ceph_iget(const struct vfs_handle_struct *handle, > uint64_t ino, >@@ -2271,17 +2304,28 @@ out: > } > > struct vfs_ceph_aio_state { >+ struct vfs_ceph_config *config; >+ struct vfs_ceph_fh *cfh; >+#if HAVE_CEPH_ASYNCIO >+ struct tevent_req *req; >+ bool orphaned; >+ struct tevent_immediate *im; >+ void *data; >+ size_t len; >+ off_t off; >+ bool write; >+ bool fsync; >+ >+ struct ceph_ll_io_info io_info; >+ struct iovec iov; >+#endif > struct timespec start_time; > struct timespec finish_time; >+ ssize_t result; > struct vfs_aio_state vfs_aio_state; > SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes); > }; > >-struct vfs_ceph_pread_state { >- ssize_t bytes_read; >- struct vfs_ceph_aio_state ceph_aio_state; >-}; >- > static void vfs_ceph_aio_start(struct vfs_ceph_aio_state *state) > { > SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes); >@@ -2297,22 +2341,218 @@ static void vfs_ceph_aio_finish(struct vfs_ceph_aio_state *state, > if (result < 0) { > state->vfs_aio_state.error = (int)result; > } >+ >+ state->result = result; > SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes); > } > >-/* >- * Fake up an async ceph read by calling the synchronous API. >- */ >+#if HAVE_CEPH_ASYNCIO >+ >+static void vfs_ceph_aio_done(struct tevent_context *ev, >+ struct tevent_immediate *im, >+ void *private_data); >+ >+static int vfs_ceph_require_tctx(struct vfs_ceph_aio_state *state, >+ struct tevent_context *ev) >+{ >+ struct vfs_ceph_config *config = state->config; >+ >+ if (config->tctx != NULL) { >+ return 0; >+ } >+ >+ config->tctx = tevent_threaded_context_create(config, ev); >+ if (config->tctx == NULL) { >+ return -ENOMEM; >+ } >+ >+ return 0; >+} >+ >+static void vfs_ceph_aio_complete(struct ceph_ll_io_info *io_info) >+{ >+ struct vfs_ceph_aio_state *state = io_info->priv; >+ >+ if (state->orphaned) { >+ return; >+ } >+ >+ DBG_DEBUG("[CEPH] aio_complete: ino=%" PRIu64 >+ " fd=%d off=%jd len=%ju result=%jd\n", >+ state->cfh->iref.ino, >+ state->cfh->fd, >+ state->off, >+ state->len, >+ state->io_info.result); >+ >+ tevent_threaded_schedule_immediate(state->config->tctx, >+ state->im, >+ vfs_ceph_aio_done, >+ state->req); >+} >+ >+static void vfs_ceph_aio_cleanup(struct tevent_req *req, >+ enum tevent_req_state req_state) >+{ >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); >+ >+ if (req_state == TEVENT_REQ_IN_PROGRESS) { >+ /* >+ * The job thread is still running, we need to protect the >+ * memory used by the job completion function. >+ */ >+ (void)talloc_reparent(req, NULL, state); >+ state->orphaned = true; >+ } >+} >+ >+static void vfs_ceph_aio_submit(struct vfs_handle_struct *handle, >+ struct tevent_req *req, >+ struct tevent_context *ev) >+{ >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); >+ int64_t res; >+ >+ DBG_DEBUG("[CEPH] aio_send: ino=%" PRIu64 "fd=%d off=%jd len=%ju\n", >+ state->cfh->iref.ino, >+ state->cfh->fd, >+ state->off, >+ state->len); >+ >+ state->io_info.callback = vfs_ceph_aio_complete; >+ state->iov.iov_base = state->data; >+ state->iov.iov_len = state->len; >+ state->io_info.priv = state; >+ state->io_info.fh = state->cfh->fh; >+ state->io_info.iov = &state->iov; >+ state->io_info.iovcnt = 1; >+ state->io_info.off = state->off; >+ state->io_info.write = state->write; >+ state->io_info.fsync = state->fsync; >+ state->io_info.result = 0; >+ >+ vfs_ceph_aio_start(state); >+ >+ res = vfs_ceph_ll_nonblocking_readv_writev(handle, >+ state->cfh, >+ &state->io_info); >+ if (res < 0) { >+ state->result = (int)res; >+ tevent_req_error(req, -((int)res)); >+ tevent_req_post(req, ev); >+ return; >+ } >+ >+ tevent_req_set_cleanup_fn(req, vfs_ceph_aio_cleanup); >+ return; >+} >+ >+static void vfs_ceph_aio_done(struct tevent_context *ev, >+ struct tevent_immediate *im, >+ void *private_data) >+{ >+ struct tevent_req *req = private_data; >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); >+ >+ DBG_DEBUG("[CEPH] aio_done: ino=%" PRIu64 >+ " fd=%d off=%jd len=%ju result=%jd\n", >+ state->cfh->iref.ino, >+ state->cfh->fd, >+ state->off, >+ state->len, >+ state->io_info.result); >+ >+ vfs_ceph_aio_finish(state, state->io_info.result); >+ if (state->result < 0) { >+ tevent_req_error(req, -((int)state->result)); >+ return; >+ } >+ >+ tevent_req_done(req); >+} >+ >+static ssize_t vfs_ceph_aio_recv(struct tevent_req *req, >+ struct vfs_aio_state *vfs_aio_state) >+{ >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); >+ ssize_t res = -1; >+ >+ DBG_DEBUG("[CEPH] aio_recv: ino=%" PRIu64 >+ " fd=%d off=%jd len=%ju result=%ld\n", >+ state->cfh->iref.ino, >+ state->cfh->fd, >+ state->off, >+ state->len, >+ state->result); >+ >+ if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { >+ goto out; >+ } >+ >+ *vfs_aio_state = state->vfs_aio_state; >+ res = state->result; >+out: >+ tevent_req_received(req); >+ return res; >+} >+ >+#endif /* HAVE_CEPH_ASYNCIO */ >+ >+static void vfs_ceph_aio_prepare(struct vfs_handle_struct *handle, >+ struct tevent_req *req, >+ struct tevent_context *ev, >+ struct files_struct *fsp) >+{ >+ struct vfs_ceph_config *config = NULL; >+ struct vfs_ceph_aio_state *state = NULL; >+ int ret = -1; >+ >+ SMB_VFS_HANDLE_GET_DATA(handle, >+ config, >+ struct vfs_ceph_config, >+ (void)0); >+ if (config == NULL) { >+ tevent_req_error(req, EINVAL); >+ return; >+ } >+ >+ state = tevent_req_data(req, struct vfs_ceph_aio_state); >+ state->config = config; >+ >+#if HAVE_CEPH_ASYNCIO >+ ret = vfs_ceph_require_tctx(state, ev); >+ if (ret != 0) { >+ tevent_req_error(req, -ret); >+ return; >+ } >+ >+ state->im = tevent_create_immediate(state); >+ if (state->im == NULL) { >+ tevent_req_error(req, ENOMEM); >+ return; >+ } >+#endif >+ >+ ret = vfs_ceph_fetch_io_fh(handle, fsp, &state->cfh); >+ if (ret != 0) { >+ tevent_req_error(req, -ret); >+ } >+} >+ > static struct tevent_req *vfs_ceph_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) >+ size_t n, >+ off_t offset) > { >- struct vfs_ceph_fh *cfh = NULL; > struct tevent_req *req = NULL; >- struct vfs_ceph_pread_state *state = NULL; >+ struct vfs_ceph_aio_state *state = NULL; > int ret = -1; > > DBG_DEBUG("[CEPH] pread_send(%p, %p, %p, %zu, %zd)\n", >@@ -2321,33 +2561,40 @@ static struct tevent_req *vfs_ceph_pread_send(struct vfs_handle_struct *handle, > data, > n, > offset); >- req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_pread_state); >+ >+ req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_aio_state); > if (req == NULL) { > return NULL; > } > >- ret = vfs_ceph_fetch_io_fh(handle, fsp, &cfh); >- if (ret != 0) { >- tevent_req_error(req, -ret); >+ vfs_ceph_aio_prepare(handle, req, ev, fsp); >+ if (!tevent_req_is_in_progress(req)) { > return tevent_req_post(req, ev); > } > > SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread, > profile_p, >- state->ceph_aio_state.profile_bytes, >+ state->profile_bytes, > n); >- SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ceph_aio_state.profile_bytes); >+ SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes); > >- vfs_ceph_aio_start(&state->ceph_aio_state); >- ret = vfs_ceph_ll_read(handle, cfh, offset, n, data); >- vfs_ceph_aio_finish(&state->ceph_aio_state, ret); >+#if HAVE_CEPH_ASYNCIO >+ state->req = req; >+ state->data = data; >+ state->len = n; >+ state->off = offset; >+ vfs_ceph_aio_submit(handle, req, ev); >+ return req; >+#endif >+ vfs_ceph_aio_start(state); >+ ret = vfs_ceph_ll_read(handle, state->cfh, offset, n, data); >+ vfs_ceph_aio_finish(state, ret); > 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); >@@ -2356,18 +2603,22 @@ static struct tevent_req *vfs_ceph_pread_send(struct vfs_handle_struct *handle, > static ssize_t vfs_ceph_pread_recv(struct tevent_req *req, > struct vfs_aio_state *vfs_aio_state) > { >- struct vfs_ceph_pread_state *state = >- tevent_req_data(req, struct vfs_ceph_pread_state); >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); > >- DBG_DEBUG("[CEPH] pread_recv: bytes_read=%zd\n", state->bytes_read); >+ DBG_DEBUG("[CEPH] pread_recv: bytes_read=%zd\n", state->result); > >- SMBPROFILE_BYTES_ASYNC_END(state->ceph_aio_state.profile_bytes); >+ SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes); > >+#if HAVE_CEPH_ASYNCIO >+ return vfs_ceph_aio_recv(req, vfs_aio_state); >+#endif > if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { > return -1; > } >- *vfs_aio_state = state->ceph_aio_state.vfs_aio_state; >- return state->bytes_read; >+ >+ *vfs_aio_state = state->vfs_aio_state; >+ return state->result; > } > > static ssize_t vfs_ceph_pwrite(struct vfs_handle_struct *handle, >@@ -2398,24 +2649,16 @@ out: > return lstatus_code(result); > } > >-struct vfs_ceph_pwrite_state { >- ssize_t bytes_written; >- struct vfs_ceph_aio_state ceph_aio_state; >-}; >- >-/* >- * Fake up an async ceph write by calling the synchronous API. >- */ > static struct tevent_req *vfs_ceph_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) >+ size_t n, >+ off_t offset) > { >- struct vfs_ceph_fh *cfh = NULL; > struct tevent_req *req = NULL; >- struct vfs_ceph_pwrite_state *state = NULL; >+ struct vfs_ceph_aio_state *state = NULL; > int ret = -1; > > DBG_DEBUG("[CEPH] pwrite_send(%p, %p, %p, %zu, %zd)\n", >@@ -2424,33 +2667,42 @@ static struct tevent_req *vfs_ceph_pwrite_send(struct vfs_handle_struct *handle, > data, > n, > offset); >- req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_pwrite_state); >+ >+ req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_aio_state); > if (req == NULL) { > return NULL; > } > >- ret = vfs_ceph_fetch_io_fh(handle, fsp, &cfh); >- if (ret != 0) { >- tevent_req_error(req, -ret); >+ vfs_ceph_aio_prepare(handle, req, ev, fsp); >+ if (!tevent_req_is_in_progress(req)) { > return tevent_req_post(req, ev); > } > > SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite, > profile_p, >- state->ceph_aio_state.profile_bytes, >+ state->profile_bytes, > n); >- SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ceph_aio_state.profile_bytes); >+ SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes); >+ >+#if HAVE_CEPH_ASYNCIO >+ state->req = req; >+ state->data = discard_const(data); >+ state->len = n; >+ state->off = offset; >+ state->write = true; >+ vfs_ceph_aio_submit(handle, req, ev); >+ return req; >+#endif > >- vfs_ceph_aio_start(&state->ceph_aio_state); >- ret = vfs_ceph_ll_write(handle, cfh, offset, n, data); >- vfs_ceph_aio_finish(&state->ceph_aio_state, ret); >+ vfs_ceph_aio_start(state); >+ ret = vfs_ceph_ll_write(handle, state->cfh, offset, n, data); >+ vfs_ceph_aio_finish(state, ret); > 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); >@@ -2459,19 +2711,23 @@ static struct tevent_req *vfs_ceph_pwrite_send(struct vfs_handle_struct *handle, > static ssize_t vfs_ceph_pwrite_recv(struct tevent_req *req, > struct vfs_aio_state *vfs_aio_state) > { >- struct vfs_ceph_pwrite_state *state = >- tevent_req_data(req, struct vfs_ceph_pwrite_state); >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); >+ >+ DBG_DEBUG("[CEPH] pwrite_recv: bytes_written=%zd\n", state->result); > >- DBG_DEBUG("[CEPH] pwrite_recv: bytes_written=%zd\n", >- state->bytes_written); >+ SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes); > >- SMBPROFILE_BYTES_ASYNC_END(state->ceph_aio_state.profile_bytes); >+#if HAVE_CEPH_ASYNCIO >+ return vfs_ceph_aio_recv(req, vfs_aio_state); >+#endif > > if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { > return -1; > } >- *vfs_aio_state = state->ceph_aio_state.vfs_aio_state; >- return state->bytes_written; >+ >+ *vfs_aio_state = state->vfs_aio_state; >+ return state->result; > } > > static off_t vfs_ceph_lseek(struct vfs_handle_struct *handle, >@@ -2585,47 +2841,46 @@ out: > return status_code(result); > } > >-/* >- * Fake up an async ceph fsync by calling the synchronous API. >- */ >- >-struct vfs_ceph_fsync_state { >- struct vfs_ceph_aio_state ceph_aio_state; >-}; >- > static struct tevent_req *vfs_ceph_fsync_send(struct vfs_handle_struct *handle, >- TALLOC_CTX *mem_ctx, >- struct tevent_context *ev, >- files_struct *fsp) >+ TALLOC_CTX *mem_ctx, >+ struct tevent_context *ev, >+ files_struct *fsp) > { >- struct vfs_ceph_fh *cfh = NULL; > struct tevent_req *req = NULL; >- struct vfs_ceph_fsync_state *state = NULL; >+ struct vfs_ceph_aio_state *state = NULL; > int ret = -1; > > DBG_DEBUG("[CEPH] fsync_send(%p, %p)\n", handle, fsp); > >- req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_fsync_state); >+ req = tevent_req_create(mem_ctx, &state, struct vfs_ceph_aio_state); > if (req == NULL) { > return NULL; > } > >- ret = vfs_ceph_fetch_io_fh(handle, fsp, &cfh); >- if (ret != 0) { >- tevent_req_error(req, -ret); >+ vfs_ceph_aio_prepare(handle, req, ev, fsp); >+ if (!tevent_req_is_in_progress(req)) { > return tevent_req_post(req, ev); > } > > SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync, > profile_p, >- state->ceph_aio_state.profile_bytes, >+ state->profile_bytes, > 0); >- SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ceph_aio_state.profile_bytes); >+ SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes); >+ >+#if HAVE_CEPH_ASYNCIO >+ state->req = req; >+ state->data = NULL; >+ state->len = 0; >+ state->off = 0; >+ state->fsync = true; >+ vfs_ceph_aio_submit(handle, req, ev); >+ return req; >+#endif > >- /* Make sync call. */ >- vfs_ceph_aio_start(&state->ceph_aio_state); >- ret = vfs_ceph_ll_fsync(handle, cfh, false); >- vfs_ceph_aio_finish(&state->ceph_aio_state, ret); >+ vfs_ceph_aio_start(state); >+ ret = vfs_ceph_ll_fsync(handle, state->cfh, false); >+ vfs_ceph_aio_finish(state, ret); > if (ret != 0) { > /* ceph_fsync returns -errno on error. */ > tevent_req_error(req, -ret); >@@ -2639,21 +2894,26 @@ static struct tevent_req *vfs_ceph_fsync_send(struct vfs_handle_struct *handle, > } > > static int vfs_ceph_fsync_recv(struct tevent_req *req, >- struct vfs_aio_state *vfs_aio_state) >+ struct vfs_aio_state *vfs_aio_state) > { >- struct vfs_ceph_fsync_state *state = tevent_req_data( >- req, struct vfs_ceph_fsync_state); >+ struct vfs_ceph_aio_state *state = tevent_req_data( >+ req, struct vfs_ceph_aio_state); > > DBG_DEBUG("[CEPH] fsync_recv: error=%d duration=%" PRIu64 "\n", >- state->ceph_aio_state.vfs_aio_state.error, >- state->ceph_aio_state.vfs_aio_state.duration); >+ state->vfs_aio_state.error, >+ state->vfs_aio_state.duration); >+ >+ SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes); > >- SMBPROFILE_BYTES_ASYNC_END(state->ceph_aio_state.profile_bytes); >+#if HAVE_CEPH_ASYNCIO >+ return vfs_ceph_aio_recv(req, vfs_aio_state); >+#endif > > if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) { > return -1; > } >- *vfs_aio_state = state->ceph_aio_state.vfs_aio_state; >+ >+ *vfs_aio_state = state->vfs_aio_state; > return 0; > } > >diff --git a/source3/wscript b/source3/wscript >index f746a67b800..3a664080317 100644 >--- a/source3/wscript >+++ b/source3/wscript >@@ -1627,6 +1627,10 @@ int main(void) { > headers='cephfs/libcephfs.h')): > conf.DEFINE('HAVE_CEPH', '1') > >+ if (conf.CHECK_FUNCS_IN('ceph_ll_nonblocking_readv_writev', 'cephfs', >+ headers='cephfs/libcephfs.h')): >+ conf.DEFINE('HAVE_CEPH_ASYNCIO', '1') >+ > if conf.CONFIG_SET('HAVE_CEPH'): > Logs.info("building ceph vfs modules") > else: >-- >2.48.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
anoopcs
:
review?
(
slow
)
gd
:
review+
anoopcs
:
ci-passed+
Actions:
View
Attachments on
bug 15810
:
18593
| 18597