aboutsummaryrefslogtreecommitdiffstats
path: root/fs/aio.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
commitbef986502fa398b1785a3979b1aa17cd902d3527 (patch)
treeb59c1afe7b1dfcc001b86e54863f550d7ddc8c34 /fs/aio.c
parent4bdbd2807deeccc0793d57fb5120d7a53f2c0b3c (diff)
parentc99767974ebd2a719d849fdeaaa1674456f5283f (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/usb/input/hid.h
Diffstat (limited to 'fs/aio.c')
-rw-r--r--fs/aio.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 94766599db00..d3a6ec2c9627 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -47,19 +47,19 @@ unsigned long aio_nr; /* current system wide number of aio requests */
47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ 47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
48/*----end sysctl variables---*/ 48/*----end sysctl variables---*/
49 49
50static kmem_cache_t *kiocb_cachep; 50static struct kmem_cache *kiocb_cachep;
51static kmem_cache_t *kioctx_cachep; 51static struct kmem_cache *kioctx_cachep;
52 52
53static struct workqueue_struct *aio_wq; 53static struct workqueue_struct *aio_wq;
54 54
55/* Used for rare fput completion. */ 55/* Used for rare fput completion. */
56static void aio_fput_routine(void *); 56static void aio_fput_routine(struct work_struct *);
57static DECLARE_WORK(fput_work, aio_fput_routine, NULL); 57static DECLARE_WORK(fput_work, aio_fput_routine);
58 58
59static DEFINE_SPINLOCK(fput_lock); 59static DEFINE_SPINLOCK(fput_lock);
60static LIST_HEAD(fput_head); 60static LIST_HEAD(fput_head);
61 61
62static void aio_kick_handler(void *); 62static void aio_kick_handler(struct work_struct *);
63static void aio_queue_work(struct kioctx *); 63static void aio_queue_work(struct kioctx *);
64 64
65/* aio_setup 65/* aio_setup
@@ -227,7 +227,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
227 227
228 INIT_LIST_HEAD(&ctx->active_reqs); 228 INIT_LIST_HEAD(&ctx->active_reqs);
229 INIT_LIST_HEAD(&ctx->run_list); 229 INIT_LIST_HEAD(&ctx->run_list);
230 INIT_WORK(&ctx->wq, aio_kick_handler, ctx); 230 INIT_DELAYED_WORK(&ctx->wq, aio_kick_handler);
231 231
232 if (aio_setup_ring(ctx) < 0) 232 if (aio_setup_ring(ctx) < 0)
233 goto out_freectx; 233 goto out_freectx;
@@ -367,8 +367,7 @@ void fastcall __put_ioctx(struct kioctx *ctx)
367{ 367{
368 unsigned nr_events = ctx->max_reqs; 368 unsigned nr_events = ctx->max_reqs;
369 369
370 if (unlikely(ctx->reqs_active)) 370 BUG_ON(ctx->reqs_active);
371 BUG();
372 371
373 cancel_delayed_work(&ctx->wq); 372 cancel_delayed_work(&ctx->wq);
374 flush_workqueue(aio_wq); 373 flush_workqueue(aio_wq);
@@ -470,7 +469,7 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
470 wake_up(&ctx->wait); 469 wake_up(&ctx->wait);
471} 470}
472 471
473static void aio_fput_routine(void *data) 472static void aio_fput_routine(struct work_struct *data)
474{ 473{
475 spin_lock_irq(&fput_lock); 474 spin_lock_irq(&fput_lock);
476 while (likely(!list_empty(&fput_head))) { 475 while (likely(!list_empty(&fput_head))) {
@@ -505,8 +504,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
505 assert_spin_locked(&ctx->ctx_lock); 504 assert_spin_locked(&ctx->ctx_lock);
506 505
507 req->ki_users --; 506 req->ki_users --;
508 if (unlikely(req->ki_users < 0)) 507 BUG_ON(req->ki_users < 0);
509 BUG();
510 if (likely(req->ki_users)) 508 if (likely(req->ki_users))
511 return 0; 509 return 0;
512 list_del(&req->ki_list); /* remove from active_reqs */ 510 list_del(&req->ki_list); /* remove from active_reqs */
@@ -668,17 +666,6 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
668 ssize_t (*retry)(struct kiocb *); 666 ssize_t (*retry)(struct kiocb *);
669 ssize_t ret; 667 ssize_t ret;
670 668
671 if (iocb->ki_retried++ > 1024*1024) {
672 printk("Maximal retry count. Bytes done %Zd\n",
673 iocb->ki_nbytes - iocb->ki_left);
674 return -EAGAIN;
675 }
676
677 if (!(iocb->ki_retried & 0xff)) {
678 pr_debug("%ld retry: %zd of %zd\n", iocb->ki_retried,
679 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
680 }
681
682 if (!(retry = iocb->ki_retry)) { 669 if (!(retry = iocb->ki_retry)) {
683 printk("aio_run_iocb: iocb->ki_retry = NULL\n"); 670 printk("aio_run_iocb: iocb->ki_retry = NULL\n");
684 return 0; 671 return 0;
@@ -859,9 +846,9 @@ static inline void aio_run_all_iocbs(struct kioctx *ctx)
859 * space. 846 * space.
860 * Run on aiod's context. 847 * Run on aiod's context.
861 */ 848 */
862static void aio_kick_handler(void *data) 849static void aio_kick_handler(struct work_struct *work)
863{ 850{
864 struct kioctx *ctx = data; 851 struct kioctx *ctx = container_of(work, struct kioctx, wq.work);
865 mm_segment_t oldfs = get_fs(); 852 mm_segment_t oldfs = get_fs();
866 int requeue; 853 int requeue;
867 854
@@ -876,7 +863,7 @@ static void aio_kick_handler(void *data)
876 * we're in a worker thread already, don't use queue_delayed_work, 863 * we're in a worker thread already, don't use queue_delayed_work,
877 */ 864 */
878 if (requeue) 865 if (requeue)
879 queue_work(aio_wq, &ctx->wq); 866 queue_delayed_work(aio_wq, &ctx->wq, 0);
880} 867}
881 868
882 869
@@ -1007,9 +994,6 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
1007 kunmap_atomic(ring, KM_IRQ1); 994 kunmap_atomic(ring, KM_IRQ1);
1008 995
1009 pr_debug("added to ring %p at [%lu]\n", iocb, tail); 996 pr_debug("added to ring %p at [%lu]\n", iocb, tail);
1010
1011 pr_debug("%ld retries: %zd of %zd\n", iocb->ki_retried,
1012 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
1013put_rq: 997put_rq:
1014 /* everything turned out well, dispose of the aiocb. */ 998 /* everything turned out well, dispose of the aiocb. */
1015 ret = __aio_put_req(ctx, iocb); 999 ret = __aio_put_req(ctx, iocb);
@@ -1415,7 +1399,6 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
1415 kiocb->ki_iovec->iov_len = kiocb->ki_left; 1399 kiocb->ki_iovec->iov_len = kiocb->ki_left;
1416 kiocb->ki_nr_segs = 1; 1400 kiocb->ki_nr_segs = 1;
1417 kiocb->ki_cur_seg = 0; 1401 kiocb->ki_cur_seg = 0;
1418 kiocb->ki_nbytes = kiocb->ki_left;
1419 return 0; 1402 return 0;
1420} 1403}
1421 1404
@@ -1593,7 +1576,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1593 req->ki_opcode = iocb->aio_lio_opcode; 1576 req->ki_opcode = iocb->aio_lio_opcode;
1594 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function); 1577 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
1595 INIT_LIST_HEAD(&req->ki_wait.task_list); 1578 INIT_LIST_HEAD(&req->ki_wait.task_list);
1596 req->ki_retried = 0;
1597 1579
1598 ret = aio_setup_iocb(req); 1580 ret = aio_setup_iocb(req);
1599 1581