Changeset View
Changeset View
Standalone View
Standalone View
sys/nlm/nlm_advlock.c
Show First 20 Lines • Show All 445 Lines • ▼ Show 20 Lines | nlm_set_creds_for_lock(struct thread *td, struct flock *fl) | ||||
if (!cred) { | if (!cred) { | ||||
cred = crhold(td->td_ucred); | cred = crhold(td->td_ucred); | ||||
} | } | ||||
td->td_ucred = cred; | td->td_ucred = cred; | ||||
} | } | ||||
static int | static int | ||||
nlm_reclaim_free_lock(struct vnode *vp, struct flock *fl, void *arg) | nlm_reclaim_free_lock(struct vnode *vp, struct xlockf *xl, void *arg) | ||||
{ | { | ||||
struct flock newfl; | struct flock newfl; | ||||
struct thread *td = curthread; | struct thread *td = curthread; | ||||
struct ucred *oldcred; | struct ucred *oldcred; | ||||
int error; | int error; | ||||
newfl = *fl; | newfl.l_start = xl->xl_start; | ||||
newfl.l_len = xl->xl_len; | |||||
newfl.l_pid = xl->xl_pid; | |||||
newfl.l_type = F_UNLCK; | newfl.l_type = F_UNLCK; | ||||
newfl.l_whence = xl->xl_whence; | |||||
newfl.l_sysid = xl->xl_sysid; | |||||
oldcred = td->td_ucred; | oldcred = td->td_ucred; | ||||
nlm_set_creds_for_lock(td, &newfl); | nlm_set_creds_for_lock(td, &newfl); | ||||
error = nlm_advlock_internal(vp, NULL, F_UNLCK, &newfl, F_REMOTE, | error = nlm_advlock_internal(vp, NULL, F_UNLCK, &newfl, F_REMOTE, | ||||
FALSE, FALSE); | FALSE, FALSE); | ||||
crfree(td->td_ucred); | crfree(td->td_ucred); | ||||
Show All 12 Lines | |||||
} | } | ||||
struct nlm_recovery_context { | struct nlm_recovery_context { | ||||
struct nlm_host *nr_host; /* host we are recovering */ | struct nlm_host *nr_host; /* host we are recovering */ | ||||
int nr_state; /* remote NSM state for recovery */ | int nr_state; /* remote NSM state for recovery */ | ||||
}; | }; | ||||
static int | static int | ||||
nlm_client_recover_lock(struct vnode *vp, struct flock *fl, void *arg) | nlm_client_recover_lock(struct vnode *vp, struct xlockf *xl, void *arg) | ||||
{ | { | ||||
struct nlm_recovery_context *nr = (struct nlm_recovery_context *) arg; | struct nlm_recovery_context *nr = (struct nlm_recovery_context *) arg; | ||||
struct thread *td = curthread; | struct thread *td = curthread; | ||||
struct ucred *oldcred; | struct ucred *oldcred; | ||||
int state, error; | int state, error; | ||||
struct flock fl; | |||||
/* | /* | ||||
* If the remote NSM state changes during recovery, the host | * If the remote NSM state changes during recovery, the host | ||||
* must have rebooted a second time. In that case, we must | * must have rebooted a second time. In that case, we must | ||||
* restart the recovery. | * restart the recovery. | ||||
*/ | */ | ||||
state = nlm_host_get_state(nr->nr_host); | state = nlm_host_get_state(nr->nr_host); | ||||
if (nr->nr_state != state) | if (nr->nr_state != state) | ||||
return (ERESTART); | return (ERESTART); | ||||
error = vn_lock(vp, LK_SHARED); | error = vn_lock(vp, LK_SHARED); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
fl.l_start = xl->xl_start; | |||||
fl.l_len = xl->xl_len; | |||||
fl.l_pid = xl->xl_pid; | |||||
fl.l_type = F_UNLCK; | |||||
fl.l_whence = xl->xl_whence; | |||||
fl.l_sysid = xl->xl_sysid; | |||||
oldcred = td->td_ucred; | oldcred = td->td_ucred; | ||||
nlm_set_creds_for_lock(td, fl); | nlm_set_creds_for_lock(td, &fl); | ||||
error = nlm_advlock_internal(vp, NULL, F_SETLK, fl, F_REMOTE, | error = nlm_advlock_internal(vp, NULL, F_SETLK, &fl, F_REMOTE, | ||||
TRUE, TRUE); | TRUE, TRUE); | ||||
crfree(td->td_ucred); | crfree(td->td_ucred); | ||||
td->td_ucred = oldcred; | td->td_ucred = oldcred; | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 753 Lines • Show Last 20 Lines |