From: Pavel Machek <pavel@suse.cz>
To: David Weinehall <tao@acc.umu.se>, Kristian <kristian@korseby.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: ext2fs corruption again
Date: Sun, 16 Sep 2001 00:19:43 +0200 [thread overview]
Message-ID: <20010916001943.A984@bug.ucw.cz> (raw)
In-Reply-To: <3BA3156C.9050704@korseby.net> <20010915144236.V26627@khan.acc.umu.se>
In-Reply-To: <20010915144236.V26627@khan.acc.umu.se>; from David Weinehall on Sat, Sep 15, 2001 at 02:42:36PM +0200
Hi!
> > Hello.
> >
> > For about 3 weeks I sent a report that I've got very strange kernel
> > error messages.
> >
> > I changed my harddrive to IBM 75 GB because someone said that IBM's 40 GB
> > harddisks are not very stable.
>
> Just to get it out of the way, can you open your computer and check
> what country the disk is manufactured in? There has been some complaints
> on this list about IBM-disks fabricated in Hungary.
Install crc loop device, and if disk does silent errors, you'll know.
Pavel
--- clean/drivers/block/loop.c Sun Jul 8 23:26:37 2001
+++ linux/drivers/block/loop.c Sun Jul 8 23:08:02 2001
@@ -69,6 +69,7 @@
#include <linux/slab.h>
#include <asm/uaccess.h>
+#include <asm/checksum.h>
#include <linux/loop.h>
@@ -107,7 +108,6 @@
in = loop_buf;
out = raw_buf;
}
-
key = lo->lo_encrypt_key;
keysize = lo->lo_encrypt_key_size;
for (i = 0; i < size; i++)
@@ -115,11 +115,106 @@
return 0;
}
-static int none_status(struct loop_device *lo, struct loop_info *info)
+#define ID printk(KERN_ERR "crc: info about (%s, %d, %d) ", kdevname(lo->lo_device), real_block, blksize);
+
+
+static int transfer_crc(struct loop_device *lo, int cmd, char *raw_buf,
+ char *loop_buf, int size, int real_block)
{
+ struct buffer_head *bh;
+ int blksize = 1024, nsect; /* Size of block on auxilary media */
+ int cksum;
+ u32 *data;
+ nsect = blksize / 4;
+
+ if (!lo->second_device) {
+ ID; printk( "reading from not-yet-setup crc device can result in armagedon. Dont try again.\n" );
+ return -1;
+ }
+ bh = getblk(lo->second_device, 1+real_block/nsect, blksize);
+ if (!bh) {
+ ID; printk( "getblk returned NULL.\n" );
+ return -1;
+ }
+ if (!buffer_uptodate(bh)) {
+ ll_rw_block(READ, 1, &bh);
+ wait_on_buffer(bh);
+ if (!buffer_uptodate(bh)) {
+ ID; printk( "could not read block with CRC\n" );
+ goto error;
+ }
+ }
+
+ data = (u32 *) bh->b_data;
+ if (cmd == READ)
+ cksum = csum_partial_copy_nocheck(raw_buf, loop_buf, size, 0);
+ else
+ cksum = csum_partial_copy_nocheck(loop_buf, raw_buf, size, 0);
+
+ if (cmd == READ) {
+ if (le32_to_cpu(data[real_block%nsect]) != cksum) {
+ if (lo->lo_encrypt_key_size == 0) { /* Normal mode */
+ ID; printk( "wrong checksum reading, is %x, should be %x\n", cksum, 0x1234 );
+ goto error;
+ } else {
+ ID; printk( "wrong checksum repairing, setting to %x\n", cksum );
+ goto repair;
+ }
+ }
+ } else {
+ repair:
+ data[real_block%nsect] = cpu_to_le32(cksum);
+ mark_buffer_uptodate(bh, 1);
+ mark_buffer_dirty(bh);
+ }
+
+ brelse(bh);
return 0;
+error:
+ brelse(bh);
+ return -1;
+
}
+static int ioctl_crc(struct loop_device *lo, int cmd, unsigned long arg)
+{
+ struct file *file;
+ struct inode *inode;
+ int error;
+
+ printk( "Entering ioctl_crc\n" );
+ if (cmd != LOOP_CRC_SET_FD)
+ return -EINVAL;
+
+ error = -EBADF;
+ file = fget(arg);
+ if (!file)
+ return -EINVAL;
+
+ error = -EINVAL;
+ inode = file->f_dentry->d_inode;
+ if (!inode) {
+ printk(KERN_ERR "ioctl_crc: NULL inode?!?\n");
+ goto out;
+ }
+
+ if (S_ISBLK(inode->i_mode)) {
+ error = blkdev_open(inode, file);
+ lo->second_device = inode->i_rdev;
+ printk( "loop_crc: Registered device %x\n", lo->second_device );
+ return error;
+ } else {
+ out:
+ fput(file);
+ return -EINVAL;
+ }
+}
+
+static int none_status(struct loop_device *lo, struct loop_info *info)
+{
+ return 0;
+}
+
static int xor_status(struct loop_device *lo, struct loop_info *info)
{
if (info->lo_encrypt_key_size <= 0)
@@ -139,10 +234,19 @@
init: xor_status
};
+struct loop_func_table crc_funcs = {
+ number: LO_CRYPT_CRC,
+ transfer: transfer_crc,
+ init: none_status,
+ ioctl: ioctl_crc
+};
+
/* xfer_funcs[0] is special - its release function is never called */
struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
&none_funcs,
- &xor_funcs
+ &xor_funcs,
+ NULL, NULL, NULL, NULL, NULL,
+ &crc_funcs,
};
#define MAX_DISK_SIZE 1024*1024*1024
@@ -728,6 +832,7 @@
lo->transfer = NULL;
lo->ioctl = NULL;
lo->lo_device = 0;
+ lo->second_device = 0;
lo->lo_encrypt_type = 0;
lo->lo_offset = 0;
lo->lo_encrypt_key_size = 0;
--- clean/include/linux/loop.h Wed Aug 29 01:23:55 2001
+++ linux/include/linux/loop.h Sun Aug 26 18:27:56 2001
@@ -28,6 +28,7 @@
int lo_number;
int lo_refcnt;
kdev_t lo_device;
+ kdev_t second_device;
int lo_offset;
int lo_encrypt_type;
int lo_encrypt_key_size;
@@ -119,6 +120,7 @@
#define LO_CRYPT_BLOW 4
#define LO_CRYPT_CAST128 5
#define LO_CRYPT_IDEA 6
+#define LO_CRYPT_CRC 7
#define LO_CRYPT_DUMMY 9
#define LO_CRYPT_SKIPJACK 10
#define MAX_LO_CRYPT 20
@@ -150,5 +152,6 @@
#define LOOP_CLR_FD 0x4C01
#define LOOP_SET_STATUS 0x4C02
#define LOOP_GET_STATUS 0x4C03
+#define LOOP_CRC_SET_FD 0x4C04
#endif
--
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org
next prev parent reply other threads:[~2001-09-15 22:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-15 8:46 ext2fs corruption again Kristian
2001-09-15 12:42 ` David Weinehall
2001-09-15 17:19 ` David Rees
2001-09-15 17:55 ` Kristian Peters
2001-09-15 22:19 ` Pavel Machek [this message]
2001-09-15 23:51 ` Andreas Dilger
2001-09-16 19:33 ` Pavel Machek
-- strict thread matches above, loose matches on Subject: below --
2001-09-15 10:44 Kristian
2001-09-15 11:14 Kristian Peters
2001-09-15 12:21 ` Roeland Th. Jansen
2001-09-15 14:49 ` Kristian
2001-09-15 21:04 ` Mike Fedyk
2001-09-15 15:48 ` Mohammad A. Haque
2001-09-15 16:19 ` Kristian Peters
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=20010916001943.A984@bug.ucw.cz \
--to=pavel@suse.cz \
--cc=kristian@korseby.net \
--cc=linux-kernel@vger.kernel.org \
--cc=tao@acc.umu.se \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.