Re: [PATCH] Add block device speciffic splice write method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 22 2008, Andrew Morton wrote:
> On Mon, 20 Oct 2008 20:11:56 +0200 Jens Axboe <jens.axboe@xxxxxxxxxx> wrote:
> 
> > +ssize_t generic_file_splice_write_file_nolock(struct pipe_inode_info *pipe,
> > +					      struct file *out, loff_t *ppos,
> > +					      size_t len, unsigned int flags)
> > +{
> > +	struct address_space *mapping = out->f_mapping;
> > +	struct inode *inode = mapping->host;
> > +	struct splice_desc sd = {
> > +		.total_len = len,
> > +		.flags = flags,
> > +		.pos = *ppos,
> > +		.u.file = out,
> > +	};
> > +	ssize_t ret;
> > +
> > +	mutex_lock(&pipe->inode->i_mutex);
> > +	ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
> > +	mutex_unlock(&pipe->inode->i_mutex);
> > +
> > +	if (ret > 0) {
> > +		unsigned long nr_pages;
> > +
> > +		*ppos += ret;
> > +		nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> > +
> > +		if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
> > +			int er;
> > +
> > +			er = sync_page_range_nolock(inode, mapping, *ppos, ret);
> > +			if (er)
> > +				ret = er;
> > +		}
> > +		balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
> > +	}
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL(generic_file_splice_write_file_nolock);
> 
> I don't think the balance_dirty_pages() is needed if we just did the
> sync_page_range().

Good point, I think we can get rid of that.
> 
> 
> But really it'd be better if the throttling happened down in
> pipe_to_file(), on a per-page basis.  As it stands we can dirty an
> arbitrary number of pagecache pages without throttling.  I think?

That's pretty exactly why it isn't done in the actor, to avoid doing it
per-page. As it's going to be PIPE_BUFFERS (16) pages max, I think this
is better.

Back in the splice early days, the balance_dirty_pages() actually showed
up in profiles when it was done on a per-page basis. So I'm reluctant to
change it :-)

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux