In message <[EMAIL PROTECTED]>, Dima Dorfman write
s:
>Alfred Perlstein <[EMAIL PROTECTED]> writes:
>> * Dima Dorfman <[EMAIL PROTECTED]> [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
> [EMAIL PROTECTED]
>
>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 [EMAIL PROTECTED]
>with "unsubscribe freebsd-current" in the body of the message
>
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message