diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-04-22 10:13:40 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-04-22 10:13:40 -0400 |
commit | ced22070363ef50e4a47aadd003a81ebeaa3f917 (patch) | |
tree | 66f094dce47a5a0f8f9936308fffe57e2c50255a /fs/jffs2/readinode.c | |
parent | 52f8301437a0ba744265e0549ee7239eb85426fc (diff) |
[JFFS2] semaphore->mutex conversion
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r-- | fs/jffs2/readinode.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index e512a93d6249..8a7cf1e8d68a 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -1193,7 +1193,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", | 1193 | JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n", |
1194 | ret, retlen, sizeof(*latest_node)); | 1194 | ret, retlen, sizeof(*latest_node)); |
1195 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ | 1195 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ |
1196 | up(&f->sem); | 1196 | mutex_unlock(&f->sem); |
1197 | jffs2_do_clear_inode(c, f); | 1197 | jffs2_do_clear_inode(c, f); |
1198 | return ret?ret:-EIO; | 1198 | return ret?ret:-EIO; |
1199 | } | 1199 | } |
@@ -1202,7 +1202,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1202 | if (crc != je32_to_cpu(latest_node->node_crc)) { | 1202 | 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", | 1203 | 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)); | 1204 | f->inocache->ino, ref_offset(rii.latest_ref)); |
1205 | up(&f->sem); | 1205 | mutex_unlock(&f->sem); |
1206 | jffs2_do_clear_inode(c, f); | 1206 | jffs2_do_clear_inode(c, f); |
1207 | return -EIO; | 1207 | return -EIO; |
1208 | } | 1208 | } |
@@ -1242,7 +1242,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); | 1242 | f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); |
1243 | if (!f->target) { | 1243 | 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)); | 1244 | 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); | 1245 | mutex_unlock(&f->sem); |
1246 | jffs2_do_clear_inode(c, f); | 1246 | jffs2_do_clear_inode(c, f); |
1247 | return -ENOMEM; | 1247 | return -ENOMEM; |
1248 | } | 1248 | } |
@@ -1255,7 +1255,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1255 | ret = -EIO; | 1255 | ret = -EIO; |
1256 | kfree(f->target); | 1256 | kfree(f->target); |
1257 | f->target = NULL; | 1257 | f->target = NULL; |
1258 | up(&f->sem); | 1258 | mutex_unlock(&f->sem); |
1259 | jffs2_do_clear_inode(c, f); | 1259 | jffs2_do_clear_inode(c, f); |
1260 | return -ret; | 1260 | return -ret; |
1261 | } | 1261 | } |
@@ -1273,14 +1273,14 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1273 | if (f->metadata) { | 1273 | if (f->metadata) { |
1274 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", | 1274 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", |
1275 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 1275 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
1276 | up(&f->sem); | 1276 | mutex_unlock(&f->sem); |
1277 | jffs2_do_clear_inode(c, f); | 1277 | jffs2_do_clear_inode(c, f); |
1278 | return -EIO; | 1278 | return -EIO; |
1279 | } | 1279 | } |
1280 | if (!frag_first(&f->fragtree)) { | 1280 | if (!frag_first(&f->fragtree)) { |
1281 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", | 1281 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", |
1282 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 1282 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
1283 | up(&f->sem); | 1283 | mutex_unlock(&f->sem); |
1284 | jffs2_do_clear_inode(c, f); | 1284 | jffs2_do_clear_inode(c, f); |
1285 | return -EIO; | 1285 | return -EIO; |
1286 | } | 1286 | } |
@@ -1289,7 +1289,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", | 1289 | 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)); | 1290 | 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 */ | 1291 | /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ |
1292 | up(&f->sem); | 1292 | mutex_unlock(&f->sem); |
1293 | jffs2_do_clear_inode(c, f); | 1293 | jffs2_do_clear_inode(c, f); |
1294 | return -EIO; | 1294 | return -EIO; |
1295 | } | 1295 | } |
@@ -1379,12 +1379,13 @@ int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i | |||
1379 | if (!f) | 1379 | if (!f) |
1380 | return -ENOMEM; | 1380 | return -ENOMEM; |
1381 | 1381 | ||
1382 | init_MUTEX_LOCKED(&f->sem); | 1382 | mutex_init(&f->sem); |
1383 | mutex_lock(&f->sem); | ||
1383 | f->inocache = ic; | 1384 | f->inocache = ic; |
1384 | 1385 | ||
1385 | ret = jffs2_do_read_inode_internal(c, f, &n); | 1386 | ret = jffs2_do_read_inode_internal(c, f, &n); |
1386 | if (!ret) { | 1387 | if (!ret) { |
1387 | up(&f->sem); | 1388 | mutex_unlock(&f->sem); |
1388 | jffs2_do_clear_inode(c, f); | 1389 | jffs2_do_clear_inode(c, f); |
1389 | } | 1390 | } |
1390 | kfree (f); | 1391 | kfree (f); |
@@ -1398,7 +1399,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
1398 | 1399 | ||
1399 | jffs2_clear_acl(f); | 1400 | jffs2_clear_acl(f); |
1400 | jffs2_xattr_delete_inode(c, f->inocache); | 1401 | jffs2_xattr_delete_inode(c, f->inocache); |
1401 | down(&f->sem); | 1402 | mutex_lock(&f->sem); |
1402 | deleted = f->inocache && !f->inocache->nlink; | 1403 | deleted = f->inocache && !f->inocache->nlink; |
1403 | 1404 | ||
1404 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) | 1405 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) |
@@ -1430,5 +1431,5 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
1430 | jffs2_del_ino_cache(c, f->inocache); | 1431 | jffs2_del_ino_cache(c, f->inocache); |
1431 | } | 1432 | } |
1432 | 1433 | ||
1433 | up(&f->sem); | 1434 | mutex_unlock(&f->sem); |
1434 | } | 1435 | } |