Subject: Re: accessing IDE hard drive via pcmcia card (redirected from netbsd-users)
To: Steve Bellovin <smb@research.att.com>
From: Daniel Carosone <dan@geek.com.au>
List: tech-kern
Date: 05/22/2004 04:58:30
--sBcizk6cgRZY6rnJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, May 21, 2004 at 02:10:19PM -0400, Steve Bellovin wrote:
> I did, however, encounter another problem that I worked around but=20
> haven't fixed; this problem requires more thought, which is why I've=20
> redirected the thread to tech-kern: on a device like this, on the last=20
> close(), power is removed from the drive before any final writes can=20
> finish.  Thus, if I unmounted a file system, the superblock wouldn't be=
=20
> marked clean, and fsck would run the next time.

Nasty.

> I finally worked around the problem by running
>=20
> 	sleep 99999 </dev/rwd1a
>=20
> in the background.

Another workaround, and interesting test, would be to turn off
write-cache on the drive:

	dkctl wdX setcache r

and then try the unmount.  I'm hoping/assuming this would wait for the
superblock write to complete.  Could you try this?  If it does, then
building the moral equivalent of

	dkctl wdX synccache force

into the close is the right way to fix this.  It even seems to me like
if we don't do this, there might be other similar lossage cases
lurking than the pcmcia one you found.

(For removable devices that might get unexpectedly yanked, running
without write cache, and perhaps mount -o sync, might also be a good
idea - but that should remain a user preference for appropriate
circumstances.)

--
Dan.

--sBcizk6cgRZY6rnJ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFArlFWEAVxvV4N66cRAtUiAKC4XzPlXr4m5tPbVjih5XKxNZ9I+QCfcvpE
7woO2FmvOPmkk6Jj/SXX6Og=
=C5gm
-----END PGP SIGNATURE-----

--sBcizk6cgRZY6rnJ--