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 10:10:09 +0200	[thread overview]
Message-ID: <20060330081008.GO13476@suse.de> (raw)
In-Reply-To: <20060330000240.156f4933.akpm@osdl.org>

On Thu, Mar 30 2006, Andrew Morton wrote:
> Jens Axboe <axboe@suse.de> wrote:
> >
> > 
> > ...
> >
> > > - I think the `size_t left' in do_splice_to() can overflow if f_pos is
> > >   sufficiently different from i_size.
> > 
> > They're both loff_t.
> 
> Nope:
> 
> +static long do_splice_to(struct file *in, struct inode *pipe, size_t len,
> +			 unsigned long flags)
> +{
> +	if (in->f_op && in->f_op->splice_read) {
> +		loff_t isize = i_size_read(in->f_mapping->host);
> +		size_t left;
> +
> +		if (unlikely(in->f_pos >= isize))
> +			return 0;
> +	
> +		left = isize - in->f_pos;
> 
> It's doing
> 
> 		32bit = 64bit - 64bit;

My mistake, I looked at a different spot. Fixed.

> > 
> > > - In generic_file_splice_read():
> > > 
> > >   - nonatomic modification of f_pos.  Is i_mutex held?  (see
> > >     generic_file_llseek())
> > 
> > Fixed.
> 
> OK.  In some ways I agree with Nick that a pwrite/pread-like interface is
> nicer, so things are more stateless and threads don't have to fight over
> f_pos.  Dunno..

I can go either way, I tend to agree that passing in offset may be the
best solution.

> > >   - These pages can get truncated at any time they're unlocked.  Does
> > >     the code cope with all that?
> > 
> > I guess page_cache_pipe_buf_map() needs the same ->mapping check?
> 
> That would seem appropriate.
> 
> btw, that function might have a problem I think - it returns NULL with
> the page locked, but pipe_to_sendpage() and other callers don't appear to
> unlock it.

Will fix that up.

> > > - hm.  What happens if the pages which find_get_pages() returned are
> > > not contiguous in pagecache?  I think your `pages' array gets all
> > > jumbled up.
> >
> > Hmm please expand. 
> 
> find_get_pages() does "find me the next N pages above `index' which are
> presently in pagecache'.  So it can return an array of page*'s which do not
> represent contiguous pages in the file - there can be holes in there.
> 
> IOW: pages[n]->index !necessarily= pages[n+1]->index-1
> 
> Maybe the code handles that by making sure that all the pages in the range
> are already in pagecache - I didn't check.  But that would take some heroic
> locking.

It doesn't, I'm assuming that find_get_pages() returns consequtive pages
atm. Would seem like the sane interface :-)

We continue doing find_or_create_page() on the remaining, but using 'i'
as the 'index' addition. So if we had non-conseq pages, we'd be screwed.

Needs a little thinking, input welcome..

-- 
Jens Axboe


  reply	other threads:[~2006-03-30  8:10 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 [this message]
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
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=20060330081008.GO13476@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