Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e871e3c2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'splice-2.6.22' of git://git.kernel.dk/data/git/linux-2.6-block

* 'splice-2.6.22' of git://git.kernel.dk/data/git/linux-2.6-block:
  splice: only check do_wakeup in splice_to_pipe() for a real pipe
  splice: fix leak of pages on short splice to pipe
  splice: adjust balance_dirty_pages_ratelimited() call
parents 3ea88d67 02676e5a
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
static ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
			      struct splice_pipe_desc *spd)
{
	unsigned int spd_pages = spd->nr_pages;
	int ret, do_wakeup, page_nr;

	ret = 0;
@@ -244,7 +245,7 @@ static ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
		pipe->waiting_writers--;
	}

	if (pipe->inode)
	if (pipe->inode) {
		mutex_unlock(&pipe->inode->i_mutex);

		if (do_wakeup) {
@@ -253,8 +254,9 @@ static ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
				wake_up_interruptible(&pipe->wait);
			kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
		}
	}

	while (page_nr < spd->nr_pages)
	while (page_nr < spd_pages)
		page_cache_release(spd->pages[page_nr++]);

	return ret;
@@ -811,7 +813,10 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,

	ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
	if (ret > 0) {
		unsigned long nr_pages;

		*ppos += ret;
		nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;

		/*
		 * If file or inode is SYNC and we actually wrote some data,
@@ -824,7 +829,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
			if (err)
				ret = err;
		}
		balance_dirty_pages_ratelimited(mapping);
		balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
	}

	return ret;
@@ -863,7 +868,10 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,

	ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
	if (ret > 0) {
		unsigned long nr_pages;

		*ppos += ret;
		nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;

		/*
		 * If file or inode is SYNC and we actually wrote some data,
@@ -878,7 +886,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
			if (err)
				ret = err;
		}
		balance_dirty_pages_ratelimited(mapping);
		balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
	}

	return ret;