Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udf: Fix handling of i_blocks

Commit 36350462 removed unused quota support from UDF. As an unfortunate
sideeffect it also removed updates of i_blocks so all files had i_block == 0.
Fix the problem by returning updates of file space back to UDF allocation and
freeing functions.

Signed-off-by: Jan Kara <jack@suse.cz>

Jan Kara fd4287db bf097aaf

+46 -38
+46 -38
fs/udf/balloc.c
··· 105 105 } 106 106 107 107 static void udf_bitmap_free_blocks(struct super_block *sb, 108 - struct inode *inode, 109 108 struct udf_bitmap *bitmap, 110 109 struct kernel_lb_addr *bloc, 111 110 uint32_t offset, ··· 171 172 } 172 173 173 174 static int udf_bitmap_prealloc_blocks(struct super_block *sb, 174 - struct inode *inode, 175 175 struct udf_bitmap *bitmap, 176 176 uint16_t partition, uint32_t first_block, 177 177 uint32_t block_count) ··· 221 223 } 222 224 223 225 static int udf_bitmap_new_block(struct super_block *sb, 224 - struct inode *inode, 225 226 struct udf_bitmap *bitmap, uint16_t partition, 226 227 uint32_t goal, int *err) 227 228 { ··· 346 349 } 347 350 348 351 static void udf_table_free_blocks(struct super_block *sb, 349 - struct inode *inode, 350 352 struct inode *table, 351 353 struct kernel_lb_addr *bloc, 352 354 uint32_t offset, ··· 577 581 } 578 582 579 583 static int udf_table_prealloc_blocks(struct super_block *sb, 580 - struct inode *inode, 581 584 struct inode *table, uint16_t partition, 582 585 uint32_t first_block, uint32_t block_count) 583 586 { ··· 638 643 } 639 644 640 645 static int udf_table_new_block(struct super_block *sb, 641 - struct inode *inode, 642 646 struct inode *table, uint16_t partition, 643 647 uint32_t goal, int *err) 644 648 { ··· 737 743 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 738 744 739 745 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { 740 - udf_bitmap_free_blocks(sb, inode, map->s_uspace.s_bitmap, 746 + udf_bitmap_free_blocks(sb, map->s_uspace.s_bitmap, 741 747 bloc, offset, count); 742 748 } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { 743 - udf_table_free_blocks(sb, inode, map->s_uspace.s_table, 749 + udf_table_free_blocks(sb, map->s_uspace.s_table, 744 750 bloc, offset, count); 745 751 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { 746 - udf_bitmap_free_blocks(sb, inode, map->s_fspace.s_bitmap, 752 + udf_bitmap_free_blocks(sb, map->s_fspace.s_bitmap, 747 753 bloc, offset, count); 748 754 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { 749 - udf_table_free_blocks(sb, inode, map->s_fspace.s_table, 755 + udf_table_free_blocks(sb, map->s_fspace.s_table, 750 756 bloc, offset, count); 757 + } 758 + 759 + if (inode) { 760 + inode_sub_bytes(inode, 761 + ((sector_t)count) << sb->s_blocksize_bits); 751 762 } 752 763 } 753 764 ··· 762 763 uint32_t block_count) 763 764 { 764 765 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 766 + sector_t allocated; 765 767 766 768 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 767 - return udf_bitmap_prealloc_blocks(sb, inode, 768 - map->s_uspace.s_bitmap, 769 - partition, first_block, 770 - block_count); 769 + allocated = udf_bitmap_prealloc_blocks(sb, 770 + map->s_uspace.s_bitmap, 771 + partition, first_block, 772 + block_count); 771 773 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 772 - return udf_table_prealloc_blocks(sb, inode, 773 - map->s_uspace.s_table, 774 - partition, first_block, 775 - block_count); 774 + allocated = udf_table_prealloc_blocks(sb, 775 + map->s_uspace.s_table, 776 + partition, first_block, 777 + block_count); 776 778 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 777 - return udf_bitmap_prealloc_blocks(sb, inode, 778 - map->s_fspace.s_bitmap, 779 - partition, first_block, 780 - block_count); 779 + allocated = udf_bitmap_prealloc_blocks(sb, 780 + map->s_fspace.s_bitmap, 781 + partition, first_block, 782 + block_count); 781 783 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 782 - return udf_table_prealloc_blocks(sb, inode, 783 - map->s_fspace.s_table, 784 - partition, first_block, 785 - block_count); 784 + allocated = udf_table_prealloc_blocks(sb, 785 + map->s_fspace.s_table, 786 + partition, first_block, 787 + block_count); 786 788 else 787 789 return 0; 790 + 791 + if (inode && allocated > 0) 792 + inode_add_bytes(inode, allocated << sb->s_blocksize_bits); 793 + return allocated; 788 794 } 789 795 790 796 inline int udf_new_block(struct super_block *sb, ··· 797 793 uint16_t partition, uint32_t goal, int *err) 798 794 { 799 795 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 796 + int block; 800 797 801 798 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 802 - return udf_bitmap_new_block(sb, inode, 803 - map->s_uspace.s_bitmap, 804 - partition, goal, err); 799 + block = udf_bitmap_new_block(sb, 800 + map->s_uspace.s_bitmap, 801 + partition, goal, err); 805 802 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 806 - return udf_table_new_block(sb, inode, 807 - map->s_uspace.s_table, 808 - partition, goal, err); 809 - else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 810 - return udf_bitmap_new_block(sb, inode, 811 - map->s_fspace.s_bitmap, 803 + block = udf_table_new_block(sb, 804 + map->s_uspace.s_table, 812 805 partition, goal, err); 806 + else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 807 + block = udf_bitmap_new_block(sb, 808 + map->s_fspace.s_bitmap, 809 + partition, goal, err); 813 810 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 814 - return udf_table_new_block(sb, inode, 815 - map->s_fspace.s_table, 816 - partition, goal, err); 811 + block = udf_table_new_block(sb, 812 + map->s_fspace.s_table, 813 + partition, goal, err); 817 814 else { 818 815 *err = -EIO; 819 816 return 0; 820 817 } 818 + if (inode && block) 819 + inode_add_bytes(inode, sb->s_blocksize); 820 + return block; 821 821 }