From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH] Add block device speciffic splice write method Date: Wed, 22 Oct 2008 22:39:28 -0700 Message-ID: <20081022223928.a6ce476f.akpm@linux-foundation.org> References: <1224424858-3927-1-git-send-email-dmonakhov@openvz.org> <20081020174931.GH19428@kernel.dk> <20081020181156.GI19428@kernel.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Dmitri Monakhov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Jens Axboe Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:58883 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbYJWFkL (ORCPT ); Thu, 23 Oct 2008 01:40:11 -0400 In-Reply-To: <20081020181156.GI19428@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, 20 Oct 2008 20:11:56 +0200 Jens Axboe 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(). 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?