Re: removing external usb hdd without unmounting causes reboot?

2007-07-31 Thread Matthew Dillon

: By the way, the problem apparently has been solved in
: DragonFly BSD (i.e. DF BSD does not panic when a mounted
: FS is physically removed).  Maybe it is worth to have a

We didn't do much here.  Just started pulling devices, looking at the
crash dumps, and fixing things.

Basically it was just a collection of minor bugs... things like certain
error paths in UFS (which only occur on an I/O error) had bugs, or
caused corruption instead of properly handling the error, and
various bits and pieces of the USB I/O path would get ripped out on
the device pull while still referenced by other bits of the USB I/O
path.

You will also have to look at the way vfs flushing handles errors
in order to allow a filesystem to be force-unmounted after the device
has been pulled.  Basically you have to make umount -f work and you have
to make sure it properly dereferencing the underlying device and properly
destroys the (now unwritable) dirty buffers.

-Matt
Matthew Dillon 
[EMAIL PROTECTED]
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-30 Thread Oliver Fromme
Peter Jeremy wrote:
  Dennis Melentyev wrote:
   Is there any correct way to initiate funding to rewrite VM/VFS related
   parts (getting non-panicable removable devices)? Who should one
   contact for this?
  
  I would suggest that the first step is finding someone (or a few
  people) with the necessary skills who is/are willing to work on the
  problem.  Offering funding may increase the potential pool but will
  not automatically solve the skills/knowledge issue.

By the way, the problem apparently has been solved in
DragonFly BSD (i.e. DF BSD does not panic when a mounted
FS is physically removed).  Maybe it is worth to have a
look at what they did to fix it, and possibly port it
over to FreeBSD.  On the other hand, the internal data
structures of the VM subsystem have diverged quite a lot
from FreeBSD, so I don't know if it would really help.

(No, I'm not volunteering; lack of time and interest.)

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

Perl is worse than Python because people wanted it worse.
-- Larry Wall
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-30 Thread Dennis Melentyev
Hi Oliver!

2007/7/30, Oliver Fromme [EMAIL PROTECTED]:
 Peter Jeremy wrote:
   Dennis Melentyev wrote:
Is there any correct way to initiate funding to rewrite VM/VFS related
parts (getting non-panicable removable devices)? Who should one
contact for this?
  
   I would suggest that the first step is finding someone (or a few
   people) with the necessary skills who is/are willing to work on the
   problem.  Offering funding may increase the potential pool but will
   not automatically solve the skills/knowledge issue.

 By the way, the problem apparently has been solved in
 DragonFly BSD (i.e. DF BSD does not panic when a mounted
 FS is physically removed).  Maybe it is worth to have a
 look at what they did to fix it, and possibly port it
 over to FreeBSD.  On the other hand, the internal data
 structures of the VM subsystem have diverged quite a lot
 from FreeBSD, so I don't know if it would really help.

 (No, I'm not volunteering; lack of time and interest.)

That was I asking same question in DragonflyBSD list :)
But yes, VFS and VM in FBSD and DFBSD are way too differ since 4.1 times.
It is not an option, sadly.

-- 
Dennis Melentyev
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-28 Thread Dennis Melentyev
Hello Peter,

Thank you for your answer.

2007/7/28, Peter Jeremy [EMAIL PROTECTED]:
 On 2007-Jul-27 18:29:44 +0300, Dennis Melentyev [EMAIL PROTECTED] wrote:

[skipped architectural description, and, thank for it]


 I'd rather consider this problem as security one.

 I think that is a very long stretch.

Well, it is. :)


 Is there any correct way to initiate funding to rewrite VM/VFS related
 parts (getting non-panicable removable devices)? Who should one
 contact for this?

 I would suggest that the first step is finding someone (or a few
 people) with the necessary skills who is/are willing to work on the
 problem.  Offering funding may increase the potential pool but will
 not automatically solve the skills/knowledge issue.

Got your point.


 As for initiating funding, you have several options:
 1) Do it yourself:  Find someone(s) to do the work (either by approaching
likely candidates or advertising on FreeBSD lists), get an indication
of the necessary funding and then raise the funds yourself.
 2) Approach the FreeBSD Foundation, with or without names.
 3) Approach corporations that are FreeBSD-friendly.  Yahoo! and Apple are
the first ones that come to mind.

I'd probably try 2nd and 3rd items - unfortunately I can't offer enough myself.

Hope, it would be possible to find enough support from the community
and/or corporations.

Thanks for the clues!

-- 
Dennis Melentyev
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-27 Thread Dennis Melentyev
Hello Peter and everybody,

Sorry for continuing this thread, but let's not forgot the security
aspect of this issue:
If you run amd on some host configured to automount USB drives, it's
easy to force DoS attack. Just insert the flash/HDD and remove it
short after it's mounted.

Sure, it's almost close to ability of just pulling off power cable or
pressing reset, but still a problem. Even if nobody will put out the
USB stick, just in case of a Flash with dead blocks  on it or just
badly formatted one it's too easy to get totally unexpected panics.

I'd rather consider this problem as security one.

Is there any correct way to initiate funding to rewrite VM/VFS related
parts (getting non-panicable removable devices)? Who should one
contact for this?

PS. Happy sysadmin day! *drink*

2007/7/24, Peter Jeremy [EMAIL PROTECTED]:
 On 2007-Jul-23 16:15:56 +0200, Oliver Fromme [EMAIL PROTECTED] wrote:
 So, currently the best work-around is to use amd with a
 very short timeout.  Or simply remember to umount your
 removable media manually.

 Or ports/emulators/mtools

 --
 Peter Jeremy




-- 
Dennis Melentyev
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-27 Thread Peter Jeremy
On 2007-Jul-27 18:29:44 +0300, Dennis Melentyev [EMAIL PROTECTED] wrote:
Sorry for continuing this thread, but let's not forgot the security
aspect of this issue:
If you run amd on some host configured to automount USB drives, it's
easy to force DoS attack. Just insert the flash/HDD and remove it
short after it's mounted.

It's almost impossible to secure a machine against someone with
physical access to that machine.  As you point out, pushing the reset
button or pulling the power cable works.

USB stick, just in case of a Flash with dead blocks  on it or just
badly formatted one it's too easy to get totally unexpected panics.

There are two distinct issues here:

When you remove the hardware, the low-level datastructures get freed
but the high level (FS) code still points into those (now freed)
structures - ie you have use-after-free errors.  As has been pointed
out, resolving these issues is difficult because they affect many
different areas within the kernel.

If the filesystem is corrupt, then it is no longer internally
consistent and assumptions/requirements in the FS code are no longer
valid.  It is possible that assert() checks are tripped or implicit
assumptions in the code are violated, possibly leading to panics.  Bad
blocks could lead to similar behaviour.  Fixing these problems is (in
general) not hard because it's mostly just adding appropriate checks
in the FS code and I believe that most of the cases where this can
occur have already been corrected.

I'd rather consider this problem as security one.

I think that is a very long stretch.

Is there any correct way to initiate funding to rewrite VM/VFS related
parts (getting non-panicable removable devices)? Who should one
contact for this?

I would suggest that the first step is finding someone (or a few
people) with the necessary skills who is/are willing to work on the
problem.  Offering funding may increase the potential pool but will
not automatically solve the skills/knowledge issue.

As for initiating funding, you have several options:
1) Do it yourself:  Find someone(s) to do the work (either by approaching
   likely candidates or advertising on FreeBSD lists), get an indication
   of the necessary funding and then raise the funds yourself.
2) Approach the FreeBSD Foundation, with or without names.
3) Approach corporations that are FreeBSD-friendly.  Yahoo! and Apple are
   the first ones that come to mind.

-- 
Peter Jeremy


pgpH7uZiEFGpr.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-24 Thread Peter Jeremy
On 2007-Jul-23 16:15:56 +0200, Oliver Fromme [EMAIL PROTECTED] wrote:
So, currently the best work-around is to use amd with a
very short timeout.  Or simply remember to umount your
removable media manually.

Or ports/emulators/mtools

-- 
Peter Jeremy


pgpDLc0Ghx67i.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-23 Thread Oliver Fromme
Stefan Esser wrote:
  Oliver Fromme wrote:
   Momchil Ivanov wrote:
I don`t know how things work, but shutting down the system when some
mounted fs is no longer present seems like the wrong thing to me.
   
   As Josh wrote, it's expected.  The problem is known
   to exist for a long time already (probably as long
   as FreeBSD itself exists), and if there was an easy
   solution, certainly someone would have fixed it.
  
  I have to check this, but AFAIK this problem exists only for
  devices/partitions that are mounted R/W. Do you happen to
  know this? (I can not risk to crash my box right now for a
  test ;-)

I'm afraid the problem affects _all_ mounts, including
read-only mounts.

  There once was an autofs implementation, but IIRC it has
  later been removed. It could not only automatically mount
  removable media, but it could also help with the problem
  of devices that are rarely written to, but still mounted
  R/W just in case for easy write-access.
  
  Long time ago I had the idea that a clean file system could
  be mounted R/O after a short delay. When all dirty buffers
  are flushed, the device could be forcefully disconnected
  without causing inconsistencies in the kernel. If there are
  no open file descriptors, the super-block could be written
  with the clean flag set, to signal that no fsck is needed
  when the partition is mounted next time.
  
  Internally, the device can be treated as R/O, with the only
  exeption that an attempted write is not rejected, but that
  it instead triggers the change back to R/W operation (this
  means setting the in-RAM copy of the super-block to dirty
  before the write is allowed to proceed as normal).

That's a very interesting idea.  Unfortunately it doesn't
solve the problem, because read-only mounts have the same
problem, unfortunately.

So, currently the best work-around is to use amd with a
very short timeout.  Or simply remember to umount your
removable media manually.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

'Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.'
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-22 Thread Nikolay Pavlov
On Saturday 21 July 2007 20:50:21 Zoran Kolic wrote:
 This topic is extremely interesting. For me, unmounting usb
 device is not so hard to do. I remember -r flag to mount
 with just read option. So, if hand follows the brain impuls,
 put another impuls to unmount it first.

Yup. But this is only valid for advenced users.

-- 

- Best regards, Nikolay Pavlov. -




signature.asc
Description: This is a digitally signed message part.


Re: removing external usb hdd without unmounting causes reboot?

2007-07-22 Thread Norberto Meijome
On Sat, 21 Jul 2007 17:19:51 +0200
Stefan Esser [EMAIL PROTECTED] wrote:

 Norberto Meijome schrieb:
  On Thu, 19 Jul 2007 17:38:14 +0200
  [LoN]Kamikaze [EMAIL PROTECTED] wrote:
  
  As I mentioned earlier I remember it working during the 5.3 era on Stable, 
  at
  some point it worked. I even remember removing my CD-Rom drive from my 
  Thinkpad
  without running atacontrol detach. The system just took it and the drive 
  just
  continued working after I put it back in.
  
  on 6.2-STABLE (of a few days ago), i have this happening a couple of times 
  with no adverse effect at all. 
  Burn DVD/Cd, when finished, hald detects the disk, mounts it, /dev/cd0 in 
  /media/whatever.
  
  i can eject the disk just fine (which in itself is weird, i think) the 
  device is still there...
  umount /dev/cd0 
  
  works fine and off it goes. other than that, no, i havent tried to access 
  the device in question
 
 In that case the device has been mounted R/O before, and if
 you don't remove it in the middle of a transaction, there
 is nothing the kernel might want to do with the physical
 device to unmount it (and even within a transfer, this ought
 to be caught by the driver). For that reason I had suggested
 to have a soft-R/O mode for removable devices, which together
 with a very short flush delay might allow such a device to
 be mounted R/O nearly all the time (tm) ;-) This is not
 a perfect solution, but it is similar to the way USB sticks
 are used with Windows/XP: Wait a second or two and remove it.
 While not perfect this covers the case of MP3 players or
 digicams that are mounted as USB storage devices, and many
 other cases. To make this a perfect solution is much harder,
 but even a simple implementation would be a big step forward.

Yes, I agree it would be a good interim solution.

thx!
_
{Beto|Norberto|Numard} Meijome

It is a lesson which all history teaches wise men, to put trust in ideas, and 
not in circumstances.
   Emerson

I speak for myself, not my employer. Contents may be hot. Slippery when wet. 
Reading disclaimers makes you go blind. Writing them is worse. You have been 
Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-22 Thread Norberto Meijome
On Sat, 21 Jul 2007 20:44:13 -0600 (MDT)
M. Warner Losh [EMAIL PROTECTED] wrote:

 In message: [EMAIL PROTECTED]
 Norberto Meijome [EMAIL PROTECTED] writes:
 : On Thu, 19 Jul 2007 09:02:50 -0600 (MDT)
 : M. Warner Losh [EMAIL PROTECTED] wrote:
 : 
 :  In message: [EMAIL PROTECTED]
 :  Momchil Ivanov [EMAIL PROTECTED] writes:
 :  : What is then the reason for the kernel not being able to unmount a
 :  : filesystem whose provider is no longer present?
 :  
 :  The problem is that the device driver has wound down, deallocated
 :  memory, etc.  Now the kernel comes along with stale references to the
 :  device and panic ensues.  It is really just that simple.  There's no
 :  replacement of the now-dead device with dead calls.
 :  
 :  And even if you fixed that, most of the file systems in the tree today
 :  do not tolerate errors on writes at all and that also leads to
 :  panics.  This is why firewire freezes the I/Os rather than failing
 :  them (and why umount -f on a firewire drive hangs).
 : 
 : Please point me to the correct RTFM, because I feel this worth it :)
 
 src/sys/fs/..., src/sys/kern/... and src/sys/vm/... are your best bets.
 
 : Is there a reason why the kernel cannot check 'upwards' if a device
 : is being used, ie mounted ? and prevent the unloading of the device
 : driver ?
 
 Check, sure, it can check.  But what does a simple check accomplish if
 the filesystem panics if the underlying media returns an error?  The
 problem isn't as simple as just looking in one place or another, but
 rather systemic in nature.
 

thanks Warner. What do you estimate is the cost (time, at least) to investigate
and fix this issue? SoC project? 4 mth project? 

cheers,
B

_
{Beto|Norberto|Numard} Meijome

Anyone who isn't confused here doesn't really understand what's going on.

I speak for myself, not my employer. Contents may be hot. Slippery when wet.
Reading disclaimers makes you go blind. Writing them is worse. You have been
Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-21 Thread Stefan Esser
Norberto Meijome schrieb:
 On Thu, 19 Jul 2007 17:38:14 +0200
 [LoN]Kamikaze [EMAIL PROTECTED] wrote:
 
 As I mentioned earlier I remember it working during the 5.3 era on Stable, at
 some point it worked. I even remember removing my CD-Rom drive from my 
 Thinkpad
 without running atacontrol detach. The system just took it and the drive just
 continued working after I put it back in.
 
 on 6.2-STABLE (of a few days ago), i have this happening a couple of times 
 with no adverse effect at all. 
 Burn DVD/Cd, when finished, hald detects the disk, mounts it, /dev/cd0 in 
 /media/whatever.
 
 i can eject the disk just fine (which in itself is weird, i think) the 
 device is still there...
 umount /dev/cd0 
 
 works fine and off it goes. other than that, no, i havent tried to access the 
 device in question

In that case the device has been mounted R/O before, and if
you don't remove it in the middle of a transaction, there
is nothing the kernel might want to do with the physical
device to unmount it (and even within a transfer, this ought
to be caught by the driver). For that reason I had suggested
to have a soft-R/O mode for removable devices, which together
with a very short flush delay might allow such a device to
be mounted R/O nearly all the time (tm) ;-) This is not
a perfect solution, but it is similar to the way USB sticks
are used with Windows/XP: Wait a second or two and remove it.
While not perfect this covers the case of MP3 players or
digicams that are mounted as USB storage devices, and many
other cases. To make this a perfect solution is much harder,
but even a simple implementation would be a big step forward.

Regards, STefan
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-21 Thread Zoran Kolic
 From: Norberto Meijome [EMAIL PROTECTED]
 i can eject the disk just fine (which in itself is weird, i think) the 
 device is still there...
 umount /dev/cd0 
 works fine and off it goes. other than that, no, i havent tried to access the 
 device in question

I never saw that behaviour. It really should not eject.
As you, I use scsi emulation, with no acd device at all.

This topic is extremely interesting. For me, unmounting usb
device is not so hard to do. I remember -r flag to mount
with just read option. So, if hand follows the brain impuls,
put another impuls to unmount it first.

Zoran

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-21 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Norberto Meijome [EMAIL PROTECTED] writes:
: On Thu, 19 Jul 2007 09:02:50 -0600 (MDT)
: M. Warner Losh [EMAIL PROTECTED] wrote:
: 
:  In message: [EMAIL PROTECTED]
:  Momchil Ivanov [EMAIL PROTECTED] writes:
:  : What is then the reason for the kernel not being able to unmount a
:  : filesystem whose provider is no longer present?
:  
:  The problem is that the device driver has wound down, deallocated
:  memory, etc.  Now the kernel comes along with stale references to the
:  device and panic ensues.  It is really just that simple.  There's no
:  replacement of the now-dead device with dead calls.
:  
:  And even if you fixed that, most of the file systems in the tree today
:  do not tolerate errors on writes at all and that also leads to
:  panics.  This is why firewire freezes the I/Os rather than failing
:  them (and why umount -f on a firewire drive hangs).
: 
: Please point me to the correct RTFM, because I feel this worth it :)

src/sys/fs/..., src/sys/kern/... and src/sys/vm/... are your best bets.

: Is there a reason why the kernel cannot check 'upwards' if a device
: is being used, ie mounted ? and prevent the unloading of the device
: driver ?

Check, sure, it can check.  But what does a simple check accomplish if
the filesystem panics if the underlying media returns an error?  The
problem isn't as simple as just looking in one place or another, but
rather systemic in nature.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-20 Thread Christian Walther

On 19/07/07, M. Warner Losh [EMAIL PROTECTED] wrote:
[...]


The best one can do without massive buffer cache work is what firewire
does: it has one attachment to handle all umass devices.  When the
device goes away, it pauses all operations to that device.  If the
device comes back, it resumes the I/O .  If the device never comes
back, then the I/O never finishes.


Is this safe? I don't know where locking occurs in this case, but if
locking occurs on a very low level it's potentially dangerous. If a
device is removed (either on purpose or by accident) the kernel can't
determine the state of the filesystem anymore.
So the user could plug the device into another machine, start some
write operations on the device, and put it back into the FreeBSD
machine.
This wouldn't know anything about the changes done, and just flush its
buffer, probably using blocks that have been filled previously.

It's a pity that FreeBSD can't handle these situations.
Since no one here on this list has enough money to get development on
the road, maybe we could try collecting money? Everyone interested in
seeing this issue fixed offers the amount of money he/she likes to
spend...

I guess for a Summer of Code project this issue would be to big to
fix, wouldn't it?
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: removing external usb hdd without unmounting causes reboot?

2007-07-20 Thread David Schwartz

 It won't fix it.  The problem is dangling pointers to devices that no
 longer exist.  And like all dangling references after 'free' you get
 bad thing happening.

 Believe me, if it were easy, it would have been fixed.  If it was
 moderate to fix, it would have been fixed.  It is a hard problem that
 people have put lots of hours into to try to resolve.  To imply
 otherwise is really insulting to all those people (myself include)
 that have tried to fix this.

There is a simple but ugly way to fix it, similar to what the FireWire layer
does. The idea is for the USB layer to create a device that never goes
away when it first sees the stick and pass that device that never goes
away to the other layers. Even if the storage device is removed, the device
still does not go away.

The virtual device can generate errors if the physical device is missing.
The virtual device can be cleaned up when the device is unmounted. This will
ensure that the 'umount -f' process generates errors (which it will ignore)
rather than crashes (which are somewhat harder to ignore).

DS


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-20 Thread Matthias Schuendehuette

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

Am 20.07.2007 um 08:16 schrieb Christian Walther:


[...]
It's a pity that FreeBSD can't handle these situations.
Since no one here on this list has enough money to get development on
the road, maybe we could try collecting money? Everyone interested in
seeing this issue fixed offers the amount of money he/she likes to
spend...

I guess for a Summer of Code project this issue would be to big to
fix, wouldn't it?


Especially if I think about software RAID it's really a show-stopper.  
I remember a stress-test of *vinum* (without the g) years ago when  
I pulled the plug on one of the disks of a RAID5-plex...


Obviously there's no change at all concerning this problem.

- --
Ciao/BSD - Matthias

Matthias Schuendehuettemsch [at] snafu.de, Berlin (Germany)
PGP-Key at pgp.mit.edu and wwwkeys.de.pgp.net ID: 0xDDFB0A5F

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGoTatf1BNcN37Cl8RAmTRAJ99PXwWaHxUq4I8P++hcMhpL5PSlwCgg5/R
9gy1Gj2+JYTRB5OvGOWFDF4=
=XVsv
-END PGP SIGNATURE-
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-20 Thread Norberto Meijome
On Thu, 19 Jul 2007 17:38:14 +0200
[LoN]Kamikaze [EMAIL PROTECTED] wrote:

 As I mentioned earlier I remember it working during the 5.3 era on Stable, at
 some point it worked. I even remember removing my CD-Rom drive from my 
 Thinkpad
 without running atacontrol detach. The system just took it and the drive just
 continued working after I put it back in.

on 6.2-STABLE (of a few days ago), i have this happening a couple of times with 
no adverse effect at all. 
Burn DVD/Cd, when finished, hald detects the disk, mounts it, /dev/cd0 in 
/media/whatever.

i can eject the disk just fine (which in itself is weird, i think) the 
device is still there...
umount /dev/cd0 

works fine and off it goes. other than that, no, i havent tried to access the 
device in question

_
{Beto|Norberto|Numard} Meijome

The people have always some champion whom they set over them and nurse into 
greatness...
 This and no other is the root from which a tyrant springs; when he first 
appears he is a protector.
   Plato

I speak for myself, not my employer. Contents may be hot. Slippery when wet. 
Reading disclaimers makes you go blind. Writing them is worse. You have been 
Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-20 Thread Norberto Meijome
On Thu, 19 Jul 2007 09:02:50 -0600 (MDT)
M. Warner Losh [EMAIL PROTECTED] wrote:

 In message: [EMAIL PROTECTED]
 Momchil Ivanov [EMAIL PROTECTED] writes:
 : What is then the reason for the kernel not being able to unmount a
 : filesystem whose provider is no longer present?
 
 The problem is that the device driver has wound down, deallocated
 memory, etc.  Now the kernel comes along with stale references to the
 device and panic ensues.  It is really just that simple.  There's no
 replacement of the now-dead device with dead calls.
 
 And even if you fixed that, most of the file systems in the tree today
 do not tolerate errors on writes at all and that also leads to
 panics.  This is why firewire freezes the I/Os rather than failing
 them (and why umount -f on a firewire drive hangs).

Please point me to the correct RTFM, because I feel this worth it :)

Is there a reason why the kernel cannot check 'upwards' if a device is being 
used, ie mounted ? and prevent the unloading of the device driver ? 

thanks for your time illuminating this ignoramus :)

_
{Beto|Norberto|Numard} Meijome

Egotism is the anesthetic that dulls the pain of stupidity.
  Frank Leahy

I speak for myself, not my employer. Contents may be hot. Slippery when wet. 
Reading disclaimers makes you go blind. Writing them is worse. You have been 
Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Julius Huang

Hi,

How Mac OS X handle this?  Method, tricks, code, etc...

Does Linux reboot when this happen?

One can argue the kernel is so different between OS X, Linux and FBSD,
but it is still better to compare WIN vs FBSD (or NTFS vs UFS).

Or may be I am wrong.

BTW,
I hardly ever put a USB Disk on our FBSD Servers,
but never had problem disconnect USB/Firewire Disk on my Powerbook.

Julius



On Thu 19 Jul 2007, at 11:02, Norberto Meijome wrote:


On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)
Oliver Fromme [EMAIL PROTECTED] wrote:


If you have problems remembering,


This is very interesting thread indeed

I have found that mounting remote SMB shares will panic the kernel  
too, but
only if i try to access it while 'gone' . If I remember correctly,  
if i thread
carefully around it, i can manage to shutdown everything and it  
will only panic

at the very last minute when the kernel tries to unmount.

And, from my point of view, the explanation 'well, don't remove  
your mounted

devices without unmounting them first' is rubbish - the problem is not
necessarily users  removing them, but ALL the reasons that could  
cause an
unwanted and unplanned removal. Like a network outage in the case  
of smbfs. or
someone killing the power on a USB device. I can't see why the  
whole kernel
should die on you. Yes, i understand there are architectural  
reasons for this -

then the architecture is not right anymore, i think.


another work-around
is to use the auto mounter daemon (amd(8)).  It umounts
file systems automatically that are not in use.
Another nice feature of amd(8) is that you don't have
to mount the file system either -- Simply plug the USB
stick in, then access it, and amd(8) will automatically
mount it for you.



Now, something I dont understand  -  amd runs
at user level, and it mounts filesystems, and nothing dies when the  
filesystems
go away (other than the obvious cases for the applications trying  
to write to
the FS in question). Doesn't amd , at some point , have to tell the  
kernel
'please mount this filesystem' here or there? Isn't the kernel  
STILL involved

in all this? and why doesnt the kernel panic when the FS goes away?

The same goes for hald - it doesn't work flawlessly, but it does  
the trick, and

i cant recall an instance when it crashed the kernel.

re. USB disks, could we not by default use amd to mount USB  
devices? It seems
the obvious native replacement for hald + polkitd + dbus I use in  
XFCE with

Thunar on my laptop...

TIA!
_
{Beto|Norberto|Numard} Meijome

Never attribute to malice what can adequately be explained by  
incompetence.


I speak for myself, not my employer. Contents may be hot. Slippery  
when wet.
Reading disclaimers makes you go blind. Writing them is worse. You  
have been

Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable- 
[EMAIL PROTECTED]


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread [LoN]Kamikaze
Oliver Fromme wrote:
 Momchil Ivanov wrote:
   On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
Josh Paetzel wrote:
 Yes, it's expected behavior.  The workaround is to not unplug mounted
 devices. (There's nothing special about USB here, if you unplugged an
 IDE drive you'd get the same behavior)

Wouldn't it make some sense not to panic if mounted devices that are in
sync get removed? A few applications might get in trouble, but that's
hardly a reason to bring a whole system down.
   
   I don`t know how things work, but shutting down the system when some
   mounted fs is no longer present seems like the wrong thing to me.
 
 As Josh wrote, it's expected.  The problem is known
 to exist for a long time already (probably as long
 as FreeBSD itself exists), and if there was an easy
 solution, certainly someone would have fixed it.

I remember on 5.3 I removed a mounted USB stick. The system did not panic, all
I had to do was to plug the stick back in to be able to unmount it. So the
behaviour has been more tolerant, in the past.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread [LoN]Kamikaze
Norberto Meijome wrote:
 On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)
 Oliver Fromme [EMAIL PROTECTED] wrote:
 another work-around
 is to use the auto mounter daemon (amd(8)).  It umounts
 file systems automatically that are not in use.
 Another nice feature of amd(8) is that you don't have
 to mount the file system either -- Simply plug the USB
 stick in, then access it, and amd(8) will automatically
 mount it for you.
 
 
 Now, something I dont understand  -  amd runs
 at user level, and it mounts filesystems, and nothing dies when the 
 filesystems
 go away (other than the obvious cases for the applications trying to write to
 the FS in question). Doesn't amd , at some point , have to tell the kernel
 'please mount this filesystem' here or there? Isn't the kernel STILL involved
 in all this? and why doesnt the kernel panic when the FS goes away? 
 

The trick is that amd unmounts the device after a couple of seconds, so when
someone accidentally removes a usb drive, it doesn't really matter. Amd will
simply fail to mount it on the next access. If you remove the device during or
shortly after accessing it, it still will panic the system.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Momchil Ivanov
On Thursday 19 July 2007 09:17:48 [LoN]Kamikaze wrote:
 Norberto Meijome wrote:
  On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)
 
  Oliver Fromme [EMAIL PROTECTED] wrote:
  another work-around
  is to use the auto mounter daemon (amd(8)).  It umounts
  file systems automatically that are not in use.
  Another nice feature of amd(8) is that you don't have
  to mount the file system either -- Simply plug the USB
  stick in, then access it, and amd(8) will automatically
  mount it for you.
 
  Now, something I dont understand  -  amd runs
  at user level, and it mounts filesystems, and nothing dies when the
  filesystems go away (other than the obvious cases for the applications
  trying to write to the FS in question). Doesn't amd , at some point ,
  have to tell the kernel 'please mount this filesystem' here or there?
  Isn't the kernel STILL involved in all this? and why doesnt the kernel
  panic when the FS goes away?

 The trick is that amd unmounts the device after a couple of seconds, so
 when someone accidentally removes a usb drive, it doesn't really matter.
 Amd will simply fail to mount it on the next access. If you remove the
 device during or shortly after accessing it, it still will panic the
 system.

What is then the reason for the kernel not being able to unmount a filesystem 
whose provider is no longer present? What in the process of unmounting denies 
unmounting a filesystem whose provider is no longer available? Why can the 
kernel not just inform all programs that files have to be closed and are 
unaccessible any more, then consider the fs as unmounted and remove any bits 
of it left in the VM. Why can kernel not just ignore interruped/pending 
writes to that fs, drop the data, return an error to the program that 
initiated the write and just go on.

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  


pgpK94L1KnIM6.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Julius Huang


On Thu 19 Jul 2007, at 15:43, Momchil Ivanov wrote:


On Thursday 19 July 2007 09:17:48 [LoN]Kamikaze wrote:

Norberto Meijome wrote:

On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)

Oliver Fromme [EMAIL PROTECTED] wrote:

another work-around
is to use the auto mounter daemon (amd(8)).  It umounts
file systems automatically that are not in use.
Another nice feature of amd(8) is that you don't have
to mount the file system either -- Simply plug the USB
stick in, then access it, and amd(8) will automatically
mount it for you.


Now, something I dont understand  -  amd runs
at user level, and it mounts filesystems, and nothing dies when the
filesystems go away (other than the obvious cases for the  
applications
trying to write to the FS in question). Doesn't amd , at some  
point ,
have to tell the kernel 'please mount this filesystem' here or  
there?
Isn't the kernel STILL involved in all this? and why doesnt the  
kernel

panic when the FS goes away?


The trick is that amd unmounts the device after a couple of  
seconds, so
when someone accidentally removes a usb drive, it doesn't really  
matter.
Amd will simply fail to mount it on the next access. If you remove  
the

device during or shortly after accessing it, it still will panic the
system.


What is then the reason for the kernel not being able to unmount a  
filesystem
whose provider is no longer present? What in the process of  
unmounting denies
unmounting a filesystem whose provider is no longer available? Why  
can the
kernel not just inform all programs that files have to be closed  
and are
unaccessible any more, then consider the fs as unmounted and remove  
any bits
of it left in the VM. Why can kernel not just ignore interruped/ 
pending

writes to that fs, drop the data, return an error to the program that
initiated the write and just go on.

--
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B





Hi,

How Mac OS X handle this?  Method, tricks, code, etc...

Does Linux reboot when this happen?

The kernel is different between OS X, Linux and FBSD.

Why FBSD handle this by reboot?  Does reboot clean up everything?

BTW,
I hardly ever put a USB Disk on our FBSD Servers,
but never had problem disconnect USB/Firewire Disk on my Powerbook.

Julius



___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Dennis Melentyev

Hi All!

2007/7/19, Momchil Ivanov [EMAIL PROTECTED]:

On Thursday 19 July 2007 09:17:48 [LoN]Kamikaze wrote:
 Norberto Meijome wrote:
  On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)
 
  Oliver Fromme [EMAIL PROTECTED] wrote:
  another work-around
  is to use the auto mounter daemon (amd(8)).  It umounts
  file systems automatically that are not in use.
  Another nice feature of amd(8) is that you don't have
  to mount the file system either -- Simply plug the USB
  stick in, then access it, and amd(8) will automatically
  mount it for you.
 
  Now, something I dont understand  -  amd runs
  at user level, and it mounts filesystems, and nothing dies when the
  filesystems go away (other than the obvious cases for the applications
  trying to write to the FS in question). Doesn't amd , at some point ,
  have to tell the kernel 'please mount this filesystem' here or there?
  Isn't the kernel STILL involved in all this? and why doesnt the kernel
  panic when the FS goes away?

 The trick is that amd unmounts the device after a couple of seconds, so
 when someone accidentally removes a usb drive, it doesn't really matter.
 Amd will simply fail to mount it on the next access. If you remove the
 device during or shortly after accessing it, it still will panic the
 system.

What is then the reason for the kernel not being able to unmount a filesystem
whose provider is no longer present? What in the process of unmounting denies
unmounting a filesystem whose provider is no longer available? Why can the
kernel not just inform all programs that files have to be closed and are
unaccessible any more, then consider the fs as unmounted and remove any bits
of it left in the VM. Why can kernel not just ignore interruped/pending
writes to that fs, drop the data, return an error to the program that
initiated the write and just go on.


For me, the most expected behaviour of API is the same as socket one:
In case recv/send fails (socket peer gone, router in-the-middle is
died, excavator came across the cables, etc) I just get a timeout (for
the first time), then (once remote socket is considered closed) just
return with -1 and appropriate errno set.
Since every (not braindamaged) program expect possible disk failures,
everyone checks for return/errno. It should be extremely safe to just
supply notify userland with -1/errno to handle over the error case
at application level.

Since I do understand the complexity and impact of VM/[V]FS code, I'd
rather vote for funding an external project on better VM/VFS
separation and improvement. Later, this project codebase must be
merged into the CURRENT, tested and go STABLE the usual way. The
famous Floppy issue of FreeBSD MUST go away, it's just a shame and
long standing base for unpleasant rumor/jokes.

Could it be the good task for FreeBSD Foundation or what ever other investor?
Sorry for adding just 0.02UAH instead of real $20-30-50 of personal
money to the fund's account.
If there is such a fund for this particular problem, I'll vote with
money instead of bytes. I believe, there will be a lot more people
willing to do the same to gain enough funding.

--
Dennis Melentyev
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Andriy Gapon
on 18/07/2007 20:34 Mark Linimon said the following:
 On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
 Bottom line here is that the kernel panics when removing a USB device
 that has filesystems mounted.
 
 s/USB //
 
 I also have a hard time believing that the reason it hasn't been fixed
 is because there isn't an easy fix.  I'm under the impression it
 hasn't been fixed because either no one cares enough to fix it (using
 the workaround as a scapegoat excuse), or because the majority of people
 do not use USB-based storage devices.
 
 The reason is not the USB stack; the reason (IIRC) is that the FreeBSD
 VM was written with the default assumption that Devices Never Go Away.
 A large rewrite, I'm told, will be needed to fix this, and the code is
 convoluted and tricky.
 
 No one finds the situation acceptable; introducing the scapegoat word
 isn't going to win you any support.  The problem is not a weekend's worth
 of work to fix, nor does it have anything to do with avoidance by one
 particular maintainer, which you apparently had encountered before.

Well, here's my two kopiykas.
Apparently there is somebody who tried to fix this problem, but for some
reason (most probably language barrier) his attempt is largely unnoticed
so far.

Here is a link to a posting to freebsd-fs:
http://lists.freebsd.org/pipermail/freebsd-fs/2007-June/003370.html

Here's a discussion about this patch (in Russian):
http://www.opennet.ru/openforum/vsluhforumID9/6467.html

I have not tried this patch myself.
I am not qualified enough to comment on its quality and the author
admitted that this is more of a workaround or hack rather than perfect
solution.
Also, the patch seems to be msdosfs-centered.

But there are some success reports on the forum mentioned above.
So I thought that this is a good opportunity to draw more attention to
the patch in hope that more people will try it and look at it and
something good will result from it.

-- 
Andriy Gapon
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Andriy Gapon
on 19/07/2007 13:03 Daniel O'Connor said the following:
 Andriy Gapon wrote:
 Well, here's my two kopiykas.
 Apparently there is somebody who tried to fix this problem, but for some
 reason (most probably language barrier) his attempt is largely unnoticed
 so far.

 Here is a link to a posting to freebsd-fs:
 http://lists.freebsd.org/pipermail/freebsd-fs/2007-June/003370.html
 
 The language barrier won't help, especially since there is no English 
 discussion about how the patch works.

Well, barriers usually stop something :-)
There are some comments in Russian, maybe someone will find time to
translate, maybe even me...

 FreeBSD VFS comitters are rare, ones that understand Russian are 
 probably almost non-existent :)

There's always a chance.

 Also it would be nice if the patch was a unified diff rather than 
 x-patch as that makes it much easier to review.

Patches _are_ unified diffs. The fact that some not-so-smart software
decided that text/x-patch is a non-text attachment is indeed
inconvenient.

-- 
Andriy Gapon
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Daniel O'Connor

Andriy Gapon wrote:

Well, barriers usually stop something :-)


Heh :)


There are some comments in Russian, maybe someone will find time to
translate, maybe even me...


It could come in handy.

FreeBSD VFS comitters are rare, ones that understand Russian are 
probably almost non-existent :)


There's always a chance.


Indeed.

Also it would be nice if the patch was a unified diff rather than 
x-patch as that makes it much easier to review.


Patches _are_ unified diffs. The fact that some not-so-smart software
decided that text/x-patch is a non-text attachment is indeed
inconvenient.


Oops, I am in Windows land at the moment and it mangled them :(

The .bin extension is somewhat confusing as well..
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Daniel O'Connor

Andriy Gapon wrote:

on 18/07/2007 20:34 Mark Linimon said the following:

On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:

Bottom line here is that the kernel panics when removing a USB device
that has filesystems mounted.

s/USB //


I also have a hard time believing that the reason it hasn't been fixed
is because there isn't an easy fix.  I'm under the impression it
hasn't been fixed because either no one cares enough to fix it (using
the workaround as a scapegoat excuse), or because the majority of people
do not use USB-based storage devices.

The reason is not the USB stack; the reason (IIRC) is that the FreeBSD
VM was written with the default assumption that Devices Never Go Away.
A large rewrite, I'm told, will be needed to fix this, and the code is
convoluted and tricky.

No one finds the situation acceptable; introducing the scapegoat word
isn't going to win you any support.  The problem is not a weekend's worth
of work to fix, nor does it have anything to do with avoidance by one
particular maintainer, which you apparently had encountered before.


Well, here's my two kopiykas.
Apparently there is somebody who tried to fix this problem, but for some
reason (most probably language barrier) his attempt is largely unnoticed
so far.

Here is a link to a posting to freebsd-fs:
http://lists.freebsd.org/pipermail/freebsd-fs/2007-June/003370.html


The language barrier won't help, especially since there is no English 
discussion about how the patch works.


FreeBSD VFS comitters are rare, ones that understand Russian are 
probably almost non-existent :)


Also it would be nice if the patch was a unified diff rather than 
x-patch as that makes it much easier to review.


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Nikola Lecic
On Thu, 19 Jul 2007 19:49:22 +0930
Daniel O'Connor [EMAIL PROTECTED] wrote:

 Andriy Gapon wrote:
  Well, barriers usually stop something :-)
 
 Heh :)
 
  There are some comments in Russian, maybe someone will find time to
  translate, maybe even me...
 
 It could come in handy.
 
  FreeBSD VFS comitters are rare, ones that understand Russian are 
  probably almost non-existent :)
  
  There's always a chance.
 
 Indeed.

http://translate.google.com/translate?u=http%3A%2F%2Fwww.opennet.ru%2Fopenforum%2FvsluhforumID9%2F6467.htmllangpair=ru%7Cenhl=enie=UTF8

Useful? Seems comprehensible enough (maybe a wrong impression since I
understand Russian text).

Nikola Lečić
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Peter Jeremy
On 2007-Jul-19 00:57:57 +0200, Momchil Ivanov [EMAIL PROTECTED] wrote:
I think you are missing the point here and it is that the drive is already 
gone, so you do not have to care about it.

I don't think anyone is missing this point.

The most natural way for me seems to be that the OS should just return errors 
to the programs trying any I/O on that drive. May be when a drive is 
unplugged the OS has to mark it and the mounted file systems as not being 
there until all opened files on it are closed, return errors for all I/O 
except for closing opened files. And when all files are closed consider the 
fs as unmounted and remove the drive from the kernel.

And everyone I am aware of agrees that this is what _should_ happen.
Unfortunately, as has already been mentioned, the filesystem and VM
code have a very incestuous relationship and actually _making_ FreeBSD
behave this way is (from all accounts) very difficult.  There is
already an entry on the project ideas list to at least make this work
for MSDOSFS (http://www.freebsd.org/projects/ideas/#p-msdosfs - also
part of SOC2007).

This is my idea of how things should be done. Ensuring that a file system is 
in a consistent state after drive disconnect is something completely 
different

Note that UFS+softupdates already implements this.

-- 
Peter Jeremy


pgp3niumMyzcX.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Peter Jeremy
On 2007-Jul-19 08:58:27 +0200, [LoN]Kamikaze [EMAIL PROTECTED] wrote:
I remember on 5.3 I removed a mounted USB stick. The system did not panic, all
I had to do was to plug the stick back in to be able to unmount it. So the
behaviour has been more tolerant, in the past.

Did you or the syncer thread try to write to the stick whilst it was
absent?  If not then the OS would have been unaware of its absence.

-- 
Peter Jeremy


pgpvTXMlOHCAu.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
[LoN]Kamikaze [EMAIL PROTECTED] writes:
: Josh Paetzel wrote:
:  On Wednesday 18 July 2007, Momchil Ivanov wrote:
:  Hi,
: 
:  I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007
:  and accidently unplugged the USB hub to which my external hdd
:  together with a mouse were connected and this caused my machine to
:  freeze for some seconds and then reboot. At that moment the hdd was
:  mounted and I was playing music out of it.
:  After that I tried to reproduce it :) so just plugged only the hdd
:  directly, mounted it and started playing music files from it. When
:  I unplugged the USB cable the same thing happened: short freeze,
:  and then reboot. Is this expected behaviour? And is there some way
:  to avoid the freeze and reboot?
: 
:  Thanks.
:  
:  Yes, it's expected behavior.  The workaround is to not unplug mounted 
:  devices. (There's nothing special about USB here, if you unplugged an 
:  IDE drive you'd get the same behavior)
:  
: 
: Wouldn't it make some sense not to panic if mounted devices that are in sync
: get removed? A few applications might get in trouble, but that's hardly a
: reason to bring a whole system down.

This is this week's winner in the Zen Master of the Obvious award.

Yes.  It is a known problem that should be fixed.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Baldur Gislason [EMAIL PROTECTED] writes:
: I vaguely remember being able to yank out USB drives in 5.x and just make
: usbd execute a forced umount without any problems. FAT32 drives mind you.
: On 6.2 I haven't even been able to unplug a USB drive even if I unmount it
: first, always results in a kernel panic.

This has never worked.  Not even on 5.x.  Or 4.10.  I've tested these
both recently accidentally...

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Jeremy Chadwick [EMAIL PROTECTED] writes:
: If someone wants to work on this and needs devices/toys (thumb drives,
: external enclosures + hard disks), let me know, I will be more than
: happy to buy them the hardware needed.

Willing to fund the work on it too?  This is a volunteer project, and
you have to motivate people to work on this.  Tirades in mailing lists
has proven to be ineffective in the past.

I've looked at the issue, and generically, if a device goes away, it
is *HARD* to not panic.  The same thing happens if you eject a CF card
in a PC Card adapter in a PC Card slot.

The best one can do without massive buffer cache work is what firewire
does: it has one attachment to handle all umass devices.  When the
device goes away, it pauses all operations to that device.  If the
device comes back, it resumes the I/O .  If the device never comes
back, then the I/O never finishes.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Momchil Ivanov [EMAIL PROTECTED] writes:
: On Wednesday 18 July 2007 19:34:06 Mark Linimon wrote:
:  On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
:   Bottom line here is that the kernel panics when removing a USB device
:   that has filesystems mounted.
: 
:  s/USB //
: 
: Just a dumb question: what does umount -f does? And doing something like 
: that when a fs goes away shouldn`t fix it?

It won't fix it.  The problem is dangling pointers to devices that no
longer exist.  And like all dangling references after 'free' you get
bad thing happening.

: If the problem is in general with a file system, regardless of the provider, 
: then what does one do when a mounted smbfs becomes unavailable due to remote 
: host down, no route to host or some other network related problems? Same 
: question for NFS mounted filesystems?

In those cases, the device doesn't go away.  Just the remote host.
This is a big difference.

Believe me, if it were easy, it would have been fixed.  If it was
moderate to fix, it would have been fixed.  It is a hard problem that
people have put lots of hours into to try to resolve.  To imply
otherwise is really insulting to all those people (myself include)
that have tried to fix this.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Jeremy Chadwick [EMAIL PROTECTED] writes:
: This would alleviate concerns over data loss, would it not?

No.  The problem is more basic: the device *driver* is gone.  All the
code unwinding has happened.  The physical device is also gone, which
is what triggered the detach.  Doing synchronous writes wouldn't
help.  The next time the file system was touched, it would dereference
a device that no longer exists, giving random results, in this case a
crash.

Meaning no disrespect for enthusiastic users, I really wish that
people with suggestions would actually try to fix it themselves
before making such obviously wrong comments.  I have the right to say
this because I have tried to fix this, and have run into these issues.

Like I've said before, if it were easy, one of the dozen or so people
that have tried to fix it in the past 8 years would have succeeded.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Jeremy Chadwick
On Thu, Jul 19, 2007 at 08:48:21AM -0600, M. Warner Losh wrote:
 In message: [EMAIL PROTECTED]
 Jeremy Chadwick [EMAIL PROTECTED] writes:
 : If someone wants to work on this and needs devices/toys (thumb drives,
 : external enclosures + hard disks), let me know, I will be more than
 : happy to buy them the hardware needed.
 
 Willing to fund the work on it too?  This is a volunteer project, and
 you have to motivate people to work on this.

I'm one man with a single day job.  I only make so much money a year,
most of which goes to rent and co-location bills.  Remaining amounts
usually go to small hobby projects of mine, or donating money to folks
like phk@ to work on features that I'll benefit from (serial console
work comes to mind, ditto with BTX fixes).

What I'm saying is that I can't afford (literally -- I don't have the
cash) to pay someone US$40/hour for programming efforts (especially when
I know it'd be a 8-12 week job), but I *can* afford to donate a few
hundred bucks getting someone hardware who has the know-how to fix or
test things much better than myself.  Most of the time though I'm told
I have the hardware I need -- it's a matter of finding the time!

Ain't that the truth.  :-)

Besides working on ports (which I've been slacking on as of late), this
is how I try to help/contribute to the FreeBSD community.

 The best one can do without massive buffer cache work is what firewire
 does: it has one attachment to handle all umass devices.  When the
 device goes away, it pauses all operations to that device.  If the
 device comes back, it resumes the I/O .  If the device never comes
 back, then the I/O never finishes.

This sounds good.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
[LoN]Kamikaze [EMAIL PROTECTED] writes:
: Oliver Fromme wrote:
:  Momchil Ivanov wrote:
:On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
: Josh Paetzel wrote:
:  Yes, it's expected behavior.  The workaround is to not unplug mounted
:  devices. (There's nothing special about USB here, if you unplugged an
:  IDE drive you'd get the same behavior)
: 
: Wouldn't it make some sense not to panic if mounted devices that are in
: sync get removed? A few applications might get in trouble, but that's
: hardly a reason to bring a whole system down.
:
:I don`t know how things work, but shutting down the system when some
:mounted fs is no longer present seems like the wrong thing to me.
:  
:  As Josh wrote, it's expected.  The problem is known
:  to exist for a long time already (probably as long
:  as FreeBSD itself exists), and if there was an easy
:  solution, certainly someone would have fixed it.
: 
: I remember on 5.3 I removed a mounted USB stick. The system did not panic, all
: I had to do was to plug the stick back in to be able to unmount it. So the
: behaviour has been more tolerant, in the past.

I'm pretty sure that 5.3 panics when you do this.  At least my 5.3
machine at work did last time I tried it, which was just last week.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Norberto Meijome [EMAIL PROTECTED] writes:
: re. USB disks, could we not by default use amd to mount USB devices? It seems
: the obvious native replacement for hald + polkitd + dbus I use in XFCE with
: Thunar on my laptop...

Won't work.  Once the device driver is already gone and devd/dbus gets
the notification, it is already too late.  umount -f will cause I/O to
a device that no longer exists, causing the panic.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Momchil Ivanov [EMAIL PROTECTED] writes:
: What is then the reason for the kernel not being able to unmount a
: filesystem whose provider is no longer present?

The problem is that the device driver has wound down, deallocated
memory, etc.  Now the kernel comes along with stale references to the
device and panic ensues.  It is really just that simple.  There's no
replacement of the now-dead device with dead calls.

And even if you fixed that, most of the file systems in the tree today
do not tolerate errors on writes at all and that also leads to
panics.  This is why firewire freezes the I/Os rather than failing
them (and why umount -f on a firewire drive hangs).

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Daniel O'Connor

Nikola Lecic wrote:

http://translate.google.com/translate?u=http%3A%2F%2Fwww.opennet.ru%2Fopenforum%2FvsluhforumID9%2F6467.htmllangpair=ru%7Cenhl=enie=UTF8

Useful? Seems comprehensible enough (maybe a wrong impression since I
understand Russian text).


I'm not a VFS guru, alas :)
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread [LoN]Kamikaze
M. Warner Losh wrote:
 In message: [EMAIL PROTECTED]
 Baldur Gislason [EMAIL PROTECTED] writes:
 : I vaguely remember being able to yank out USB drives in 5.x and just make
 : usbd execute a forced umount without any problems. FAT32 drives mind you.
 : On 6.2 I haven't even been able to unplug a USB drive even if I unmount it
 : first, always results in a kernel panic.
 
 This has never worked.  Not even on 5.x.  Or 4.10.  I've tested these
 both recently accidentally...
 
 Warner

As I mentioned earlier I remember it working during the 5.3 era on Stable, at
some point it worked. I even remember removing my CD-Rom drive from my Thinkpad
without running atacontrol detach. The system just took it and the drive just
continued working after I put it back in.

Anyway, is there a way to convince the kernel that removable devices are NFS
mounts? I suppose there'd be an additional layer required that clusters file
operations to consistent atomic operations similar to NFS.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Josh Paetzel
On Thursday 19 July 2007, M. Warner Losh wrote:
 In message: [EMAIL PROTECTED]

 Jeremy Chadwick [EMAIL PROTECTED] writes:
 : If someone wants to work on this and needs devices/toys (thumb
 : drives, external enclosures + hard disks), let me know, I will be
 : more than happy to buy them the hardware needed.

 Willing to fund the work on it too?  This is a volunteer project,
 and you have to motivate people to work on this.  Tirades in
 mailing lists has proven to be ineffective in the past.

 I've looked at the issue, and generically, if a device goes away,
 it is *HARD* to not panic.  The same thing happens if you eject a
 CF card in a PC Card adapter in a PC Card slot.

 The best one can do without massive buffer cache work is what
 firewire does: it has one attachment to handle all umass devices. 
 When the device goes away, it pauses all operations to that device.
  If the device comes back, it resumes the I/O .  If the device
 never comes back, then the I/O never finishes.

 Warner


Just curious, but what, if any, is the performance hit with this 
strategy?  I could care less about performance on a usb stick, but if 
we are talking about changes that are going to affect all filesystems 
regardless of storage device implimentation then I'm sort of 
interested.

eg: I wouldn't be happy trading filesystem performance for avoiding a 
panic that is trivial to avoid in the first place.

-- 
Thanks,

Josh Paetzel


pgpmLTsui8umW.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread Ian Smith
On Thu, 19 Jul 2007, M. Warner Losh wrote:
  In message: [EMAIL PROTECTED]
  [LoN]Kamikaze [EMAIL PROTECTED] writes:
  : Oliver Fromme wrote:
  :  Momchil Ivanov wrote:
  :On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
  : Josh Paetzel wrote:
  :  Yes, it's expected behavior.  The workaround is to not unplug 
  mounted
  :  devices. (There's nothing special about USB here, if you 
  unplugged an
  :  IDE drive you'd get the same behavior)
  : 
  : Wouldn't it make some sense not to panic if mounted devices that 
  are in
  : sync get removed? A few applications might get in trouble, but 
  that's
  : hardly a reason to bring a whole system down.
  :
  :I don`t know how things work, but shutting down the system when some
  :mounted fs is no longer present seems like the wrong thing to me.
  :  
  :  As Josh wrote, it's expected.  The problem is known
  :  to exist for a long time already (probably as long
  :  as FreeBSD itself exists), and if there was an easy
  :  solution, certainly someone would have fixed it.
  : 
  : I remember on 5.3 I removed a mounted USB stick. The system did not panic, 
  all
  : I had to do was to plug the stick back in to be able to unmount it. So the
  : behaviour has been more tolerant, in the past.
  
  I'm pretty sure that 5.3 panics when you do this.  At least my 5.3
  machine at work did last time I tried it, which was just last week.

5.4 too.  Now at 5.5-STABLE, on APM if it matters, I've had much fun
several times having the laptop, when on battery, suspend/resume with a
USB stick mounted on da0 (msdosfs or ufs) - without removing the device.

With rc.suspend kldunload'ing usb and rc.resume kldload'ing it (as
recommended for UHCI and, iirc, needed here) then on resume umass0
detaches  reattaches, but assigns the stick to da1.  mount still shows
the da0sX mount.  It doesn't panic unless / until something accesses
da0.  So at least I usually get a window to reboot, the only way out. 

Sure I've learned don't do that but it's painful when I forget ..

Might this new USB stack offer any relief to this need to unload/reload
usb on s/r, and if so keep hold of a mount (assuming the stick remains)?

Cheers, Ian

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-19 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Jeremy Chadwick [EMAIL PROTECTED] writes:
: On Thu, Jul 19, 2007 at 08:48:21AM -0600, M. Warner Losh wrote:
:  In message: [EMAIL PROTECTED]
:  Jeremy Chadwick [EMAIL PROTECTED] writes:
:  : If someone wants to work on this and needs devices/toys (thumb drives,
:  : external enclosures + hard disks), let me know, I will be more than
:  : happy to buy them the hardware needed.
:  
:  Willing to fund the work on it too?  This is a volunteer project, and
:  you have to motivate people to work on this.
: 
: I'm one man with a single day job.  I only make so much money a year,
: most of which goes to rent and co-location bills.  Remaining amounts
: usually go to small hobby projects of mine, or donating money to folks
: like phk@ to work on features that I'll benefit from (serial console
: work comes to mind, ditto with BTX fixes).
: 
: What I'm saying is that I can't afford (literally -- I don't have the
: cash) to pay someone US$40/hour for programming efforts (especially when
: I know it'd be a 8-12 week job), but I *can* afford to donate a few
: hundred bucks getting someone hardware who has the know-how to fix or
: test things much better than myself.  Most of the time though I'm told
: I have the hardware I need -- it's a matter of finding the time!

A total fix would be a lot of effort.  Some of it would be easy to
incrementally adopt, while other parts would have ripples far and
wide.

: Besides working on ports (which I've been slacking on as of late), this
: is how I try to help/contribute to the FreeBSD community.

Yea.  I understand that.

:  The best one can do without massive buffer cache work is what firewire
:  does: it has one attachment to handle all umass devices.  When the
:  device goes away, it pauses all operations to that device.  If the
:  device comes back, it resumes the I/O .  If the device never comes
:  back, then the I/O never finishes.
: 
: This sounds good.

It likely is the easiest 'bang for buck' solution.

Warner
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Momchil Ivanov
Hi,

I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007 and 
accidently unplugged the USB hub to which my external hdd together with a 
mouse were connected and this caused my machine to freeze for some seconds 
and then reboot. At that moment the hdd was mounted and I was playing music 
out of it.
After that I tried to reproduce it :) so just plugged only the hdd directly, 
mounted it and started playing music files from it. When I unplugged the USB 
cable the same thing happened: short freeze, and then reboot.
Is this expected behaviour? And is there some way to avoid the freeze and 
reboot?

Thanks.

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Mark Linimon
On Wed, Jul 18, 2007 at 11:42:26AM +0200, Momchil Ivanov wrote:
 accidently unplugged the USB hub to which my external hdd together with a 
 mouse were connected and this caused my machine to freeze for some seconds 
 and then reboot.

Yes, this is a known problem, for which there is no workaround at the moment.

mcl
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Josh Paetzel
On Wednesday 18 July 2007, Momchil Ivanov wrote:
 Hi,

 I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007
 and accidently unplugged the USB hub to which my external hdd
 together with a mouse were connected and this caused my machine to
 freeze for some seconds and then reboot. At that moment the hdd was
 mounted and I was playing music out of it.
 After that I tried to reproduce it :) so just plugged only the hdd
 directly, mounted it and started playing music files from it. When
 I unplugged the USB cable the same thing happened: short freeze,
 and then reboot. Is this expected behaviour? And is there some way
 to avoid the freeze and reboot?

 Thanks.

Yes, it's expected behavior.  The workaround is to not unplug mounted 
devices. (There's nothing special about USB here, if you unplugged an 
IDE drive you'd get the same behavior)

-- 
Thanks,

Josh Paetzel


pgpUBWpa2fyAG.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread [LoN]Kamikaze
Josh Paetzel wrote:
 On Wednesday 18 July 2007, Momchil Ivanov wrote:
 Hi,

 I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007
 and accidently unplugged the USB hub to which my external hdd
 together with a mouse were connected and this caused my machine to
 freeze for some seconds and then reboot. At that moment the hdd was
 mounted and I was playing music out of it.
 After that I tried to reproduce it :) so just plugged only the hdd
 directly, mounted it and started playing music files from it. When
 I unplugged the USB cable the same thing happened: short freeze,
 and then reboot. Is this expected behaviour? And is there some way
 to avoid the freeze and reboot?

 Thanks.
 
 Yes, it's expected behavior.  The workaround is to not unplug mounted 
 devices. (There's nothing special about USB here, if you unplugged an 
 IDE drive you'd get the same behavior)
 

Wouldn't it make some sense not to panic if mounted devices that are in sync
get removed? A few applications might get in trouble, but that's hardly a
reason to bring a whole system down.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Momchil Ivanov
On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
 Josh Paetzel wrote:
  On Wednesday 18 July 2007, Momchil Ivanov wrote:
  Hi,
 
  I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007
  and accidently unplugged the USB hub to which my external hdd
  together with a mouse were connected and this caused my machine to
  freeze for some seconds and then reboot. At that moment the hdd was
  mounted and I was playing music out of it.
  After that I tried to reproduce it :) so just plugged only the hdd
  directly, mounted it and started playing music files from it. When
  I unplugged the USB cable the same thing happened: short freeze,
  and then reboot. Is this expected behaviour? And is there some way
  to avoid the freeze and reboot?
 
  Thanks.
 
  Yes, it's expected behavior.  The workaround is to not unplug mounted
  devices. (There's nothing special about USB here, if you unplugged an
  IDE drive you'd get the same behavior)

 Wouldn't it make some sense not to panic if mounted devices that are in
 sync get removed? A few applications might get in trouble, but that's
 hardly a reason to bring a whole system down.

I don`t know how things work, but shutting down the system when some mounted 
fs is no longer present seems like the wrong thing to me. It`s surely safe :) 
just bring everything down in order to ensure not messing things ups. But 
nowadays there are a lot of USB devices and umounting every time is something 
that one is surely going to forget once and ooops everyting goes down.
If the same thing happens when a network fs is mounted (say NFS or SMBFS) and 
then becomes unavailable due to network outages (wireless connections break 
easily compared to cable connections, and nowadays the former become 
popular), then I think it should be fixed.
Windows doesn`t reboot if you unplug the usb or network cable, which I think 
is the right way of handling these kind of situations.

Idea: do something like umount -f when a fs becomes unavailabe, just tell 
every program that files are unaccessible?

I don`t have the programming skills and knowledge of how freebsd works, that`s 
why I can only help with feedback and ideas :) Shutting down the system 
without user`s desire seems like a problem to me, regardless of the reason. 
And problems are there to be solved.

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  


pgpIlHaW3FprO.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Baldur Gislason
I vaguely remember being able to yank out USB drives in 5.x and just make
usbd execute a forced umount without any problems. FAT32 drives mind you.
On 6.2 I haven't even been able to unplug a USB drive even if I unmount it
first, always results in a kernel panic.

Baldur


On Wed, Jul 18, 2007 at 08:39:46AM -0500, Josh Paetzel wrote:
 On Wednesday 18 July 2007, Momchil Ivanov wrote:
  Hi,
 
  I am running FreeBSD 6.2-STABLE #11: Sat Jul 14 16:27:12 CEST 2007
  and accidently unplugged the USB hub to which my external hdd
  together with a mouse were connected and this caused my machine to
  freeze for some seconds and then reboot. At that moment the hdd was
  mounted and I was playing music out of it.
  After that I tried to reproduce it :) so just plugged only the hdd
  directly, mounted it and started playing music files from it. When
  I unplugged the USB cable the same thing happened: short freeze,
  and then reboot. Is this expected behaviour? And is there some way
  to avoid the freeze and reboot?
 
  Thanks.
 
 Yes, it's expected behavior.  The workaround is to not unplug mounted 
 devices. (There's nothing special about USB here, if you unplugged an 
 IDE drive you'd get the same behavior)
 
 -- 
 Thanks,
 
 Josh Paetzel



___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Oliver Fromme
Momchil Ivanov wrote:
  On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
   Josh Paetzel wrote:
Yes, it's expected behavior.  The workaround is to not unplug mounted
devices. (There's nothing special about USB here, if you unplugged an
IDE drive you'd get the same behavior)
   
   Wouldn't it make some sense not to panic if mounted devices that are in
   sync get removed? A few applications might get in trouble, but that's
   hardly a reason to bring a whole system down.
  
  I don`t know how things work, but shutting down the system when some
  mounted fs is no longer present seems like the wrong thing to me.

As Josh wrote, it's expected.  The problem is known
to exist for a long time already (probably as long
as FreeBSD itself exists), and if there was an easy
solution, certainly someone would have fixed it.

Just remember to always umount first, and you're safe.
In the early 90s I panicked a FreeBSD machine by
removing a floppy disk that was mounted.  I did that
mistake only once -- afterwards I always remembered.

If you have problems remembering, another work-around
is to use the auto mounter daemon (amd(8)).  It umounts
file systems automatically that are not in use.
Another nice feature of amd(8) is that you don't have
to mount the file system either -- Simply plug the USB
stick in, then access it, and amd(8) will automatically
mount it for you.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

I learned Java 3 years before Python.  It was my language of
choice.  It took me two weekends with Python before I was more
productive with it than with Java. -- Anthony Roberts
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Jeremy Chadwick
On Wed, Jul 18, 2007 at 05:03:03PM +0200, Momchil Ivanov wrote:
 Windows doesn`t reboot if you unplug the usb or network cable, which I 
 think 
 is the right way of handling these kind of situations.

Windows also (as of XP; I don't think it was this way in 2000) by
default disables read/write caching on all USB-plugged storage devices.

This was done because people were unplugging USB storage devices without
shutting them down (going to the systray and selecting the device then
choosing Stop to ensure all caches were flushed and data on the device
had been written).  The performance hit is pretty major, but the
attitude is safety first.

You can, of course, toggle the caching feature per device/drive, but
you'll need to Stop the device before removing it from the USB bus.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Momchil Ivanov
On Wednesday 18 July 2007 17:41:04 Oliver Fromme wrote:
 As Josh wrote, it's expected.  The problem is known
 to exist for a long time already (probably as long
 as FreeBSD itself exists), and if there was an easy
 solution, certainly someone would have fixed it.

 Just remember to always umount first, and you're safe.
 In the early 90s I panicked a FreeBSD machine by
 removing a floppy disk that was mounted.  I did that
 mistake only once -- afterwards I always remembered.

 If you have problems remembering, another work-around
 is to use the auto mounter daemon (amd(8)).  It umounts
 file systems automatically that are not in use.
 Another nice feature of amd(8) is that you don't have
 to mount the file system either -- Simply plug the USB
 stick in, then access it, and amd(8) will automatically
 mount it for you.

 Best regards
Oliver

I started the thread just because it hit me today. I wanted to disconnect my 
mouse and forgot that the hdd is connected to the same hub, I realized that 
after having unplugged the usb hub and saw the system freeze. I know that 
this has been an issue for a long time. With cdroms it`s easy, the tray won`t 
open until you umount the cd fs, floppies. nowadays they have been 
replaced by usb sticks, but they have no trays as cdroms do :) moreover 
people use other usb storages too and unplugging those is just as simple as 
unpluging the cable.

I think this is a critical problem and needs to be addressed, avoiding it 
doesn`t solve it.

As technology advances I think FreeBSD has to advance too. You said you 
paniced a system in the early 90s, which is more than 10 years from now. In 
the past floppy disks were maybe the only problem, but nowadays as storage is 
cheap more and more people use USB storage devices, and these are easy to 
unplug. It`s even worse if you have a laptop, since it`s easier to connect 
everything to a hub (mouse, hdds, other usb stuff) and connect/disconnect it.

In the days before common storage devices (hard drives) where fixed inside the 
computer`s case, so unpluging a hard drive when the computer was running was 
considered as insane, so panicing is ok. Nowadays things have changed. USB 
(maybe Firewire too, have no experience with that) offers a simple way to 
connect/disconnect devices to your computer (here I have to note: not just 
one!), having a laptop and 1,2,3 or even more external storage devices is 
something usual.
That`s why I think this particular problem needs to be addressed.

Thanks for the tip about amd(8) I will give it a try.

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  


pgpPIKc8k2BdR.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Baldur Gislason
This really struck me as a problem when I had a short power outage and my 
external USB hard drive
wasn't plugged into the UPS. Laptop didn't reboot from the power outage but it 
rebooted
anyway because it lost a hard drive (which was mounted but I wasn't doing any 
work on)

Baldur

On Wed, Jul 18, 2007 at 06:30:44PM +0200, Momchil Ivanov wrote:
 On Wednesday 18 July 2007 17:41:04 Oliver Fromme wrote:
  As Josh wrote, it's expected.  The problem is known
  to exist for a long time already (probably as long
  as FreeBSD itself exists), and if there was an easy
  solution, certainly someone would have fixed it.
 
  Just remember to always umount first, and you're safe.
  In the early 90s I panicked a FreeBSD machine by
  removing a floppy disk that was mounted.  I did that
  mistake only once -- afterwards I always remembered.
 
  If you have problems remembering, another work-around
  is to use the auto mounter daemon (amd(8)).  It umounts
  file systems automatically that are not in use.
  Another nice feature of amd(8) is that you don't have
  to mount the file system either -- Simply plug the USB
  stick in, then access it, and amd(8) will automatically
  mount it for you.
 
  Best regards
 Oliver
 
 I started the thread just because it hit me today. I wanted to disconnect my 
 mouse and forgot that the hdd is connected to the same hub, I realized that 
 after having unplugged the usb hub and saw the system freeze. I know that 
 this has been an issue for a long time. With cdroms it`s easy, the tray won`t 
 open until you umount the cd fs, floppies. nowadays they have been 
 replaced by usb sticks, but they have no trays as cdroms do :) moreover 
 people use other usb storages too and unplugging those is just as simple as 
 unpluging the cable.
 
 I think this is a critical problem and needs to be addressed, avoiding it 
 doesn`t solve it.
 
 As technology advances I think FreeBSD has to advance too. You said you 
 paniced a system in the early 90s, which is more than 10 years from now. In 
 the past floppy disks were maybe the only problem, but nowadays as storage is 
 cheap more and more people use USB storage devices, and these are easy to 
 unplug. It`s even worse if you have a laptop, since it`s easier to connect 
 everything to a hub (mouse, hdds, other usb stuff) and connect/disconnect it.
 
 In the days before common storage devices (hard drives) where fixed inside 
 the 
 computer`s case, so unpluging a hard drive when the computer was running was 
 considered as insane, so panicing is ok. Nowadays things have changed. USB 
 (maybe Firewire too, have no experience with that) offers a simple way to 
 connect/disconnect devices to your computer (here I have to note: not just 
 one!), having a laptop and 1,2,3 or even more external storage devices is 
 something usual.
 That`s why I think this particular problem needs to be addressed.
 
 Thanks for the tip about amd(8) I will give it a try.
 
 -- 
 PGP KeyID: 0x3118168B
 Keyserver: pgp.mit.edu
 Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
   



___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Jeremy Chadwick
On Wed, Jul 18, 2007 at 06:30:44PM +0200, Momchil Ivanov wrote:
 On Wednesday 18 July 2007 17:41:04 Oliver Fromme wrote:
  As Josh wrote, it's expected.  The problem is known
  to exist for a long time already (probably as long
  as FreeBSD itself exists), and if there was an easy
  solution, certainly someone would have fixed it.
 
 I think this is a critical problem and needs to be addressed, avoiding it 
 doesn`t solve it.

I agree.

I also have a hard time believing that the reason it hasn't been fixed
is because there isn't an easy fix.  I'm under the impression it
hasn't been fixed because either no one cares enough to fix it (using
the workaround as a scapegoat excuse), or because the majority of people
do not use USB-based storage devices.

All of this brings me back a few years when I went on a quest to write a
application that interfaced with a Logitech USB webcam for FreeBSD (for
a streaming fishtank camera).  I found that USB alternative indexes were
broken (the code was there, but did not work), which the camera relied
upon.  When I reported the issue to the FreeBSD USB stack maintainer at
the time (who will remain nameless since he enjoyed arguing rather than
fixing or working with me), I was told 2 things: I just ported this
from NetBSD, don't blame me, Alt. indexes aren't commonly used so I
don't really care.

So, based on my experience as documented above, I would say the reasons
I listed are dead on.

Bottom line here is that the kernel panics when removing a USB device
that has filesystems mounted.  This shouldn't happen.  Spitting out
errors on the console is one thing, but a panic is another.  Sometimes
things cannot be avoided (re: unmount and you'll be fine), such as
cats pulling on USB hub AC power cables and other such things.

If someone wants to work on this and needs devices/toys (thumb drives,
external enclosures + hard disks), let me know, I will be more than
happy to buy them the hardware needed.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Mark Linimon
On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
 Bottom line here is that the kernel panics when removing a USB device
 that has filesystems mounted.

s/USB //

 I also have a hard time believing that the reason it hasn't been fixed
 is because there isn't an easy fix.  I'm under the impression it
 hasn't been fixed because either no one cares enough to fix it (using
 the workaround as a scapegoat excuse), or because the majority of people
 do not use USB-based storage devices.

The reason is not the USB stack; the reason (IIRC) is that the FreeBSD
VM was written with the default assumption that Devices Never Go Away.
A large rewrite, I'm told, will be needed to fix this, and the code is
convoluted and tricky.

No one finds the situation acceptable; introducing the scapegoat word
isn't going to win you any support.  The problem is not a weekend's worth
of work to fix, nor does it have anything to do with avoidance by one
particular maintainer, which you apparently had encountered before.

mcl
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Zaphod Beeblebrox

Nobody's said what the problem is.  I'm not a filesystem code monkey, but
IIRC, the problem is that the filesystem plays fast and loose with pointers
and is too closely related to the VM.

One solution is (as mentioned) a userland filesystem that doesn't panic.
automount approximates this if you set the disconnect interval short ( 5
seconds).

The other way to look at this, though, is the general goal of not panicing
when it can be avoided.  As a research OS, it's my feeling that BSD derived
unixes have followed the if in doubt, panic regime.  I don't think this is
appropriate to a modern desktop or server OS.

To my mind, an OS should only panic if there are indications of hardware
corruption in a subsystem that can't be turned off.  Ie: memory bad: panic;
controller bad, turn off controller.

In this particular case, we have unmount -f.  If there are no dirty buffers,
the USB system triggering the equivalent of unomunt -f should succeed.  If
we only mount usb devices async, this should be sufficient for most cases.
If there are dirty buffers, what do we loose by just forgetting about them?
The filesystem on the device is already as corrupt as its going to be...
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Momchil Ivanov
On Wednesday 18 July 2007 19:34:06 Mark Linimon wrote:
 On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
  Bottom line here is that the kernel panics when removing a USB device
  that has filesystems mounted.

 s/USB //

Just a dumb question: what does umount -f does? And doing something like 
that when a fs goes away shouldn`t fix it?

If the problem is in general with a file system, regardless of the provider, 
then what does one do when a mounted smbfs becomes unavailable due to remote 
host down, no route to host or some other network related problems? Same 
question for NFS mounted filesystems?

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  


pgpfXbuzcbviO.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Kris Moore


Momchil Ivanov wrote:
 On Wednesday 18 July 2007 19:34:06 Mark Linimon wrote:
 On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
 Bottom line here is that the kernel panics when removing a USB device
 that has filesystems mounted.
 s/USB //
 
 Just a dumb question: what does umount -f does? And doing something like 
 that when a fs goes away shouldn`t fix it?
 
 If the problem is in general with a file system, regardless of the provider, 
 then what does one do when a mounted smbfs becomes unavailable due to remote 
 host down, no route to host or some other network related problems? Same 
 question for NFS mounted filesystems?
 
 
 
 
 
 !DSPAM:1,469e538b20763944420674!


Wow, quite a thread going on over this issue. I'll throw my 2cents into
the ring also :)

From a desktop perspective, it makes total sense to not have the system
crash just because a USB disk was unplugged while mounted. When a new
end user does this for the first time and the system crashes, usually
the first thing they assume is that it's a bug. Then somebody like me
comes around and tells them to unmount it first. Then usually the next
thing they say is something along the lines of That's so early 90's,
why can't you guys get your act together?

I can understand requiring unmounting for devices such as CD's or
internal IDE / SCSI hard drives. With a CD at least you can physically
lock the drive bay to prevent the user from ejecting until unmounted
first. However, with a USB the ballgame changes, the whole concept is to
be hot-swappable, plugin and unplug at will. If a normal desktop user
copies a file to a USB disk and the file transfer dialog is done, then
they should be able to unplug it, without a total system crash.

That being said, I think it would be a good idea to at least have the
kernel / HAL or some process maybe warn the user that they should
unmount the USB disk first, to prevent data loss at minimum. But I think
this can be improved, so you don't have to deal with an entire system
panic :P When that happens you gotta reboot, fsck, and run the risk of
something really being corrupted on the drive :(


-- 

Kris Moore
PC-BSD Software
http://www.pcbsd.com


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Josh Paetzel
On Wednesday 18 July 2007, Mark Linimon wrote:
 On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
  Bottom line here is that the kernel panics when removing a USB
  device that has filesystems mounted.

 s/USB //

  I also have a hard time believing that the reason it hasn't been
  fixed is because there isn't an easy fix.  I'm under the
  impression it hasn't been fixed because either no one cares
  enough to fix it (using the workaround as a scapegoat excuse), or
  because the majority of people do not use USB-based storage
  devices.

 The reason is not the USB stack; the reason (IIRC) is that the
 FreeBSD VM was written with the default assumption that Devices
 Never Go Away. A large rewrite, I'm told, will be needed to fix
 this, and the code is convoluted and tricky.

 No one finds the situation acceptable; introducing the scapegoat
 word isn't going to win you any support.  The problem is not a
 weekend's worth of work to fix, nor does it have anything to do
 with avoidance by one particular maintainer, which you apparently
 had encountered before.

 mcl

Panicing really is the right thing to do with the current 
architecture.  Not panicing when a mounted filesystem disappears runs 
the risk of corrupting other mounted filesystems.

Mark is entirely correct, FreeBSD faces an architecture problem here 
in that the vm and filesystems we have today were not designed in an 
era when they could just disappear from a running system.  The BSD 
way isn't to apply a quick and dirty little hack to fix 
the 'problem', it's to design the system properly.  And this is 
assuming a quick and dirty hack even exists.

The other problem you're running in to with UFS anyways is that there 
is no chance to 'unmount' the filesystem when you disconnect the 
drive.  By the time anything has a chance to realize it's gone it's 
too late.  Whether the disk is in the middle of a write, still has 
buffers to be written out, or is perfectly clean and needs to just be 
marked as such by the time the OS realizes any of that needs to be 
done the drive is no longer physically connected to the computer.

What might need to happen is a redesign of the vm subsystem so that it 
can safely deal with mounted filesystems going away, and designing a 
filesystem that doesn't need to be unmounted specifically for 
removeable devices.  Doesn't sound trivial to me.

Or

You can just not remove devices with mounted filesystems from your 
computer.

-- 
Thanks,

Josh Paetzel


pgpBhbiMYM6HX.pgp
Description: PGP signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Stefan Esser
Oliver Fromme wrote:
 Momchil Ivanov wrote:
   On Wednesday 18 July 2007 15:52:42 [LoN]Kamikaze wrote:
Josh Paetzel wrote:
 Yes, it's expected behavior.  The workaround is to not unplug mounted
 devices. (There's nothing special about USB here, if you unplugged an
 IDE drive you'd get the same behavior)

Wouldn't it make some sense not to panic if mounted devices that are in
sync get removed? A few applications might get in trouble, but that's
hardly a reason to bring a whole system down.
   
   I don`t know how things work, but shutting down the system when some
   mounted fs is no longer present seems like the wrong thing to me.
 
 As Josh wrote, it's expected.  The problem is known
 to exist for a long time already (probably as long
 as FreeBSD itself exists), and if there was an easy
 solution, certainly someone would have fixed it.

I have to check this, but AFAIK this problem exists only for
devices/partitions that are mounted R/W. Do you happen to
know this? (I can not risk to crash my box right now for a
test ;-)

There once was an autofs implementation, but IIRC it has
later been removed. It could not only automatically mount
removable media, but it could also help with the problem
of devices that are rarely written to, but still mounted
R/W just in case for easy write-access.


Long time ago I had the idea that a clean file system could
be mounted R/O after a short delay. When all dirty buffers
are flushed, the device could be forcefully disconnected
without causing inconsistencies in the kernel. If there are
no open file descriptors, the super-block could be written
with the clean flag set, to signal that no fsck is needed
when the partition is mounted next time.

Internally, the device can be treated as R/O, with the only
exeption that an attempted write is not rejected, but that
it instead triggers the change back to R/W operation (this
means setting the in-RAM copy of the super-block to dirty
before the write is allowed to proceed as normal).

Removable devices and dealing with a device that is gone and
re-appears (either the same device or one that takes its place)
needs special consideration, e.g. by checking a disk label and
flushing cached blocks that were associated with the device
that now is definitely gone.

I had this idea back when floppy disks were common, but with
USB memory sticks and devices the same situation exists ...

The mode change to R/O could be triggered by a timer after
the necessary condition exists (e.g. half a second after the
last write to the device with no dirty buffers left).

The system already knows whether there are dirty buffers for
a partition, it is not hard to detect this case. The other
parameter of interest is whether there are any open files on
that partition (which decides whether the super-block can be
marked as clean).

This functionality could be implemented within an autofs as
a special case (mount only R/O and upgrade only when needed
and for as long as necessary), but I think it should be not
too hard to add as a small in-kernel modification ...

Regards, STefan
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Jeremy Chadwick
On Wed, Jul 18, 2007 at 11:54:19AM -0700, Kris Moore wrote:
 That being said, I think it would be a good idea to at least have the
 kernel / HAL or some process maybe warn the user that they should
 unmount the USB disk first, to prevent data loss at minimum. But I think
 this can be improved, so you don't have to deal with an entire system
 panic :P When that happens you gotta reboot, fsck, and run the risk of
 something really being corrupted on the drive :(

So there's two issues here:

1) Kernel panics when a device (regardless of type (USB, SATA, etc.))
is removed from the system with filesystems mounted,

2) Concern over data loss when device is removed.

As I mentioned earlier in the thread, Windows addresses #2 by marking
all filesystems on USB storage devices (thumb drives, HDDs, etc.) as
synchronous (e.g. mount -o sync).  The impact is slow I/O, but it's
safe.

It seems like we'd be able to implement such a transparent feature
into the subsystem where filesystems mounted from USB devices would use
synchronous I/O (mount -o sync).  I don't know how this would be coded,
since there would have to be some way to figure out a physical device
type (USB mass storage devices show up as /dev/daXXX).

Providing an override option for those who know what they're doing,
(umount /mnt then physically remove device) would be nice too.

This would alleviate concerns over data loss, would it not?

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Ivan Voras
Zaphod Beeblebrox wrote:

 One solution is (as mentioned) a userland filesystem that doesn't panic.
 automount approximates this if you set the disconnect interval short ( 5
 seconds).

Unfortunately the approximation is far from perfect because it takes
noticable time to mount a msdosfs on large drives (I think the FAT is
being read?).

 The other way to look at this, though, is the general goal of not
 panicing
 when it can be avoided.  As a research OS, it's my feeling that BSD derived
 unixes have followed the if in doubt, panic regime.  I don't think
 this is
 appropriate to a modern desktop or server OS.

Agreed very much, though some of the older hackers here seem to like the
old approach.



signature.asc
Description: OpenPGP digital signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Kris Moore
Jeremy Chadwick wrote:
 On Wed, Jul 18, 2007 at 11:54:19AM -0700, Kris Moore wrote:
 That being said, I think it would be a good idea to at least have the
 kernel / HAL or some process maybe warn the user that they should
 unmount the USB disk first, to prevent data loss at minimum. But I think
 this can be improved, so you don't have to deal with an entire system
 panic :P When that happens you gotta reboot, fsck, and run the risk of
 something really being corrupted on the drive :(
 
 So there's two issues here:
 
 1) Kernel panics when a device (regardless of type (USB, SATA, etc.))
 is removed from the system with filesystems mounted,
 
 2) Concern over data loss when device is removed.
 
 As I mentioned earlier in the thread, Windows addresses #2 by marking
 all filesystems on USB storage devices (thumb drives, HDDs, etc.) as
 synchronous (e.g. mount -o sync).  The impact is slow I/O, but it's
 safe.
 
 It seems like we'd be able to implement such a transparent feature
 into the subsystem where filesystems mounted from USB devices would use
 synchronous I/O (mount -o sync).  I don't know how this would be coded,
 since there would have to be some way to figure out a physical device
 type (USB mass storage devices show up as /dev/daXXX).
 
 Providing an override option for those who know what they're doing,
 (umount /mnt then physically remove device) would be nice too.
 
 This would alleviate concerns over data loss, would it not?
 



This sounds like an excellent idea to me. If something along these lines
were implemented, it would be very helpful for us on the desktop end of
things.

-- 

Kris Moore
PC-BSD Software
http://www.pcbsd.com
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Ivan Voras
Josh Paetzel wrote:

 designing a 
 filesystem that doesn't need to be unmounted specifically for 
 removeable devices.  

Or just do what Windows does on its hard-drive-mounted NTFS and MSDOS
file systems and mark it clean after several seconds of inactivity. This
also helps solve other problems like power failures, laptop battery
drainage (in its common form and when the battery dies while the system
is suspened).




signature.asc
Description: OpenPGP digital signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Ivan Voras
Mark Linimon wrote:

 The reason is not the USB stack; the reason (IIRC) is that the FreeBSD
 VM was written with the default assumption that Devices Never Go Away.
 A large rewrite, I'm told, will be needed to fix this, and the code is
 convoluted and tricky.

I also feel that the institutial knowledge about the VM+VFS+UFS
conglomerate seems to be going away. There were many attempts to port
file systems to FreeBSD that have stopped dead once they've reached
read-only phase, and recent problems with UFS looked really ugly (I
don't even know if they are solved - I'm scared of filling up UFS drives
right now :) ). My first production ZFS panicked the other day so ZFS is
not yet the answer.

(And yes, I know I'm complaining without suggesting solutions).



signature.asc
Description: OpenPGP digital signature


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Don Lewis
On 18 Jul, Momchil Ivanov wrote:

 If the problem is in general with a file system, regardless of the provider, 
 then what does one do when a mounted smbfs becomes unavailable due to remote 
 host down, no route to host or some other network related problems? Same 
 question for NFS mounted filesystems?

In the case of NFS, nothing happens if the filesystem is idle.  If the
filesystem is active, any pending operations are retried indefinitely by
periodically resending the I/O requests if the file system is hard
mounted.  If the filesystem is soft mounted, then the I/O requests are
eventually timed out with the appropriate error status returned to the
process on the client.

An important difference between NFS and UFS is that a loss of network
connectivity (or a clean server reboot) can't cause any filesystem
inconsistencies in the NFS case because complex filesystem operations
that require multiple disk operations are treated as atomic operations
between the client and server.  For example, creating a new directory
requires a number of physical disk writes in the UFS case, and
unplugging the disk in the middle would result in an inconsistent
filesystem state.  In the NFS case, creating a new directory only
requires only one NFS operation over the wire, and the client is allowed
to keep retrying the operation until it receives a status response from
the server.  Retries might be necessary if either the request or the
response packet was dropped by the network, the server crashed, etc.

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Momchil Ivanov
On Wednesday 18 July 2007 21:03:10 Josh Paetzel wrote:
 On Wednesday 18 July 2007, Mark Linimon wrote:
  On Wed, Jul 18, 2007 at 10:05:59AM -0700, Jeremy Chadwick wrote:
   Bottom line here is that the kernel panics when removing a USB
   device that has filesystems mounted.
 
  s/USB //
 
   I also have a hard time believing that the reason it hasn't been
   fixed is because there isn't an easy fix.  I'm under the
   impression it hasn't been fixed because either no one cares
   enough to fix it (using the workaround as a scapegoat excuse), or
   because the majority of people do not use USB-based storage
   devices.
 
  The reason is not the USB stack; the reason (IIRC) is that the
  FreeBSD VM was written with the default assumption that Devices
  Never Go Away. A large rewrite, I'm told, will be needed to fix
  this, and the code is convoluted and tricky.
 
  No one finds the situation acceptable; introducing the scapegoat
  word isn't going to win you any support.  The problem is not a
  weekend's worth of work to fix, nor does it have anything to do
  with avoidance by one particular maintainer, which you apparently
  had encountered before.
 
  mcl

 Panicing really is the right thing to do with the current
 architecture.  Not panicing when a mounted filesystem disappears runs
 the risk of corrupting other mounted filesystems.

 Mark is entirely correct, FreeBSD faces an architecture problem here
 in that the vm and filesystems we have today were not designed in an
 era when they could just disappear from a running system.  The BSD
 way isn't to apply a quick and dirty little hack to fix
 the 'problem', it's to design the system properly.  And this is
 assuming a quick and dirty hack even exists.

 The other problem you're running in to with UFS anyways is that there
 is no chance to 'unmount' the filesystem when you disconnect the
 drive.  By the time anything has a chance to realize it's gone it's
 too late.  Whether the disk is in the middle of a write, still has
 buffers to be written out, or is perfectly clean and needs to just be
 marked as such by the time the OS realizes any of that needs to be
 done the drive is no longer physically connected to the computer.

I think you are missing the point here and it is that the drive is already 
gone, so you do not have to care about it. The state of the drive`s 
filesystem is of no interest since you cannot to anything to change it any 
more. The point is that the drive is gone. If you were in the middle of a 
write, you just return an error (like your disk is going physically bad/ some 
broken cable issue... for instance) and forget about the data you wanted to 
write, the drive is not there any more. 

Maybe I am naive and uneducated enough (don`t know how freebsd does things, 
nor am I a programmer) but I will give my 2 stotinki here.
The most natural way for me seems to be that the OS should just return errors 
to the programs trying any I/O on that drive. May be when a drive is 
unplugged the OS has to mark it and the mounted file systems as not being 
there until all opened files on it are closed, return errors for all I/O 
except for closing opened files. And when all files are closed consider the 
fs as unmounted and remove the drive from the kernel.

This is my idea of how things should be done. Ensuring that a file system is 
in a consistent state after drive disconnect is something completely 
different (wanted to discuss just disconnecting devices, not filesystems that 
can be disconnected without unmount, not ensuring fully operational file 
system even it a case of disconnected drive). One can try to implement 
something here (as mentioned in some of the replies), but not necessary. If 
the user has unpluged the device without unmounting it first he might be left 
with a broken file system on that drive, we cannot do anything, so we should 
not care about it, it`s his mistake and his fs fucked up. The point is that 
unpluging should not lead to system crash, which is in my opinion critical 
system error.

I as user I should be able to unplug any external device without crashing the 
OS. Doing this and thus leaving me with a broken filesystem or some other 
device issues should be considered my error. Thus I should learn the hard way 
to unmount first.

Designing a filesystem or some hacks to ensure consistent state after 
disconnect should not be in the scope of this thread and problem, I think.


 What might need to happen is a redesign of the vm subsystem so that it
 can safely deal with mounted filesystems going away, and designing a
 filesystem that doesn't need to be unmounted specifically for
 removeable devices.  Doesn't sound trivial to me.

 Or

 You can just not remove devices with mounted filesystems from your
 computer.

-- 
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
  
___
freebsd-stable@freebsd.org mailing 

Re: removing external usb hdd without unmounting causes reboot?

2007-07-18 Thread Norberto Meijome
On Wed, 18 Jul 2007 17:41:04 +0200 (CEST)
Oliver Fromme [EMAIL PROTECTED] wrote:

 If you have problems remembering, 

This is very interesting thread indeed

I have found that mounting remote SMB shares will panic the kernel too, but
only if i try to access it while 'gone' . If I remember correctly, if i thread
carefully around it, i can manage to shutdown everything and it will only panic
at the very last minute when the kernel tries to unmount.

And, from my point of view, the explanation 'well, don't remove your mounted
devices without unmounting them first' is rubbish - the problem is not
necessarily users  removing them, but ALL the reasons that could cause an
unwanted and unplanned removal. Like a network outage in the case of smbfs. or
someone killing the power on a USB device. I can't see why the whole kernel
should die on you. Yes, i understand there are architectural reasons for this -
then the architecture is not right anymore, i think.

 another work-around
 is to use the auto mounter daemon (amd(8)).  It umounts
 file systems automatically that are not in use.
 Another nice feature of amd(8) is that you don't have
 to mount the file system either -- Simply plug the USB
 stick in, then access it, and amd(8) will automatically
 mount it for you.


Now, something I dont understand  -  amd runs
at user level, and it mounts filesystems, and nothing dies when the filesystems
go away (other than the obvious cases for the applications trying to write to
the FS in question). Doesn't amd , at some point , have to tell the kernel
'please mount this filesystem' here or there? Isn't the kernel STILL involved
in all this? and why doesnt the kernel panic when the FS goes away? 

The same goes for hald - it doesn't work flawlessly, but it does the trick, and
i cant recall an instance when it crashed the kernel.

re. USB disks, could we not by default use amd to mount USB devices? It seems
the obvious native replacement for hald + polkitd + dbus I use in XFCE with
Thunar on my laptop...

TIA!
_
{Beto|Norberto|Numard} Meijome

Never attribute to malice what can adequately be explained by incompetence.

I speak for myself, not my employer. Contents may be hot. Slippery when wet.
Reading disclaimers makes you go blind. Writing them is worse. You have been
Warned.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]