From owner-freebsd-fs@FreeBSD.ORG Wed Apr 28 22:43:36 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A00B1106566C for ; Wed, 28 Apr 2010 22:43:36 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello089077043238.chello.pl [89.77.43.238]) by mx1.freebsd.org (Postfix) with ESMTP id E6FF08FC20 for ; Wed, 28 Apr 2010 22:43:35 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 2C23645CD8; Thu, 29 Apr 2010 00:43:34 +0200 (CEST) Received: from localhost (chello089077043238.chello.pl [89.77.43.238]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 0C75E45685; Thu, 29 Apr 2010 00:43:28 +0200 (CEST) Date: Thu, 29 Apr 2010 00:43:26 +0200 From: Pawel Jakub Dawidek To: Mikolaj Golub Message-ID: <20100428224326.GE1677@garage.freebsd.pl> References: <86iq7ex9j0.fsf@kopusha.onet> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="C94crkcyjafcjHxo" Content-Disposition: inline In-Reply-To: <86iq7ex9j0.fsf@kopusha.onet> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 9.0-CURRENT amd64 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: freebsd-fs Subject: Re: hastd segfaults reading metadata from not initialized provider X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Apr 2010 22:43:36 -0000 --C94crkcyjafcjHxo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 26, 2010 at 11:07:31PM +0300, Mikolaj Golub wrote: > Hi, >=20 > When configuring a new provider if one forgets to do=20 >=20 > hastctl create tank >=20 > before=20 >=20 > hastctl role primary tank In my tests I cannot reproduce it. If metadata is empty hastd should notice that, but check for NULL was missing anyway. > the worker core dumps on reading metadata: >=20 > (gdb) bt > #0 strcmp () at /usr/src/lib/libc/i386/string/strcmp.S:61 > #1 0x0804fa18 in metadata_read (res=3D0x284cb600, openrw=3Dtrue) at /usr= /src/sbin/hastd/metadata.c:120 > #2 0x080570ac in init_local (res=3D0x284cb600) at /usr/src/sbin/hastd/pr= imary.c:425 > #3 0x08057f88 in hastd_primary (res=3D0x284cb600) at /usr/src/sbin/hastd= /primary.c:754 > #4 0x0804e270 in child_exit () at /usr/src/sbin/hastd/hastd.c:145 > #5 0x0804edd1 in main_loop () at /usr/src/sbin/hastd/hastd.c:389 > #6 0x0804f3d8 in main (argc=3D0, argv=3D0xbfbfed84) at /usr/src/sbin/has= td/hastd.c:520 > Current language: auto; currently asm > (gdb) fr 1 > #1 0x0804fa18 in metadata_read (res=3D0x284cb600, openrw=3Dtrue) at /usr= /src/sbin/hastd/metadata.c:120 > 120 if (strcmp(str, res->hr_name) !=3D 0) { > Current language: auto; currently c > (gdb) list > 115 ebuf_free(eb); > 116 goto fail; > 117 } > 118 > 119 str =3D nv_get_string(nv, "resource"); > 120 if (strcmp(str, res->hr_name) !=3D 0) { > 121 pjdlog_error("Provider %s is not part of resource= %s.", > 122 res->hr_localpath, res->hr_name); > 123 nv_free(nv); > 124 goto fail; > (gdb) p str > $1 =3D 0x0 >=20 > In the attached patch the check for str is added so we would have a > termination with the error message instead of a core dump: >=20 > Apr 26 22:46:06 hasta hastd: [tank] (primary) Metadata read from /dev/ad6= is invalid. > Apr 26 22:46:06 hasta hastd: [tank] (primary) Worker process failed (pid= =3D6196, status=3D66). I fixed it a bit different. In general nv API is constructued in a way that the consumer might execute various calls and check for error at the end. This is what we do there already, only (str !=3D NULL) check was missing. Thanks for the report, I committed fix to HEAD. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --C94crkcyjafcjHxo Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkvYug4ACgkQForvXbEpPzQF+QCglCAj4IMHWZR5KPQqIS9itw5m lSYAoNNSQHuEsekxz7zrQdJtFbMQLWgT =M1ca -----END PGP SIGNATURE----- --C94crkcyjafcjHxo--