mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
[PATCH] splice: fix bugs with stealing regular pipe pages
- Check that page has suitable count for stealing in the regular pipes. - pipe_to_file() assumes that the page is locked on succesful steal, so do that in the pipe steal hook - Missing unlock_page() in add_to_page_cache() failure. Signed-off-by: Jens Axboe <axboe@suse.de>
This commit is contained in:
parent
e0a515bc6a
commit
46e678c96b
2 changed files with 12 additions and 3 deletions
11
fs/pipe.c
11
fs/pipe.c
|
@ -127,8 +127,15 @@ static void anon_pipe_buf_unmap(struct pipe_inode_info *pipe,
|
||||||
static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
|
static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
|
||||||
struct pipe_buffer *buf)
|
struct pipe_buffer *buf)
|
||||||
{
|
{
|
||||||
buf->flags |= PIPE_BUF_FLAG_STOLEN;
|
struct page *page = buf->page;
|
||||||
return 0;
|
|
||||||
|
if (page_count(page) == 1) {
|
||||||
|
buf->flags |= PIPE_BUF_FLAG_STOLEN;
|
||||||
|
lock_page(page);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void anon_pipe_buf_get(struct pipe_inode_info *info,
|
static void anon_pipe_buf_get(struct pipe_inode_info *info,
|
||||||
|
|
|
@ -599,8 +599,10 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
|
||||||
goto find_page;
|
goto find_page;
|
||||||
|
|
||||||
page = buf->page;
|
page = buf->page;
|
||||||
if (add_to_page_cache(page, mapping, index, gfp_mask))
|
if (add_to_page_cache(page, mapping, index, gfp_mask)) {
|
||||||
|
unlock_page(page);
|
||||||
goto find_page;
|
goto find_page;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(buf->flags & PIPE_BUF_FLAG_LRU))
|
if (!(buf->flags & PIPE_BUF_FLAG_LRU))
|
||||||
lru_cache_add(page);
|
lru_cache_add(page);
|
||||||
|
|
Loading…
Reference in a new issue