From owner-freebsd-geom@FreeBSD.ORG Fri Jul 27 11:06:08 2007 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 220D716A421; Fri, 27 Jul 2007 11:06:08 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from fri.itea.ntnu.no (fri.itea.ntnu.no [129.241.7.60]) by mx1.freebsd.org (Postfix) with ESMTP id B101D13C4CC; Fri, 27 Jul 2007 11:06:07 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by fri.itea.ntnu.no (Postfix) with ESMTP id 97F8FB1AA; Fri, 27 Jul 2007 12:39:35 +0200 (CEST) Received: from gaupe.stud.ntnu.no (gaupe.stud.ntnu.no [129.241.56.184]) by fri.itea.ntnu.no (Postfix) with ESMTP; Fri, 27 Jul 2007 12:39:35 +0200 (CEST) Received: by gaupe.stud.ntnu.no (Postfix, from userid 2312) id BEB3DD003A; Fri, 27 Jul 2007 12:39:44 +0200 (CEST) Date: Fri, 27 Jul 2007 12:39:44 +0200 From: Ulf Lilleengen To: freebsd-geom@freebsd.org Message-ID: <20070727103944.GA12318@stud.ntnu.no> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Content-Scanned: with sophos and spamassassin at mailgw.ntnu.no. Cc: pjd@FreeBSD.org, phk@FreeBSD.org Subject: [PATCH] geom_bsd tasting holds topology_lock when doing I/O X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2007 11:06:08 -0000 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I started having problems with gvinum hanging itself up because it was waiting for the topology lock. At the same time geom_bsd was trying to taste the new gvinum provider that I created. This resulted in a deadlock where gvinum waited for the lock and g_bsd_taste waited for gvinum to finish a read BIO. The patch also asserts that the lock is not held in g_bsd_taste -- Ulf Lilleengen --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="geom_bsd_toplock.diff" Index: sys/geom/geom_bsd.c =================================================================== RCS file: /home/ncvs/src/sys/geom/geom_bsd.c,v retrieving revision 1.78 diff -u -r1.78 geom_bsd.c --- sys/geom/geom_bsd.c 24 May 2006 11:02:32 -0000 1.78 +++ sys/geom/geom_bsd.c 27 Jul 2007 10:34:49 -0000 @@ -201,6 +201,8 @@ struct disklabel *dl; off_t secoff; + g_topology_assert_not(); + /* * We need to read entire aligned sectors, and we assume that the * disklabel does not span sectors, so one sector is enough. @@ -502,6 +504,7 @@ * using a simple "break". This improves code clarity without * ending up in deep nesting and without using goto or come from. */ + g_topology_unlock(); do { /* * If the provider is an MBR we will only auto attach @@ -571,8 +574,11 @@ * Process the found disklabel, and modify our "slice" * instance to match it, if possible. */ + g_topology_lock(); error = g_bsd_modify(gp, ms->label); + g_topology_unlock(); } while (0); + g_topology_lock(); /* Success or failure, we can close our provider now. */ g_access(cp, -1, 0, 0); --envbJBWh7q8WU6mo--