Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137
b: refs/heads/master
c: 29504ff
h: refs/heads/master
i:
  135: 7c6f141
v: v3
  • Loading branch information
Daniel McNeil authored and Linus Torvalds committed Apr 16, 2005
1 parent afcd3cc commit 1001b63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1f08ad02379530e1c970d3d104343b9907b4d1b4
refs/heads/master: 29504ff3be784372c4e2f7e31681a3e0292c4d9a
20 changes: 17 additions & 3 deletions trunk/fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct dio {
struct bio *bio; /* bio under assembly */
struct inode *inode;
int rw;
loff_t i_size; /* i_size when submitted */
int lock_type; /* doesn't change */
unsigned blkbits; /* doesn't change */
unsigned blkfactor; /* When we're using an alignment which
Expand Down Expand Up @@ -230,17 +231,29 @@ static void finished_one_bio(struct dio *dio)
spin_lock_irqsave(&dio->bio_lock, flags);
if (dio->bio_count == 1) {
if (dio->is_async) {
ssize_t transferred;
loff_t offset;

/*
* Last reference to the dio is going away.
* Drop spinlock and complete the DIO.
*/
spin_unlock_irqrestore(&dio->bio_lock, flags);
dio_complete(dio, dio->block_in_file << dio->blkbits,
dio->result);

/* Check for short read case */
transferred = dio->result;
offset = dio->iocb->ki_pos;

if ((dio->rw == READ) &&
((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;

dio_complete(dio, offset, transferred);

/* Complete AIO later if falling back to buffered i/o */
if (dio->result == dio->size ||
((dio->rw == READ) && dio->result)) {
aio_complete(dio->iocb, dio->result, 0);
aio_complete(dio->iocb, transferred, 0);
kfree(dio);
return;
} else {
Expand Down Expand Up @@ -951,6 +964,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
dio->page_errors = 0;
dio->result = 0;
dio->iocb = iocb;
dio->i_size = i_size_read(inode);

/*
* BIO completion state.
Expand Down

0 comments on commit 1001b63

Please sign in to comment.