diff options
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -317,7 +317,7 @@ out: | |||
317 | /* wait_on_sync_kiocb: | 317 | /* wait_on_sync_kiocb: |
318 | * Waits on the given sync kiocb to complete. | 318 | * Waits on the given sync kiocb to complete. |
319 | */ | 319 | */ |
320 | ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb) | 320 | ssize_t wait_on_sync_kiocb(struct kiocb *iocb) |
321 | { | 321 | { |
322 | while (iocb->ki_users) { | 322 | while (iocb->ki_users) { |
323 | set_current_state(TASK_UNINTERRUPTIBLE); | 323 | set_current_state(TASK_UNINTERRUPTIBLE); |
@@ -336,7 +336,7 @@ ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb) | |||
336 | * go away, they will call put_ioctx and release any pinned memory | 336 | * go away, they will call put_ioctx and release any pinned memory |
337 | * associated with the request (held via struct page * references). | 337 | * associated with the request (held via struct page * references). |
338 | */ | 338 | */ |
339 | void fastcall exit_aio(struct mm_struct *mm) | 339 | void exit_aio(struct mm_struct *mm) |
340 | { | 340 | { |
341 | struct kioctx *ctx = mm->ioctx_list; | 341 | struct kioctx *ctx = mm->ioctx_list; |
342 | mm->ioctx_list = NULL; | 342 | mm->ioctx_list = NULL; |
@@ -365,7 +365,7 @@ void fastcall exit_aio(struct mm_struct *mm) | |||
365 | * Called when the last user of an aio context has gone away, | 365 | * Called when the last user of an aio context has gone away, |
366 | * and the struct needs to be freed. | 366 | * and the struct needs to be freed. |
367 | */ | 367 | */ |
368 | void fastcall __put_ioctx(struct kioctx *ctx) | 368 | void __put_ioctx(struct kioctx *ctx) |
369 | { | 369 | { |
370 | unsigned nr_events = ctx->max_reqs; | 370 | unsigned nr_events = ctx->max_reqs; |
371 | 371 | ||
@@ -397,8 +397,7 @@ void fastcall __put_ioctx(struct kioctx *ctx) | |||
397 | * This prevents races between the aio code path referencing the | 397 | * This prevents races between the aio code path referencing the |
398 | * req (after submitting it) and aio_complete() freeing the req. | 398 | * req (after submitting it) and aio_complete() freeing the req. |
399 | */ | 399 | */ |
400 | static struct kiocb *__aio_get_req(struct kioctx *ctx); | 400 | static struct kiocb *__aio_get_req(struct kioctx *ctx) |
401 | static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx) | ||
402 | { | 401 | { |
403 | struct kiocb *req = NULL; | 402 | struct kiocb *req = NULL; |
404 | struct aio_ring *ring; | 403 | struct aio_ring *ring; |
@@ -533,7 +532,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | |||
533 | * Returns true if this put was the last user of the kiocb, | 532 | * Returns true if this put was the last user of the kiocb, |
534 | * false if the request is still in use. | 533 | * false if the request is still in use. |
535 | */ | 534 | */ |
536 | int fastcall aio_put_req(struct kiocb *req) | 535 | int aio_put_req(struct kiocb *req) |
537 | { | 536 | { |
538 | struct kioctx *ctx = req->ki_ctx; | 537 | struct kioctx *ctx = req->ki_ctx; |
539 | int ret; | 538 | int ret; |
@@ -893,7 +892,7 @@ static void try_queue_kicked_iocb(struct kiocb *iocb) | |||
893 | * The retry is usually executed by aio workqueue | 892 | * The retry is usually executed by aio workqueue |
894 | * threads (See aio_kick_handler). | 893 | * threads (See aio_kick_handler). |
895 | */ | 894 | */ |
896 | void fastcall kick_iocb(struct kiocb *iocb) | 895 | void kick_iocb(struct kiocb *iocb) |
897 | { | 896 | { |
898 | /* sync iocbs are easy: they can only ever be executing from a | 897 | /* sync iocbs are easy: they can only ever be executing from a |
899 | * single context. */ | 898 | * single context. */ |
@@ -912,7 +911,7 @@ EXPORT_SYMBOL(kick_iocb); | |||
912 | * Returns true if this is the last user of the request. The | 911 | * Returns true if this is the last user of the request. The |
913 | * only other user of the request can be the cancellation code. | 912 | * only other user of the request can be the cancellation code. |
914 | */ | 913 | */ |
915 | int fastcall aio_complete(struct kiocb *iocb, long res, long res2) | 914 | int aio_complete(struct kiocb *iocb, long res, long res2) |
916 | { | 915 | { |
917 | struct kioctx *ctx = iocb->ki_ctx; | 916 | struct kioctx *ctx = iocb->ki_ctx; |
918 | struct aio_ring_info *info; | 917 | struct aio_ring_info *info; |
@@ -1330,6 +1329,10 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) | |||
1330 | opcode = IOCB_CMD_PWRITEV; | 1329 | opcode = IOCB_CMD_PWRITEV; |
1331 | } | 1330 | } |
1332 | 1331 | ||
1332 | /* This matches the pread()/pwrite() logic */ | ||
1333 | if (iocb->ki_pos < 0) | ||
1334 | return -EINVAL; | ||
1335 | |||
1333 | do { | 1336 | do { |
1334 | ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], | 1337 | ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], |
1335 | iocb->ki_nr_segs - iocb->ki_cur_seg, | 1338 | iocb->ki_nr_segs - iocb->ki_cur_seg, |
@@ -1348,6 +1351,13 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) | |||
1348 | if ((ret == 0) || (iocb->ki_left == 0)) | 1351 | if ((ret == 0) || (iocb->ki_left == 0)) |
1349 | ret = iocb->ki_nbytes - iocb->ki_left; | 1352 | ret = iocb->ki_nbytes - iocb->ki_left; |
1350 | 1353 | ||
1354 | /* If we managed to write some out we return that, rather than | ||
1355 | * the eventual error. */ | ||
1356 | if (opcode == IOCB_CMD_PWRITEV | ||
1357 | && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY | ||
1358 | && iocb->ki_nbytes - iocb->ki_left) | ||
1359 | ret = iocb->ki_nbytes - iocb->ki_left; | ||
1360 | |||
1351 | return ret; | 1361 | return ret; |
1352 | } | 1362 | } |
1353 | 1363 | ||
@@ -1523,7 +1533,7 @@ static int aio_wake_function(wait_queue_t *wait, unsigned mode, | |||
1523 | return 1; | 1533 | return 1; |
1524 | } | 1534 | } |
1525 | 1535 | ||
1526 | int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | 1536 | int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, |
1527 | struct iocb *iocb) | 1537 | struct iocb *iocb) |
1528 | { | 1538 | { |
1529 | struct kiocb *req; | 1539 | struct kiocb *req; |