All of lore.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 09:45:34 +0200	[thread overview]
Message-ID: <20060330074534.GL13476@suse.de> (raw)
In-Reply-To: <20060329143758.607c1ccc.akpm@osdl.org>


(going over the other comments, thanks a lot for taking a good look
Andrew!)

On Wed, Mar 29 2006, Andrew Morton wrote:
> - Please don't call it `len'.  VFS has to deal with "lengths" which can
>   be in units of PAGE_CACHE_SIZE, fs blocksize, 512-bytes sectors or bytes,
>   and it gets confusing.  Our liking for variable names like `len' and
>   `count' just makes it worse.
> 
>   If it's in units of pages then call it `npages'.  If it's in bytes then
>   call it `nbytes'.

Hmm well I usually use 'len' or something like that when it's a base
unit, like bytes. If it was in units of pages or something I agree it
would be confusing.

>   What _is_ it in units of, anyway?  I guess bytes, since it's size_t.
> 
>   I assume all this lenning:
> 
> 			unsigned int this_len;
> 
> 			this_len = buf->len;
> 			if (this_len > len)
> 				this_len = len;
> 
>   is dealing with bytes too.  You'll be wanting a size_t in there.

But buf->len is unsigned int to begin with.

> - 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.

> - In pipe_to_file():
> 
>   - Shouldn't it be using GFP_HIGHUSER()?
> 
>   - local variable `index' should be unsigned long or, for clarity
>     value, pgoff_t.

Fixed.

>   - Incoming arg `pos' should be loff_t?

Fixed

>   - It's racy against truncate().  After running ->readpage and
>     lock_page(), need to check for page->mapping == NULL.

Indeed, fixed.

>   - There's a duplicate flush_dcache_page().

Doh, fixed.

>   - Why does it run write_one_page()???  (Don't tell me.  I'll work it
>     out when I see the commented version ;))

Can probably go, will re-check!

>   - I worry a bit about the assumption in one place that a non-zero
>     return from commit_write() indicates an error, whereas another place
>     assumes that a negative return is an error.  We had problems in the
>     past where some a_ops implementations decided to return small positive
>     numbers from prepare_write() or commit_write() a_ops, which broke
>     stuff.  They shouldn't be doing that now, but it's a thing to watch out
>     for.

I'll just check for < 0 and be safe.

>   - Bug.  If write_one_page() returned an error, it still unlocked the page.

Ok, I guess that could be a future but (it can't fail with !wait now).

> - In pipe_to_sendpage():
> 
>   - local variable `offset' is ulong, but elsewhere you've used uint. 
>     The latter is better.

Fixed.

>   - Again, incoming arg `len' is confusing.  I _think_ it's actually
>     "number of bytes to be moved from this page".  A comment which explains
>     these things would be nice, and perhaps a better name (bytes_to_send?)

It's bytes, yes. Comment added.

>   - Should incoming arg `pos' be loff_t?  That would give it some meaning.

Yes changed with the pipe_to_file() change since it modified the actor
typedef anyways.

>   - Why does it use PAGE_SIZE and PAGE_SHIFT rather than PAGE_CACHE_*?

Fixed, the other places used PAGE_CACHE_*.

> - In generic_file_splice_read():
> 
>   - nonatomic modification of f_pos.  Is i_mutex held?  (see
>     generic_file_llseek())

Fixed.

>   - Darnit, we carried `flags' this far and ended up not using it. 
>     (What _does_ flags do, anyway?  Reads on..)

It'll be passed to the actor next! Will probably change some of the
actor args into a little struct instead of passing so many variables.

> - In __generic_file_splice_read():
> 
>   - local variable `index' is ulong, could be pgoff_t (for clarity)

Fixed.

>   - local variable `offset' could be uint (it is uint elsewhere, and
>     might generate better code).

Fixed.

>   - local variable `pages' could be uint (but watch out for overflow!!).

Fixed.

>     A better name might be nr_pages (matches find_get_pages()).  Then,
>     local variable `array' can be renamed to `pages', which is all much
>     better.

Agree, fixed.

>   - whoa.  We move the pages into the pipe while they're still under
>     read I/O.  Is that deliberate?  (pls add nice comment).

It's fine, you need to call ->map() to get at it anways, which will lock
the page.

>   - 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?

>   - 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.

> - In move_to_pipe()
> 
>   - Suggest you rename `pages' to `nr_pages', `array' to `pages'.  And
>     `i' to `page_nr'.

Done (except 'i').

>   - local var `bufs' could be renamed `nrbufs' to align with
>     pipe_inode_info and could be made uint.
> 
>   - Do we actually need local var `bufs'?  It seems to be caching info->nrbufs.

Cleaner that way, imho.

>   - release_pages() might be faster than one-at-a-time page_cache_release()

We should not hit that case very often. Not sure how to handle the
'cold' right now, so I'll just leave it.

-- 
Jens Axboe


  parent reply	other threads:[~2006-03-30  7: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 [this message]
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
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=20060330074534.GL13476@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.