diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-03-20 16:26:24 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-03-31 16:03:15 -0400 |
commit | 06af121eab543e5554f7a29538f171a382aaf855 (patch) | |
tree | 5d072174c381aa284bff396b2176f077a8536ec5 | |
parent | a1c2aa1e86a25e7cace2ded47ec52754206a5733 (diff) |
aio: merge aio_cancel_all() with wait_for_all_aios()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/aio.c | 22 |
1 files changed, 7 insertions, 15 deletions
@@ -305,15 +305,18 @@ out_freectx: | |||
305 | return ERR_PTR(err); | 305 | return ERR_PTR(err); |
306 | } | 306 | } |
307 | 307 | ||
308 | /* aio_cancel_all | 308 | /* kill_ctx |
309 | * Cancels all outstanding aio requests on an aio context. Used | 309 | * Cancels all outstanding aio requests on an aio context. Used |
310 | * when the processes owning a context have all exited to encourage | 310 | * when the processes owning a context have all exited to encourage |
311 | * the rapid destruction of the kioctx. | 311 | * the rapid destruction of the kioctx. |
312 | */ | 312 | */ |
313 | static void aio_cancel_all(struct kioctx *ctx) | 313 | static void kill_ctx(struct kioctx *ctx) |
314 | { | 314 | { |
315 | int (*cancel)(struct kiocb *, struct io_event *); | 315 | int (*cancel)(struct kiocb *, struct io_event *); |
316 | struct task_struct *tsk = current; | ||
317 | DECLARE_WAITQUEUE(wait, tsk); | ||
316 | struct io_event res; | 318 | struct io_event res; |
319 | |||
317 | spin_lock_irq(&ctx->ctx_lock); | 320 | spin_lock_irq(&ctx->ctx_lock); |
318 | ctx->dead = 1; | 321 | ctx->dead = 1; |
319 | while (!list_empty(&ctx->active_reqs)) { | 322 | while (!list_empty(&ctx->active_reqs)) { |
@@ -329,15 +332,7 @@ static void aio_cancel_all(struct kioctx *ctx) | |||
329 | spin_lock_irq(&ctx->ctx_lock); | 332 | spin_lock_irq(&ctx->ctx_lock); |
330 | } | 333 | } |
331 | } | 334 | } |
332 | spin_unlock_irq(&ctx->ctx_lock); | ||
333 | } | ||
334 | 335 | ||
335 | static void wait_for_all_aios(struct kioctx *ctx) | ||
336 | { | ||
337 | struct task_struct *tsk = current; | ||
338 | DECLARE_WAITQUEUE(wait, tsk); | ||
339 | |||
340 | spin_lock_irq(&ctx->ctx_lock); | ||
341 | if (!ctx->reqs_active) | 336 | if (!ctx->reqs_active) |
342 | goto out; | 337 | goto out; |
343 | 338 | ||
@@ -387,9 +382,7 @@ void exit_aio(struct mm_struct *mm) | |||
387 | ctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list); | 382 | ctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list); |
388 | hlist_del_rcu(&ctx->list); | 383 | hlist_del_rcu(&ctx->list); |
389 | 384 | ||
390 | aio_cancel_all(ctx); | 385 | kill_ctx(ctx); |
391 | |||
392 | wait_for_all_aios(ctx); | ||
393 | 386 | ||
394 | if (1 != atomic_read(&ctx->users)) | 387 | if (1 != atomic_read(&ctx->users)) |
395 | printk(KERN_DEBUG | 388 | printk(KERN_DEBUG |
@@ -1269,8 +1262,7 @@ static void io_destroy(struct kioctx *ioctx) | |||
1269 | if (likely(!was_dead)) | 1262 | if (likely(!was_dead)) |
1270 | put_ioctx(ioctx); /* twice for the list */ | 1263 | put_ioctx(ioctx); /* twice for the list */ |
1271 | 1264 | ||
1272 | aio_cancel_all(ioctx); | 1265 | kill_ctx(ioctx); |
1273 | wait_for_all_aios(ioctx); | ||
1274 | 1266 | ||
1275 | /* | 1267 | /* |
1276 | * Wake up any waiters. The setting of ctx->dead must be seen | 1268 | * Wake up any waiters. The setting of ctx->dead must be seen |