diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-10-05 15:33:31 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-10-05 15:33:31 -0600 |
commit | 5daa95bae187d09a50bc2663ee6291eb7c46b5dd (patch) | |
tree | 582ffeedb8a5aa6ed4b6d3da6ff4cf47eb475b1d | |
parent | 2bbdd8cc73bea765bf9464e3316c1b8a5cd8a47e (diff) | |
download | nuttx-5daa95bae187d09a50bc2663ee6291eb7c46b5dd.tar.gz nuttx-5daa95bae187d09a50bc2663ee6291eb7c46b5dd.tar.bz2 nuttx-5daa95bae187d09a50bc2663ee6291eb7c46b5dd.zip |
Move all file operations from libc/aio to fs/aio. These will need to be kernel routines in order to handler issues with using file descriptors on worker thread
-rw-r--r-- | nuttx/fs/Kconfig | 1 | ||||
-rw-r--r-- | nuttx/fs/Makefile | 1 | ||||
-rw-r--r-- | nuttx/fs/aio/Make.defs | 46 | ||||
-rw-r--r-- | nuttx/fs/aio/aio.h | 91 | ||||
-rw-r--r-- | nuttx/fs/aio/aio_cancel.c (renamed from nuttx/libc/aio/aio_cancel.c) | 4 | ||||
-rw-r--r-- | nuttx/fs/aio/aio_fsync.c (renamed from nuttx/libc/aio/aio_fsync.c) | 6 | ||||
-rw-r--r-- | nuttx/fs/aio/aio_read.c (renamed from nuttx/libc/aio/aio_read.c) | 6 | ||||
-rw-r--r-- | nuttx/fs/aio/aio_signal.c (renamed from nuttx/libc/aio/aio_signal.c) | 2 | ||||
-rw-r--r-- | nuttx/fs/aio/aio_write.c (renamed from nuttx/libc/aio/aio_write.c) | 14 | ||||
-rw-r--r-- | nuttx/include/aio.h | 24 | ||||
-rw-r--r-- | nuttx/libc/Kconfig | 8 | ||||
-rw-r--r-- | nuttx/libc/aio/Make.defs | 3 | ||||
-rw-r--r-- | nuttx/libc/aio/aio.h | 28 |
13 files changed, 161 insertions, 73 deletions
diff --git a/nuttx/fs/Kconfig b/nuttx/fs/Kconfig index 9165814dc..85de5acd6 100644 --- a/nuttx/fs/Kconfig +++ b/nuttx/fs/Kconfig @@ -48,6 +48,7 @@ config FS_WRITABLE bool default n +source fs/aio/Kconfig source fs/semaphore/Kconfig source fs/mqueue/Kconfig source fs/shm/Kconfig diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile index 2d3a97422..92f1a9400 100644 --- a/nuttx/fs/Makefile +++ b/nuttx/fs/Makefile @@ -47,6 +47,7 @@ include inode/Make.defs include vfs/Make.defs include driver/Make.defs include dirent/Make.defs +include aio/Make.defs include mmap/Make.defs # OS resources diff --git a/nuttx/fs/aio/Make.defs b/nuttx/fs/aio/Make.defs new file mode 100644 index 000000000..c1d0bea8a --- /dev/null +++ b/nuttx/fs/aio/Make.defs @@ -0,0 +1,46 @@ +############################################################################ +# fs/aio/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_LIBC_AIO),y) + +# Add the asynchronous I/O C files to the build + +CSRCS += aio_cancel.c aio_fsync.c aio_read.c aio_signal.c aio_write.c + +# Add the asynchronous I/O directory to the build + +DEPPATH += --dep-path aio +VPATH += :aio +endif diff --git a/nuttx/fs/aio/aio.h b/nuttx/fs/aio/aio.h new file mode 100644 index 000000000..a7a179171 --- /dev/null +++ b/nuttx/fs/aio/aio.h @@ -0,0 +1,91 @@ +/**************************************************************************** + * fs/aio/aio.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __FS_AIO_AIO_H +#define __FS_AIO_AIO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <aio.h> +#include <nuttx/wqueue.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: aio_signal + * + * Description: + * Signal the client that an I/O has completed. + * + * Input Parameters: + * aiocbp - Pointer to the asynchronous I/O state structure that includes + * information about how to signal the client + * + * Returned Value: + * Zero (OK) if the client was successfully signalled. Otherwise, a + * negated errno value is returned. + * + ****************************************************************************/ + +int aio_signal(FAR struct aiocb *aiocbp); + +#endif /* __FS_AIO_AIO_H */ diff --git a/nuttx/libc/aio/aio_cancel.c b/nuttx/fs/aio/aio_cancel.c index 4e67354c8..7e6c17d1e 100644 --- a/nuttx/libc/aio/aio_cancel.c +++ b/nuttx/fs/aio/aio_cancel.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libc/aio/aio_cancel.c + * fs/aio/aio_cancel.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -150,7 +150,7 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp) * -ENOENT in the first case. */ - status = work_cancel(AIO_QUEUE, &aiocbp->aio_work); + status = work_cancel(LPWORK, &aiocbp->aio_work); ret = status >= 0 ? AIO_CANCELED : AIO_NOTCANCELED; } else diff --git a/nuttx/libc/aio/aio_fsync.c b/nuttx/fs/aio/aio_fsync.c index 8c68618b3..f4441d5df 100644 --- a/nuttx/libc/aio/aio_fsync.c +++ b/nuttx/fs/aio/aio_fsync.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libc/aio/aio_fsync.c + * fs/aio/aio_fsync.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -43,10 +43,10 @@ #include <aio.h> #include <assert.h> #include <errno.h> +#include <debug.h> #include <nuttx/wqueue.h> -#include "lib_internal.h" #include "aio/aio.h" #ifdef CONFIG_LIBC_AIO @@ -214,7 +214,7 @@ int aio_fsync(int op, FAR struct aiocb *aiocbp) /* Defer the work to the worker thread */ - ret = work_queue(AIO_QUEUE, &aiocbp->aio_work, aio_fsync_worker, aiocbp, 0); + ret = work_queue(LPWORK, &aiocbp->aio_work, aio_fsync_worker, aiocbp, 0); if (ret < 0) { aiocbp->aio_result = ret; diff --git a/nuttx/libc/aio/aio_read.c b/nuttx/fs/aio/aio_read.c index 26a8f816b..90c6a024a 100644 --- a/nuttx/libc/aio/aio_read.c +++ b/nuttx/fs/aio/aio_read.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libc/aio/aio_read.c + * fs/aio/aio_read.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -44,10 +44,10 @@ #include <aio.h> #include <assert.h> #include <errno.h> +#include <debug.h> #include <nuttx/wqueue.h> -#include "lib_internal.h" #include "aio/aio.h" #ifdef CONFIG_LIBC_AIO @@ -262,7 +262,7 @@ int aio_read(FAR struct aiocb *aiocbp) /* Defer the work to the worker thread */ - ret = work_queue(AIO_QUEUE, &aiocbp->aio_work, aio_read_worker, aiocbp, 0); + ret = work_queue(LPWORK, &aiocbp->aio_work, aio_read_worker, aiocbp, 0); if (ret < 0) { aiocbp->aio_result = ret; diff --git a/nuttx/libc/aio/aio_signal.c b/nuttx/fs/aio/aio_signal.c index 64dd7f75f..60cb0be77 100644 --- a/nuttx/libc/aio/aio_signal.c +++ b/nuttx/fs/aio/aio_signal.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libc/aio/aio_signal.c + * fs/aio/aio_signal.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> diff --git a/nuttx/libc/aio/aio_write.c b/nuttx/fs/aio/aio_write.c index c46ddc9ae..51a470964 100644 --- a/nuttx/libc/aio/aio_write.c +++ b/nuttx/fs/aio/aio_write.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libc/aio/aio_write.c + * fs/aio/aio_write.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -45,10 +45,10 @@ #include <aio.h> #include <assert.h> #include <errno.h> +#include <debug.h> #include <nuttx/wqueue.h> -#include "lib_internal.h" #include "aio/aio.h" #ifdef CONFIG_LIBC_AIO @@ -97,13 +97,7 @@ static void aio_write_worker(FAR void *arg) ssize_t nwritten; int oflags; - /* Call fcntl(F_GETFL) to get the file open mode. - * - * REVISIT: Consider moving aio_write into the kernel. Notice that in a - * system using system calls, up to three system calls may be required: - * (1) fcntl, (2) write or pwrite, and possibly (3) sigueue(). If aio_write - * were a system call, then only one would be required. - */ + /* Call fcntl(F_GETFL) to get the file open mode. */ oflags = fcntl(aiocbp->aio_fildes, F_GETFL); if (oflags < 0) @@ -299,7 +293,7 @@ int aio_write(FAR struct aiocb *aiocbp) /* Defer the work to the worker thread */ - ret = work_queue(AIO_QUEUE, &aiocbp->aio_work, aio_write_worker, aiocbp, 0); + ret = work_queue(LPWORK, &aiocbp->aio_work, aio_write_worker, aiocbp, 0); if (ret < 0) { aiocbp->aio_result = ret; diff --git a/nuttx/include/aio.h b/nuttx/include/aio.h index 5de5bb713..202a24417 100644 --- a/nuttx/include/aio.h +++ b/nuttx/include/aio.h @@ -58,28 +58,20 @@ # undef CONFIG_LIBC_AIO #endif -/* Work queue support is required. In the flat, embedded build the low- - * priority work queue is required so that the asynchronous I/O does not - * interfere with high priority driver operations. In the protected and - * kernel mode builds, user-space work queue support is required. If these - * pre-requisites are met, then asynchronous I/O support can be enabled with - * CONFIG_LIBC_AIO +/* Work queue support is required. The low-priority work queue is required + * so that the asynchronous I/O does not interfere with high priority driver + * operations. If this pre-requisite is met, then asynchronous I/O support + * can be enabled with CONFIG_LIBC_AIO */ #ifdef CONFIG_LIBC_AIO #ifndef CONFIG_SCHED_WORKQUEUE # error Asynchronous I/O requires CONFIG_SCHED_WORKQUEUE -#else -# if defined (CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) -# ifndef CONFIG_SCHED_USRWORK -# error User-space asynchronous I/O requires CONFIG_SCHED_USRWORK -# endif -# else -# ifndef CONFIG_SCHED_LPWORK -# error Flat-build asynchronous I/O requires CONFIG_SCHED_LPWORK -# endif -# endif +#endif + +#ifndef CONFIG_SCHED_LPWORK +# error Asynchronous I/O requires CONFIG_SCHED_LPWORK #endif /* Standard Definitions *****************************************************/ diff --git a/nuttx/libc/Kconfig b/nuttx/libc/Kconfig index 32eb7464c..c71972b93 100644 --- a/nuttx/libc/Kconfig +++ b/nuttx/libc/Kconfig @@ -79,14 +79,6 @@ config EOL_IS_EITHER_CRLF endchoice -config LIBC_AIO - bool "Asynchronous I/O support" - default n - depends on ((BUILD_PROTECTED || BUILD_KERNEL) && SCHED_USRWORK) || (BUILD_FLAT && SCHED_LPWORK) - ---help--- - Enable support for aynchronous I/O. This selection enabled the - interface declared in include/aio.h. - config LIBC_EXECFUNCS bool "Enable exec[l|v] / posix_spawn() Support" default n diff --git a/nuttx/libc/aio/Make.defs b/nuttx/libc/aio/Make.defs index 5af09c03c..e9187bcd2 100644 --- a/nuttx/libc/aio/Make.defs +++ b/nuttx/libc/aio/Make.defs @@ -37,8 +37,7 @@ ifeq ($(CONFIG_LIBC_AIO),y) # Add the asynchronous I/O C files to the build -CSRCS += aio_cancel.c aio_error.c aio_fsync.c aio_read.c aio_return.c -CSRCS += aio_signal.c aio_suspend.c aio_write.c lio_listio.c +CSRCS += aio_error.c aio_return.c aio_suspend.c lio_listio.c # Add the asynchronous I/O directory to the build diff --git a/nuttx/libc/aio/aio.h b/nuttx/libc/aio/aio.h index 7b6e800d6..3adc53ed2 100644 --- a/nuttx/libc/aio/aio.h +++ b/nuttx/libc/aio/aio.h @@ -42,19 +42,9 @@ #include <nuttx/config.h> -#include <aio.h> -#include <nuttx/wqueue.h> - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Select the appropriate work queue */ - -#if defined (CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) -# define AIO_QUEUE LPWORK -#else -# define AIO_QUEUE USRWORK -#endif /**************************************************************************** * Public Types @@ -77,22 +67,4 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -/**************************************************************************** - * Name: aio_signal - * - * Description: - * Signal the client that an I/O has completed. - * - * Input Parameters: - * aiocbp - Pointer to the asynchronous I/O state structure that includes - * information about how to signal the client - * - * Returned Value: - * Zero (OK) if the client was successfully signalled. Otherwise, a - * negated errno value is returned. - * - ****************************************************************************/ - -int aio_signal(FAR struct aiocb *aiocbp); - #endif /* __LIBC_AIO_AIO_H */ |