diff options
Diffstat (limited to 'fs/jffs2/nodemgmt.c')
| -rw-r--r-- | fs/jffs2/nodemgmt.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 9a0f312cfcda..8feb8749bc75 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
| @@ -23,13 +23,12 @@ | |||
| 23 | * jffs2_reserve_space - request physical space to write nodes to flash | 23 | * jffs2_reserve_space - request physical space to write nodes to flash |
| 24 | * @c: superblock info | 24 | * @c: superblock info |
| 25 | * @minsize: Minimum acceptable size of allocation | 25 | * @minsize: Minimum acceptable size of allocation |
| 26 | * @ofs: Returned value of node offset | ||
| 27 | * @len: Returned value of allocation length | 26 | * @len: Returned value of allocation length |
| 28 | * @prio: Allocation type - ALLOC_{NORMAL,DELETION} | 27 | * @prio: Allocation type - ALLOC_{NORMAL,DELETION} |
| 29 | * | 28 | * |
| 30 | * Requests a block of physical space on the flash. Returns zero for success | 29 | * Requests a block of physical space on the flash. Returns zero for success |
| 31 | * and puts 'ofs' and 'len' into the appriopriate place, or returns -ENOSPC | 30 | * and puts 'len' into the appropriate place, or returns -ENOSPC or other |
| 32 | * or other error if appropriate. | 31 | * error if appropriate. Doesn't return len since that's |
| 33 | * | 32 | * |
| 34 | * If it returns zero, jffs2_reserve_space() also downs the per-filesystem | 33 | * If it returns zero, jffs2_reserve_space() also downs the per-filesystem |
| 35 | * allocation semaphore, to prevent more than one allocation from being | 34 | * allocation semaphore, to prevent more than one allocation from being |
| @@ -40,9 +39,9 @@ | |||
| 40 | */ | 39 | */ |
| 41 | 40 | ||
| 42 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | 41 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, |
| 43 | uint32_t *ofs, uint32_t *len, uint32_t sumsize); | 42 | uint32_t *len, uint32_t sumsize); |
| 44 | 43 | ||
| 45 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | 44 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, |
| 46 | uint32_t *len, int prio, uint32_t sumsize) | 45 | uint32_t *len, int prio, uint32_t sumsize) |
| 47 | { | 46 | { |
| 48 | int ret = -EAGAIN; | 47 | int ret = -EAGAIN; |
| @@ -132,7 +131,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
| 132 | spin_lock(&c->erase_completion_lock); | 131 | spin_lock(&c->erase_completion_lock); |
| 133 | } | 132 | } |
| 134 | 133 | ||
| 135 | ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); | 134 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
| 136 | if (ret) { | 135 | if (ret) { |
| 137 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); | 136 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); |
| 138 | } | 137 | } |
| @@ -143,8 +142,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
| 143 | return ret; | 142 | return ret; |
| 144 | } | 143 | } |
| 145 | 144 | ||
| 146 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | 145 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, |
| 147 | uint32_t *len, uint32_t sumsize) | 146 | uint32_t *len, uint32_t sumsize) |
| 148 | { | 147 | { |
| 149 | int ret = -EAGAIN; | 148 | int ret = -EAGAIN; |
| 150 | minsize = PAD(minsize); | 149 | minsize = PAD(minsize); |
| @@ -153,7 +152,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t * | |||
| 153 | 152 | ||
| 154 | spin_lock(&c->erase_completion_lock); | 153 | spin_lock(&c->erase_completion_lock); |
| 155 | while(ret == -EAGAIN) { | 154 | while(ret == -EAGAIN) { |
| 156 | ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); | 155 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
| 157 | if (ret) { | 156 | if (ret) { |
| 158 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); | 157 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); |
| 159 | } | 158 | } |
| @@ -259,10 +258,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
| 259 | } | 258 | } |
| 260 | 259 | ||
| 261 | /* Called with alloc sem _and_ erase_completion_lock */ | 260 | /* Called with alloc sem _and_ erase_completion_lock */ |
| 262 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, uint32_t sumsize) | 261 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, |
| 262 | uint32_t *len, uint32_t sumsize) | ||
| 263 | { | 263 | { |
| 264 | struct jffs2_eraseblock *jeb = c->nextblock; | 264 | struct jffs2_eraseblock *jeb = c->nextblock; |
| 265 | uint32_t reserved_size; /* for summary information at the end of the jeb */ | 265 | uint32_t reserved_size; /* for summary information at the end of the jeb */ |
| 266 | int ret; | 266 | int ret; |
| 267 | 267 | ||
| 268 | restart: | 268 | restart: |
| @@ -349,7 +349,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin | |||
| 349 | } | 349 | } |
| 350 | /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has | 350 | /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has |
| 351 | enough space */ | 351 | enough space */ |
| 352 | *ofs = jeb->offset + (c->sector_size - jeb->free_size); | ||
| 353 | *len = jeb->free_size - reserved_size; | 352 | *len = jeb->free_size - reserved_size; |
| 354 | 353 | ||
| 355 | if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && | 354 | if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && |
| @@ -365,7 +364,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin | |||
| 365 | spin_lock(&c->erase_completion_lock); | 364 | spin_lock(&c->erase_completion_lock); |
| 366 | } | 365 | } |
| 367 | 366 | ||
| 368 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", *len, *ofs)); | 367 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", |
| 368 | *len, jeb->offset + (c->sector_size - jeb->free_size))); | ||
| 369 | return 0; | 369 | return 0; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| @@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin | |||
| 381 | * Must be called with the alloc_sem held. | 381 | * Must be called with the alloc_sem held. |
| 382 | */ | 382 | */ |
| 383 | 383 | ||
| 384 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len) | 384 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, |
| 385 | uint32_t len, struct jffs2_inode_cache *ic) | ||
| 385 | { | 386 | { |
| 386 | struct jffs2_eraseblock *jeb; | 387 | struct jffs2_eraseblock *jeb; |
| 387 | 388 | ||
| @@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r | |||
| 403 | #endif | 404 | #endif |
| 404 | spin_lock(&c->erase_completion_lock); | 405 | spin_lock(&c->erase_completion_lock); |
| 405 | 406 | ||
| 406 | jffs2_link_node_ref(c, jeb, new, len); | 407 | jffs2_link_node_ref(c, jeb, new, len, ic); |
| 407 | 408 | ||
| 408 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { | 409 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { |
| 409 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ | 410 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ |
| @@ -660,6 +661,10 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
| 660 | spin_lock(&c->erase_completion_lock); | 661 | spin_lock(&c->erase_completion_lock); |
| 661 | 662 | ||
| 662 | ic = jffs2_raw_ref_to_ic(ref); | 663 | ic = jffs2_raw_ref_to_ic(ref); |
| 664 | /* It seems we should never call jffs2_mark_node_obsolete() for | ||
| 665 | XATTR nodes.... yet. Make sure we notice if/when we change | ||
| 666 | that :) */ | ||
| 667 | BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE); | ||
| 663 | for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino)) | 668 | for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino)) |
| 664 | ; | 669 | ; |
| 665 | 670 | ||
