public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sendfile(2) fails for devices?
@ 2000-11-12  0:14 Jeff Garzik
  2000-11-12  0:57 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Garzik @ 2000-11-12  0:14 UTC (permalink / raw)
  To: Linux Kernel Mailing List

sendfile(2) fails with -EINVAL every time I try to read from a device
file.

This sounds like a bug... is it?  (the man page doesn't mention such a
restriction)

I am using kernel 2.4.0-test11-pre2.  All other tests with sendfile(2)
succeed:  file->file, file->STDOUT, STDIN->file...

-- 
Jeff Garzik             |
Building 1024           | Would you like a Twinkie?
MandrakeSoft            |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: sendfile(2) fails for devices?
  2000-11-12  0:14 sendfile(2) fails for devices? Jeff Garzik
@ 2000-11-12  0:57 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2000-11-12  0:57 UTC (permalink / raw)
  To: linux-kernel

In article <3A0DE0C8.C700F33D@mandrakesoft.com>,
Jeff Garzik  <jgarzik@mandrakesoft.com> wrote:
>sendfile(2) fails with -EINVAL every time I try to read from a device
>file.
>
>This sounds like a bug... is it?  (the man page doesn't mention such a
>restriction)

sendfile() on purpose only works on things that use the page cache. 
EINVAL is basically sendfiles way of saying "I would fall back on doing
a read+write, so you might as well do it yourself in user space because
it might actually be more efficient that way". 

>I am using kernel 2.4.0-test11-pre2.  All other tests with sendfile(2)
>succeed:  file->file, file->STDOUT, STDIN->file...

Yes, as long as STDIN is a file ;)

sendfile() wants the source to be in the page cache, because the whole
point of sendfile() was to avoid a copy. 

The current device model does _not_ use the page cache. Now, arguably
that's a bug - it also means that you cannot mmap() a block device - but
as it could be easily documented (maybe it is, somewhere), I'll call it
a bad feature for now.

Now, if you want to add the code to do address spaces for block devices,
I wouldn't be all that unhappy.  I've wanted to see it for a while.  I'm
not likely to apply it for 2.4.x any more, but I'd love to have it early
for 2.5.x. 

		Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-11-12  0:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-12  0:14 sendfile(2) fails for devices? Jeff Garzik
2000-11-12  0:57 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox