Avoid holding the vnode interlock around malloc() or free() to prevent a

lock order reversal.

Reviewed by:	jeff
This commit is contained in:
Alan Cox 2002-12-23 06:20:41 +00:00
parent 7af7dd3c6f
commit 903caa598d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108198

View File

@ -2622,6 +2622,8 @@ nfs_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td,
bvecpos = 0;
if (NFS_ISV3(vp) && commit) {
s = splbio();
if (bvec != NULL && bvec != bvec_on_stack)
free(bvec, M_TEMP);
/*
* Count up how many buffers waiting for a commit.
*/
@ -2640,12 +2642,16 @@ nfs_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td,
* If we can't get memory (for whatever reason), we will end up
* committing the buffers one-by-one in the loop below.
*/
if (bvec != NULL && bvec != bvec_on_stack)
free(bvec, M_TEMP);
if (bveccount > NFS_COMMITBVECSIZ) {
/*
* Release the vnode interlock to avoid a lock
* order reversal.
*/
VI_UNLOCK(vp);
bvec = (struct buf **)
malloc(bveccount * sizeof(struct buf *),
M_TEMP, M_NOWAIT);
VI_LOCK(vp);
if (bvec == NULL) {
bvec = bvec_on_stack;
bvecsize = NFS_COMMITBVECSIZ;