FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 11-30-2009, 12:09 PM
Pierre Ossman
 
Default Bug#504391: mmc: add module parameter to set whether cards are assumed removable

On Mon, 30 Nov 2009 12:54:05 +0000
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

>
> For most file systems it is sufficient to check the superblock related
> information. So we'd need an fs->ops->validate_media() or somesuch but it
> wouldn't be that horrific or need to do much I/O in most cases.
>
> You could defeat that by being really stupid, but the purpose of the
> check isn't a stupidity filter but to stop accidents happening in normal
> use.
>

Agreed. Something like that would more or less solve the issue. Someone
just needs to write the code for all (or most) filesystems.

> > Another way of putting it is that the kernel needs to umount/mount
> > around suspend in a way that's transparent to users of the filesystem.
>
> No. The kernel needs to push stuff to media on suspend (which is good
> manners anyway), and validate on resume. if the validate fails you mark
> the media as changed and the block layer will already see to it that
> everything gets aborted as it already does with a truely removable device.
>
> In fact if you did this by media serial numbers and idents you don't even
> need the fs hook, although it would certainly be safer that way.
>

The hardware driver layer can only check if it's the same device being
plugged in, not if someone has done something with it during suspend,
so I see no other way than solving this in the filesystem layer.

Rgds
--
-- Pierre Ossman

WARNING: This correspondence is being monitored by FRA, a
Swedish intelligence agency. Make sure your server uses
encryption for SMTP traffic and consider using PGP for
end-to-end encryption.
 
Old 11-30-2009, 12:32 PM
Maxim Levitsky
 
Default Bug#504391: mmc: add module parameter to set whether cards are assumed removable

On Mon, 2009-11-30 at 13:39 +0100, Pierre Ossman wrote:
> On Tue, 17 Nov 2009 08:53:00 +0100
> Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
>
> > Ben Hutchings wrote:
> > > In general, it is not possible to tell whether a card present in an MMC
> > > slot after resume is the same that was there before suspend.
> >
> > That's true for virtually all storage devices, not just MMC.
> >
> > > So there are two possible behaviours, each of which will cause data
> > > loss in some cases:
> > >
> > > CONFIG_MMC_UNSAFE_RESUME=n (default): Cards are assumed to be removed
> > > during suspend. Any filesystem on them must be unmounted before
> > > suspend; otherwise, buffered writes will be lost.
> > >
> > > CONFIG_MMC_UNSAFE_RESUME=y: Cards are assumed to remain present during
> > > suspend. They must not be swapped during suspend; otherwise, buffered
> > > writes will be flushed to the wrong card.
> > >
> > > Currently the choice is made at compile time and this allows that to be
> > > overridden at module load time.
> >
> > Can't the kernel flush the write buffer at suspend time, so that you can
> > remove this choice for good?
>
> I'm afraid that's insufficient. What it would need to do is to is
> flush everything (to make sure what's on disk matches what's in
> memory), but also read back the filesystem on resume to verify that
> nothing else modified it (i.e. making sure what's on disk still matches
> what's in memory).

I had just an idea.

Before we do suspend, pick few random sectors from the media, run that
through some hash function, thus creating some sort of watermark.

On resume do that again.

This should catch all unintentional card swappings.

Of course this is only half of the problem, because user could edit the
card meanwhile, but still solving half the problem is better that
nothing?


What do you think ?

Best regards,
Maxim Levitsky




--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 11-30-2009, 12:51 PM
Alan Cox
 
Default Bug#504391: mmc: add module parameter to set whether cards are assumed removable

> Before we do suspend, pick few random sectors from the media, run that
> through some hash function, thus creating some sort of watermark.

Statistically speaking the chances are you'll catch zero sectors and
lose. You'll also not detect the suspend, move to other box, use, put
back error. That is one users make and we need to be at least vaguely
robust against.

Hence you need the fs checking here.

Alan



--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 11-30-2009, 02:27 PM
Maxim Levitsky
 
Default Bug#504391: mmc: add module parameter to set whether cards are assumed removable

On Mon, 2009-11-30 at 13:51 +0000, Alan Cox wrote:
> > Before we do suspend, pick few random sectors from the media, run that
> > through some hash function, thus creating some sort of watermark.
>
> Statistically speaking the chances are you'll catch zero sectors and
> lose. You'll also not detect the suspend, move to other box, use, put
> back error. That is one users make and we need to be at least vaguely
> robust against.
>
> Hence you need the fs checking here.
>
> Alan
I have to agree with you about that one.
An FS checking is really only solution.

Then I think such check can be added gradually to existing filesystems
(starting with fat), and allow these filesystems to persist across low
power states regardsless of CONFIG_$system_UNSAFE_RESUME

For fat, simple checksum of the 'fat' table will catch most attempts.
Also directory modification times can be compared, at least for root
directory.

Best regards,
Maxim Levitsky






--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 12-01-2009, 06:57 PM
Wouter van Heyst
 
Default Bug#504391: mmc: add module parameter to set whether cards are assumed removable

On Sun, Nov 22, 2009 at 12:32:16PM +0000, Ben Hutchings wrote:
> On Sun, 2009-11-22 at 12:42 +0100, Wouter van Heyst wrote:

...

> > I'm running 2.6.32-rc7 with this patch applied and CONFIG_MMC_UNSAFE_RESUME=y
> > That works as desired for my non-removable case. Is it desired that I
> > test if 'removable=1' will thrash my filesystem?
>
> Please test with CONFIG_MMC_UNSAFE_RESUME=n (which Debian will continue
> to use) and removable=0.

It took a while to get around to it correctly, but yes this works.
Without setting removable=0 my Acer Aspire One hangs while trying to
resume if the mmc card is mounted.

Wouter van Heyst



--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 07:59 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org