Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26435
b: refs/heads/master
c: 0568b40
h: refs/heads/master
i:
  26433: deeebe7
  26431: c05d126
v: v3
  • Loading branch information
Jens Axboe committed May 1, 2006
1 parent 4fb0a66 commit 1baecae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 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: 46e678c96bbd775abd05d3ddbe2fd334794f9157
refs/heads/master: 0568b409c74f7a125d92a09a3f386785700ef688
3 changes: 0 additions & 3 deletions trunk/fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
{
struct page *page = buf->page;

buf->flags &= ~PIPE_BUF_FLAG_STOLEN;

/*
* If nobody else uses this page, and we don't already have a
* temporary page, let's keep track of it as a one-deep
Expand Down Expand Up @@ -130,7 +128,6 @@ static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
struct page *page = buf->page;

if (page_count(page) == 1) {
buf->flags |= PIPE_BUF_FLAG_STOLEN;
lock_page(page);
return 0;
}
Expand Down
37 changes: 19 additions & 18 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *info,
return 1;
}

buf->flags |= PIPE_BUF_FLAG_STOLEN | PIPE_BUF_FLAG_LRU;
buf->flags |= PIPE_BUF_FLAG_LRU;
return 0;
}

Expand All @@ -87,7 +87,7 @@ static void page_cache_pipe_buf_release(struct pipe_inode_info *info,
{
page_cache_release(buf->page);
buf->page = NULL;
buf->flags &= ~(PIPE_BUF_FLAG_STOLEN | PIPE_BUF_FLAG_LRU);
buf->flags &= ~PIPE_BUF_FLAG_LRU;
}

static void *page_cache_pipe_buf_map(struct file *file,
Expand Down Expand Up @@ -587,9 +587,10 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
this_len = PAGE_CACHE_SIZE - offset;

/*
* Reuse buf page, if SPLICE_F_MOVE is set.
* Reuse buf page, if SPLICE_F_MOVE is set and we are doing a full
* page.
*/
if (sd->flags & SPLICE_F_MOVE) {
if ((sd->flags & SPLICE_F_MOVE) && this_len == PAGE_CACHE_SIZE) {
/*
* If steal succeeds, buf->page is now pruned from the vm
* side (LRU and page cache) and we can reuse it. The page
Expand All @@ -604,6 +605,8 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
goto find_page;
}

page_cache_get(page);

if (!(buf->flags & PIPE_BUF_FLAG_LRU))
lru_cache_add(page);
} else {
Expand Down Expand Up @@ -662,7 +665,7 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
} else if (ret)
goto out;

if (!(buf->flags & PIPE_BUF_FLAG_STOLEN)) {
if (buf->page != page) {
char *dst = kmap_atomic(page, KM_USER0);

memcpy(dst + offset, src + buf->offset, this_len);
Expand All @@ -671,22 +674,20 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
}

ret = mapping->a_ops->commit_write(file, page, offset, offset+this_len);
if (ret == AOP_TRUNCATED_PAGE) {
if (!ret) {
/*
* Return the number of bytes written and mark page as
* accessed, we are now done!
*/
ret = this_len;
mark_page_accessed(page);
balance_dirty_pages_ratelimited(mapping);
} else if (ret == AOP_TRUNCATED_PAGE) {
page_cache_release(page);
goto find_page;
} else if (ret)
goto out;

/*
* Return the number of bytes written.
*/
ret = this_len;
mark_page_accessed(page);
balance_dirty_pages_ratelimited(mapping);
}
out:
if (!(buf->flags & PIPE_BUF_FLAG_STOLEN))
page_cache_release(page);

page_cache_release(page);
unlock_page(page);
out_nomem:
buf->ops->unmap(info, buf);
Expand Down
3 changes: 1 addition & 2 deletions trunk/include/linux/pipe_fs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#define PIPE_BUFFERS (16)

#define PIPE_BUF_FLAG_STOLEN 0x01
#define PIPE_BUF_FLAG_LRU 0x02
#define PIPE_BUF_FLAG_LRU 0x01

struct pipe_buffer {
struct page *page;
Expand Down

0 comments on commit 1baecae

Please sign in to comment.