From nobody@FreeBSD.org  Tue Jan 17 18:40:40 2012
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 3218A106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jan 2012 18:40:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 16B868FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jan 2012 18:40:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0HIed4l009150
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jan 2012 18:40:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q0HIedH1009147;
	Tue, 17 Jan 2012 18:40:39 GMT
	(envelope-from nobody)
Message-Id: <201201171840.q0HIedH1009147@red.freebsd.org>
Date: Tue, 17 Jan 2012 18:40:39 GMT
From: Oliver <grimeton@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: GJournal not stopping on GPT partitions
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         164254
>Category:       kern
>Synopsis:       [geom] gjournal not stopping on GPT partitions
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-geom
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 17 18:50:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Wed Jan 18 11:50:07 UTC 2012
>Originator:     Oliver
>Release:        9.0-RELEASE
>Organization:
n/a
>Environment:
FreeBSD test 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
If you have a harddrive with GPT scheme and you use gjournal on one of
the partitions, it switches between the "old" device name and the "new"
gptid device name and you can't stop the journal on that device.

The system has a GPT partitioned drive:

# gpart show

=>       34  976773101  ada0  GPT  (465G)
         34  976773101     1  freebsd-ufs  (465G)
#

The filesystem on top is unmounted, but gjournal is still using it:
# mount
dev/ada1p2 on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)

# ls /dev/ada0*
/dev/ada0               /dev/ada0p1             /dev/ada0p1.journal

# gjournal list
Geom name: gjournal 2801902713
ID: 2801902713
Providers:
1. Name: ada0p1.journal
   Mediasize: 499034085376 (464G)
   Sectorsize: 512
   Mode: r0w0e0
Consumers:
1. Name: ada0p1
   Mediasize: 500107827712 (465G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r1w1e1
   Jend: 500107827200
   Jstart: 499034085376
   Role: Data,Journal
#

Now, if I stop the provider or the consumer (doesn't matter):

# gjournal stop /dev/ada0p1

Then I can see that the journal is gone:

# ls /dev/ada0*
/dev/ada0       /dev/ada0p1

But if I try to remove the partiton:

# gpart delete -i 1 ada0
gpart: Device busy
#

it's still used, so checking what's going on in gjournal gives me

# gjournal list

Geom name: gjournal 2801902713
ID: 2801902713
Providers:
1. Name: gptid/f9074aa8-4113-11e1-b382-00301bbc854a.journal
   Mediasize: 499034085376 (464G)
   Sectorsize: 512
   Mode: r0w0e0
Consumers:
1. Name: gptid/f9074aa8-4113-11e1-b382-00301bbc854a
   Mediasize: 500107827712 (465G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r1w1e1
   Jend: 500107827200
   Jstart: 499034085376
   Role: Data,Journal

#

So stopping the journal on /dev/ada0p1 enabled the journal on
/dev/gptid/f9074aa8-4113-11e1-b382-00301bbc854a which is the same drive:

# gpart list ada0
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 976773134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada0p1
   Mediasize: 500107827712 (465G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r1w1e2
   rawuuid: f9074aa8-4113-11e1-b382-00301bbc854a
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 500107827712
   offset: 17408
   type: freebsd-ufs
   index: 1
   end: 976773134
   start: 34
Consumers:
1. Name: ada0
   Mediasize: 500107862016 (465G)
   Sectorsize: 512
   Mode: r1w1e3
#

Now guess what happens if I stop the journal on
/dev/gptid/f9074aa8-4113-11e1-b382-00301bbc854a

# gjournal stop /dev/gptid/f9074aa8-4113-11e1-b382-00301bbc854a
# gjournal list
Geom name: gjournal 2801902713
ID: 2801902713
Providers:
1. Name: ada0p1.journal
   Mediasize: 499034085376 (464G)
   Sectorsize: 512
   Mode: r0w0e0
Consumers:
1. Name: ada0p1
   Mediasize: 500107827712 (465G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r1w1e1
   Jend: 500107827200
   Jstart: 499034085376
   Role: Data,Journal

Maybe it's not a bug and I'm missing something,but it's weird.

Thanks!

KR,

Grimeton
>How-To-Repeat:
- Install 9.0-Release
- On top of an empty harddrive create a GPT partitioning scheme with one
  partition
- Label the partition with gjournal
- create an UFS2 with journaling enabled on top of the journaled partition
- stop the journal on the "old" device name /dev/$diskp0
- check gjournal list and see the journal enabled on the same device under
  its gptid-name
- disable the journal on the gptid-device and see it enabled on the "old"
  device again

>Fix:
No clue.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-geom 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jan 18 01:04:10 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Vincent Hoffman-Kazlauskas <vhoffman@names.co.uk>
To: bug-followup@FreeBSD.org, grimeton@gmx.net
Cc:  
Subject: Re: kern/164254: [geom] gjournal not stopping on GPT partitions
Date: Wed, 18 Jan 2012 09:42:05 +0000

 I'm not a maintainer or even a coder but I got bitten by this before.
 
 The solution in the sort term is to disable gtpid labels
 sysctl kern.geom.label.gptid.enable=0
 Its somewhat annoying though and while I dont use gptid labels, some
 people must.
 
 an entry in one (all?) of the appropriate geom manpages might be an idea.
 
 
 Vince
>Unformatted:
