From owner-freebsd-current Sat May 26 0:50:23 2001 Delivered-To: freebsd-current@freebsd.org Received: from critter.freebsd.dk (beachchick.freebsd.dk [212.242.34.253]) by hub.freebsd.org (Postfix) with ESMTP id 9745437B422; Sat, 26 May 2001 00:50:18 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.3/8.11.3) with ESMTP id f4Q7o8m97927; Sat, 26 May 2001 09:50:08 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Dima Dorfman Cc: Alfred Perlstein , current@FreeBSD.ORG Subject: Re: vm_pager_(de)allocate and vm_mtx In-Reply-To: Your message of "Fri, 25 May 2001 22:51:11 PDT." <20010526055111.7B5803E28@bazooka.unixfreak.org> Date: Sat, 26 May 2001 09:50:08 +0200 Message-ID: <97925.990863408@critter> From: Poul-Henning Kamp Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <20010526055111.7B5803E28@bazooka.unixfreak.org>, Dima Dorfman write s: >Alfred Perlstein writes: >> * Dima Dorfman [010525 22:22] wrote: >> > Is there a reason vm_pager_allocate acquires vm_mtx itself if >> > necessary but vm_pager_deallocate does not? At the moment, detaching >> > an md(4) disk will panic the system with a failed mtx_assert in >> > vm_pager_deallocate. This can be fixed one of two ways: >> > vm_pager_deallocate could be made to deal with vm_mtx itself like >> > vm_pager_allocate does, or md(4) and any other drivers which call >> > vm_pager_deallocate can be fixed to acquire vm_mtx. So which will it >> > be? I'll supply patches for either case. >> >> Usually fixing the caller is better as it will catch people that >> expect vm state to remain unchanged across several calls. > >Patch to fix md(4) attached. Look okay? Looks fine, go ahead and commit. Poul-Henning > > Dima Dorfman > dima@unixfreak.org > >Index: md.c >=================================================================== >RCS file: /stl/src/FreeBSD/src/sys/dev/md/md.c,v >retrieving revision 1.33 >diff -u -r1.33 md.c >--- md.c 2001/05/21 18:52:00 1.33 >+++ md.c 2001/05/26 05:48:57 >@@ -711,8 +711,11 @@ > (void)vn_close(sc->vnode, sc->flags & MD_READONLY ? FREAD : (FREAD|FWRITE), sc->cred, p); > if (sc->cred != NULL) > crfree(sc->cred); >- if (sc->object != NULL) >+ if (sc->object != NULL) { >+ mtx_lock(&vm_mtx); > vm_pager_deallocate(sc->object); >+ mtx_unlock(&vm_mtx); >+ } > if (sc->secp != NULL) { > for (u = 0; u < sc->nsect; u++) > if ((uintptr_t)sc->secp[u] > 255) >@@ -763,17 +766,20 @@ > * Note the truncation. > */ > >+ mtx_lock(&vm_mtx); > sc->secsize = PAGE_SIZE; > sc->nsect = mdio->md_size / (PAGE_SIZE / DEV_BSIZE); > sc->object = vm_pager_allocate(OBJT_SWAP, NULL, sc->secsize * (vm_offset_t)sc->nsect, VM_PROT_DEFAULT, 0); > if (mdio->md_options & MD_RESERVE) { > if (swap_pager_reserve(sc->object, 0, sc->nsect) < 0) { > vm_pager_deallocate(sc->object); >+ mtx_unlock(&vm_mtx); > sc->object = NULL; > mddestroy(sc, mdio, p); > return(EDOM); > } > } >+ mtx_unlock(&vm_mtx); > error = mdsetcred(sc, p->p_ucred); > if (error) > mddestroy(sc, mdio, p); > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-current" in the body of the message > -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message