svn commit: samba r20624 - in
branches/SAMBA_4_0/source/ntvfs/posix: .
tridge at samba.org
tridge at samba.org
Tue Jan 9 04:04:27 GMT 2007
Author: tridge
Date: 2007-01-09 04:04:26 +0000 (Tue, 09 Jan 2007)
New Revision: 20624
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20624
Log:
added AIO read to pvfs backend
Added:
branches/SAMBA_4_0/source/ntvfs/posix/pvfs_aio.c
Modified:
branches/SAMBA_4_0/source/ntvfs/posix/config.m4
branches/SAMBA_4_0/source/ntvfs/posix/config.mk
branches/SAMBA_4_0/source/ntvfs/posix/pvfs_read.c
branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.c
branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h
Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/config.m4
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/config.m4 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/config.m4 2007-01-09 04:04:26 UTC (rev 20624)
@@ -29,3 +29,9 @@
AC_DEFINE(HAVE_LIBBLKID,1,[Whether we have blkid support (e2fsprogs)])
SMB_ENABLE(BLKID,YES)
fi
+
+AC_CHECK_HEADERS(libaio.h)
+SMB_ENABLE(pvfs_aio,NO)
+if test x"$ac_cv_header_libaio_h" = x"yes"; then
+ SMB_ENABLE(pvfs_aio,YES)
+fi
Modified: branches/SAMBA_4_0/source/ntvfs/posix/config.mk
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/config.mk 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/config.mk 2007-01-09 04:04:26 UTC (rev 20624)
@@ -21,6 +21,13 @@
################################################
################################################
+[MODULE::pvfs_aio]
+SUBSYSTEM = ntvfs
+OBJ_FILES = pvfs_aio.o
+PRIVATE_DEPENDENCIES = LIBAIO_LINUX
+################################################
+
+################################################
# Start MODULE ntvfs_posix
[MODULE::ntvfs_posix]
SUBSYSTEM = ntvfs
@@ -56,6 +63,6 @@
xattr_system.o \
xattr_tdb.o
#PRIVATE_DEPENDENCIES = pvfs_acl_xattr pvfs_acl_nfs4
-PUBLIC_DEPENDENCIES = NDR_XATTR WRAP_XATTR BLKID ntvfs_common MESSAGING
+PUBLIC_DEPENDENCIES = NDR_XATTR WRAP_XATTR BLKID ntvfs_common MESSAGING pvfs_aio
# End MODULE ntvfs_posix
################################################
Added: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_aio.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_aio.c 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_aio.c 2007-01-09 04:04:26 UTC (rev 20624)
@@ -0,0 +1,96 @@
+/*
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "vfs_posix.h"
+#include "lib/events/events.h"
+#include "system/aio.h"
+
+struct pvfs_aio_read_state {
+ struct ntvfs_request *req;
+ union smb_read *rd;
+ struct pvfs_file *f;
+ struct aio_event *ae;
+};
+
+/*
+ called when an aio read has finished
+*/
+static void pvfs_aio_handler(struct event_context *ev, struct aio_event *ae,
+ int ret, void *private)
+{
+ struct pvfs_aio_read_state *state = talloc_get_type(private,
+ 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 = event_add_aio(req->ctx->event_ctx, req->ctx->event_ctx, &iocb,
+ pvfs_aio_handler, state);
+ if (state->ae == NULL) {
+ DEBUG(0,("Failed event_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;
+}
+
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_read.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_read.c 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_read.c 2007-01-09 04:04:26 UTC (rev 20624)
@@ -22,7 +22,7 @@
#include "includes.h"
#include "vfs_posix.h"
-#include "librpc/gen_ndr/security.h"
+#include "lib/events/events.h"
/*
read from a file
@@ -75,6 +75,16 @@
ret = pvfs_stream_read(pvfs, f->handle,
rd->readx.out.data, maxcnt, rd->readx.in.offset);
} else {
+#if 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,
Modified: branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.c 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.c 2007-01-09 04:04:26 UTC (rev 20624)
@@ -55,9 +55,10 @@
pvfs->flags |= PVFS_FLAG_STRICT_LOCKING;
if (share_bool_option(scfg, SHARE_CI_FILESYSTEM, SHARE_CI_FILESYSTEM_DEFAULT))
pvfs->flags |= PVFS_FLAG_CI_FILESYSTEM;
- if (share_bool_option(scfg, PVFS_FAKE_OPLOCKS, PVFS_FAKE_OPLOCKS_DEFAULT)) {
+ 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;
/* this must be a power of 2 */
pvfs->alloc_size_rounding = share_int_option(scfg,
Modified: branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h 2007-01-09 03:52:07 UTC (rev 20623)
+++ branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h 2007-01-09 04:04:26 UTC (rev 20624)
@@ -210,6 +210,7 @@
#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)
/* forward declare some anonymous structures */
struct pvfs_dir;
@@ -224,6 +225,7 @@
#define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
#define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
#define PVFS_ACL "posix:acl"
+#define PVFS_AIO "posix:aio"
#define PVFS_XATTR_DEFAULT True
#define PVFS_FAKE_OPLOCKS_DEFAULT False
@@ -240,4 +242,7 @@
#include "ntvfs/posix/vfs_posix_proto.h"
+NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
+ struct pvfs_file *f, uint32_t maxcnt);
+
#endif /* _VFS_POSIX_H_ */
More information about the samba-cvs
mailing list