The aio_ring_empty() function returns true if the AIO event ring has no elements, false otherwise. Signed-off-by: Davi E. M. Arnaut --- fs/aio.c | 17 +++++++++++++++++ include/linux/aio.h | 1 + 2 files changed, 18 insertions(+) Index: linux-2.6/fs/aio.c =================================================================== --- linux-2.6.orig/fs/aio.c +++ linux-2.6/fs/aio.c @@ -1004,6 +1004,23 @@ put_rq: return ret; } +int fastcall aio_ring_empty(struct kioctx *ioctx) +{ + struct aio_ring_info *info = &ioctx->ring_info; + struct aio_ring *ring; + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&ioctx->ctx_lock, flags); + ring = kmap_atomic(info->ring_pages[0], KM_IRQ1); + if (ring->head == ring->tail) + ret = 1; + kunmap_atomic(ring, KM_IRQ1); + spin_unlock_irqrestore(&ioctx->ctx_lock, flags); + + return ret; +} + /* aio_read_evt * Pull an event off of the ioctx's event ring. Returns the number of * events fetched (0 or 1 ;-) Index: linux-2.6/include/linux/aio.h =================================================================== --- linux-2.6.orig/include/linux/aio.h +++ linux-2.6/include/linux/aio.h @@ -202,6 +202,7 @@ extern unsigned aio_max_size; extern ssize_t FASTCALL(wait_on_sync_kiocb(struct kiocb *iocb)); extern int FASTCALL(aio_put_req(struct kiocb *iocb)); +extern int FASTCALL(aio_ring_empty(struct kioctx *ioctx)); extern void FASTCALL(kick_iocb(struct kiocb *iocb)); extern int FASTCALL(aio_complete(struct kiocb *iocb, long res, long res2)); extern void FASTCALL(__put_ioctx(struct kioctx *ctx)); -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/