ntvfs: Remove pvfs_aio.c
authorVolker Lendecke <vl@samba.org>
Fri, 4 Oct 2019 08:36:30 +0000 (10:36 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 4 Oct 2019 17:01:39 +0000 (17:01 +0000)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/ntvfs/posix/pvfs_aio.c [deleted file]
source4/ntvfs/posix/pvfs_read.c
source4/ntvfs/posix/pvfs_write.c
source4/ntvfs/posix/vfs_posix.c
source4/ntvfs/posix/vfs_posix.h
source4/ntvfs/posix/wscript_build

diff --git a/source4/ntvfs/posix/pvfs_aio.c b/source4/ntvfs/posix/pvfs_aio.c
deleted file mode 100644 (file)
index e2028d0..0000000
+++ /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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include <tevent.h>
-#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;
-}
-
index 23cbe458ed699afd238a74495fa517fe4dbc52f1..09eedd570f313f76167cb67524963d12630c5680 100644 (file)
@@ -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,
index e4725ec579f22c9e785465adcaba2b990f8ef453..97733255e295bd1c9712abae75981781a2016f5a 100644 (file)
@@ -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,
index c69e979c31c9165ab2eb6726723cd43332931b00..9f131581762f999fe934f1a0b8b47a14273835dd 100644 (file)
@@ -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
index 04d78f291892305d1b60d0ea15c0650157c7b688..3dbd785b9b82be21834e5a4ad1b1f41bbc46e5e9 100644 (file)
@@ -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_ */
index 96c6b35441b9a8eb508ebb2d01b7f3824942657f..649dea68adf183773c3ae7bcd4b4e0141cb29b06 100644 (file)
@@ -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
     )