Re: [PATCH 12/33] aio: refcounting cleanup

From: Theodore Ts'o
Date: Mon Apr 01 2013 - 21:32:53 EST


On Thu, Mar 21, 2013 at 09:35:33AM -0700, Kent Overstreet wrote:
> The usage of ctx->dead was fubar - it makes no sense to explicitly check
> it all over the place, especially when we're already using RCU.
>
> Now, ctx->dead only indicates whether we've dropped the initial
> refcount. The new teardown sequence is:
> set ctx->dead
> hlist_del_rcu();
> synchronize_rcu();
>
> Now we know no system calls can take a new ref, and it's safe to drop
> the initial ref:
> put_ioctx();
>
> We also need to ensure there are no more outstanding kiocbs. This was
> done incorrectly - it was being done in kill_ctx(), and before dropping
> the initial refcount. At this point, other syscalls may still be
> submitting kiocbs!
>
> Now, we cancel and wait for outstanding kiocbs in free_ioctx(), after
> kioctx->users has dropped to 0 and we know no more iocbs could be
> submitted.
>
> Signed-off-by: Kent Overstreet <koverstreet@xxxxxxxxxx>
> Cc: Zach Brown <zab@xxxxxxxxxx>
> Cc: Felipe Balbi <balbi@xxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Mark Fasheh <mfasheh@xxxxxxxx>
> Cc: Joel Becker <jlbec@xxxxxxxxxxxx>
> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> Cc: Jens Axboe <axboe@xxxxxxxxx>
> Cc: Asai Thambi S P <asamymuthupa@xxxxxxxxxx>
> Cc: Selvan Mani <smani@xxxxxxxxxx>
> Cc: Sam Bradshaw <sbradshaw@xxxxxxxxxx>
> Cc: Jeff Moyer <jmoyer@xxxxxxxxxx>
> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Cc: Benjamin LaHaise <bcrl@xxxxxxxxx>
> Cc: Theodore Ts'o <tytso@xxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

Reviewed-by: "Theodore Ts'o" <tytso@xxxxxxx>
--
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/