2014-10-07 16:24:50 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* fs/aio/aio_queue.c
|
|
|
|
*
|
2021-02-03 14:47:23 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-10-07 16:24:50 +02:00
|
|
|
*
|
2021-02-03 14:47:23 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-10-07 16:24:50 +02:00
|
|
|
*
|
2021-02-03 14:47:23 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-10-07 16:24:50 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sched.h>
|
|
|
|
#include <aio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/wqueue.h>
|
|
|
|
|
|
|
|
#include "aio/aio.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_FS_AIO
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: aio_queue
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Schedule the asynchronous I/O on the low priority work queue
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* arg - Worker argument. In this case, a pointer to an instance of
|
|
|
|
* struct aiocb cast to void *.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) on success. Otherwise, -1 is returned and the errno is set
|
|
|
|
* appropriately.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int aio_queue(FAR struct aio_container_s *aioc, worker_t worker)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRIORITY_INHERITANCE
|
|
|
|
/* Prohibit context switches until we complete the queuing */
|
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
|
|
|
|
/* Make sure that the low-priority worker thread is running at at least
|
|
|
|
* the priority specified for this action.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lpwork_boostpriority(aioc->aioc_prio);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Schedule the work on the low priority worker thread */
|
|
|
|
|
|
|
|
ret = work_queue(LPWORK, &aioc->aioc_work, worker, aioc, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
FAR struct aiocb *aiocbp = aioc->aioc_aiocbp;
|
|
|
|
DEBUGASSERT(aiocbp);
|
|
|
|
|
2019-01-27 16:39:33 +01:00
|
|
|
#ifdef CONFIG_PRIORITY_INHERITANCE
|
|
|
|
lpwork_restorepriority(aioc->aioc_prio);
|
|
|
|
#endif
|
2014-10-07 16:24:50 +02:00
|
|
|
aiocbp->aio_result = ret;
|
|
|
|
set_errno(-ret);
|
|
|
|
ret = ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRIORITY_INHERITANCE
|
|
|
|
/* Now the low-priority work queue might run at its new priority */
|
|
|
|
|
|
|
|
sched_unlock();
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_FS_AIO */
|