From: GOTO Masanori <gotom@debian.org>
To: marcelo@conectiva.com.br, torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, gotom@debian.org, andrea@suse.de
Subject: Re: [PATCH] direct IO breaks root filesystem
Date: Mon, 10 Dec 2001 12:59:32 +0900 [thread overview]
Message-ID: <w534rmzendn.wl@megaela.fe.dis.titech.ac.jp> (raw)
In-Reply-To: In your message of "Sun, 09 Dec 2001 00:24:20 +0900" <w53bsh9ybtn.wl@megaela.fe.dis.titech.ac.jp>
In-Reply-To: <w53bsh9ybtn.wl@megaela.fe.dis.titech.ac.jp>
Hi,
Kernel both 2.4.16-pre7 and 2.5.1-pre8 have serious problem
when we use direct IO for the block device.
These kernel breaks my root filesystem which has /dev
(block device entry) when an application like dd write data
into /dev/sdXX (= not root filesystem's device).
My environment is:
/dev/hda root filesystem with /dev/ dir.
/dev/sda target direct io device
I lost my root filesystem with:
fd = open("/dev/sda", O_DIRECT);
write(fd, data, large_size);
The reason is that when kernel accesses /dev/sda with O_DIRECT,
blkdev_direct_IO() is called. But, it calls generic_direct_IO(),
and generic_direct_IO() calls brw_kiovec(..., inode->i_dev, ...).
If inode->i_dev is root filesystem, not target direct io device,
then inode->i_dev is used for root filesystem overwriting (= then
I lost my root file system...).
Here is patch, it was based some parts in 2.4.10 (and some 2.4.1x-aa).
In my test with this patch, it works well and
kernel does not break my root partition.
Linus and Marcelo, please apply this patch.
-- gotom
--- fs/block_dev.c.vanilla Sat Dec 8 22:46:15 2001
+++ fs/block_dev.c Mon Dec 10 10:45:20 2001
@@ -115,7 +115,25 @@
static int blkdev_direct_IO(int rw, struct inode * inode, struct kiobuf * iobuf, unsigned long blocknr, int blocksize)
{
- return generic_direct_IO(rw, inode, iobuf, blocknr, blocksize, blkdev_get_block);
+ int i, nr_blocks, retval;
+ unsigned long * blocks = iobuf->blocks;
+
+ nr_blocks = iobuf->length / blocksize;
+ /* build the blocklist */
+ for (i = 0; i < nr_blocks; i++, blocknr++) {
+ struct buffer_head bh;
+
+ retval = blkdev_get_block(inode, blocknr, &bh, 0);
+ if (retval)
+ goto out;
+
+ blocks[i] = bh.b_blocknr;
+ }
+
+ retval = brw_kiovec(rw, 1, &iobuf, inode->i_rdev, iobuf->blocks, blocksize);
+
+ out:
+ return retval;
}
static int blkdev_writepage(struct page * page)
next parent reply other threads:[~2001-12-10 3:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <w53bsh9ybtn.wl@megaela.fe.dis.titech.ac.jp>
2001-12-10 3:59 ` GOTO Masanori [this message]
2001-12-10 5:55 ` Linus Torvalds
2001-12-10 12:39 ` GOTO Masanori
2001-12-10 14:40 ` Andrea Arcangeli
2001-12-10 17:10 ` Linus Torvalds
2001-12-11 9:03 ` GOTO Masanori
2001-12-11 9:13 ` Alexander Viro
2001-12-11 11:30 ` GOTO Masanori
2001-12-11 17:26 ` Linus Torvalds
2001-12-11 17:37 ` Linus Torvalds
2001-12-11 18:03 ` Martin Dalecki
2001-12-12 0:25 ` Tachino Nobuhiro
2001-12-12 0:34 ` Linus Torvalds
2001-12-12 0:51 ` Tachino Nobuhiro
2001-12-12 1:46 ` Linus Torvalds
2001-12-12 3:25 ` GOTO Masanori
2001-12-12 16:20 ` Marcelo Tosatti
2001-12-12 2:46 ` Tachino Nobuhiro
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=w534rmzendn.wl@megaela.fe.dis.titech.ac.jp \
--to=gotom@debian.org \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.com \
/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
all inboxes | Powered by JetHome®