Linux-kernel mailing list archive 2000-06,: Bug in fs/block_dev.c in 2.2.14 and 2.3.42

# Bug in fs/block_dev.c in 2.2.14 and 2.3.42

Jan Kara (jack@suse.cz)
Thu, 10 Feb 2000 00:21:16 +0100

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jeff V. Merkey: "Re: "Id Rather be Dead Than Red NWFS 2.0 Linux Contest" (fwd)"
- Previous message: Jun Sun: "switching from kernel mode to user mode?"

--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii

Hello.

I've found a small bug in fs/block_dev.c. The problem is that when read_ahead of disk
is smaller than twice blocksize (which is true for my disk on 4kb blocksize) then
no block is read. That results in !uptodate buffer and possible data corruption.
Small patch is attached.

Honza.

--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="block_dev-2.2.14.diff"

--- linux/fs/block_dev.c Sun Jan 16 23:39:56 2000
+++ linux/fs/block_dev.c Thu Feb 10 01:14:11 2000
@@ -84,7 +84,7 @@
else
{
bhlist[0] = bh;
- if (!filp->f_reada || !read_ahead[MAJOR(dev)]) {
+ if (!filp->f_reada || read_ahead[MAJOR(dev)] < (blocksize >> 9) * 2) {
/* We do this to force the read of a single buffer */
blocks = 1;
} else {

--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="block_dev-2.3.42.diff"

--- linux/fs/block_dev.c Sun Jan 16 22:06:21 2000
+++ linux/fs/block_dev.c Thu Feb 10 01:11:55 2000
@@ -76,7 +76,7 @@
if (chars != blocksize && !buffer_uptodate(bh)) {
if(!filp->f_reada ||
- !read_ahead[MAJOR(dev)]) {
+ read_ahead[MAJOR(dev)] < (blocksize >> 9) * 2) {
/* We do this to force the read of a single buffer */
brelse(bh);
bh = bread(dev,block,blocksize);

--8t9RHnE3ZwKMSgU+--

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

- Next message: Jeff V. Merkey: "Re: "Id Rather be Dead Than Red NWFS 2.0 Linux Contest" (fwd)"
- Previous message: Jun Sun: "switching from kernel mode to user mode?"