Ensure that vnode for directory isn't reclaimed before ffs_snapshot() has

completed expunging unlinked files.  It could come back at another memory
location causing a lock order reversal.
This commit is contained in:
Tor Egge 2006-03-19 21:05:10 +00:00
parent 87f0769a57
commit 8c86028f11

View File

@ -269,12 +269,11 @@ ffs_snapshot(mp, snapfile)
} }
VOP_LEASE(nd.ni_dvp, td, KERNCRED, LEASE_WRITE); VOP_LEASE(nd.ni_dvp, td, KERNCRED, LEASE_WRITE);
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vat); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vat);
vhold(nd.ni_dvp); VOP_UNLOCK(nd.ni_dvp, 0, td);
vput(nd.ni_dvp);
if (error) { if (error) {
NDFREE(&nd, NDF_ONLY_PNBUF); NDFREE(&nd, NDF_ONLY_PNBUF);
vn_finished_write(wrtmp); vn_finished_write(wrtmp);
vdrop(nd.ni_dvp); vrele(nd.ni_dvp);
return (error); return (error);
} }
vp = nd.ni_vp; vp = nd.ni_vp;
@ -580,7 +579,6 @@ ffs_snapshot(mp, snapfile)
MNT_ILOCK(mp); MNT_ILOCK(mp);
} }
MNT_IUNLOCK(mp); MNT_IUNLOCK(mp);
vdrop(nd.ni_dvp);
/* /*
* If there already exist snapshots on this filesystem, grab a * If there already exist snapshots on this filesystem, grab a
* reference to their shared lock. If this is the first snapshot * reference to their shared lock. If this is the first snapshot
@ -796,6 +794,7 @@ ffs_snapshot(mp, snapfile)
vput(vp); vput(vp);
else else
VOP_UNLOCK(vp, 0, td); VOP_UNLOCK(vp, 0, td);
vrele(nd.ni_dvp);
vn_finished_write(wrtmp); vn_finished_write(wrtmp);
process_deferred_inactive(mp); process_deferred_inactive(mp);
return (error); return (error);