staging: lustre: fix lock imbalance
nrs_resource_put_safe() might hold a lock one one struct while operating on the other. There are 2 levels of structures. Use nrs_policy_put(), which has locking baked in. sparse gives the following warning: drivers/staging/lustre//lustre/ptlrpc/nrs.c:498:39: warning: context imbalance in 'nrs_resource_put_safe' - different lock contexts for basic block Signed-off-by: Joshua Clayton <stillcompiling@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ad0d779938
commit
a4113d61e5
|
@ -482,7 +482,6 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs,
|
||||||
static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
|
static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
|
||||||
{
|
{
|
||||||
struct ptlrpc_nrs_policy *pols[NRS_RES_MAX];
|
struct ptlrpc_nrs_policy *pols[NRS_RES_MAX];
|
||||||
struct ptlrpc_nrs *nrs = NULL;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < NRS_RES_MAX; i++) {
|
for (i = 0; i < NRS_RES_MAX; i++) {
|
||||||
|
@ -496,18 +495,9 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NRS_RES_MAX; i++) {
|
for (i = 0; i < NRS_RES_MAX; i++) {
|
||||||
if (pols[i] == NULL)
|
if (pols[i])
|
||||||
continue;
|
nrs_policy_put(pols[i]);
|
||||||
|
|
||||||
if (nrs == NULL) {
|
|
||||||
nrs = pols[i]->pol_nrs;
|
|
||||||
spin_lock(&nrs->nrs_lock);
|
|
||||||
}
|
|
||||||
nrs_policy_put_locked(pols[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nrs != NULL)
|
|
||||||
spin_unlock(&nrs->nrs_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue