diff options
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 32 |
1 files changed, 7 insertions, 25 deletions
@@ -398,7 +398,7 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx) | |||
398 | if (unlikely(!req)) | 398 | if (unlikely(!req)) |
399 | return NULL; | 399 | return NULL; |
400 | 400 | ||
401 | req->ki_flags = 1 << KIF_LOCKED; | 401 | req->ki_flags = 0; |
402 | req->ki_users = 2; | 402 | req->ki_users = 2; |
403 | req->ki_key = 0; | 403 | req->ki_key = 0; |
404 | req->ki_ctx = ctx; | 404 | req->ki_ctx = ctx; |
@@ -547,25 +547,6 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id) | |||
547 | return ioctx; | 547 | return ioctx; |
548 | } | 548 | } |
549 | 549 | ||
550 | static int lock_kiocb_action(void *param) | ||
551 | { | ||
552 | schedule(); | ||
553 | return 0; | ||
554 | } | ||
555 | |||
556 | static inline void lock_kiocb(struct kiocb *iocb) | ||
557 | { | ||
558 | wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action, | ||
559 | TASK_UNINTERRUPTIBLE); | ||
560 | } | ||
561 | |||
562 | static inline void unlock_kiocb(struct kiocb *iocb) | ||
563 | { | ||
564 | kiocbClearLocked(iocb); | ||
565 | smp_mb__after_clear_bit(); | ||
566 | wake_up_bit(&iocb->ki_flags, KIF_LOCKED); | ||
567 | } | ||
568 | |||
569 | /* | 550 | /* |
570 | * use_mm | 551 | * use_mm |
571 | * Makes the calling kernel thread take on the specified | 552 | * Makes the calling kernel thread take on the specified |
@@ -796,9 +777,7 @@ static int __aio_run_iocbs(struct kioctx *ctx) | |||
796 | * Hold an extra reference while retrying i/o. | 777 | * Hold an extra reference while retrying i/o. |
797 | */ | 778 | */ |
798 | iocb->ki_users++; /* grab extra reference */ | 779 | iocb->ki_users++; /* grab extra reference */ |
799 | lock_kiocb(iocb); | ||
800 | aio_run_iocb(iocb); | 780 | aio_run_iocb(iocb); |
801 | unlock_kiocb(iocb); | ||
802 | if (__aio_put_req(ctx, iocb)) /* drop extra ref */ | 781 | if (__aio_put_req(ctx, iocb)) /* drop extra ref */ |
803 | put_ioctx(ctx); | 782 | put_ioctx(ctx); |
804 | } | 783 | } |
@@ -1418,6 +1397,9 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb) | |||
1418 | if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf, | 1397 | if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf, |
1419 | kiocb->ki_left))) | 1398 | kiocb->ki_left))) |
1420 | break; | 1399 | break; |
1400 | ret = security_file_permission(file, MAY_READ); | ||
1401 | if (unlikely(ret)) | ||
1402 | break; | ||
1421 | ret = -EINVAL; | 1403 | ret = -EINVAL; |
1422 | if (file->f_op->aio_read) | 1404 | if (file->f_op->aio_read) |
1423 | kiocb->ki_retry = aio_pread; | 1405 | kiocb->ki_retry = aio_pread; |
@@ -1430,6 +1412,9 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb) | |||
1430 | if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf, | 1412 | if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf, |
1431 | kiocb->ki_left))) | 1413 | kiocb->ki_left))) |
1432 | break; | 1414 | break; |
1415 | ret = security_file_permission(file, MAY_WRITE); | ||
1416 | if (unlikely(ret)) | ||
1417 | break; | ||
1433 | ret = -EINVAL; | 1418 | ret = -EINVAL; |
1434 | if (file->f_op->aio_write) | 1419 | if (file->f_op->aio_write) |
1435 | kiocb->ki_retry = aio_pwrite; | 1420 | kiocb->ki_retry = aio_pwrite; |
@@ -1542,7 +1527,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | |||
1542 | 1527 | ||
1543 | spin_lock_irq(&ctx->ctx_lock); | 1528 | spin_lock_irq(&ctx->ctx_lock); |
1544 | aio_run_iocb(req); | 1529 | aio_run_iocb(req); |
1545 | unlock_kiocb(req); | ||
1546 | if (!list_empty(&ctx->run_list)) { | 1530 | if (!list_empty(&ctx->run_list)) { |
1547 | /* drain the run list */ | 1531 | /* drain the run list */ |
1548 | while (__aio_run_iocbs(ctx)) | 1532 | while (__aio_run_iocbs(ctx)) |
@@ -1674,7 +1658,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, | |||
1674 | if (NULL != cancel) { | 1658 | if (NULL != cancel) { |
1675 | struct io_event tmp; | 1659 | struct io_event tmp; |
1676 | pr_debug("calling cancel\n"); | 1660 | pr_debug("calling cancel\n"); |
1677 | lock_kiocb(kiocb); | ||
1678 | memset(&tmp, 0, sizeof(tmp)); | 1661 | memset(&tmp, 0, sizeof(tmp)); |
1679 | tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user; | 1662 | tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user; |
1680 | tmp.data = kiocb->ki_user_data; | 1663 | tmp.data = kiocb->ki_user_data; |
@@ -1686,7 +1669,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, | |||
1686 | if (copy_to_user(result, &tmp, sizeof(tmp))) | 1669 | if (copy_to_user(result, &tmp, sizeof(tmp))) |
1687 | ret = -EFAULT; | 1670 | ret = -EFAULT; |
1688 | } | 1671 | } |
1689 | unlock_kiocb(kiocb); | ||
1690 | } else | 1672 | } else |
1691 | ret = -EINVAL; | 1673 | ret = -EINVAL; |
1692 | 1674 | ||