ATA -- erratic behaviour when removing disk

Jeremy Chadwick koitsu at freebsd.org
Sun Feb 17 06:19:06 UTC 2008


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"

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.  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.

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 |



More information about the freebsd-stable mailing list