Subject: Re: sd rereads
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 08/31/1999 19:33:02
>> Back a version or two ago, on last close of an sd device, almost all
>> state would be cleared - in particular, on next open the disklabel
>> would be reread.

> If it no longer does this, i'd call that a "serious bug."

I'm quite sure "my" NetBSD/sparc machines don't (don't reread the
label, that is).  I'm sure of this because I normally relabel (and in
particular repartition) my drives on Sun ports with sunlabel, if only
because it has a much nicer user interface to partitioning than
disklabel (in my admittedly possibly biased opinion).

And these days, I find I have to detach and reattach the disk to make
the kernel reread the label when I'm done running sunlabel.

I do have some patches in place, but I don't think any of them bear on
this issue.  Just just out of paranoia, could someone who has a stock
system test it?  It's easy enough, even without sunlabel, on a Sun port
(/sparc or /sun3)....

1) Arrange to have an sd disk around that you're not using for anything
    else.  I'll call it sdN below.

2) Save the previous label sector:
	dd if=/dev/rsdNc bs=512 count=1 of=some.temp.file

3) Change the label with disklabel -e.  Add a partition, delete a
    partition, move some around, whatever.  Something so it's clear
    whether you've got the old label or the new.

4) Put the old label back, on the disk but not in-core:
	dd of=/dev/rsdNc bs=512 count=1 if=some.temp.file

5) Check ("disklabel sdN") to see which label you have.

If it's rereading the label upon first (re)open, the way it used to, it
will do a reread at practically every step of the way; in particular,
between steps 4 and 5, the reread will pick up the changed label.

If you have sunlabel, it's even easier:

1') as (1) above
2') as (2) above
3') change the label with sunlabel (write to disk but not kernel)
4') check with disklabel and see which label you have

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B