aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/readinode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r--fs/jffs2/readinode.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index e512a93d6249..4cb4d76de07f 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -825,8 +825,9 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
825 else // normal case... 825 else // normal case...
826 tn->fn->size = je32_to_cpu(rd->dsize); 826 tn->fn->size = je32_to_cpu(rd->dsize);
827 827
828 dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n", 828 dbg_readinode2("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",
829 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize); 829 ref_offset(ref), je32_to_cpu(rd->version),
830 je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);
830 831
831 ret = jffs2_add_tn_to_tree(c, rii, tn); 832 ret = jffs2_add_tn_to_tree(c, rii, tn);
832 833
@@ -836,13 +837,13 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
836 jffs2_free_tmp_dnode_info(tn); 837 jffs2_free_tmp_dnode_info(tn);
837 return ret; 838 return ret;
838 } 839 }
839#ifdef JFFS2_DBG_READINODE_MESSAGES 840#ifdef JFFS2_DBG_READINODE2_MESSAGES
840 dbg_readinode("After adding ver %d:\n", je32_to_cpu(rd->version)); 841 dbg_readinode2("After adding ver %d:\n", je32_to_cpu(rd->version));
841 tn = tn_first(&rii->tn_root); 842 tn = tn_first(&rii->tn_root);
842 while (tn) { 843 while (tn) {
843 dbg_readinode("%p: v %d r 0x%x-0x%x ov %d\n", 844 dbg_readinode2("%p: v %d r 0x%x-0x%x ov %d\n",
844 tn, tn->version, tn->fn->ofs, 845 tn, tn->version, tn->fn->ofs,
845 tn->fn->ofs+tn->fn->size, tn->overlapped); 846 tn->fn->ofs+tn->fn->size, tn->overlapped);
846 tn = tn_next(tn); 847 tn = tn_next(tn);
847 } 848 }
848#endif 849#endif
@@ -1193,7 +1194,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1193 JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n", 1194 JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n",
1194 ret, retlen, sizeof(*latest_node)); 1195 ret, retlen, sizeof(*latest_node));
1195 /* FIXME: If this fails, there seems to be a memory leak. Find it. */ 1196 /* FIXME: If this fails, there seems to be a memory leak. Find it. */
1196 up(&f->sem); 1197 mutex_unlock(&f->sem);
1197 jffs2_do_clear_inode(c, f); 1198 jffs2_do_clear_inode(c, f);
1198 return ret?ret:-EIO; 1199 return ret?ret:-EIO;
1199 } 1200 }
@@ -1202,7 +1203,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1202 if (crc != je32_to_cpu(latest_node->node_crc)) { 1203 if (crc != je32_to_cpu(latest_node->node_crc)) {
1203 JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n", 1204 JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n",
1204 f->inocache->ino, ref_offset(rii.latest_ref)); 1205 f->inocache->ino, ref_offset(rii.latest_ref));
1205 up(&f->sem); 1206 mutex_unlock(&f->sem);
1206 jffs2_do_clear_inode(c, f); 1207 jffs2_do_clear_inode(c, f);
1207 return -EIO; 1208 return -EIO;
1208 } 1209 }
@@ -1242,7 +1243,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1242 f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); 1243 f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL);
1243 if (!f->target) { 1244 if (!f->target) {
1244 JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize)); 1245 JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize));
1245 up(&f->sem); 1246 mutex_unlock(&f->sem);
1246 jffs2_do_clear_inode(c, f); 1247 jffs2_do_clear_inode(c, f);
1247 return -ENOMEM; 1248 return -ENOMEM;
1248 } 1249 }
@@ -1255,7 +1256,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1255 ret = -EIO; 1256 ret = -EIO;
1256 kfree(f->target); 1257 kfree(f->target);
1257 f->target = NULL; 1258 f->target = NULL;
1258 up(&f->sem); 1259 mutex_unlock(&f->sem);
1259 jffs2_do_clear_inode(c, f); 1260 jffs2_do_clear_inode(c, f);
1260 return -ret; 1261 return -ret;
1261 } 1262 }
@@ -1273,14 +1274,14 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1273 if (f->metadata) { 1274 if (f->metadata) {
1274 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", 1275 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n",
1275 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 1276 f->inocache->ino, jemode_to_cpu(latest_node->mode));
1276 up(&f->sem); 1277 mutex_unlock(&f->sem);
1277 jffs2_do_clear_inode(c, f); 1278 jffs2_do_clear_inode(c, f);
1278 return -EIO; 1279 return -EIO;
1279 } 1280 }
1280 if (!frag_first(&f->fragtree)) { 1281 if (!frag_first(&f->fragtree)) {
1281 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", 1282 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n",
1282 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 1283 f->inocache->ino, jemode_to_cpu(latest_node->mode));
1283 up(&f->sem); 1284 mutex_unlock(&f->sem);
1284 jffs2_do_clear_inode(c, f); 1285 jffs2_do_clear_inode(c, f);
1285 return -EIO; 1286 return -EIO;
1286 } 1287 }
@@ -1289,7 +1290,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1289 JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n", 1290 JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n",
1290 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 1291 f->inocache->ino, jemode_to_cpu(latest_node->mode));
1291 /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ 1292 /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */
1292 up(&f->sem); 1293 mutex_unlock(&f->sem);
1293 jffs2_do_clear_inode(c, f); 1294 jffs2_do_clear_inode(c, f);
1294 return -EIO; 1295 return -EIO;
1295 } 1296 }
@@ -1379,12 +1380,13 @@ int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i
1379 if (!f) 1380 if (!f)
1380 return -ENOMEM; 1381 return -ENOMEM;
1381 1382
1382 init_MUTEX_LOCKED(&f->sem); 1383 mutex_init(&f->sem);
1384 mutex_lock(&f->sem);
1383 f->inocache = ic; 1385 f->inocache = ic;
1384 1386
1385 ret = jffs2_do_read_inode_internal(c, f, &n); 1387 ret = jffs2_do_read_inode_internal(c, f, &n);
1386 if (!ret) { 1388 if (!ret) {
1387 up(&f->sem); 1389 mutex_unlock(&f->sem);
1388 jffs2_do_clear_inode(c, f); 1390 jffs2_do_clear_inode(c, f);
1389 } 1391 }
1390 kfree (f); 1392 kfree (f);
@@ -1398,7 +1400,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
1398 1400
1399 jffs2_clear_acl(f); 1401 jffs2_clear_acl(f);
1400 jffs2_xattr_delete_inode(c, f->inocache); 1402 jffs2_xattr_delete_inode(c, f->inocache);
1401 down(&f->sem); 1403 mutex_lock(&f->sem);
1402 deleted = f->inocache && !f->inocache->nlink; 1404 deleted = f->inocache && !f->inocache->nlink;
1403 1405
1404 if (f->inocache && f->inocache->state != INO_STATE_CHECKING) 1406 if (f->inocache && f->inocache->state != INO_STATE_CHECKING)
@@ -1430,5 +1432,5 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
1430 jffs2_del_ino_cache(c, f->inocache); 1432 jffs2_del_ino_cache(c, f->inocache);
1431 } 1433 }
1432 1434
1433 up(&f->sem); 1435 mutex_unlock(&f->sem);
1434} 1436}