Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Jul 2009 00:05:45 -0600
From:      Anthony Chavez <acc@hexadecagram.org>
To:        freebsd-geom@freebsd.org
Cc:        freebsd-fs@freebsd.org, Pawel Jakub Dawidek <pjd@FreeBSD.org>
Subject:   Re: Re-starting a gjournal provider
Message-ID:  <4A7289B9.2060907@hexadecagram.org>
In-Reply-To: <20090729140436.GG1586@garage.freebsd.pl>
References:  <4A62E0CE.1000508@hexadecagram.org> <20090729140436.GG1586@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigB401B05976538240EEF8BBEA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thanks very much for responding, Pawel.

I'm moving this discussion to freebsd-geom, which is where I probably
should have posted in the first place.  Lack of sleep and coffee on
Sunday morning were partly to blame, I'm sure. ;-)

Pawel Jakub Dawidek wrote:
> On Sun, Jul 19, 2009 at 03:01:02AM -0600, Anthony Chavez wrote:
>> Hello freebsd-fs,
>>
>> I'm trying to get gjournal working on a "removable" hard disk.  I use
>> the term loosely, because I'm using a very simple eSATA enclosure: an
>> AMS Venus DS5 [1].
>>
>> If I swap out disks, atacontrol cap ad0 seems sufficient enough to
>> detect the new drive: the reported device model, serial number, firmwa=
re
>> revision, and CHS values change as one would expect.
>>
>> My interpretation of [2] section 5.3 and gjournal(8) is that the
>> following sequence of commands should ensure me that all write buffers=

>> have been flushed and bring the system to a point where it is safe to
>> remove a disk.
>>
>> sync; sync; sync
>> gjournal sync
>> umount /dev/ad0s1.journal
>> gjournal stop ad0s1.journal
>=20
> You should first unmount and then call 'gjournal sync'.

Thank you for clarifying that.  You mention this again later on in your
response, and I respond below.

>> However, once they are executed, /dev/ad0s1.journal disappears and whe=
n
>> I swap out the disk it doesn't come back.  The only way I've found to
>> bring it back is atacontrol detach ata0; atacontrol attach ata0, which=

>> doesn't seem like a wise thing to do if I have another device on the
>> same channel.
>=20
> It doesn't come back because something (ATA layer?) doesn't properly
> remove ad0 provider. When you remove the disk, /dev/ad0 should disappea=
r
> and reappear once you insert it again.
>=20
> You can still do this trick after you insert the disk again so the GEOM=

> can schedule retaste:
>=20
> 	# true > /dev/ad0

Thank you for informing me of that trick.  I tried using it after
"gjournal stop" but unfortunately, nothing changed.

My terminology might have been a bit off in my initial post (gjournal is
still a bit new to me).  So I will attempt to clarify a bit more.  Here
is an example of a typical session (the only difference this time being
"gjournal sync" following umount as you prescribed).

% sudo atacontrol info ata0
Master:  ad0 <ST31000340AS/SD15> SATA revision 1.x
Slave:       no device present
% ls /dev/ad0*
/dev/ad0		/dev/ad0s1		/dev/ad0s1.journal
% mount | grep ad0s1
/dev/ad0s1.journal on /mnt/ad0s1 (ufs, local, gjournal)
% (
subsh> set -o errexit
subsh> sync
subsh> sync
subsh> sync
subsh> sudo umount /dev/ad0s1.journal
subsh> gjournal sync
subsh> sudo gjournal stop ad0s1.journal
subsh> )
% ls /dev/ad0*
/dev/ad0	/dev/ad0s1
% sudo true \> /dev/ad0; ls /dev/ad0*
/dev/ad0	/dev/ad0s1
% sudo true \> /dev/ad0s1; ls /dev/ad0*
/dev/ad0	/dev/ad0s1
% sudo atacontrol detach ata0 && sudo atacontrol attach ata0
Master:  ad0 <ST31000340AS/SD15> SATA revision 1.x
Slave:       no device present
% ls /dev/ad0*
/dev/ad0		/dev/ad0s1		/dev/ad0s1.journal

Here are the points to note.

1) When I physically remove a drive from the enclosure, /dev/ad0 does
not disappear.  /dev/ad0 *always* exists until I "atacontrol detach."
Even when the device is powered off, /dev/ad0 continues to exist.

2) /dev/ad0s1.journal disappears when I "gjournal stop."
/dev/ad0s1.journal is the device that, AFAIK, will only come back after
"atacontrol detach ata0; atacontrol attach ata0".

3) When I swap drives, "atacontrol cap ad0" will produce a report for
the newly-inserted drive.  If I attempt to "atacontrol info ata0" before
issuing that command, it continues to display the drive model and
firmware revision from the drive that was previously inserted.  However,
"atacontrol cap" does not appear to provoke the return of
/dev/ad0s1.journal.

>> My question is, do I need to issue gjournal stop before I swap disks?
>> And if so, is there any way that I can avoid the atacontrol
>> detach/attach cycle that would need to take place before any mount is
>> attempted so that /dev/ad0s1.journal appears (if in the drive inserted=

>> at the time does in fact utilize gjournal; I may want to experiment wi=
th
>> having disks with either gjournal or soft updates)?

This paragraph (above) and the one that that proceeded it in my original
post contains the following 2 questions that remain unanswered (I've
added another which was implied previously at best).

1) Is "atacontrol detach ata0 && atacontrol attach ata0" in fact a safe
operation to perform in any circumstance?

My better judgment has me thinking that the answer to this question is
almost certainly "no."  However, I am hypothesizing that it would safe
enough if all devices on ata0 are properly unmounted first, but if I can
avoid that, I will.  It feels clumsy and seems to defeat the purpose of
hot-swapping.

2) Is it *necessary* to "gjournal stop" before hot-swapping?

In such a scenario, I would opt to simply "umount; gjournal sync," swap
disks, and then "atacontrol cap ad0; mount" (or even just "mount").  It
seems quite likely, however, that all drives that undergo this treatment
would be *required* to have gjournal labels since /dev/ad0s1.journal
would never disappear (although I've yet to actually test that).

3) If the answer to question 2 is "yes," then how can I handle the case
of inserting a drive that does *not* have a gjournal label?

>> And while I'm on the subject, are the (gjournal) syncs commands
>> preceeding umount absolutely necessary in the case of removable media?=

>=20
> 'gjournal sync' should follow unmount, not the other way around. And it=
s
> better to do it, but 'gjournal stop' should do the same.

If that is indeed the case then the article I referenced as [2],
"Implementing UFS Journaling on a Desktop PC," should be updated to
reflect that ordering (section 5.3 prescribes a "umount" followed by
"gjournal sync").  I'm submitting a PR that addresses this.

In any case, the question I was asking here is actually twofold:

1) Is it really necessary to perform 3 "sync" commands before "umount"?

Line 94 of src/sbin/umount/umount.c,v 1.45.20.1 has me thinking that the
answer is "no," since it calls sync() itself, albeit only once.  I got
the idea for executing "sync" three times from /etc/rc.suspend.

2) Is it necessary to "gjournal sync" if I'm going to "gjournal stop"
anyway? (You answered this one already.)

Thank you for the assistance.

--=20
Anthony Chavez                                  http://hexadecagram.org/
mailto:acc@hexadecagram.org                    xmpp:acc@hexadecagram.org


--------------enigB401B05976538240EEF8BBEA
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpyicAACgkQbZTbIaRBRXFQPgCfemQsbeTMnQsFfSkLIR7VMvjM
f1UAmwWwuO8tnWGM3hmXOqp5F7nbFo3c
=rY6f
-----END PGP SIGNATURE-----

--------------enigB401B05976538240EEF8BBEA--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A7289B9.2060907>