fd: stop looping in pwd_hold
We don't expect to fail acquiring the reference unless running into a corner case. Just in case ensure forward progress by taking the lock. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D25616
This commit is contained in:
parent
463b8ebdcb
commit
373278a7f6
@ -3347,13 +3347,17 @@ pwd_hold(struct thread *td)
|
|||||||
fdp = td->td_proc->p_fd;
|
fdp = td->td_proc->p_fd;
|
||||||
|
|
||||||
smr_enter(pwd_smr);
|
smr_enter(pwd_smr);
|
||||||
for (;;) {
|
pwd = smr_entered_load(&fdp->fd_pwd, pwd_smr);
|
||||||
pwd = smr_entered_load(&fdp->fd_pwd, pwd_smr);
|
MPASS(pwd != NULL);
|
||||||
MPASS(pwd != NULL);
|
if (__predict_true(refcount_acquire_if_not_zero(&pwd->pwd_refcount))) {
|
||||||
if (refcount_acquire_if_not_zero(&pwd->pwd_refcount))
|
smr_exit(pwd_smr);
|
||||||
break;
|
return (pwd);
|
||||||
}
|
}
|
||||||
smr_exit(pwd_smr);
|
smr_exit(pwd_smr);
|
||||||
|
FILEDESC_SLOCK(fdp);
|
||||||
|
pwd = pwd_hold_filedesc(fdp);
|
||||||
|
MPASS(pwd != NULL);
|
||||||
|
FILEDESC_SUNLOCK(fdp);
|
||||||
return (pwd);
|
return (pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user