From: Peter Staubach <staubach@redhat.com>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Suppress deprecated f_maxcount in 'struct file'
Date: Mon, 22 Aug 2005 09:08:02 -0400 [thread overview]
Message-ID: <4309CE32.50408@redhat.com> (raw)
In-Reply-To: <430656AA.6030805@cosmosbay.com>
[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]
Eric Dumazet wrote:
> Andrew Morton a écrit :
>
>> Eric Dumazet <dada1@cosmosbay.com> wrote:
>>
>>> Considering :
>>>
>>> [root@dada1 linux-2.6.13-rc6]# find .|xargs grep f_maxcount
>>> ./fs/file_table.c: f->f_maxcount = INT_MAX;
>>> ./fs/read_write.c: if (unlikely(count > file->f_maxcount))
>>> ./include/linux/fs.h: size_t f_maxcount;
>>>
>>>
>>> I was wondering if f_maxcount has a real use these days...
>>
>>
>>
>> No, I guess we can just stick a hard-wired INT_MAX in there.
>>
>>
>
> OK here is a patch doing the hard wiring then :)
>
> * struct file cleanup : f_maxcount has an unique value (INT_MAX). Just
> use the hard-wired value.
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
>
>------------------------------------------------------------------------
>diff -Nru linux-2.6.13-rc6/fs/read_write.c linux-2.6.13-rc6-ed/fs/read_write.c
>--- linux-2.6.13-rc6/fs/read_write.c 2005-08-07 20:18:56.000000000 +0200
>+++ linux-2.6.13-rc6-ed/fs/read_write.c 2005-08-19 23:51:20.000000000 +0200
>@@ -188,7 +188,7 @@
> struct inode *inode;
> loff_t pos;
>
>- if (unlikely(count > file->f_maxcount))
>+ if (unlikely(count > INT_MAX))
> goto Einval;
> pos = *ppos;
> if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
>
And depending upon how you feel about read(2) and write(2) returning larger
than can be represented by a ssize_t, you can get rid of this test too and
apply the attached patch to prevent failures occuring in the direct-io
subsystem.
Limiting i/o requests to INT_MAX is starting to seem a little small.
Thanx...
ps
Signed-off-by: Peter Staubach <staubach@redhat.com>
[-- Attachment #2: devel --]
[-- Type: text/plain, Size: 2212 bytes --]
--- linux-2.6.12/fs/direct-io.c.org 2005-08-22 08:56:40.000000000 -0400
+++ linux-2.6.12/fs/direct-io.c 2005-08-22 08:59:49.000000000 -0400
@@ -1139,6 +1139,12 @@ direct_io_worker(int rw, struct kiocb *i
}
/*
+ * The maximum size of an i/o request which can handled by block
+ * devices.
+ */
+#define MAX_DIO_SIZE ((u32)INT_MAX + 1)
+
+/*
* This is a library function for use by filesystem drivers.
* The locking rules are governed by the dio_lock_type parameter.
*
@@ -1174,6 +1180,12 @@ __blockdev_direct_IO(int rw, struct kioc
loff_t end = offset;
struct dio *dio;
int reader_with_isem = (rw == READ && dio_lock_type == DIO_OWN_LOCKING);
+ int nseg;
+ unsigned long segs_reqd;
+ struct iovec *niov = NULL;
+ int asegs;
+ caddr_t nbase;
+ size_t nlen;
if (rw & WRITE)
current->flags |= PF_SYNCWRITE;
@@ -1189,6 +1201,44 @@ __blockdev_direct_IO(int rw, struct kioc
goto out;
}
+ /*
+ * Check to see if any individual segment is larger than
+ * 2G. If so, then break it up into 2G sized chunks.
+ */
+ segs_reqd = 0;
+ for (seg = 0; seg < nr_segs; seg++)
+ segs_reqd += ((iov[seg].iov_len - 1) / MAX_DIO_SIZE) + 1;
+ if (segs_reqd != nr_segs) {
+ if (segs_reqd > UIO_MAXIOV) {
+ retval = -EINVAL;
+ goto out;
+ }
+ niov = kmalloc(sizeof(*niov) * segs_reqd, GFP_KERNEL);
+ if (!niov) {
+ retval = -ENOMEM;
+ goto out;
+ }
+ nseg = 0;
+ for (seg = 0; seg < nr_segs; seg++) {
+ nbase = iov[seg].iov_base;
+ nlen = iov[seg].iov_len;
+ asegs = (iov[seg].iov_len - 1) / MAX_DIO_SIZE;
+ while (asegs > 0) {
+ niov[nseg].iov_base = nbase;
+ niov[nseg].iov_len = MAX_DIO_SIZE;
+ nbase += MAX_DIO_SIZE;
+ nlen -= MAX_DIO_SIZE;
+ nseg++;
+ asegs--;
+ }
+ niov[nseg].iov_base = nbase;
+ niov[nseg].iov_len = nlen;
+ nseg++;
+ }
+ iov = niov;
+ nr_segs = segs_reqd;
+ }
+
/* Check the memory alignment. Blocks cannot straddle pages */
for (seg = 0; seg < nr_segs; seg++) {
addr = (unsigned long)iov[seg].iov_base;
@@ -1265,6 +1315,8 @@ __blockdev_direct_IO(int rw, struct kioc
out:
if (reader_with_isem)
up(&inode->i_sem);
+ if (niov)
+ kfree(niov);
if (rw & WRITE)
current->flags &= ~PF_SYNCWRITE;
return retval;
next prev parent reply other threads:[~2005-08-22 21:45 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-19 11:33 2.6.13-rc6-mm1 Andrew Morton
2005-08-19 13:12 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 13:18 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 13:22 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 13:21 ` 2.6.13-rc6-mm1 Reuben Farrelly
2005-08-19 17:34 ` 2.6.13-rc6-mm1 Andrew Morton
2005-08-20 1:27 ` 2.6.13-rc6-mm1 Reuben Farrelly
2005-08-20 1:34 ` 2.6.13-rc6-mm1 Andrew Morton
2005-08-20 1:36 ` 2.6.13-rc6-mm1 Andrew Morton
2005-08-20 13:40 ` 2.6.13-rc6-mm1 David Woodhouse
2005-08-21 6:25 ` 2.6.13-rc6-mm1 Reuben Farrelly
2005-08-19 13:25 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 13:27 ` 2.6.13-rc6-mm1 Russell King
2005-08-19 13:41 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 13:45 ` 2.6.13-rc6-mm1 Russell King
2005-08-19 14:05 ` 2.6.13-rc6-mm1 Brice Goglin
2005-08-19 15:02 ` 2.6.13-rc6-mm1: drivers/net/s2io.c: compile error with gcc 4.0 Adrian Bunk
2005-08-19 15:20 ` [PATCH] mips: add pcibios_select_root Yoichi Yuasa
2005-08-19 15:45 ` 2.6.13-rc6-mm1 Ed Tomlinson
2005-08-19 16:04 ` 2.6.13-rc6-mm1 Benoit Boissinot
2005-08-19 21:01 ` 2.6.13-rc6-mm1 Ed Tomlinson
2005-08-19 21:24 ` 2.6.13-rc6-mm1 Benoit Boissinot
2005-08-19 16:11 ` 2.6.13-rc6-mm1 Dave Kleikamp
2005-08-19 19:21 ` 2.6.13-rc6-mm1 Andrew Morton
2005-08-19 21:27 ` [RFC] f_maxcount seems to be deprecated ? Eric Dumazet
2005-08-19 21:33 ` Andrew Morton
2005-08-19 22:01 ` [PATCH] Suppress deprecated f_maxcount in 'struct file' Eric Dumazet
2005-08-22 13:08 ` Peter Staubach [this message]
2005-08-22 21:57 ` Jesper Juhl
2005-08-19 16:40 ` 2.6.13-rc6-mm1: drivers/scsi/aic7xxx/ compile error Adrian Bunk
2005-08-19 16:42 ` Christoph Hellwig
2005-08-19 16:42 ` 2.6.13-rc6-mm1 Avuton Olrich
2005-08-19 21:10 ` 2.6.13-rc6-mm1 Greg KH
2005-08-19 21:21 ` 2.6.13-rc6-mm1 Avuton Olrich
2005-08-19 17:28 ` 2.6.13-rc6-mm1: too many 'ipv4_table' variables Adrian Bunk
2005-08-19 18:03 ` 2.6.13-rc6-mm1 Jesper Juhl
2005-08-20 1:00 ` [PATCH] fix warning of TANBAC_TB0219 in drivers/char/Kconfig Yoichi Yuasa
2005-08-19 19:22 ` 2.6.13-rc6-mm1 hallyn
2005-08-19 19:51 ` 2.6.13-rc6-mm1 - OOPS in drivers/net/phy Marc Ballarin
2005-08-19 20:34 ` 2.6.13-rc6-mm1: remove-asm-hdregh.patch problems Adrian Bunk
2005-08-19 20:37 ` Andrew Morton
2005-08-19 22:49 ` 2.6.13-rc6-mm1 broke parallel port printer Adrian Bunk
2005-08-19 23:36 ` [-mm patch] drivers/cdrom/sbpcd.c: fix the compilation Adrian Bunk
2005-08-19 23:45 ` Nish Aravamudan
2005-08-20 0:20 ` 2.6.13-rc6-mm1: why is PHYLIB a user-visible option? Adrian Bunk
2005-08-20 0:29 ` Jeff Garzik
2005-08-20 14:49 ` 2.6.13-rc6-mm1 Martin J. Bligh
2005-08-20 15:43 ` 2.6.13-rc6-mm1 [i6300escb.c 2 bugs, little cleanup] Jiri Slaby
2005-08-20 17:36 ` 2.6.13-rc6-mm1: git-ocfs2.patch breaks jffs Adrian Bunk
2005-08-20 19:03 ` [-mm patch] net/core/sysctl_net_core.c: fix PROC_FS=n compile Adrian Bunk
2005-08-21 0:14 ` David S. Miller
2005-08-21 15:08 ` 2.6.13-rc6-mm1 Martin J. Bligh
2005-08-21 16:30 ` 2.6.13-rc6-mm1 Benoit Boissinot
2005-08-21 17:40 ` 2.6.13-rc6-mm1 Jon Smirl
2005-08-21 21:44 ` 2.6.13-rc6-mm1 Benoit Boissinot
2005-08-21 22:11 ` 2.6.13-rc6-mm1 Jon Smirl
2005-08-22 1:36 ` 2.6.13-rc6-mm1 Rogério Brito
[not found] ` <20050822011528.GA12602@ime.usp.br>
2005-08-22 3:48 ` 2.6.13-rc6-mm1 Andrew Morton
2005-08-22 13:30 ` 2.6.13-rc6-mm1 Rogério Brito
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=4309CE32.50408@redhat.com \
--to=staubach@redhat.com \
--cc=akpm@osdl.org \
--cc=dada1@cosmosbay.com \
--cc=linux-kernel@vger.kernel.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