From bcbadeb82656fafb68b506a3067999c03c481cd2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 4 Oct 2019 10:36:30 +0200 Subject: [PATCH] ntvfs: Remove pvfs_aio.c This uses the Linux libaio that does not meet Samba's needs. If someone wanted to add async I/O to ntvfs, the io_uring API is the way to go. Second option would be to use a pthreads-based API. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source4/ntvfs/posix/pvfs_aio.c | 166 ------------------------------ source4/ntvfs/posix/pvfs_read.c | 10 -- source4/ntvfs/posix/pvfs_write.c | 10 -- source4/ntvfs/posix/vfs_posix.c | 2 - source4/ntvfs/posix/vfs_posix.h | 7 -- source4/ntvfs/posix/wscript_build | 9 +- 6 files changed, 1 insertion(+), 203 deletions(-) delete mode 100644 source4/ntvfs/posix/pvfs_aio.c diff --git a/source4/ntvfs/posix/pvfs_aio.c b/source4/ntvfs/posix/pvfs_aio.c deleted file mode 100644 index e2028d001726..000000000000 --- a/source4/ntvfs/posix/pvfs_aio.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - POSIX NTVFS backend - Linux AIO calls - - Copyright (C) Andrew Tridgell 2006 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" -#include -#include "vfs_posix.h" -#include "system/aio.h" - -struct pvfs_aio_read_state { - struct ntvfs_request *req; - union smb_read *rd; - struct pvfs_file *f; - struct tevent_aio *ae; -}; - -struct pvfs_aio_write_state { - struct ntvfs_request *req; - union smb_write *wr; - struct pvfs_file *f; - struct tevent_aio *ae; -}; - -/* - called when an aio read has finished -*/ -static void pvfs_aio_read_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private_data) -{ - struct pvfs_aio_read_state *state = talloc_get_type(private_data, - struct pvfs_aio_read_state); - struct pvfs_file *f = state->f; - union smb_read *rd = state->rd; - - if (ret < 0) { - /* errno is -ret on error */ - state->req->async_states->status = pvfs_map_errno(f->pvfs, -ret); - state->req->async_states->send_fn(state->req); - return; - } - - f->handle->position = f->handle->seek_offset = rd->readx.in.offset + ret; - - rd->readx.out.nread = ret; - rd->readx.out.remaining = 0xFFFF; - rd->readx.out.compaction_mode = 0; - - talloc_steal(ev, state->ae); - - state->req->async_states->status = NT_STATUS_OK; - state->req->async_states->send_fn(state->req); -} - - -/* - read from a file -*/ -NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd, - struct pvfs_file *f, uint32_t maxcnt) -{ - struct iocb iocb; - struct pvfs_aio_read_state *state; - - state = talloc(req, struct pvfs_aio_read_state); - NT_STATUS_HAVE_NO_MEMORY(state); - - io_prep_pread(&iocb, f->handle->fd, rd->readx.out.data, - maxcnt, rd->readx.in.offset); - state->ae = tevent_add_aio(req->ctx->event_ctx, req->ctx->event_ctx, &iocb, - pvfs_aio_read_handler, state); - if (state->ae == NULL) { - DEBUG(0,("Failed tevent_add_aio\n")); - talloc_free(state); - return NT_STATUS_NOT_IMPLEMENTED; - } - - state->req = req; - state->rd = rd; - state->f = f; - - req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; - - return NT_STATUS_OK; -} - - - - -/* - called when an aio write has finished -*/ -static void pvfs_aio_write_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private_data) -{ - struct pvfs_aio_write_state *state = talloc_get_type(private_data, - struct pvfs_aio_write_state); - struct pvfs_file *f = state->f; - union smb_write *wr = state->wr; - - if (ret < 0) { - /* errno is -ret on error */ - state->req->async_states->status = pvfs_map_errno(f->pvfs, -ret); - state->req->async_states->send_fn(state->req); - return; - } - - f->handle->seek_offset = wr->writex.in.offset + ret; - - wr->writex.out.nwritten = ret; - wr->writex.out.remaining = 0; - - talloc_steal(ev, state->ae); - - state->req->async_states->status = NT_STATUS_OK; - state->req->async_states->send_fn(state->req); -} - - -/* - write to a file -*/ -NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr, - struct pvfs_file *f) -{ - struct iocb iocb; - struct pvfs_aio_write_state *state; - - state = talloc(req, struct pvfs_aio_write_state); - NT_STATUS_HAVE_NO_MEMORY(state); - - io_prep_pwrite(&iocb, f->handle->fd, discard_const(wr->writex.in.data), - wr->writex.in.count, wr->writex.in.offset); - state->ae = tevent_add_aio(req->ctx->event_ctx, req->ctx->event_ctx, &iocb, - pvfs_aio_write_handler, state); - if (state->ae == NULL) { - DEBUG(0,("Failed tevent_add_aio\n")); - talloc_free(state); - return NT_STATUS_NOT_IMPLEMENTED; - } - - state->req = req; - state->wr = wr; - state->f = f; - - req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; - - return NT_STATUS_OK; -} - diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c index 23cbe458ed69..09eedd570f31 100644 --- a/source4/ntvfs/posix/pvfs_read.c +++ b/source4/ntvfs/posix/pvfs_read.c @@ -76,16 +76,6 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs, ret = pvfs_stream_read(pvfs, f->handle, rd->readx.out.data, maxcnt, rd->readx.in.offset); } else { -#ifdef HAVE_LINUX_AIO - /* possibly try an aio read */ - if ((req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC) && - (pvfs->flags & PVFS_FLAG_LINUX_AIO)) { - status = pvfs_aio_pread(req, rd, f, maxcnt); - if (NT_STATUS_IS_OK(status)) { - return NT_STATUS_OK; - } - } -#endif ret = pread(f->handle->fd, rd->readx.out.data, maxcnt, diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c index e4725ec579f2..97733255e295 100644 --- a/source4/ntvfs/posix/pvfs_write.c +++ b/source4/ntvfs/posix/pvfs_write.c @@ -124,16 +124,6 @@ NTSTATUS pvfs_write(struct ntvfs_module_context *ntvfs, wr->writex.in.count, wr->writex.in.offset); } else { -#ifdef HAVE_LINUX_AIO - /* possibly try an aio write */ - if ((req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC) && - (pvfs->flags & PVFS_FLAG_LINUX_AIO)) { - status = pvfs_aio_pwrite(req, wr, f); - if (NT_STATUS_IS_OK(status)) { - return NT_STATUS_OK; - } - } -#endif ret = pwrite(f->handle->fd, wr->writex.in.data, wr->writex.in.count, diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index c69e979c31c9..9f131581762f 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -58,8 +58,6 @@ static void pvfs_setup_options(struct pvfs_state *pvfs) pvfs->flags |= PVFS_FLAG_CI_FILESYSTEM; if (share_bool_option(scfg, PVFS_FAKE_OPLOCKS, PVFS_FAKE_OPLOCKS_DEFAULT)) pvfs->flags |= PVFS_FLAG_FAKE_OPLOCKS; - if (share_bool_option(scfg, PVFS_AIO, false)) - pvfs->flags |= PVFS_FLAG_LINUX_AIO; #if defined(O_DIRECTORY) && defined(O_NOFOLLOW) /* set PVFS_PERM_OVERRIDE by default only if the system diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index 04d78f291892..3dbd785b9b82 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -245,7 +245,6 @@ struct pvfs_search_state { #define PVFS_FLAG_STRICT_LOCKING (1<<6) #define PVFS_FLAG_XATTR_ENABLE (1<<7) #define PVFS_FLAG_FAKE_OPLOCKS (1<<8) -#define PVFS_FLAG_LINUX_AIO (1<<9) #define PVFS_FLAG_PERM_OVERRIDE (1<<10) /* forward declare some anonymous structures */ @@ -268,7 +267,6 @@ struct pvfs_odb_retry; #define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding" #define PVFS_SEARCH_INACTIVITY "posix:searchinactivity" #define PVFS_ACL "posix:acl" -#define PVFS_AIO "posix:aio" #define PVFS_PERM_OVERRIDE "posix:permission override" #define PVFS_XATTR_DEFAULT true @@ -289,9 +287,4 @@ struct pvfs_acl_ops { #include "ntvfs/posix/vfs_posix_proto.h" #include "ntvfs/posix/vfs_acl_proto.h" -NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd, - struct pvfs_file *f, uint32_t maxcnt); -NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr, - struct pvfs_file *f); - #endif /* _VFS_POSIX_H_ */ diff --git a/source4/ntvfs/posix/wscript_build b/source4/ntvfs/posix/wscript_build index 96c6b35441b9..649dea68adf1 100644 --- a/source4/ntvfs/posix/wscript_build +++ b/source4/ntvfs/posix/wscript_build @@ -24,19 +24,12 @@ if bld.CONFIG_SET('WITH_NTVFS_FILESERVER'): ) - bld.SAMBA_SUBSYSTEM('pvfs_aio', - source='pvfs_aio.c', - deps='tevent', - enabled=False - ) - - bld.SAMBA_MODULE('ntvfs_posix', source='vfs_posix.c pvfs_util.c pvfs_search.c pvfs_dirlist.c pvfs_fileinfo.c pvfs_unlink.c pvfs_mkdir.c pvfs_open.c pvfs_read.c pvfs_flush.c pvfs_write.c pvfs_fsinfo.c pvfs_qfileinfo.c pvfs_setfileinfo.c pvfs_rename.c pvfs_resolve.c pvfs_shortname.c pvfs_lock.c pvfs_oplock.c pvfs_wait.c pvfs_seek.c pvfs_ioctl.c pvfs_xattr.c pvfs_streams.c pvfs_notify.c pvfs_sys.c xattr_system.c', autoproto='vfs_posix_proto.h', subsystem='ntvfs', init_function='ntvfs_posix_init', - deps='NDR_XATTR attr ntvfs_common MESSAGING LIBWBCLIENT_OLD pvfs_acl pvfs_aio posix_eadb', + deps='NDR_XATTR attr ntvfs_common MESSAGING LIBWBCLIENT_OLD pvfs_acl posix_eadb', internal_module=True ) -- 2.34.1