Using a mutex instead of a spinlock results in more flexibility (
i.e it allows to sleep while the lock is held).
Signed-off-by: Shraddha Barke <shraddha.6596(a)gmail.com>
---
Changes in v2:
-Replace DEFINE_SPINLOCK() with DEFINE_MUTEX
drivers/staging/lustre/lustre/llite/llite_lib.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index ab4839c..cd71eaa 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -61,7 +61,7 @@ struct dentry *llite_root;
struct kset *llite_kset;
static LIST_HEAD(ll_super_blocks);
-static DEFINE_SPINLOCK(ll_sb_lock);
+static DEFINE_MUTEX(ll_sb_lock);
#ifndef log2
#define log2(n) ffz(~(n))
@@ -112,9 +112,9 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb)
class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
CDEBUG(D_CONFIG, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
- spin_lock(&ll_sb_lock);
+ mutex_lock(&ll_sb_lock);
list_add_tail(&sbi->ll_list, &ll_super_blocks);
- spin_unlock(&ll_sb_lock);
+ mutex_unlock(&ll_sb_lock);
sbi->ll_flags |= LL_SBI_VERBOSE;
sbi->ll_flags |= LL_SBI_CHECKSUM;
@@ -145,9 +145,9 @@ static void ll_free_sbi(struct super_block *sb)
struct ll_sb_info *sbi = ll_s2sbi(sb);
if (sbi != NULL) {
- spin_lock(&ll_sb_lock);
+ mutex_lock(&ll_sb_lock);
list_del(&sbi->ll_list);
- spin_unlock(&ll_sb_lock);
+ mutex_unlock(&ll_sb_lock);
kfree(sbi);
}
}
--
2.1.0