From nobody@FreeBSD.org  Sat Apr  3 01:22:47 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6C7AD106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Apr 2010 01:22:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5BC908FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Apr 2010 01:22:47 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o331MldI059549
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 3 Apr 2010 01:22:47 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o331Mkcf059536;
	Sat, 3 Apr 2010 01:22:46 GMT
	(envelope-from nobody)
Message-Id: <201004030122.o331Mkcf059536@www.freebsd.org>
Date: Sat, 3 Apr 2010 01:22:46 GMT
From: Yar Tikhiy <yar@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Editing disk label invalidates the whole device
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145309
>Category:       bin
>Synopsis:       bsdlabel: Editing disk label invalidates the whole device
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 03 01:30:06 UTC 2010
>Closed-Date:    
>Last-Modified:  Tue Feb  7 23:10:10 UTC 2012
>Originator:     Yar Tikhiy
>Release:        8.0-RELEASE
>Organization:
NA
>Environment:
8.0-RELEASE GENERIC
>Description:
In single-user mode (with just / mounted r/o), any change to the label of the disk the root partition is residing on seems to immediately invalidate the device for the kernel.  E.g., after the partition was written out by bsdlabel(8), any access to the disk with fail with EIO or EXIO.

OTOH, in multi-user mode (i.e., with everything mounted r/w) editing the label is just impossible: bsdlabel will complain:
bsdlabel: Class not found
>How-To-Repeat:
Boot in single-user mode.
Create MFS /tmp so that the editor is happy: mdmfs -s10m md /tmp
Change the default editor: export EDITOR=ed
Start bsdlabel: bsdlabel -e ad0s1
Make a harmless change, e.g., create a new partition in the unused space at the end of the disk -- make sure there is some!
Save.
Run any command from / as nothing else is mounted, e.g., "ls /boot" or "reboot"
See the kernel croak:

vnode_pager_getpages: I/O read error
ls: Input/output error

or

reboot: Device not configured
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: remko 
Responsible-Changed-When: Sat Apr 3 07:54:34 UTC 2010 
Responsible-Changed-Why:  
Filesystem related. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145309 

From: Tsurutani Naoki <turutani@scphys.kyoto-u.ac.jp>
To: bug-followup@FreeBSD.org, yar@FreeBSD.org
Cc:  
Subject: kern/145309: [disklabel]: Editing disk label invalidates the whole device
Date: Fri, 07 May 2010 08:12:35 +0900

 I found 
 	bsdlabel: Class not found
 many times, and I have no solution.
 I saw it even on single user mode.
 Please help me, for I cannot update my boot code by
 bsdlabel -B, and I cannot use ahci.
State-Changed-From-To: open->feedback 
State-Changed-By: ae 
State-Changed-When: Sun Nov 6 20:50:17 UTC 2011 
State-Changed-Why:  
Do you still able to reproduce this problem on recent releases? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145309 

From: Yar Tikhiy <yar@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/145309: bsdlabel: Editing disk label invalidates the whole device
Date: Sat, 4 Feb 2012 14:17:15 +1100

 Hi there,
 
 Sorry but FreeBSD 9.0-RELEASE still appears to have this issue.  When
 installed using BSD label partitioning scheme, a modification to
 ada0's label seems to nuke the kernel's view of the disk -- I can't
 think of a better way to explain it.  The disk itself is OK and the
 change makes it OK to the disk but the kernel can no more use the root
 partition until rebooted, returning weird errnos such as EIO or EXIO.
 No idea here if the bug is limited to BSD label scheme.
 
 Cheers,
 Yar

From: Yar Tikhiy <yar@freebsd.org>
To: "Andrey V. Elsukov" <ae@freebsd.org>
Cc: Pawel Jakub Dawidek <pjd@freebsd.org>, bug-followup@freebsd.org
Subject: Re: bin/145309: bsdlabel: Editing disk label invalidates the whole device
Date: Wed, 8 Feb 2012 10:08:54 +1100

 Hi Andrey,
 
 2012/2/6 Andrey V. Elsukov <ae@freebsd.org>:
 > On 04.02.2012 7:50, Yar Tikhiy wrote:
 >>
 >> =A0Sorry but FreeBSD 9.0-RELEASE still appears to have this issue. =A0Wh=
 en
 >> =A0installed using BSD label partitioning scheme, a modification to
 >> =A0ada0's label seems to nuke the kernel's view of the disk -- I can't
 >> =A0think of a better way to explain it. =A0The disk itself is OK and the
 >> =A0change makes it OK to the disk but the kernel can no more use the roo=
 t
 >> =A0partition until rebooted, returning weird errnos such as EIO or EXIO.
 >> =A0No idea here if the bug is limited to BSD label scheme.
 >
 > When you are in single user mode your root filesystem is mounted read-onl=
 y.
 > When you run bsdlabel it opens geom provider for writing and this trigger=
 s spoiling for it.
 > When bsdlabel closes provider GEOM_PART destroys it and creates again.
 > But VFS code seems loses it.
 
 Sorry but do you think it's intended behavior or not?  It doesn't look
 so to me and, IMMSMR, it wasn't there before.  Please correct me if
 I'm wrong.
 
 Thanks,
 Yar
>Unformatted:
