From owner-svn-src-head@freebsd.org Thu Jun 23 20:06:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93F45B73A3A; Thu, 23 Jun 2016 20:06:00 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F48D1DCD; Thu, 23 Jun 2016 20:06:00 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5NK5xGm017066; Thu, 23 Jun 2016 20:05:59 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5NK5xTc017063; Thu, 23 Jun 2016 20:05:59 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201606232005.u5NK5xTc017063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Thu, 23 Jun 2016 20:05:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302150 - in head/sys: geom sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2016 20:06:00 -0000 Author: ken Date: Thu Jun 23 20:05:59 2016 New Revision: 302150 URL: https://svnweb.freebsd.org/changeset/base/302150 Log: Switch geom_disk over to using a pool mutex. The GEOM disk d_mtx is only acquired on disk creation and destruction. It is a good candidate for replacement with a pool mutex. This eliminates the mutex initialization and teardown and the mutex and name variables themselves from struct disk. sys/geom/geom_disk.h: Take d_mtx and d_mtx_name out of struct disk. sys/geom/geom_disk.c: Use mtx_pool_lock() and mtx_pool_unlock() to guard the disk initialization state instead of a dedicated mutex. This allows removing the initialization and destruction of d_mtx. sys/sys/param.h: Bump __FreeBSD_version to 1100119 for the change to struct disk. Suggested by: jhb Sponsored by: Spectra Logic Approved by: re (gjb) Modified: head/sys/geom/geom_disk.c head/sys/geom/geom_disk.h head/sys/sys/param.h Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Thu Jun 23 19:37:00 2016 (r302149) +++ head/sys/geom/geom_disk.c Thu Jun 23 20:05:59 2016 (r302150) @@ -670,7 +670,7 @@ g_disk_create(void *arg, int flag) g_topology_assert(); dp = arg; - mtx_lock(&dp->d_mtx); + mtx_pool_lock(mtxpool_sleep, dp); dp->d_init_level = DISK_INIT_START; /* @@ -678,12 +678,12 @@ g_disk_create(void *arg, int flag) * call the user's callback to tell him we've cleaned things up. */ if (dp->d_goneflag != 0) { - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); if (dp->d_gone != NULL) dp->d_gone(dp); return; } - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); mtx_init(&sc->start_mtx, "g_disk_start", NULL, MTX_DEF); @@ -721,7 +721,7 @@ g_disk_create(void *arg, int flag) dp->d_geom = gp; g_error_provider(pp, 0); - mtx_lock(&dp->d_mtx); + mtx_pool_lock(mtxpool_sleep, dp); dp->d_init_level = DISK_INIT_DONE; /* @@ -729,11 +729,11 @@ g_disk_create(void *arg, int flag) * process for it. */ if (dp->d_goneflag != 0) { - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); g_wither_provider(pp, ENXIO); return; } - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); } @@ -786,8 +786,6 @@ g_disk_destroy(void *ptr, int flag) g_wither_geom(gp, ENXIO); } - mtx_destroy(&dp->d_mtx); - g_free(dp); } @@ -852,9 +850,6 @@ disk_create(struct disk *dp, int version DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX); dp->d_geom = NULL; - snprintf(dp->d_mtx_name, sizeof(dp->d_mtx_name), "%s%ddlk", - dp->d_name, dp->d_unit); - mtx_init(&dp->d_mtx, dp->d_mtx_name, NULL, MTX_DEF); dp->d_init_level = DISK_INIT_NONE; g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident)); @@ -878,7 +873,7 @@ disk_gone(struct disk *dp) struct g_geom *gp; struct g_provider *pp; - mtx_lock(&dp->d_mtx); + mtx_pool_lock(mtxpool_sleep, dp); dp->d_goneflag = 1; /* @@ -897,10 +892,10 @@ disk_gone(struct disk *dp) * has not been fully setup in any case. */ if (dp->d_init_level < DISK_INIT_DONE) { - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); return; } - mtx_unlock(&dp->d_mtx); + mtx_pool_unlock(mtxpool_sleep, dp); gp = dp->d_geom; if (gp != NULL) { Modified: head/sys/geom/geom_disk.h ============================================================================== --- head/sys/geom/geom_disk.h Thu Jun 23 19:37:00 2016 (r302149) +++ head/sys/geom/geom_disk.h Thu Jun 23 20:05:59 2016 (r302150) @@ -72,8 +72,6 @@ struct disk { struct devstat *d_devstat; int d_goneflag; int d_destroyed; - struct mtx d_mtx; - char d_mtx_name[24]; disk_init_level d_init_level; /* Shared fields */ Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Thu Jun 23 19:37:00 2016 (r302149) +++ head/sys/sys/param.h Thu Jun 23 20:05:59 2016 (r302150) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100118 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100119 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,