aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
authorEstelle Hammache <estelle.hammache@st.com>2005-02-05 13:23:40 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-05-23 06:23:54 -0400
commit67d9e95c393d23c229836e28b262dc73d71da784 (patch)
tree1c22b8ad2715d8155570aa082d6c20ed8c269e11 /fs/jffs2
parent72b56a2d7dccd9ea90f34f6ddb653086a3f3bd2e (diff)
[JFFS2] Prevent deadlock during write buffer recovery
Prevent deadlock when checking erased block for space allocation during wbuf recovery. Signed-off-by: Estelle Hammache <estelle.hammache@st.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/wbuf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 4346940b4871..79414abadd5e 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * For licensing information, see the file 'LICENCE' in this directory. 10 * For licensing information, see the file 'LICENCE' in this directory.
11 * 11 *
12 * $Id: wbuf.c,v 1.85 2005/02/02 22:12:04 dwmw2 Exp $ 12 * $Id: wbuf.c,v 1.86 2005/02/05 18:23:37 hammache Exp $
13 * 13 *
14 */ 14 */
15 15
@@ -865,7 +865,6 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re
865 865
866 /* Read flash */ 866 /* Read flash */
867 if (!jffs2_can_mark_obsolete(c)) { 867 if (!jffs2_can_mark_obsolete(c)) {
868 down_read(&c->wbuf_sem);
869 868
870 if (jffs2_cleanmarker_oob(c)) 869 if (jffs2_cleanmarker_oob(c))
871 ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf, NULL, c->oobinfo); 870 ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf, NULL, c->oobinfo);
@@ -892,11 +891,16 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re
892 891
893 /* if no writebuffer available or write buffer empty, return */ 892 /* if no writebuffer available or write buffer empty, return */
894 if (!c->wbuf_pagesize || !c->wbuf_len) 893 if (!c->wbuf_pagesize || !c->wbuf_len)
895 goto exit; 894 return ret;;
896 895
897 /* if we read in a different block, return */ 896 /* if we read in a different block, return */
898 if ( (ofs & ~(c->sector_size-1)) != (c->wbuf_ofs & ~(c->sector_size-1)) ) 897 if ( (ofs & ~(c->sector_size-1)) != (c->wbuf_ofs & ~(c->sector_size-1)) )
899 goto exit; 898 return ret;
899
900 /* Lock only if we have reason to believe wbuf contains relevant data,
901 so that checking an erased block during wbuf recovery space allocation
902 does not deadlock. */
903 down_read(&c->wbuf_sem);
900 904
901 if (ofs >= c->wbuf_ofs) { 905 if (ofs >= c->wbuf_ofs) {
902 owbf = (ofs - c->wbuf_ofs); /* offset in write buffer */ 906 owbf = (ofs - c->wbuf_ofs); /* offset in write buffer */