ATA -- erratic behaviour when removing disk

Carlos A. M. dos Santos unixmania at gmail.com
Sun Feb 17 14:03:33 UTC 2008


On Feb 17, 2008 3:19 AM, Jeremy Chadwick <koitsu at freebsd.org> wrote:
> On Sat, Feb 16, 2008 at 09:08:38PM -0200, Carlos A. M. dos Santos wrote:
> > On Feb 16, 2008 7:07 PM, Jeremy Chadwick <koitsu at freebsd.org> wrote:
> > > Is anyone aware of the situation where FreeBSD behaves erratically when
> > > a disk is physically removed without "atacontrol detach ataX" being run
> > > prior to removal (at least on RELENG_7)?
> >
> > Yes, I have seen this since 4.5, IIRC.
>
> Wonderful.
>
> > > Also FWIW: I also tested all this for comparison on Ubuntu Linux earlier
> > > this morning.  I was able to yank the disk in the middle of an I/O
> > > operation, resulting in an immediate I/O error from dd.  I took no
> > > precautions prior to yanking the disk.  Upon reinsertion, the system
> > > found the disk and I could continue I/O operations on it as if it had
> > > never been removed.  Only reason I'm pointing this out is that it
> > > confirms the issue isn't hardware or with vendor implementation, but
> > > rather specific to the OS.
> >
> > Congratulations to the Linux folks. Or not, since this looks like a
> > very risky behavior. Who warrants you that the *same* disk was plugged
> > back? Blindly continuing to write could easily corrupt the contents of
> > the second drive.
>
> I'm not sure I understand.  There were no filesystems on the drive, and
> nothing mounted prior to removal: just like what I did with FreeBSD.
> The procedure:
>
> * Boot Ubuntu CD, get a shell
> * dd if=/dev/sdb of=/dev/null bs=8k
> * In the middle of I/O, yank the disk
> * dd exits with "I/O error"
> * System continued to be responsive; no ATA subsystem oddities
> * Reinserted disk; kernel saw the disk without any issue
> * dd if=/dev/sdb of=/dev/null bs=8k
> * I/O still operating as before; no system "oddities"

I'm still not convinced that this is a valid use case.

> If you'd like, I can try inserting a completely different disk (both in
> size and vendor), but I really don't think anything odd will happen.  If
> there were filesystems mounted or other whatnots, yes, I could see how
> there might be concern. [...]

This is exctly what I was talking about when I said "risky".

> [...] I can try that as well if you're interested.  I
> am a bit curious to see what Linux does if I pull a disk that has
> mounted filesystems which are being accessed at the time.

Yes, do it please. I must admit [precious brat mode on] that I'm very
curious about what would happen. :-)

> This test was done solely to see how FreeBSD behaved when a disk was
> removed.  The fact that the entire ATA channel goes into some bizarre
> non-recoverable state when a disk is removed without detaching first
> warrants the need for investigation, especially if this behaviour has
> existed since the mid-4.x days.
>
> --
>
> | Jeremy Chadwick                                    jdc 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 |

-- 
Carlos A. M. dos Santos


More information about the freebsd-stable mailing list