mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kay Sievers" <kay.sievers@vrfy.org>
To: "Pavel Machek" <pavel@suse.cz>
Cc: "Michael Tokarev" <mjt@tls.msk.ru>,
	"Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: data corruption: revalidating a (removable) hdd/flash on re-insert
Date: Tue, 4 Nov 2008 21:13:10 +0100	[thread overview]
Message-ID: <ac3eb2510811041213l4a20fa12h3c5beb3c2d317574@mail.gmail.com> (raw)
In-Reply-To: <20081104195728.GC5862@ucw.cz>

On Tue, Nov 4, 2008 at 20:57, Pavel Machek <pavel@suse.cz> wrote:
> On Fri 2008-10-31 17:10:26, Kay Sievers wrote:
>> On Fri, Oct 31, 2008 at 16:38, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> > To make a long story short: is there a way to force kernel
>> > to re-validate a replaced usb-connected hard drive (or a
>> > flash) *automatically*?
>> >
>> > Because right now, the kernel does not see that the drive
>> > has been replaced, and uses *some* old cached values, which
>> > results in random data corruption here and there, and other
>> > similar odd things.
>>
>> Maybe your card reader is broken. I can not reproduce this with any of
>> the many readers I have. Usually a media change results in media
>> revalidation with the next access to the device. You can easily
>> reproduce that:
>>
>> Insert the media, and force a validation:
>>   $ touch /dev/sdb
>>
>> Start logging of the kernel uevents to the console:
>>   $ udevadm monitor --kernel &
>>
>> Access the device:
>>   $ touch /dev/sdb
>>
>> Nothing should happen, as the reader/kernel knows it is still valid.
>>
>> Now remove the media and insert it immediately again.
>>
>> Access the device:
>>   $ touch /dev/sdb
>>   UEVENT[1225468868.803950] change
>> /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host8/target8:0:0/8:0:0:0
>> (scsi)
>>
>> and you see the reader told to kernel (scsi unit attention) to
>> revalidate the device.
>>
>> These events happen only when the device is accessed. That's why
>> distros poll removable devices for media changes.
>>
>> Every access to removable media is guarded by this revalidation check.
>> If you don't see these events, you should not trust this reader, and
>> at least never change the media while it is connected.
>
> This is rather nasty data-corrupter.

Sure, it is.

> Could we at least blacklist
> broken device, and force revalidation on each close or something like
> that?

What's your idea of revalidation if the hardware does not tell you?
Get an md5 of the disk content? :)

Kay

  reply	other threads:[~2008-11-04 20:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 15:38 Michael Tokarev
2008-10-31 15:59 ` Lennart Sorensen
2008-10-31 16:10   ` Michael Tokarev
2008-10-31 18:28     ` Lennart Sorensen
2008-10-31 16:10 ` Kay Sievers
2008-10-31 17:39   ` Michael Tokarev
2008-10-31 18:49     ` Kay Sievers
2008-11-04 19:57   ` Pavel Machek
2008-11-04 20:13     ` Kay Sievers [this message]
2008-11-04 20:20       ` Pavel Machek
2008-11-04 21:22         ` Michael Tokarev
2008-11-04 21:28           ` Pavel Machek
2008-11-05  8:04             ` Michael Tokarev
2008-11-05  0:29           ` Kay Sievers

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=ac3eb2510811041213l4a20fa12h3c5beb3c2d317574@mail.gmail.com \
    --to=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjt@tls.msk.ru \
    --cc=pavel@suse.cz \
    /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®