mtd: mtdblock: remove the needless mtdblks_lock

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Feb 16 18:59:02 PST 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=362376a7c65936835f39ff29b082a646d522efbc
Commit:     362376a7c65936835f39ff29b082a646d522efbc
Parent:     0b56d2d45e7c27581ca90f36b4317373f23e7622
Author:     Gu Zheng <guz.fnst at cn.fujitsu.com>
AuthorDate: Wed Dec 3 10:19:52 2014 +0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed Jan 7 12:51:56 2015 -0800

    mtd: mtdblock: remove the needless mtdblks_lock
    
    The global lock mtdblks_lock was used to protect the original mtdblks
    array to avoid race conditions. As the mtdblks array was already gone,
    but the mtdblks_lock is left, and it causes latency when open/release dev.
    So we need to remove it here.
    
    Signed-off-by: Gu Zheng <guz.fnst at cn.fujitsu.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/mtdblock.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 485ea75..bb4c14f 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -45,8 +45,6 @@ struct mtdblk_dev {
 	enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state;
 };
 
-static DEFINE_MUTEX(mtdblks_lock);
-
 /*
  * Cache stuff...
  *
@@ -286,10 +284,8 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
 
 	pr_debug("mtdblock_open\n");
 
-	mutex_lock(&mtdblks_lock);
 	if (mtdblk->count) {
 		mtdblk->count++;
-		mutex_unlock(&mtdblks_lock);
 		return 0;
 	}
 
@@ -302,8 +298,6 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
 		mtdblk->cache_data = NULL;
 	}
 
-	mutex_unlock(&mtdblks_lock);
-
 	pr_debug("ok\n");
 
 	return 0;
@@ -315,8 +309,6 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
 
 	pr_debug("mtdblock_release\n");
 
-	mutex_lock(&mtdblks_lock);
-
 	mutex_lock(&mtdblk->cache_mutex);
 	write_cached_data(mtdblk);
 	mutex_unlock(&mtdblk->cache_mutex);
@@ -331,8 +323,6 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
 		vfree(mtdblk->cache_data);
 	}
 
-	mutex_unlock(&mtdblks_lock);
-
 	pr_debug("ok\n");
 }
 



More information about the linux-mtd-cvs mailing list