diff options
Diffstat (limited to 'fs/udf/balloc.c')
-rw-r--r-- | fs/udf/balloc.c | 164 |
1 files changed, 74 insertions, 90 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 1b809bd494bd..e48e9a3af763 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -87,12 +87,12 @@ static int read_block_bitmap(struct super_block *sb, | |||
87 | { | 87 | { |
88 | struct buffer_head *bh = NULL; | 88 | struct buffer_head *bh = NULL; |
89 | int retval = 0; | 89 | int retval = 0; |
90 | kernel_lb_addr loc; | 90 | struct kernel_lb_addr loc; |
91 | 91 | ||
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 | ||
@@ -140,27 +140,29 @@ static inline int load_block_bitmap(struct super_block *sb, | |||
140 | return slot; | 140 | return slot; |
141 | } | 141 | } |
142 | 142 | ||
143 | static bool udf_add_free_space(struct udf_sb_info *sbi, | 143 | static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt) |
144 | u16 partition, u32 cnt) | ||
145 | { | 144 | { |
145 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
146 | struct logicalVolIntegrityDesc *lvid; | 146 | struct logicalVolIntegrityDesc *lvid; |
147 | 147 | ||
148 | if (sbi->s_lvid_bh == NULL) | 148 | if (!sbi->s_lvid_bh) |
149 | return false; | 149 | return; |
150 | 150 | ||
151 | lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; | 151 | lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
152 | le32_add_cpu(&lvid->freeSpaceTable[partition], cnt); | 152 | le32_add_cpu(&lvid->freeSpaceTable[partition], cnt); |
153 | return true; | 153 | udf_updated_lvid(sb); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void udf_bitmap_free_blocks(struct super_block *sb, | 156 | static 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 | 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 { |
@@ -206,8 +208,8 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
206 | ((char *)bh->b_data)[(bit + i) >> 3]); | 208 | ((char *)bh->b_data)[(bit + i) >> 3]); |
207 | } else { | 209 | } else { |
208 | if (inode) | 210 | if (inode) |
209 | DQUOT_FREE_BLOCK(inode, 1); | 211 | vfs_dq_free_block(inode, 1); |
210 | udf_add_free_space(sbi, sbi->s_partition, 1); | 212 | udf_add_free_space(sb, sbi->s_partition, 1); |
211 | } | 213 | } |
212 | } | 214 | } |
213 | mark_buffer_dirty(bh); | 215 | mark_buffer_dirty(bh); |
@@ -218,9 +220,6 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
218 | } while (overflow); | 220 | } while (overflow); |
219 | 221 | ||
220 | error_return: | 222 | error_return: |
221 | sb->s_dirt = 1; | ||
222 | if (sbi->s_lvid_bh) | ||
223 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
224 | mutex_unlock(&sbi->s_alloc_mutex); | 223 | mutex_unlock(&sbi->s_alloc_mutex); |
225 | } | 224 | } |
226 | 225 | ||
@@ -261,11 +260,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
261 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { | 260 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { |
262 | if (!udf_test_bit(bit, bh->b_data)) | 261 | if (!udf_test_bit(bit, bh->b_data)) |
263 | goto out; | 262 | goto out; |
264 | else if (DQUOT_PREALLOC_BLOCK(inode, 1)) | 263 | else if (vfs_dq_prealloc_block(inode, 1)) |
265 | goto out; | 264 | goto out; |
266 | else if (!udf_clear_bit(bit, bh->b_data)) { | 265 | else if (!udf_clear_bit(bit, bh->b_data)) { |
267 | udf_debug("bit already cleared for block %d\n", bit); | 266 | udf_debug("bit already cleared for block %d\n", bit); |
268 | DQUOT_FREE_BLOCK(inode, 1); | 267 | vfs_dq_free_block(inode, 1); |
269 | goto out; | 268 | goto out; |
270 | } | 269 | } |
271 | block_count--; | 270 | block_count--; |
@@ -277,9 +276,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
277 | } while (block_count > 0); | 276 | } while (block_count > 0); |
278 | 277 | ||
279 | out: | 278 | out: |
280 | if (udf_add_free_space(sbi, partition, -alloc_count)) | 279 | udf_add_free_space(sb, partition, -alloc_count); |
281 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
282 | sb->s_dirt = 1; | ||
283 | mutex_unlock(&sbi->s_alloc_mutex); | 280 | mutex_unlock(&sbi->s_alloc_mutex); |
284 | return alloc_count; | 281 | return alloc_count; |
285 | } | 282 | } |
@@ -393,7 +390,7 @@ got_block: | |||
393 | /* | 390 | /* |
394 | * Check quota for allocation of this block. | 391 | * Check quota for allocation of this block. |
395 | */ | 392 | */ |
396 | if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) { | 393 | if (inode && vfs_dq_alloc_block(inode, 1)) { |
397 | mutex_unlock(&sbi->s_alloc_mutex); | 394 | mutex_unlock(&sbi->s_alloc_mutex); |
398 | *err = -EDQUOT; | 395 | *err = -EDQUOT; |
399 | return 0; | 396 | return 0; |
@@ -409,9 +406,7 @@ got_block: | |||
409 | 406 | ||
410 | mark_buffer_dirty(bh); | 407 | mark_buffer_dirty(bh); |
411 | 408 | ||
412 | if (udf_add_free_space(sbi, partition, -1)) | 409 | udf_add_free_space(sb, partition, -1); |
413 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
414 | sb->s_dirt = 1; | ||
415 | mutex_unlock(&sbi->s_alloc_mutex); | 410 | mutex_unlock(&sbi->s_alloc_mutex); |
416 | *err = 0; | 411 | *err = 0; |
417 | return newblock; | 412 | return newblock; |
@@ -425,26 +420,28 @@ error_return: | |||
425 | static void udf_table_free_blocks(struct super_block *sb, | 420 | static void udf_table_free_blocks(struct super_block *sb, |
426 | struct inode *inode, | 421 | struct inode *inode, |
427 | struct inode *table, | 422 | struct inode *table, |
428 | kernel_lb_addr bloc, uint32_t offset, | 423 | struct kernel_lb_addr *bloc, |
424 | uint32_t offset, | ||
429 | uint32_t count) | 425 | uint32_t count) |
430 | { | 426 | { |
431 | struct udf_sb_info *sbi = UDF_SB(sb); | 427 | struct udf_sb_info *sbi = UDF_SB(sb); |
428 | struct udf_part_map *partmap; | ||
432 | uint32_t start, end; | 429 | uint32_t start, end; |
433 | uint32_t elen; | 430 | uint32_t elen; |
434 | kernel_lb_addr eloc; | 431 | struct kernel_lb_addr eloc; |
435 | struct extent_position oepos, epos; | 432 | struct extent_position oepos, epos; |
436 | int8_t etype; | 433 | int8_t etype; |
437 | int i; | 434 | int i; |
438 | struct udf_inode_info *iinfo; | 435 | struct udf_inode_info *iinfo; |
439 | 436 | ||
440 | mutex_lock(&sbi->s_alloc_mutex); | 437 | mutex_lock(&sbi->s_alloc_mutex); |
441 | if (bloc.logicalBlockNum < 0 || | 438 | partmap = &sbi->s_partmaps[bloc->partitionReferenceNum]; |
442 | (bloc.logicalBlockNum + count) > | 439 | if (bloc->logicalBlockNum < 0 || |
443 | sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { | 440 | (bloc->logicalBlockNum + count) > |
441 | partmap->s_partition_len) { | ||
444 | udf_debug("%d < %d || %d + %d > %d\n", | 442 | udf_debug("%d < %d || %d + %d > %d\n", |
445 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 443 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
446 | sbi->s_partmaps[bloc.partitionReferenceNum]. | 444 | partmap->s_partition_len); |
447 | s_partition_len); | ||
448 | goto error_return; | 445 | goto error_return; |
449 | } | 446 | } |
450 | 447 | ||
@@ -452,12 +449,11 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
452 | /* We do this up front - There are some error conditions that | 449 | /* We do this up front - There are some error conditions that |
453 | could occure, but.. oh well */ | 450 | could occure, but.. oh well */ |
454 | if (inode) | 451 | if (inode) |
455 | DQUOT_FREE_BLOCK(inode, count); | 452 | vfs_dq_free_block(inode, count); |
456 | if (udf_add_free_space(sbi, sbi->s_partition, count)) | 453 | udf_add_free_space(sb, sbi->s_partition, count); |
457 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
458 | 454 | ||
459 | start = bloc.logicalBlockNum + offset; | 455 | start = bloc->logicalBlockNum + offset; |
460 | end = bloc.logicalBlockNum + offset + count - 1; | 456 | end = bloc->logicalBlockNum + offset + count - 1; |
461 | 457 | ||
462 | epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); | 458 | epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); |
463 | elen = 0; | 459 | elen = 0; |
@@ -483,7 +479,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
483 | start += count; | 479 | start += count; |
484 | count = 0; | 480 | count = 0; |
485 | } | 481 | } |
486 | udf_write_aext(table, &oepos, eloc, elen, 1); | 482 | udf_write_aext(table, &oepos, &eloc, elen, 1); |
487 | } else if (eloc.logicalBlockNum == (end + 1)) { | 483 | } else if (eloc.logicalBlockNum == (end + 1)) { |
488 | if ((0x3FFFFFFF - elen) < | 484 | if ((0x3FFFFFFF - elen) < |
489 | (count << sb->s_blocksize_bits)) { | 485 | (count << sb->s_blocksize_bits)) { |
@@ -502,7 +498,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
502 | end -= count; | 498 | end -= count; |
503 | count = 0; | 499 | count = 0; |
504 | } | 500 | } |
505 | udf_write_aext(table, &oepos, eloc, elen, 1); | 501 | udf_write_aext(table, &oepos, &eloc, elen, 1); |
506 | } | 502 | } |
507 | 503 | ||
508 | if (epos.bh != oepos.bh) { | 504 | if (epos.bh != oepos.bh) { |
@@ -532,8 +528,8 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
532 | */ | 528 | */ |
533 | 529 | ||
534 | int adsize; | 530 | int adsize; |
535 | short_ad *sad = NULL; | 531 | struct short_ad *sad = NULL; |
536 | long_ad *lad = NULL; | 532 | struct long_ad *lad = NULL; |
537 | struct allocExtDesc *aed; | 533 | struct allocExtDesc *aed; |
538 | 534 | ||
539 | eloc.logicalBlockNum = start; | 535 | eloc.logicalBlockNum = start; |
@@ -541,9 +537,9 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
541 | (count << sb->s_blocksize_bits); | 537 | (count << sb->s_blocksize_bits); |
542 | 538 | ||
543 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 539 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
544 | adsize = sizeof(short_ad); | 540 | adsize = sizeof(struct short_ad); |
545 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | 541 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
546 | adsize = sizeof(long_ad); | 542 | adsize = sizeof(struct long_ad); |
547 | else { | 543 | else { |
548 | brelse(oepos.bh); | 544 | brelse(oepos.bh); |
549 | brelse(epos.bh); | 545 | brelse(epos.bh); |
@@ -563,7 +559,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
563 | elen -= sb->s_blocksize; | 559 | elen -= sb->s_blocksize; |
564 | 560 | ||
565 | epos.bh = udf_tread(sb, | 561 | epos.bh = udf_tread(sb, |
566 | udf_get_lb_pblock(sb, epos.block, 0)); | 562 | udf_get_lb_pblock(sb, &epos.block, 0)); |
567 | if (!epos.bh) { | 563 | if (!epos.bh) { |
568 | brelse(oepos.bh); | 564 | brelse(oepos.bh); |
569 | goto error_return; | 565 | goto error_return; |
@@ -601,15 +597,15 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
601 | if (sbi->s_udfrev >= 0x0200) | 597 | if (sbi->s_udfrev >= 0x0200) |
602 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, | 598 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, |
603 | 3, 1, epos.block.logicalBlockNum, | 599 | 3, 1, epos.block.logicalBlockNum, |
604 | sizeof(tag)); | 600 | sizeof(struct tag)); |
605 | else | 601 | else |
606 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, | 602 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, |
607 | 2, 1, epos.block.logicalBlockNum, | 603 | 2, 1, epos.block.logicalBlockNum, |
608 | sizeof(tag)); | 604 | sizeof(struct tag)); |
609 | 605 | ||
610 | switch (iinfo->i_alloc_type) { | 606 | switch (iinfo->i_alloc_type) { |
611 | case ICBTAG_FLAG_AD_SHORT: | 607 | case ICBTAG_FLAG_AD_SHORT: |
612 | sad = (short_ad *)sptr; | 608 | sad = (struct short_ad *)sptr; |
613 | sad->extLength = cpu_to_le32( | 609 | sad->extLength = cpu_to_le32( |
614 | EXT_NEXT_EXTENT_ALLOCDECS | | 610 | EXT_NEXT_EXTENT_ALLOCDECS | |
615 | sb->s_blocksize); | 611 | sb->s_blocksize); |
@@ -617,7 +613,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
617 | cpu_to_le32(epos.block.logicalBlockNum); | 613 | cpu_to_le32(epos.block.logicalBlockNum); |
618 | break; | 614 | break; |
619 | case ICBTAG_FLAG_AD_LONG: | 615 | case ICBTAG_FLAG_AD_LONG: |
620 | lad = (long_ad *)sptr; | 616 | lad = (struct long_ad *)sptr; |
621 | lad->extLength = cpu_to_le32( | 617 | lad->extLength = cpu_to_le32( |
622 | EXT_NEXT_EXTENT_ALLOCDECS | | 618 | EXT_NEXT_EXTENT_ALLOCDECS | |
623 | sb->s_blocksize); | 619 | sb->s_blocksize); |
@@ -635,7 +631,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
635 | 631 | ||
636 | /* It's possible that stealing the block emptied the extent */ | 632 | /* It's possible that stealing the block emptied the extent */ |
637 | if (elen) { | 633 | if (elen) { |
638 | udf_write_aext(table, &epos, eloc, elen, 1); | 634 | udf_write_aext(table, &epos, &eloc, elen, 1); |
639 | 635 | ||
640 | if (!epos.bh) { | 636 | if (!epos.bh) { |
641 | iinfo->i_lenAlloc += adsize; | 637 | iinfo->i_lenAlloc += adsize; |
@@ -653,7 +649,6 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
653 | brelse(oepos.bh); | 649 | brelse(oepos.bh); |
654 | 650 | ||
655 | error_return: | 651 | error_return: |
656 | sb->s_dirt = 1; | ||
657 | mutex_unlock(&sbi->s_alloc_mutex); | 652 | mutex_unlock(&sbi->s_alloc_mutex); |
658 | return; | 653 | return; |
659 | } | 654 | } |
@@ -666,7 +661,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
666 | struct udf_sb_info *sbi = UDF_SB(sb); | 661 | struct udf_sb_info *sbi = UDF_SB(sb); |
667 | int alloc_count = 0; | 662 | int alloc_count = 0; |
668 | uint32_t elen, adsize; | 663 | uint32_t elen, adsize; |
669 | kernel_lb_addr eloc; | 664 | struct kernel_lb_addr eloc; |
670 | struct extent_position epos; | 665 | struct extent_position epos; |
671 | int8_t etype = -1; | 666 | int8_t etype = -1; |
672 | struct udf_inode_info *iinfo; | 667 | struct udf_inode_info *iinfo; |
@@ -677,9 +672,9 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
677 | 672 | ||
678 | iinfo = UDF_I(table); | 673 | iinfo = UDF_I(table); |
679 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 674 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
680 | adsize = sizeof(short_ad); | 675 | adsize = sizeof(struct short_ad); |
681 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | 676 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
682 | adsize = sizeof(long_ad); | 677 | adsize = sizeof(struct long_ad); |
683 | else | 678 | else |
684 | return 0; | 679 | return 0; |
685 | 680 | ||
@@ -700,14 +695,14 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
700 | epos.offset -= adsize; | 695 | epos.offset -= adsize; |
701 | 696 | ||
702 | alloc_count = (elen >> sb->s_blocksize_bits); | 697 | alloc_count = (elen >> sb->s_blocksize_bits); |
703 | if (inode && DQUOT_PREALLOC_BLOCK(inode, | 698 | if (inode && vfs_dq_prealloc_block(inode, |
704 | alloc_count > block_count ? block_count : alloc_count)) | 699 | alloc_count > block_count ? block_count : alloc_count)) |
705 | alloc_count = 0; | 700 | alloc_count = 0; |
706 | else if (alloc_count > block_count) { | 701 | else if (alloc_count > block_count) { |
707 | alloc_count = block_count; | 702 | alloc_count = block_count; |
708 | eloc.logicalBlockNum += alloc_count; | 703 | eloc.logicalBlockNum += alloc_count; |
709 | elen -= (alloc_count << sb->s_blocksize_bits); | 704 | elen -= (alloc_count << sb->s_blocksize_bits); |
710 | udf_write_aext(table, &epos, eloc, | 705 | udf_write_aext(table, &epos, &eloc, |
711 | (etype << 30) | elen, 1); | 706 | (etype << 30) | elen, 1); |
712 | } else | 707 | } else |
713 | udf_delete_aext(table, epos, eloc, | 708 | udf_delete_aext(table, epos, eloc, |
@@ -718,10 +713,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
718 | 713 | ||
719 | brelse(epos.bh); | 714 | brelse(epos.bh); |
720 | 715 | ||
721 | if (alloc_count && udf_add_free_space(sbi, partition, -alloc_count)) { | 716 | if (alloc_count) |
722 | mark_buffer_dirty(sbi->s_lvid_bh); | 717 | udf_add_free_space(sb, partition, -alloc_count); |
723 | sb->s_dirt = 1; | ||
724 | } | ||
725 | mutex_unlock(&sbi->s_alloc_mutex); | 718 | mutex_unlock(&sbi->s_alloc_mutex); |
726 | return alloc_count; | 719 | return alloc_count; |
727 | } | 720 | } |
@@ -735,7 +728,7 @@ static int udf_table_new_block(struct super_block *sb, | |||
735 | uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF; | 728 | uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF; |
736 | uint32_t newblock = 0, adsize; | 729 | uint32_t newblock = 0, adsize; |
737 | uint32_t elen, goal_elen = 0; | 730 | uint32_t elen, goal_elen = 0; |
738 | kernel_lb_addr eloc, uninitialized_var(goal_eloc); | 731 | struct kernel_lb_addr eloc, uninitialized_var(goal_eloc); |
739 | struct extent_position epos, goal_epos; | 732 | struct extent_position epos, goal_epos; |
740 | int8_t etype; | 733 | int8_t etype; |
741 | struct udf_inode_info *iinfo = UDF_I(table); | 734 | struct udf_inode_info *iinfo = UDF_I(table); |
@@ -743,9 +736,9 @@ static int udf_table_new_block(struct super_block *sb, | |||
743 | *err = -ENOSPC; | 736 | *err = -ENOSPC; |
744 | 737 | ||
745 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 738 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
746 | adsize = sizeof(short_ad); | 739 | adsize = sizeof(struct short_ad); |
747 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | 740 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
748 | adsize = sizeof(long_ad); | 741 | adsize = sizeof(struct long_ad); |
749 | else | 742 | else |
750 | return newblock; | 743 | return newblock; |
751 | 744 | ||
@@ -806,7 +799,7 @@ static int udf_table_new_block(struct super_block *sb, | |||
806 | goal_eloc.logicalBlockNum++; | 799 | goal_eloc.logicalBlockNum++; |
807 | goal_elen -= sb->s_blocksize; | 800 | goal_elen -= sb->s_blocksize; |
808 | 801 | ||
809 | if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) { | 802 | if (inode && vfs_dq_alloc_block(inode, 1)) { |
810 | brelse(goal_epos.bh); | 803 | brelse(goal_epos.bh); |
811 | mutex_unlock(&sbi->s_alloc_mutex); | 804 | mutex_unlock(&sbi->s_alloc_mutex); |
812 | *err = -EDQUOT; | 805 | *err = -EDQUOT; |
@@ -814,46 +807,37 @@ static int udf_table_new_block(struct super_block *sb, | |||
814 | } | 807 | } |
815 | 808 | ||
816 | if (goal_elen) | 809 | if (goal_elen) |
817 | udf_write_aext(table, &goal_epos, goal_eloc, goal_elen, 1); | 810 | udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1); |
818 | else | 811 | else |
819 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); | 812 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); |
820 | brelse(goal_epos.bh); | 813 | brelse(goal_epos.bh); |
821 | 814 | ||
822 | if (udf_add_free_space(sbi, partition, -1)) | 815 | udf_add_free_space(sb, partition, -1); |
823 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
824 | 816 | ||
825 | sb->s_dirt = 1; | ||
826 | mutex_unlock(&sbi->s_alloc_mutex); | 817 | mutex_unlock(&sbi->s_alloc_mutex); |
827 | *err = 0; | 818 | *err = 0; |
828 | return newblock; | 819 | return newblock; |
829 | } | 820 | } |
830 | 821 | ||
831 | inline void udf_free_blocks(struct super_block *sb, | 822 | void udf_free_blocks(struct super_block *sb, struct inode *inode, |
832 | struct inode *inode, | 823 | struct kernel_lb_addr *bloc, uint32_t offset, |
833 | kernel_lb_addr bloc, uint32_t offset, | 824 | uint32_t count) |
834 | uint32_t count) | ||
835 | { | 825 | { |
836 | uint16_t partition = bloc.partitionReferenceNum; | 826 | uint16_t partition = bloc->partitionReferenceNum; |
837 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; | 827 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; |
838 | 828 | ||
839 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { | 829 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { |
840 | return udf_bitmap_free_blocks(sb, inode, | 830 | udf_bitmap_free_blocks(sb, inode, map->s_uspace.s_bitmap, |
841 | map->s_uspace.s_bitmap, | 831 | bloc, offset, count); |
842 | bloc, offset, count); | ||
843 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { | 832 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
844 | return udf_table_free_blocks(sb, inode, | 833 | udf_table_free_blocks(sb, inode, map->s_uspace.s_table, |
845 | map->s_uspace.s_table, | 834 | bloc, offset, count); |
846 | bloc, offset, count); | ||
847 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { | 835 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
848 | return udf_bitmap_free_blocks(sb, inode, | 836 | udf_bitmap_free_blocks(sb, inode, map->s_fspace.s_bitmap, |
849 | map->s_fspace.s_bitmap, | 837 | bloc, offset, count); |
850 | bloc, offset, count); | ||
851 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { | 838 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
852 | return udf_table_free_blocks(sb, inode, | 839 | udf_table_free_blocks(sb, inode, map->s_fspace.s_table, |
853 | map->s_fspace.s_table, | 840 | bloc, offset, count); |
854 | bloc, offset, count); | ||
855 | } else { | ||
856 | return; | ||
857 | } | 841 | } |
858 | } | 842 | } |
859 | 843 | ||