@@ -622,21 +622,28 @@ static int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
static LIST_HEAD(lustre_profile_list);
static DEFINE_SPINLOCK(lustre_profile_list_lock);
-struct lustre_profile *class_get_profile(const char *prof)
+static struct lustre_profile *class_get_profile_nolock(const char *prof)
{
struct lustre_profile *lprof;
- spin_lock(&lustre_profile_list_lock);
list_for_each_entry(lprof, &lustre_profile_list, lp_list) {
- if (!strcmp(lprof->lp_profile, prof)) {
+ if (strcmp(lprof->lp_profile, prof) == 0) {
lprof->lp_refs++;
- spin_unlock(&lustre_profile_list_lock);
return lprof;
}
}
- spin_unlock(&lustre_profile_list_lock);
return NULL;
}
+
+struct lustre_profile *class_get_profile(const char *prof)
+{
+ struct lustre_profile *lprof;
+
+ spin_lock(&lustre_profile_list_lock);
+ lprof = class_get_profile_nolock(prof);
+ spin_unlock(&lustre_profile_list_lock);
+ return lprof;
+}
EXPORT_SYMBOL(class_get_profile);
/** Create a named "profile".
@@ -701,9 +708,9 @@ void class_del_profile(const char *prof)
CDEBUG(D_CONFIG, "Del profile %s\n", prof);
- lprof = class_get_profile(prof);
+ spin_lock(&lustre_profile_list_lock);
+ lprof = class_get_profile_nolock(prof);
if (lprof) {
- spin_lock(&lustre_profile_list_lock);
/* because get profile increments the ref counter */
lprof->lp_refs--;
list_del(&lprof->lp_list);
@@ -711,6 +718,8 @@ void class_del_profile(const char *prof)
spin_unlock(&lustre_profile_list_lock);
class_put_profile(lprof);
+ } else {
+ spin_unlock(&lustre_profile_list_lock);
}
}
EXPORT_SYMBOL(class_del_profile);