aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-02-16 07:00:14 -0500
committerJan Kara <jack@suse.cz>2012-02-29 15:53:47 -0500
commitfd4287dbc07763595c1e74edbb6520092290185c (patch)
tree0d3e679ee18b45db63f147a43adb2456d981faa9
parentbf097aaff45eba2244ca3a61e531ec6f2801f6b2 (diff)
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>
-rw-r--r--fs/udf/balloc.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 987585bb0a1d..1ba2baaf4367 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -105,7 +105,6 @@ static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt)
105} 105}
106 106
107static void udf_bitmap_free_blocks(struct super_block *sb, 107static void udf_bitmap_free_blocks(struct super_block *sb,
108 struct inode *inode,
109 struct udf_bitmap *bitmap, 108 struct udf_bitmap *bitmap,
110 struct kernel_lb_addr *bloc, 109 struct kernel_lb_addr *bloc,
111 uint32_t offset, 110 uint32_t offset,
@@ -172,7 +171,6 @@ error_return:
172} 171}
173 172
174static int udf_bitmap_prealloc_blocks(struct super_block *sb, 173static int udf_bitmap_prealloc_blocks(struct super_block *sb,
175 struct inode *inode,
176 struct udf_bitmap *bitmap, 174 struct udf_bitmap *bitmap,
177 uint16_t partition, uint32_t first_block, 175 uint16_t partition, uint32_t first_block,
178 uint32_t block_count) 176 uint32_t block_count)
@@ -223,7 +221,6 @@ out:
223} 221}
224 222
225static int udf_bitmap_new_block(struct super_block *sb, 223static int udf_bitmap_new_block(struct super_block *sb,
226 struct inode *inode,
227 struct udf_bitmap *bitmap, uint16_t partition, 224 struct udf_bitmap *bitmap, uint16_t partition,
228 uint32_t goal, int *err) 225 uint32_t goal, int *err)
229{ 226{
@@ -349,7 +346,6 @@ error_return:
349} 346}
350 347
351static void udf_table_free_blocks(struct super_block *sb, 348static void udf_table_free_blocks(struct super_block *sb,
352 struct inode *inode,
353 struct inode *table, 349 struct inode *table,
354 struct kernel_lb_addr *bloc, 350 struct kernel_lb_addr *bloc,
355 uint32_t offset, 351 uint32_t offset,
@@ -581,7 +577,6 @@ error_return:
581} 577}
582 578
583static int udf_table_prealloc_blocks(struct super_block *sb, 579static int udf_table_prealloc_blocks(struct super_block *sb,
584 struct inode *inode,
585 struct inode *table, uint16_t partition, 580 struct inode *table, uint16_t partition,
586 uint32_t first_block, uint32_t block_count) 581 uint32_t first_block, uint32_t block_count)
587{ 582{
@@ -643,7 +638,6 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
643} 638}
644 639
645static int udf_table_new_block(struct super_block *sb, 640static int udf_table_new_block(struct super_block *sb,
646 struct inode *inode,
647 struct inode *table, uint16_t partition, 641 struct inode *table, uint16_t partition,
648 uint32_t goal, int *err) 642 uint32_t goal, int *err)
649{ 643{
@@ -743,18 +737,23 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,
743 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 737 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
744 738
745 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { 739 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
746 udf_bitmap_free_blocks(sb, inode, map->s_uspace.s_bitmap, 740 udf_bitmap_free_blocks(sb, map->s_uspace.s_bitmap,
747 bloc, offset, count); 741 bloc, offset, count);
748 } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { 742 } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
749 udf_table_free_blocks(sb, inode, map->s_uspace.s_table, 743 udf_table_free_blocks(sb, map->s_uspace.s_table,
750 bloc, offset, count); 744 bloc, offset, count);
751 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { 745 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
752 udf_bitmap_free_blocks(sb, inode, map->s_fspace.s_bitmap, 746 udf_bitmap_free_blocks(sb, map->s_fspace.s_bitmap,
753 bloc, offset, count); 747 bloc, offset, count);
754 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { 748 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
755 udf_table_free_blocks(sb, inode, map->s_fspace.s_table, 749 udf_table_free_blocks(sb, map->s_fspace.s_table,
756 bloc, offset, count); 750 bloc, offset, count);
757 } 751 }
752
753 if (inode) {
754 inode_sub_bytes(inode,
755 ((sector_t)count) << sb->s_blocksize_bits);
756 }
758} 757}
759 758
760inline int udf_prealloc_blocks(struct super_block *sb, 759inline int udf_prealloc_blocks(struct super_block *sb,
@@ -763,29 +762,34 @@ inline int udf_prealloc_blocks(struct super_block *sb,
763 uint32_t block_count) 762 uint32_t block_count)
764{ 763{
765 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 764 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
765 sector_t allocated;
766 766
767 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 767 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
768 return udf_bitmap_prealloc_blocks(sb, inode, 768 allocated = udf_bitmap_prealloc_blocks(sb,
769 map->s_uspace.s_bitmap, 769 map->s_uspace.s_bitmap,
770 partition, first_block, 770 partition, first_block,
771 block_count); 771 block_count);
772 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 772 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
773 return udf_table_prealloc_blocks(sb, inode, 773 allocated = udf_table_prealloc_blocks(sb,
774 map->s_uspace.s_table, 774 map->s_uspace.s_table,
775 partition, first_block, 775 partition, first_block,
776 block_count); 776 block_count);
777 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 777 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
778 return udf_bitmap_prealloc_blocks(sb, inode, 778 allocated = udf_bitmap_prealloc_blocks(sb,
779 map->s_fspace.s_bitmap, 779 map->s_fspace.s_bitmap,
780 partition, first_block, 780 partition, first_block,
781 block_count); 781 block_count);
782 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 782 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
783 return udf_table_prealloc_blocks(sb, inode, 783 allocated = udf_table_prealloc_blocks(sb,
784 map->s_fspace.s_table, 784 map->s_fspace.s_table,
785 partition, first_block, 785 partition, first_block,
786 block_count); 786 block_count);
787 else 787 else
788 return 0; 788 return 0;
789
790 if (inode && allocated > 0)
791 inode_add_bytes(inode, allocated << sb->s_blocksize_bits);
792 return allocated;
789} 793}
790 794
791inline int udf_new_block(struct super_block *sb, 795inline int udf_new_block(struct super_block *sb,
@@ -793,25 +797,29 @@ inline int udf_new_block(struct super_block *sb,
793 uint16_t partition, uint32_t goal, int *err) 797 uint16_t partition, uint32_t goal, int *err)
794{ 798{
795 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 799 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
800 int block;
796 801
797 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 802 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
798 return udf_bitmap_new_block(sb, inode, 803 block = udf_bitmap_new_block(sb,
799 map->s_uspace.s_bitmap, 804 map->s_uspace.s_bitmap,
800 partition, goal, err); 805 partition, goal, err);
801 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 806 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
802 return udf_table_new_block(sb, inode, 807 block = udf_table_new_block(sb,
803 map->s_uspace.s_table, 808 map->s_uspace.s_table,
804 partition, goal, err);
805 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
806 return udf_bitmap_new_block(sb, inode,
807 map->s_fspace.s_bitmap,
808 partition, goal, err); 809 partition, goal, err);
810 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
811 block = udf_bitmap_new_block(sb,
812 map->s_fspace.s_bitmap,
813 partition, goal, err);
809 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 814 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
810 return udf_table_new_block(sb, inode, 815 block = udf_table_new_block(sb,
811 map->s_fspace.s_table, 816 map->s_fspace.s_table,
812 partition, goal, err); 817 partition, goal, err);
813 else { 818 else {
814 *err = -EIO; 819 *err = -EIO;
815 return 0; 820 return 0;
816 } 821 }
822 if (inode && block)
823 inode_add_bytes(inode, sb->s_blocksize);
824 return block;
817} 825}