Re: PATCH 2.6.0-test6-mm2] aio ref count during retry

From: Daniel McNeil
Date: Fri Oct 03 2003 - 17:02:44 EST


On Fri, 2003-10-03 at 14:40, Andrew Morton wrote:
> Daniel McNeil <daniel@xxxxxxxx> wrote:
> >
> > Here is the patch for AIO retry to hold an extra ref count.
> > The patch is small, but I wanted to make sure it was safe.
> > I spent time looking over the retry code and this patch looks
> > ok to me. It is potentially calling put_ioctx() while holding
> > ctx->ctx_lock, I do not think that will cause any problems.
> > This should never be the last reference on the ioctx anyway,
> > since the loop is checking list_empty(&ctx->run_list).
>
> So... if the refcount is never zero in there, why are you changing it to
> take an additional reference?

The extra reference is on the iocb itself. Each iocb has a reference
on the ioctx. When dropping the extra reference using __aio_put_req(),
you have to check if it was the last reference and then drop that iocb's
reference on the ioctx by calling put_ioctx(). It is the ioctx's ref
count that is never zero here.

Having the extra ref on the iocb, guarantees that the iocb won't be
freed until the extra reference is dropped. In the initial submit
case, the lower level code has looking at the iocb after submitting
it (which was racy without the extra reference). This patch just
added the extra reference for iocb during retries.

Daniel

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/