UBI: use separate mutex for volumes checking

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jan 8 02:59:03 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=783b273afab43437dca731a229d53d72faf77fd3
Commit:     783b273afab43437dca731a229d53d72faf77fd3
Parent:     897a316c9e6f7fea6f1d3759797b75c0ebaec479
Author:     Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Tue Dec 25 18:13:33 2007 +0200
Committer:  Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
CommitDate: Wed Dec 26 19:15:17 2007 +0200

    UBI: use separate mutex for volumes checking
    
    Introduce a separate mutex which serializes volumes checking,
    because we cammot really use volumes_mutex - it cases reverse
    locking problems with mtd_tbl_mutex when gluebi is used -
    thanks to lockdep.
    
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
 drivers/mtd/ubi/build.c |    1 +
 drivers/mtd/ubi/kapi.c  |   11 +++--------
 drivers/mtd/ubi/ubi.h   |    1 +
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 70c0b9a..6ac1339 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -703,6 +703,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
 		goto out_free;
 
 	mutex_init(&ubi->buf_mutex);
+	mutex_init(&ubi->ckvol_mutex);
 	ubi->peb_buf1 = vmalloc(ubi->peb_size);
 	if (!ubi->peb_buf1)
 		goto out_free;
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 4ec3a33..146957c 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -169,17 +169,12 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
 	desc->vol = vol;
 	desc->mode = mode;
 
-	/*
-	 * To prevent simultaneous checks of the same volume we use
-	 * @volumes_mutex, although it is not the purpose it was introduced
-	 * for.
-	 */
-	mutex_lock(&ubi->volumes_mutex);
+	mutex_lock(&ubi->ckvol_mutex);
 	if (!vol->checked) {
 		/* This is the first open - check the volume */
 		err = ubi_check_volume(ubi, vol_id);
 		if (err < 0) {
-			mutex_unlock(&ubi->volumes_mutex);
+			mutex_unlock(&ubi->ckvol_mutex);
 			ubi_close_volume(desc);
 			return ERR_PTR(err);
 		}
@@ -190,7 +185,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
 		}
 		vol->checked = 1;
 	}
-	mutex_unlock(&ubi->volumes_mutex);
+	mutex_unlock(&ubi->ckvol_mutex);
 
 	return desc;
 
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 2a61712..ef22f92 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -392,6 +392,7 @@ struct ubi_device {
 	void *peb_buf1;
 	void *peb_buf2;
 	struct mutex buf_mutex;
+	struct mutex ckvol_mutex;
 #ifdef CONFIG_MTD_UBI_DEBUG
 	void *dbg_peb_buf;
 	struct mutex dbg_buf_mutex;



More information about the linux-mtd-cvs mailing list