summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-11-02 23:15:32 +0000
committerrwatson <rwatson@FreeBSD.org>2008-11-02 23:15:32 +0000
commit4de0ed8a13e19ea3c0d32de28e7f1974cc2a0490 (patch)
treef31b0ff6da1f9379fadfe2805cae5474b594e20c
parentd819bb20f8fec8800e90f58484a1a50ed9820dfd (diff)
downloadFreeBSD-src-4de0ed8a13e19ea3c0d32de28e7f1974cc2a0490.zip
FreeBSD-src-4de0ed8a13e19ea3c0d32de28e7f1974cc2a0490.tar.gz
Catch up internal locking routines in netsmb with lockmgr changes --
explicit thread arguments are no longer required in many places.
-rw-r--r--sys/netsmb/smb_conn.c99
-rw-r--r--sys/netsmb/smb_conn.h12
2 files changed, 54 insertions, 57 deletions
diff --git a/sys/netsmb/smb_conn.c b/sys/netsmb/smb_conn.c
index 3480181..2307f97 100644
--- a/sys/netsmb/smb_conn.c
+++ b/sys/netsmb/smb_conn.c
@@ -63,9 +63,9 @@ SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW, NULL, "SMB protocol");
MALLOC_DEFINE(M_SMBCONN, "smb_conn", "SMB connection");
static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname,
- char *lockname, struct thread *td);
+ char *lockname);
static void smb_co_done(struct smb_connobj *cp);
-static int smb_co_lockstatus(struct smb_connobj *cp, struct thread *td);
+static int smb_co_lockstatus(struct smb_connobj *cp);
static int smb_vc_disconnect(struct smb_vc *vcp);
static void smb_vc_free(struct smb_connobj *cp);
@@ -82,8 +82,8 @@ int
smb_sm_init(void)
{
- smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm", curthread);
- smb_co_unlock(&smb_vclist, 0, curthread);
+ smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm");
+ smb_co_unlock(&smb_vclist, 0);
return 0;
}
@@ -96,30 +96,29 @@ smb_sm_done(void)
SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1);
return EBUSY;
}
- lockmgr(&smb_vclist.co_lock, LK_DRAIN, 0);
+ lockmgr(&smb_vclist.co_lock, LK_DRAIN, NULL);
smb_co_done(&smb_vclist);
return 0;
}
static int
-smb_sm_lockvclist(int flags, struct thread *td)
+smb_sm_lockvclist(int flags)
{
- return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE, td);
+ return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE);
}
static void
-smb_sm_unlockvclist(struct thread *td)
+smb_sm_unlockvclist(void)
{
- smb_co_unlock(&smb_vclist, LK_RELEASE, td);
+ smb_co_unlock(&smb_vclist, LK_RELEASE);
}
static int
smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
struct smb_cred *scred, struct smb_vc **vcpp)
{
- struct thread *td = scred->scr_td;
struct smb_connobj *scp;
struct smb_vc *vcp;
int exact = 1;
@@ -130,7 +129,7 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
vcp = NULL;
SMBCO_FOREACH(scp, &smb_vclist) {
vcp = (struct smb_vc *)scp;
- error = smb_vc_lock(vcp, LK_EXCLUSIVE, td);
+ error = smb_vc_lock(vcp, LK_EXCLUSIVE);
if (error)
continue;
@@ -167,7 +166,7 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
err1:
error = 1;
fail:
- smb_vc_unlock(vcp, 0, td);
+ smb_vc_unlock(vcp, 0);
}
if (vcp) {
smb_vc_ref(vcp);
@@ -180,19 +179,18 @@ int
smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
struct smb_cred *scred, struct smb_vc **vcpp)
{
- struct thread *td = scred->scr_td;
struct smb_vc *vcp;
struct smb_share *ssp = NULL;
int error;
*vcpp = vcp = NULL;
- error = smb_sm_lockvclist(LK_EXCLUSIVE, td);
+ error = smb_sm_lockvclist(LK_EXCLUSIVE);
if (error)
return error;
error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) {
- smb_sm_unlockvclist(td);
+ smb_sm_unlockvclist();
return error;
}
error = smb_sm_lookupint(vcspec, NULL, scred, &vcp);
@@ -215,11 +213,11 @@ smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
else
smb_share_put(ssp, scred);
out:
- smb_sm_unlockvclist(td);
+ smb_sm_unlockvclist();
if (error == 0)
*vcpp = vcp;
else if (vcp) {
- smb_vc_lock(vcp, LK_EXCLUSIVE, scred->scr_td);
+ smb_vc_lock(vcp, LK_EXCLUSIVE);
smb_vc_put(vcp, scred);
}
return error;
@@ -229,15 +227,14 @@ out:
* Common code for connection object
*/
static void
-smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname,
- struct thread *td)
+smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
{
SLIST_INIT(&cp->co_children);
smb_sl_init(&cp->co_interlock, ilockname);
lockinit(&cp->co_lock, PZERO, lockname, 0, 0);
cp->co_level = level;
cp->co_usecount = 1;
- if (smb_co_lock(cp, LK_EXCLUSIVE, td) != 0)
+ if (smb_co_lock(cp, LK_EXCLUSIVE) != 0)
panic("smb_co_init: lock failed");
}
@@ -245,7 +242,7 @@ static void
smb_co_done(struct smb_connobj *cp)
{
smb_sl_destroy(&cp->co_interlock);
- lockmgr(&cp->co_lock, LK_RELEASE, 0);
+ lockmgr(&cp->co_lock, LK_RELEASE, NULL);
lockdestroy(&cp->co_lock);
}
@@ -258,7 +255,7 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred)
cp->co_gone(cp, scred);
parent = cp->co_parent;
if (parent) {
- smb_co_lock(parent, LK_EXCLUSIVE, scred->scr_td);
+ smb_co_lock(parent, LK_EXCLUSIVE);
SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
smb_co_put(parent, scred);
}
@@ -305,7 +302,7 @@ smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred)
if ((flags & LK_INTERLOCK) == 0)
SMB_CO_LOCK(cp);
cp->co_usecount++;
- error = smb_co_lock(cp, flags | LK_INTERLOCK, scred->scr_td);
+ error = smb_co_lock(cp, flags | LK_INTERLOCK);
if (error) {
SMB_CO_LOCK(cp);
cp->co_usecount--;
@@ -336,20 +333,20 @@ smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
}
int
-smb_co_lockstatus(struct smb_connobj *cp, struct thread *td)
+smb_co_lockstatus(struct smb_connobj *cp)
{
return lockstatus(&cp->co_lock);
}
int
-smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td)
+smb_co_lock(struct smb_connobj *cp, int flags)
{
if (cp->co_flags & SMBO_GONE)
return EINVAL;
if ((flags & LK_TYPE_MASK) == 0)
flags |= LK_EXCLUSIVE;
- if (smb_co_lockstatus(cp, td) == LK_EXCLUSIVE &&
+ if (smb_co_lockstatus(cp) == LK_EXCLUSIVE &&
(flags & LK_CANRECURSE) == 0) {
SMBERROR("recursive lock for object %d\n", cp->co_level);
return 0;
@@ -358,7 +355,7 @@ smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td)
}
void
-smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td)
+smb_co_unlock(struct smb_connobj *cp, int flags)
{
(void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock);
}
@@ -366,8 +363,11 @@ smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td)
static void
smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
{
- KASSERT(smb_co_lockstatus(parent, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: parent not locked"));
- KASSERT(smb_co_lockstatus(child, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: child not locked"));
+
+ KASSERT(smb_co_lockstatus(parent) == LK_EXCLUSIVE,
+ ("smb_co_addchild: parent not locked"));
+ KASSERT(smb_co_lockstatus(child) == LK_EXCLUSIVE,
+ ("smb_co_addchild: child not locked"));
smb_co_ref(parent);
SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
@@ -383,7 +383,6 @@ smb_vc_create(struct smb_vcspec *vcspec,
struct smb_cred *scred, struct smb_vc **vcpp)
{
struct smb_vc *vcp;
- struct thread *td = scred->scr_td;
struct ucred *cred = scred->scr_cred;
uid_t uid = vcspec->owner;
gid_t gid = vcspec->group;
@@ -401,7 +400,7 @@ smb_vc_create(struct smb_vcspec *vcspec,
return EPERM;
vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK);
- smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc", td);
+ smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc");
vcp->obj.co_free = smb_vc_free;
vcp->obj.co_gone = smb_vc_gone;
vcp->vc_number = smb_vcnext++;
@@ -538,15 +537,15 @@ smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred)
}
int
-smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td)
+smb_vc_lock(struct smb_vc *vcp, int flags)
{
- return smb_co_lock(VCTOCP(vcp), flags, td);
+ return smb_co_lock(VCTOCP(vcp), flags);
}
void
-smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td)
+smb_vc_unlock(struct smb_vc *vcp, int flags)
{
- smb_co_unlock(VCTOCP(vcp), flags, td);
+ smb_co_unlock(VCTOCP(vcp), flags);
}
int
@@ -598,7 +597,6 @@ int
smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
struct smb_cred *scred, struct smb_share **sspp)
{
- struct thread *td = scred->scr_td;
struct smb_connobj *scp = NULL;
struct smb_share *ssp = NULL;
int error;
@@ -607,12 +605,12 @@ smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
dp->scred = scred;
SMBCO_FOREACH(scp, VCTOCP(vcp)) {
ssp = (struct smb_share *)scp;
- error = smb_share_lock(ssp, LK_EXCLUSIVE, td);
+ error = smb_share_lock(ssp, LK_EXCLUSIVE);
if (error)
continue;
if (smb_vc_cmpshare(ssp, dp) == 0)
break;
- smb_share_unlock(ssp, 0, td);
+ smb_share_unlock(ssp, 0);
}
if (ssp) {
smb_share_ref(ssp);
@@ -694,7 +692,6 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
struct smb_cred *scred, struct smb_share **sspp)
{
struct smb_share *ssp;
- struct thread *td = scred->scr_td;
struct ucred *cred = scred->scr_cred;
uid_t realuid = cred->cr_uid;
uid_t uid = shspec->owner;
@@ -719,7 +716,7 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
if (gid == SMBM_ANY_GROUP)
gid = cred->cr_groups[0];
ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK);
- smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss", td);
+ smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss");
ssp->obj.co_free = smb_share_free;
ssp->obj.co_gone = smb_share_gone;
smb_sl_init(&ssp->ss_stlock, "ssstlock");
@@ -781,15 +778,15 @@ smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
}
int
-smb_share_lock(struct smb_share *ssp, int flags, struct thread *td)
+smb_share_lock(struct smb_share *ssp, int flags)
{
- return smb_co_lock(SSTOCP(ssp), flags, td);
+ return smb_co_lock(SSTOCP(ssp), flags);
}
void
-smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td)
+smb_share_unlock(struct smb_share *ssp, int flags)
{
- smb_co_unlock(SSTOCP(ssp), flags, td);
+ smb_co_unlock(SSTOCP(ssp), flags);
}
int
@@ -866,34 +863,34 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
error = sysctl_wire_old_buffer(req, 0);
if (error)
return (error);
- error = smb_sm_lockvclist(LK_SHARED, td);
+ error = smb_sm_lockvclist(LK_SHARED);
if (error)
return error;
SMBCO_FOREACH(scp1, &smb_vclist) {
vcp = (struct smb_vc *)scp1;
- error = smb_vc_lock(vcp, LK_SHARED, td);
+ error = smb_vc_lock(vcp, LK_SHARED);
if (error)
continue;
smb_vc_getinfo(vcp, &vci);
error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
if (error) {
- smb_vc_unlock(vcp, 0, td);
+ smb_vc_unlock(vcp, 0);
break;
}
SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
ssp = (struct smb_share *)scp2;
- error = smb_share_lock(ssp, LK_SHARED, td);
+ error = smb_share_lock(ssp, LK_SHARED);
if (error) {
error = 0;
continue;
}
smb_share_getinfo(ssp, &ssi);
- smb_share_unlock(ssp, 0, td);
+ smb_share_unlock(ssp, 0);
error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
if (error)
break;
}
- smb_vc_unlock(vcp, 0, td);
+ smb_vc_unlock(vcp, 0);
if (error)
break;
}
@@ -901,6 +898,6 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
itype = SMB_INFO_NONE;
error = SYSCTL_OUT(req, &itype, sizeof(itype));
}
- smb_sm_unlockvclist(td);
+ smb_sm_unlockvclist();
return error;
}
diff --git a/sys/netsmb/smb_conn.h b/sys/netsmb/smb_conn.h
index 6dc95ab..153c83a 100644
--- a/sys/netsmb/smb_conn.h
+++ b/sys/netsmb/smb_conn.h
@@ -363,8 +363,8 @@ void smb_co_ref(struct smb_connobj *cp);
void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred);
int smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred);
void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred);
-int smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td);
-void smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td);
+int smb_co_lock(struct smb_connobj *cp, int flags);
+void smb_co_unlock(struct smb_connobj *cp, int flags);
/*
* session level functions
@@ -377,8 +377,8 @@ int smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred);
void smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred);
void smb_vc_ref(struct smb_vc *vcp);
void smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred);
-int smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td);
-void smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td);
+int smb_vc_lock(struct smb_vc *vcp, int flags);
+void smb_vc_unlock(struct smb_vc *vcp, int flags);
int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec,
struct smb_cred *scred, struct smb_share **sspp);
const char * smb_vc_getpass(struct smb_vc *vcp);
@@ -394,8 +394,8 @@ void smb_share_ref(struct smb_share *ssp);
void smb_share_rele(struct smb_share *ssp, struct smb_cred *scred);
int smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred);
void smb_share_put(struct smb_share *ssp, struct smb_cred *scred);
-int smb_share_lock(struct smb_share *ssp, int flags, struct thread *td);
-void smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td);
+int smb_share_lock(struct smb_share *ssp, int flags);
+void smb_share_unlock(struct smb_share *ssp, int flags);
void smb_share_invalidate(struct smb_share *ssp);
int smb_share_valid(struct smb_share *ssp);
const char * smb_share_getpass(struct smb_share *ssp);
OpenPOWER on IntegriCloud