107
107
static void udf_bitmap_free_blocks(struct super_block *sb,
109
108
struct udf_bitmap *bitmap,
110
109
struct kernel_lb_addr *bloc,
174
173
static int udf_bitmap_prealloc_blocks(struct super_block *sb,
176
174
struct udf_bitmap *bitmap,
177
175
uint16_t partition, uint32_t first_block,
178
176
uint32_t block_count)
583
579
static int udf_table_prealloc_blocks(struct super_block *sb,
585
580
struct inode *table, uint16_t partition,
586
581
uint32_t first_block, uint32_t block_count)
743
737
struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
745
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
741
bloc, offset, count);
748
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
744
bloc, offset, count);
751
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
747
bloc, offset, count);
754
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
750
bloc, offset, count);
754
inode_sub_bytes(inode,
755
((sector_t)count) << sb->s_blocksize_bits);
760
759
inline int udf_prealloc_blocks(struct super_block *sb,
763
762
uint32_t block_count)
765
764
struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
767
767
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
768
return udf_bitmap_prealloc_blocks(sb, inode,
769
map->s_uspace.s_bitmap,
770
partition, first_block,
768
allocated = udf_bitmap_prealloc_blocks(sb,
769
map->s_uspace.s_bitmap,
770
partition, first_block,
772
772
else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
773
return udf_table_prealloc_blocks(sb, inode,
774
map->s_uspace.s_table,
775
partition, first_block,
773
allocated = udf_table_prealloc_blocks(sb,
774
map->s_uspace.s_table,
775
partition, first_block,
777
777
else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
778
return udf_bitmap_prealloc_blocks(sb, inode,
779
map->s_fspace.s_bitmap,
780
partition, first_block,
778
allocated = udf_bitmap_prealloc_blocks(sb,
779
map->s_fspace.s_bitmap,
780
partition, first_block,
782
782
else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
783
return udf_table_prealloc_blocks(sb, inode,
784
map->s_fspace.s_table,
785
partition, first_block,
783
allocated = udf_table_prealloc_blocks(sb,
784
map->s_fspace.s_table,
785
partition, first_block,
790
if (inode && allocated > 0)
791
inode_add_bytes(inode, allocated << sb->s_blocksize_bits);
791
795
inline int udf_new_block(struct super_block *sb,
793
797
uint16_t partition, uint32_t goal, int *err)
795
799
struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
797
802
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
798
return udf_bitmap_new_block(sb, inode,
799
map->s_uspace.s_bitmap,
800
partition, goal, err);
803
block = udf_bitmap_new_block(sb,
804
map->s_uspace.s_bitmap,
805
partition, goal, err);
801
806
else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
802
return udf_table_new_block(sb, inode,
803
map->s_uspace.s_table,
804
partition, goal, err);
807
block = udf_table_new_block(sb,
808
map->s_uspace.s_table,
809
partition, goal, err);
805
810
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);
811
block = udf_bitmap_new_block(sb,
812
map->s_fspace.s_bitmap,
813
partition, goal, err);
809
814
else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
810
return udf_table_new_block(sb, inode,
811
map->s_fspace.s_table,
812
partition, goal, err);
815
block = udf_table_new_block(sb,
816
map->s_fspace.s_table,
817
partition, goal, err);
823
inode_add_bytes(inode, sb->s_blocksize);