public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 09/12] sendfile: several fixes
@ 2009-08-06 23:10 akpm
  2009-08-06 23:24 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: akpm @ 2009-08-06 23:10 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, akpm, msb, rlove

From: Mandeep Singh Baines <msb@google.com>

Three fixes for sendfile, mostly related to sending large files from pseudo
filesystems:

- Fix sendfile for offsets > 300G. This can happen with pseudo filesystems.
  This happens because the overflow check is using inode->i_sb->s_maxbytes
  and not the superblock of the backing device's s_maxbytes. For a regular file
  these are interchangible but for a special file these are different and you
  want the latter.

- Don't compare against the max of the out_inode's superblock. Doesn't make
  sense.

- For pseudo and other filesystems with s_maxbytes set to ~0ULL, max ends up
  holding a negative number as it is signed. Check for and correct that.

Signed-off-by: Robert Love <rlove@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/read_write.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff -puN fs/read_write.c~sendfile-several-fixes fs/read_write.c
--- a/fs/read_write.c~sendfile-several-fixes
+++ a/fs/read_write.c
@@ -835,8 +835,15 @@ static ssize_t do_sendfile(int out_fd, i
 		goto fput_out;
 	count = retval;
 
-	if (!max)
-		max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
+	if (!max) {
+		max = in_inode->i_mapping->host->i_sb->s_maxbytes;
+		/*
+		 * For psuedo filesystems, s_maxbytes is ~0ULL. When converted
+		 * to loff_t, it can go negative. So we check for and fix that.
+		 */
+		if (max < 0)
+			max = LLONG_MAX;
+	}
 
 	pos = *ppos;
 	retval = -EINVAL;
_

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

end of thread, other threads:[~2009-08-07 11:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 23:10 [patch 09/12] sendfile: several fixes akpm
2009-08-06 23:24 ` Christoph Hellwig
2009-08-06 23:25   ` Robert Love
2009-08-06 23:29     ` Christoph Hellwig
2009-08-07  6:12       ` Mandeep Singh Baines
2009-08-07  6:26         ` Andrew Morton
2009-08-07 11:29           ` Jeff Layton

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