aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/balloc.c
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2008-10-15 06:29:03 -0400
committerJan Kara <jack@suse.cz>2009-04-02 06:29:47 -0400
commit97e961fdbf32488b7386c9f1effa2bee97d47929 (patch)
treefa006f5e803e532c9781d4f5f6e34cf9d8382814 /fs/udf/balloc.c
parent5ca4e4be841e389d7d17833fef7be2359f290163 (diff)
Fix the udf code not to pass structs on stack where possible.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/balloc.c')
-rw-r--r--fs/udf/balloc.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 1237900e81b6..94d876a6d19a 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -92,7 +92,7 @@ static int read_block_bitmap(struct super_block *sb,
92 loc.logicalBlockNum = bitmap->s_extPosition; 92 loc.logicalBlockNum = bitmap->s_extPosition;
93 loc.partitionReferenceNum = UDF_SB(sb)->s_partition; 93 loc.partitionReferenceNum = UDF_SB(sb)->s_partition;
94 94
95 bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); 95 bh = udf_tread(sb, udf_get_lb_pblock(sb, &loc, block));
96 if (!bh) 96 if (!bh)
97 retval = -EIO; 97 retval = -EIO;
98 98
@@ -156,11 +156,13 @@ static bool udf_add_free_space(struct udf_sb_info *sbi,
156static void udf_bitmap_free_blocks(struct super_block *sb, 156static void udf_bitmap_free_blocks(struct super_block *sb,
157 struct inode *inode, 157 struct inode *inode,
158 struct udf_bitmap *bitmap, 158 struct udf_bitmap *bitmap,
159 struct kernel_lb_addr bloc, uint32_t offset, 159 struct kernel_lb_addr *bloc,
160 uint32_t offset,
160 uint32_t count) 161 uint32_t count)
161{ 162{
162 struct udf_sb_info *sbi = UDF_SB(sb); 163 struct udf_sb_info *sbi = UDF_SB(sb);
163 struct buffer_head *bh = NULL; 164 struct buffer_head *bh = NULL;
165 struct udf_part_map *partmap;
164 unsigned long block; 166 unsigned long block;
165 unsigned long block_group; 167 unsigned long block_group;
166 unsigned long bit; 168 unsigned long bit;
@@ -169,17 +171,17 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
169 unsigned long overflow; 171 unsigned long overflow;
170 172
171 mutex_lock(&sbi->s_alloc_mutex); 173 mutex_lock(&sbi->s_alloc_mutex);
172 if (bloc.logicalBlockNum < 0 || 174 partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
173 (bloc.logicalBlockNum + count) > 175 if (bloc->logicalBlockNum < 0 ||
174 sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { 176 (bloc->logicalBlockNum + count) >
177 partmap->s_partition_len) {
175 udf_debug("%d < %d || %d + %d > %d\n", 178 udf_debug("%d < %d || %d + %d > %d\n",
176 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, 179 bloc->logicalBlockNum, 0, bloc->logicalBlockNum,
177 sbi->s_partmaps[bloc.partitionReferenceNum]. 180 count, partmap->s_partition_len);
178 s_partition_len);
179 goto error_return; 181 goto error_return;
180 } 182 }
181 183
182 block = bloc.logicalBlockNum + offset + 184 block = bloc->logicalBlockNum + offset +
183 (sizeof(struct spaceBitmapDesc) << 3); 185 (sizeof(struct spaceBitmapDesc) << 3);
184 186
185 do { 187 do {
@@ -425,10 +427,12 @@ error_return:
425static void udf_table_free_blocks(struct super_block *sb, 427static void udf_table_free_blocks(struct super_block *sb,
426 struct inode *inode, 428 struct inode *inode,
427 struct inode *table, 429 struct inode *table,
428 struct kernel_lb_addr bloc, uint32_t offset, 430 struct kernel_lb_addr *bloc,
431 uint32_t offset,
429 uint32_t count) 432 uint32_t count)
430{ 433{
431 struct udf_sb_info *sbi = UDF_SB(sb); 434 struct udf_sb_info *sbi = UDF_SB(sb);
435 struct udf_part_map *partmap;
432 uint32_t start, end; 436 uint32_t start, end;
433 uint32_t elen; 437 uint32_t elen;
434 struct kernel_lb_addr eloc; 438 struct kernel_lb_addr eloc;
@@ -438,13 +442,13 @@ static void udf_table_free_blocks(struct super_block *sb,
438 struct udf_inode_info *iinfo; 442 struct udf_inode_info *iinfo;
439 443
440 mutex_lock(&sbi->s_alloc_mutex); 444 mutex_lock(&sbi->s_alloc_mutex);
441 if (bloc.logicalBlockNum < 0 || 445 partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
442 (bloc.logicalBlockNum + count) > 446 if (bloc->logicalBlockNum < 0 ||
443 sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { 447 (bloc->logicalBlockNum + count) >
448 partmap->s_partition_len) {
444 udf_debug("%d < %d || %d + %d > %d\n", 449 udf_debug("%d < %d || %d + %d > %d\n",
445 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, 450 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
446 sbi->s_partmaps[bloc.partitionReferenceNum]. 451 partmap->s_partition_len);
447 s_partition_len);
448 goto error_return; 452 goto error_return;
449 } 453 }
450 454
@@ -456,8 +460,8 @@ static void udf_table_free_blocks(struct super_block *sb,
456 if (udf_add_free_space(sbi, sbi->s_partition, count)) 460 if (udf_add_free_space(sbi, sbi->s_partition, count))
457 mark_buffer_dirty(sbi->s_lvid_bh); 461 mark_buffer_dirty(sbi->s_lvid_bh);
458 462
459 start = bloc.logicalBlockNum + offset; 463 start = bloc->logicalBlockNum + offset;
460 end = bloc.logicalBlockNum + offset + count - 1; 464 end = bloc->logicalBlockNum + offset + count - 1;
461 465
462 epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); 466 epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
463 elen = 0; 467 elen = 0;
@@ -483,7 +487,7 @@ static void udf_table_free_blocks(struct super_block *sb,
483 start += count; 487 start += count;
484 count = 0; 488 count = 0;
485 } 489 }
486 udf_write_aext(table, &oepos, eloc, elen, 1); 490 udf_write_aext(table, &oepos, &eloc, elen, 1);
487 } else if (eloc.logicalBlockNum == (end + 1)) { 491 } else if (eloc.logicalBlockNum == (end + 1)) {
488 if ((0x3FFFFFFF - elen) < 492 if ((0x3FFFFFFF - elen) <
489 (count << sb->s_blocksize_bits)) { 493 (count << sb->s_blocksize_bits)) {
@@ -502,7 +506,7 @@ static void udf_table_free_blocks(struct super_block *sb,
502 end -= count; 506 end -= count;
503 count = 0; 507 count = 0;
504 } 508 }
505 udf_write_aext(table, &oepos, eloc, elen, 1); 509 udf_write_aext(table, &oepos, &eloc, elen, 1);
506 } 510 }
507 511
508 if (epos.bh != oepos.bh) { 512 if (epos.bh != oepos.bh) {
@@ -563,7 +567,7 @@ static void udf_table_free_blocks(struct super_block *sb,
563 elen -= sb->s_blocksize; 567 elen -= sb->s_blocksize;
564 568
565 epos.bh = udf_tread(sb, 569 epos.bh = udf_tread(sb,
566 udf_get_lb_pblock(sb, epos.block, 0)); 570 udf_get_lb_pblock(sb, &epos.block, 0));
567 if (!epos.bh) { 571 if (!epos.bh) {
568 brelse(oepos.bh); 572 brelse(oepos.bh);
569 goto error_return; 573 goto error_return;
@@ -635,7 +639,7 @@ static void udf_table_free_blocks(struct super_block *sb,
635 639
636 /* It's possible that stealing the block emptied the extent */ 640 /* It's possible that stealing the block emptied the extent */
637 if (elen) { 641 if (elen) {
638 udf_write_aext(table, &epos, eloc, elen, 1); 642 udf_write_aext(table, &epos, &eloc, elen, 1);
639 643
640 if (!epos.bh) { 644 if (!epos.bh) {
641 iinfo->i_lenAlloc += adsize; 645 iinfo->i_lenAlloc += adsize;
@@ -707,7 +711,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
707 alloc_count = block_count; 711 alloc_count = block_count;
708 eloc.logicalBlockNum += alloc_count; 712 eloc.logicalBlockNum += alloc_count;
709 elen -= (alloc_count << sb->s_blocksize_bits); 713 elen -= (alloc_count << sb->s_blocksize_bits);
710 udf_write_aext(table, &epos, eloc, 714 udf_write_aext(table, &epos, &eloc,
711 (etype << 30) | elen, 1); 715 (etype << 30) | elen, 1);
712 } else 716 } else
713 udf_delete_aext(table, epos, eloc, 717 udf_delete_aext(table, epos, eloc,
@@ -814,7 +818,7 @@ static int udf_table_new_block(struct super_block *sb,
814 } 818 }
815 819
816 if (goal_elen) 820 if (goal_elen)
817 udf_write_aext(table, &goal_epos, goal_eloc, goal_elen, 1); 821 udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1);
818 else 822 else
819 udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); 823 udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
820 brelse(goal_epos.bh); 824 brelse(goal_epos.bh);
@@ -828,12 +832,11 @@ static int udf_table_new_block(struct super_block *sb,
828 return newblock; 832 return newblock;
829} 833}
830 834
831inline void udf_free_blocks(struct super_block *sb, 835void udf_free_blocks(struct super_block *sb, struct inode *inode,
832 struct inode *inode, 836 struct kernel_lb_addr *bloc, uint32_t offset,
833 struct kernel_lb_addr bloc, uint32_t offset, 837 uint32_t count)
834 uint32_t count)
835{ 838{
836 uint16_t partition = bloc.partitionReferenceNum; 839 uint16_t partition = bloc->partitionReferenceNum;
837 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 840 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
838 841
839 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { 842 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {