Skip to content

Commit

Permalink
[PATCH] splice: fix unlocking of page on error ->prepare_write()
Browse files Browse the repository at this point in the history
Looking at generic_file_buffered_write(), we need to unlock_page() if
prepare write fails and it isn't due to racing with truncate().

Also trim the size if ->prepare_write() fails, if we have to.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jens Axboe authored and Jens Axboe committed May 4, 2006
1 parent 5dea517 commit bfc4ee3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,24 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
}

ret = mapping->a_ops->prepare_write(file, page, offset, offset+this_len);
if (ret == AOP_TRUNCATED_PAGE) {
if (unlikely(ret)) {
loff_t isize = i_size_read(mapping->host);

if (ret != AOP_TRUNCATED_PAGE)
unlock_page(page);
page_cache_release(page);
goto find_page;
} else if (ret)
if (ret == AOP_TRUNCATED_PAGE)
goto find_page;

/*
* prepare_write() may have instantiated a few blocks
* outside i_size. Trim these off again.
*/
if (sd->pos + this_len > isize)
vmtruncate(mapping->host, isize);

goto out;
}

if (buf->page != page) {
/*
Expand Down

0 comments on commit bfc4ee3

Please sign in to comment.