aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/balloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/balloc.c')
-rw-r--r--fs/ext3/balloc.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index b41a7d7e20f0..22161740ba29 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -144,7 +144,7 @@ restart:
144 144
145 printk("Block Allocation Reservation Windows Map (%s):\n", fn); 145 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
146 while (n) { 146 while (n) {
147 rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node); 147 rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
148 if (verbose) 148 if (verbose)
149 printk("reservation window 0x%p " 149 printk("reservation window 0x%p "
150 "start: %lu, end: %lu\n", 150 "start: %lu, end: %lu\n",
@@ -730,7 +730,7 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
730 here = 0; 730 here = 0;
731 731
732 p = ((char *)bh->b_data) + (here >> 3); 732 p = ((char *)bh->b_data) + (here >> 3);
733 r = memscan(p, 0, (maxblocks - here + 7) >> 3); 733 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
734 next = (r - ((char *)bh->b_data)) << 3; 734 next = (r - ((char *)bh->b_data)) << 3;
735 735
736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh)) 736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
@@ -949,7 +949,7 @@ static int find_next_reservable_window(
949 949
950 prev = rsv; 950 prev = rsv;
951 next = rb_next(&rsv->rsv_node); 951 next = rb_next(&rsv->rsv_node);
952 rsv = list_entry(next,struct ext3_reserve_window_node,rsv_node); 952 rsv = rb_entry(next,struct ext3_reserve_window_node,rsv_node);
953 953
954 /* 954 /*
955 * Reached the last reservation, we can just append to the 955 * Reached the last reservation, we can just append to the
@@ -1148,7 +1148,7 @@ retry:
1148 * check if the first free block is within the 1148 * check if the first free block is within the
1149 * free space we just reserved 1149 * free space we just reserved
1150 */ 1150 */
1151 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) 1151 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
1152 return 0; /* success */ 1152 return 0; /* success */
1153 /* 1153 /*
1154 * if the first free bit we found is out of the reservable space 1154 * if the first free bit we found is out of the reservable space
@@ -1193,7 +1193,7 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1193 if (!next) 1193 if (!next)
1194 my_rsv->rsv_end += size; 1194 my_rsv->rsv_end += size;
1195 else { 1195 else {
1196 next_rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node); 1196 next_rsv = rb_entry(next, struct ext3_reserve_window_node, rsv_node);
1197 1197
1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) 1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1199 my_rsv->rsv_end += size; 1199 my_rsv->rsv_end += size;
@@ -1271,7 +1271,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1271 } 1271 }
1272 /* 1272 /*
1273 * grp_goal is a group relative block number (if there is a goal) 1273 * grp_goal is a group relative block number (if there is a goal)
1274 * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb) 1274 * 0 <= grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
1275 * first block is a filesystem wide block number 1275 * first block is a filesystem wide block number
1276 * first block is the block number of the first block in this group 1276 * first block is the block number of the first block in this group
1277 */ 1277 */
@@ -1307,10 +1307,14 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1307 if (!goal_in_my_reservation(&my_rsv->rsv_window, 1307 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1308 grp_goal, group, sb)) 1308 grp_goal, group, sb))
1309 grp_goal = -1; 1309 grp_goal = -1;
1310 } else if (grp_goal > 0 && 1310 } else if (grp_goal >= 0) {
1311 (my_rsv->rsv_end-grp_goal+1) < *count) 1311 int curr = my_rsv->rsv_end -
1312 try_to_extend_reservation(my_rsv, sb, 1312 (grp_goal + group_first_block) + 1;
1313 *count-my_rsv->rsv_end + grp_goal - 1); 1313
1314 if (curr < *count)
1315 try_to_extend_reservation(my_rsv, sb,
1316 *count - curr);
1317 }
1314 1318
1315 if ((my_rsv->rsv_start > group_last_block) || 1319 if ((my_rsv->rsv_start > group_last_block) ||
1316 (my_rsv->rsv_end < group_first_block)) { 1320 (my_rsv->rsv_end < group_first_block)) {
@@ -1511,10 +1515,8 @@ retry_alloc:
1511 if (group_no >= ngroups) 1515 if (group_no >= ngroups)
1512 group_no = 0; 1516 group_no = 0;
1513 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh); 1517 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
1514 if (!gdp) { 1518 if (!gdp)
1515 *errp = -EIO; 1519 goto io_error;
1516 goto out;
1517 }
1518 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); 1520 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1519 /* 1521 /*
1520 * skip this group if the number of 1522 * skip this group if the number of
@@ -1548,6 +1550,7 @@ retry_alloc:
1548 */ 1550 */
1549 if (my_rsv) { 1551 if (my_rsv) {
1550 my_rsv = NULL; 1552 my_rsv = NULL;
1553 windowsz = 0;
1551 group_no = goal_group; 1554 group_no = goal_group;
1552 goto retry_alloc; 1555 goto retry_alloc;
1553 } 1556 }