udf: Fix handling of i_blocks
Subsystems (2)
Jan Kara
reviewerPATCH 1/1 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 <[email protected]>
--- fs/udf/balloc.c | 84 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 46 insertions(+), 38 deletions(-)
JFYI: I've added this fix to my tree and plan to merge it in the next
merge window.
fs/udf/balloc.c +46 -38
@@ -105,7 +105,6 @@ static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt) } static void udf_bitmap_free_blocks(struct super_block *sb, - struct inode *inode, struct udf_bitmap *bitmap, struct kernel_lb_addr *bloc, uint32_t offset,
@@ -172,7 +171,6 @@ error_return: }static int udf_bitmap_prealloc_blocks (struct super_block *sb, -struct inode *inode,struct udf_bitmap *bitmap,uint16_t partition,uint32_t first_block,uint32_t block_count)
@@ -223,7 +221,6 @@ out: }static int udf_bitmap_new_block (struct super_block *sb, -struct inode *inode,struct udf_bitmap *bitmap,uint16_t partition,uint32_t goal,int *err) {
@@ -349,7 +346,6 @@ error_return: } static void udf_table_free_blocks(struct super_block *sb, - struct inode *inode, struct inode *table, struct kernel_lb_addr *bloc, uint32_t offset,
@@ -581,7 +577,6 @@ error_return: }static int udf_table_prealloc_blocks (struct super_block *sb, -struct inode *inode,struct inode *table,uint16_t partition,uint32_t first_block,uint32_t block_count) {
@@ -643,7 +638,6 @@ static int udf_table_prealloc_blocks(struct super_block *sb, }static int udf_table_new_block (struct super_block *sb, -struct inode *inode,struct inode *table,uint16_t partition,uint32_t goal,int *err) {
@@ -743,18 +737,23 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[partition];if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_BITMAP ) { -udf_bitmap_free_blocks (sb, inode, map->s_uspace.s_bitmap, +udf_bitmap_free_blocks (sb, map->s_uspace.s_bitmap, bloc, offset, count); }else if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_TABLE ) { -udf_table_free_blocks (sb, inode, map->s_uspace.s_table, +udf_table_free_blocks (sb, map->s_uspace.s_table, bloc, offset, count); }else if (map->s_partition_flags &UDF_PART_FLAG_FREED_BITMAP ) { -udf_bitmap_free_blocks (sb, inode, map->s_fspace.s_bitmap, +udf_bitmap_free_blocks (sb, map->s_fspace.s_bitmap, bloc, offset, count); }else if (map->s_partition_flags &UDF_PART_FLAG_FREED_TABLE ) { -udf_table_free_blocks (sb, inode, map->s_fspace.s_table, +udf_table_free_blocks (sb, map->s_fspace.s_table, bloc, offset, count); } + +if (inode) { +inode_sub_bytes (inode, + ((sector_t )count) << sb->s_blocksize_bits); + } } inline int udf_prealloc_blocks(struct super_block *sb,
@@ -763,29 +762,34 @@ inline int udf_prealloc_blocks(struct super_block *sb, uint32_t block_count) {struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[partition]; +sector_t allocated;if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_BITMAP ) -return udf_bitmap_prealloc_blocks (sb, inode, - map->s_uspace.s_bitmap, - partition, first_block, - block_count); + allocated =udf_bitmap_prealloc_blocks (sb, + map->s_uspace.s_bitmap, + partition, first_block, + block_count);else if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_TABLE ) -return udf_table_prealloc_blocks (sb, inode, - map->s_uspace.s_table, - partition, first_block, - block_count); + allocated =udf_table_prealloc_blocks (sb, + map->s_uspace.s_table, + partition, first_block, + block_count);else if (map->s_partition_flags &UDF_PART_FLAG_FREED_BITMAP ) -return udf_bitmap_prealloc_blocks (sb, inode, - map->s_fspace.s_bitmap, - partition, first_block, - block_count); + allocated =udf_bitmap_prealloc_blocks (sb, + map->s_fspace.s_bitmap, + partition, first_block, + block_count);else if (map->s_partition_flags &UDF_PART_FLAG_FREED_TABLE ) -return udf_table_prealloc_blocks (sb, inode, - map->s_fspace.s_table, - partition, first_block, - block_count); + allocated =udf_table_prealloc_blocks (sb, + map->s_fspace.s_table, + partition, first_block, + block_count);else return 0 ; + +if (inode && allocated >0 ) +inode_add_bytes (inode, allocated << sb->s_blocksize_bits); +return allocated; } inline int udf_new_block(struct super_block *sb,
@@ -793,25 +797,29 @@ inline int udf_new_block(struct super_block *sb, uint16_t partition, uint32_t goal, int *err) { struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; +int block;if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_BITMAP ) -return udf_bitmap_new_block (sb, inode, - map->s_uspace.s_bitmap, - partition, goal, err); + block =udf_bitmap_new_block (sb, + map->s_uspace.s_bitmap, + partition, goal, err);else if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_TABLE ) -return udf_table_new_block (sb, inode, - map->s_uspace.s_table, - partition, goal, err); -else if (map->s_partition_flags &UDF_PART_FLAG_FREED_BITMAP ) -return udf_bitmap_new_block (sb, inode, - map->s_fspace.s_bitmap, + block =udf_table_new_block (sb, + map->s_uspace.s_table, partition, goal, err); +else if (map->s_partition_flags &UDF_PART_FLAG_FREED_BITMAP ) + block =udf_bitmap_new_block (sb, + map->s_fspace.s_bitmap, + partition, goal, err);else if (map->s_partition_flags &UDF_PART_FLAG_FREED_TABLE ) -return udf_table_new_block (sb, inode, - map->s_fspace.s_table, - partition, goal, err); + block =udf_table_new_block (sb, + map->s_fspace.s_table, + partition, goal, err);else { *err = -EIO ;return 0 ; } +if (inode && block) +inode_add_bytes (inode, sb->s_blocksize); +return block; }
Signature · 1 line
1.7.1