On 2015/08/06, 1:37 PM, "Shraddha Barke" <shraddha.6596(a)gmail.com> wrote:
Using a mutex instead of a spinlock results in more flexibility (
i.e it allows to sleep while the lock is held).
Nak.
I don't see any reason for this patch at all. Why would we want the
overhead of a mutex instead of a spinlock for adding something to a
list (i.e. something that only takes a few CPU cycles and is typically
uncontended)? This code definitely could never sleep, so there isn't
any reason to have a mutex here.
Looking into this code further, I see that ll_super_blocks and ll_list
are not actually used anymore, so their usage could be removed entirely.
That would be a much more useful patch to submit.
Cheers, Andreas
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
Cheers, Andreas
--
Andreas Dilger
Lustre Software Architect
Intel High Performance Data Division