In the ufsdirhash_build() failure case for corrupted directories

or unreadable blocks, make sure to destroy the mutex we created.
Also fix an unrelated typo in a comment.

Found by:	Peter Holm's stress tests
Reviewed by:	dwmalone
MFC after:	3 days
This commit is contained in:
Ian Dowse 2005-08-17 08:48:42 +00:00
parent 516ad423b1
commit 65ed954554

View File

@ -188,6 +188,7 @@ ufsdirhash_build(struct inode *ip)
DIRHASHLIST_UNLOCK();
return (-1);
}
mtx_init(&dh->dh_mtx, "dirhash", NULL, MTX_DEF);
MALLOC(dh->dh_hash, doff_t **, narrays * sizeof(dh->dh_hash[0]),
M_DIRHASH, M_NOWAIT | M_ZERO);
MALLOC(dh->dh_blkfree, u_int8_t *, nblocks * sizeof(dh->dh_blkfree[0]),
@ -202,7 +203,6 @@ ufsdirhash_build(struct inode *ip)
}
/* Initialise the hash table and block statistics. */
mtx_init(&dh->dh_mtx, "dirhash", NULL, MTX_DEF);
dh->dh_narrays = narrays;
dh->dh_hlen = nslots;
dh->dh_nblk = nblocks;
@ -265,6 +265,7 @@ ufsdirhash_build(struct inode *ip)
}
if (dh->dh_blkfree != NULL)
FREE(dh->dh_blkfree, M_DIRHASH);
mtx_destroy(&dh->dh_mtx);
FREE(dh, M_DIRHASH);
ip->i_dirhash = NULL;
DIRHASHLIST_LOCK();
@ -398,7 +399,7 @@ ufsdirhash_lookup(struct inode *ip, char *name, int namelen, doff_t *offp,
/*
* We found an entry with the expected offset. This
* is probably the entry we want, but if not, the
* code below will turn off seqoff and retry.
* code below will turn off seqopt and retry.
*/
slot = i;
} else