public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH][RFC] splice support
Date: Thu, 30 Mar 2006 11:45:22 +0200	[thread overview]
Message-ID: <20060330094522.GR13476@suse.de> (raw)
In-Reply-To: <20060330014024.6ada0532.akpm@osdl.org>

On Thu, Mar 30 2006, Andrew Morton wrote:
> Jens Axboe <axboe@suse.de> wrote:
> >
> > Actually it isn't so bad, how does this look?
> > 
> > ...
> >
> >  @@ -180,30 +181,48 @@ static int __generic_file_splice_read(st
> >   	i = find_get_pages(mapping, index, nr_pages, pages);
> >   
> >   	/*
> >  -	 * If not all pages were in the page-cache, we'll
> >  -	 * just assume that the rest haven't been read in,
> >  -	 * so we'll get the rest locked and start IO on
> >  -	 * them if we can..
> >  +	 * common case - we found all pages, kick it off
> >   	 */
> >  -	while (i < nr_pages) {
> >  -		struct page *page;
> >  -		int error;
> >  -
> >  -		page = find_or_create_page(mapping, index + i, GFP_USER);
> >  -		if (!page)
> >  -			break;
> >  +	if (i == nr_pages)
> >  +		goto splice_them;
> 
> The return value from find_get_pages() is "how many pages did I find" - it
> doesn't tell us whether they were contiguous.

Oh right, so there's still a hole there. The above logic foolishly
thinks that if i == nr_pages, they must be contig. But I can see that
may not be the case. Additionally, I need to init pages[] from i and
forward, since we may be looking at that in the loop.

> How about
> 
> 	if (i && (pages[i - 1]->index == index + i - 1))
> 
> <thinks>
> 
> So if we asked for N pages starting at index=10 and got
> 
> 	[11, 13]
> 
> i == 2
> pages[i-1]->index == 13
> index + i - 1 == 11.
> 
> So I think it's OK.  Yeah, it has to be - any gap at all in the returned
> page array will make pages[i-1]->index too big.

Agree, that should be sound. I'll adjust the code.

> The one-at-a-time logic looks OK from a quick scan.  Do we have logic in
> there to check that we're not overrunning i_size?  (See the pain
> do_generic_mapping_read() goes through).

do_splice_to() checks that, should I move that checking further down in
case the file is truncated?

> argh, readahead.  Really we should be kicking the readahead engine in there
> as well.  That's fairly straightforward - see do_generic_mapping_read().
> 
> Also, the code here _might_ be able to use do_page_cache_readahead() just
> to prepopulate the pages which you know you'll be needing.  There are no
> guarantees that the pages will still be there when you want them of course,
> but it's a decent way of putting a block of pages into a single BIO and
> speeding up the common case.  But if the code is calling
> page_cache_readahead() it won't need to do that.

I'll look into readahead.

-- 
Jens Axboe


  reply	other threads:[~2006-03-30  9:45 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-29 12:28 [PATCH][RFC] splice support Jens Axboe
2006-03-29 12:30 ` Jens Axboe
2006-03-29 13:15 ` Jeff Garzik
2006-03-29 13:27   ` Jens Axboe
2006-03-29 21:49     ` Nathan Scott
2006-03-29 20:06   ` Linus Torvalds
2006-03-29 20:42     ` Jens Axboe
2006-03-29 20:43       ` Jens Axboe
2006-03-29 21:14         ` Linus Torvalds
2006-03-30  6:17           ` Jens Axboe
2006-03-29 22:37 ` Andrew Morton
2006-03-30  0:50   ` Linus Torvalds
2006-03-30  1:04     ` Jeff Garzik
2006-03-30  1:20       ` Andrew Morton
2006-03-30  6:18         ` Jens Axboe
2006-03-30  2:08     ` Andrew Morton
2006-03-30  3:44       ` Nick Piggin
2006-03-30  7:21       ` Jens Axboe
2006-03-30  7:30         ` Andrew Morton
2006-03-30  7:33           ` Jens Axboe
2006-03-30  8:02             ` Jan Engelhardt
2006-03-30  3:10     ` Nick Piggin
2006-03-30  7:16     ` Jens Axboe
2006-03-30  8:09     ` Jan Engelhardt
2006-03-30  7:45   ` Jens Axboe
2006-03-30  8:02     ` Andrew Morton
2006-03-30  8:10       ` Jens Axboe
2006-03-30  8:25         ` Nick Piggin
2006-03-30  8:27         ` Andrew Morton
2006-03-30  8:50           ` Nick Piggin
2006-03-30  8:51           ` Jens Axboe
2006-03-30  9:15             ` Jens Axboe
2006-03-30  9:40               ` Andrew Morton
2006-03-30  9:45                 ` Jens Axboe [this message]
2006-03-30  9:56                   ` Andrew Morton
2006-03-30 10:01                     ` Jens Axboe
2006-03-30  2:36 ` Nick Piggin
2006-03-30  7:00   ` Jens Axboe
2006-03-30  7:33     ` Nick Piggin
2006-03-30  8:54 ` KAMEZAWA Hiroyuki
2006-03-30 13:53   ` Jens Axboe
2006-03-30 14:05     ` KAMEZAWA Hiroyuki
2006-03-30 14:38       ` Jens Axboe
2006-03-30 14:55         ` KAMEZAWA Hiroyuki
  -- strict thread matches above, loose matches on Subject: below --
2005-12-19  9:16 Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060330094522.GR13476@suse.de \
    --to=axboe@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox