diff options
-rw-r--r-- | fs/pipe.c | 11 | ||||
-rw-r--r-- | fs/splice.c | 4 |
2 files changed, 12 insertions, 3 deletions
@@ -127,8 +127,15 @@ static void anon_pipe_buf_unmap(struct pipe_inode_info *pipe, | |||
127 | static int anon_pipe_buf_steal(struct pipe_inode_info *pipe, | 127 | static int anon_pipe_buf_steal(struct pipe_inode_info *pipe, |
128 | struct pipe_buffer *buf) | 128 | struct pipe_buffer *buf) |
129 | { | 129 | { |
130 | buf->flags |= PIPE_BUF_FLAG_STOLEN; | 130 | struct page *page = buf->page; |
131 | return 0; | 131 | |
132 | if (page_count(page) == 1) { | ||
133 | buf->flags |= PIPE_BUF_FLAG_STOLEN; | ||
134 | lock_page(page); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | return 1; | ||
132 | } | 139 | } |
133 | 140 | ||
134 | static void anon_pipe_buf_get(struct pipe_inode_info *info, | 141 | static void anon_pipe_buf_get(struct pipe_inode_info *info, |
diff --git a/fs/splice.c b/fs/splice.c index a46ddd28561e..9df28d30efa0 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -599,8 +599,10 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf, | |||
599 | goto find_page; | 599 | goto find_page; |
600 | 600 | ||
601 | page = buf->page; | 601 | page = buf->page; |
602 | if (add_to_page_cache(page, mapping, index, gfp_mask)) | 602 | if (add_to_page_cache(page, mapping, index, gfp_mask)) { |
603 | unlock_page(page); | ||
603 | goto find_page; | 604 | goto find_page; |
605 | } | ||
604 | 606 | ||
605 | if (!(buf->flags & PIPE_BUF_FLAG_LRU)) | 607 | if (!(buf->flags & PIPE_BUF_FLAG_LRU)) |
606 | lru_cache_add(page); | 608 | lru_cache_add(page); |