From owner-svn-src-all@FreeBSD.ORG Sat Jun 1 04:02:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E380C364; Sat, 1 Jun 2013 04:02:52 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BC71DCD3; Sat, 1 Jun 2013 04:02:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r5142pqp011662; Sat, 1 Jun 2013 04:02:51 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r5142pA4011661; Sat, 1 Jun 2013 04:02:51 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201306010402.r5142pA4011661@svn.freebsd.org> From: "Justin T. Gibbs" Date: Sat, 1 Jun 2013 04:02:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251214 - head/sys/dev/xen/blkfront X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Jun 2013 04:02:53 -0000 Author: gibbs Date: Sat Jun 1 04:02:51 2013 New Revision: 251214 URL: http://svnweb.freebsd.org/changeset/base/251214 Log: sys/dev/xen/blkfront/blkfront.c: Remove local, and incorrect, definition for the value of an invalid grant reference. Extract ring cleanup code into xbd_free_ring() function for symetry with xbd_alloc_ring(). This process also eliminated an initialized but unused variable. Sponsored by: Spectra Logic Corporation MFC after: 1 week Modified: head/sys/dev/xen/blkfront/blkfront.c Modified: head/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- head/sys/dev/xen/blkfront/blkfront.c Sat Jun 1 02:07:37 2013 (r251213) +++ head/sys/dev/xen/blkfront/blkfront.c Sat Jun 1 04:02:51 2013 (r251214) @@ -87,8 +87,6 @@ static void xbd_startio(struct xbd_softc #define XBD_SECTOR_SIZE 512 /* XXX: assume for now */ #define XBD_SECTOR_SHFT 9 -#define GRANT_INVALID_REF 0 - /* Control whether runtime update of vbds is enabled. */ #define ENABLE_VBD_UPDATE 0 @@ -709,6 +707,24 @@ xbd_alloc_ring(struct xbd_softc *sc) return (0); } +static void +xbd_free_ring(struct xbd_softc *sc) +{ + int i; + + if (sc->xbd_ring.sring == NULL) + return; + + for (i = 0; i < sc->xbd_ring_pages; i++) { + if (sc->xbd_ring_ref[i] != GRANT_REF_INVALID) { + gnttab_end_foreign_access_ref(sc->xbd_ring_ref[i]); + sc->xbd_ring_ref[i] = GRANT_REF_INVALID; + } + } + free(sc->xbd_ring.sring, M_XENBLOCKFRONT); + sc->xbd_ring.sring = NULL; +} + /*-------------------------- Initialization/Teardown -------------------------*/ static void xbd_setup_sysctl(struct xbd_softc *xbd) @@ -846,7 +862,6 @@ xbd_instance_create(struct xbd_softc *sc static void xbd_free(struct xbd_softc *sc) { - uint8_t *sring_page_ptr; int i; /* Prevent new requests being issued until we fix things up. */ @@ -855,22 +870,7 @@ xbd_free(struct xbd_softc *sc) mtx_unlock(&sc->xbd_io_lock); /* Free resources associated with old device channel. */ - if (sc->xbd_ring.sring != NULL) { - sring_page_ptr = (uint8_t *)sc->xbd_ring.sring; - for (i = 0; i < sc->xbd_ring_pages; i++) { - grant_ref_t *ref; - - ref = &sc->xbd_ring_ref[i]; - if (*ref != GRANT_INVALID_REF) { - gnttab_end_foreign_access_ref(*ref); - *ref = GRANT_INVALID_REF; - } - sring_page_ptr += PAGE_SIZE; - } - free(sc->xbd_ring.sring, M_XENBLOCKFRONT); - sc->xbd_ring.sring = NULL; - } - + xbd_free_ring(sc); if (sc->xbd_shadow) { for (i = 0; i < sc->xbd_max_requests; i++) { @@ -1277,7 +1277,7 @@ xbd_attach(device_t dev) xbd_initq_complete(sc); xbd_initq_bio(sc); for (i = 0; i < XBD_MAX_RING_PAGES; i++) - sc->xbd_ring_ref[i] = GRANT_INVALID_REF; + sc->xbd_ring_ref[i] = GRANT_REF_INVALID; sc->xbd_dev = dev; sc->xbd_vdevice = vdevice;