aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/balloc.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index dc9f8a96b6e4..c3db91b790fd 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -140,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb,
140 return slot; 140 return slot;
141} 141}
142 142
143static bool udf_add_free_space(struct udf_sb_info *sbi,
144 u16 partition, u32 cnt)
145{
146 struct logicalVolIntegrityDesc *lvid;
147
148 if (sbi->s_lvid_bh)
149 return false;
150
151 lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
152 lvid->freeSpaceTable[partition] = cpu_to_le32(le32_to_cpu(
153 lvid->freeSpaceTable[partition]) + cnt);
154 return true;
155}
156
143static void udf_bitmap_free_blocks(struct super_block *sb, 157static void udf_bitmap_free_blocks(struct super_block *sb,
144 struct inode *inode, 158 struct inode *inode,
145 struct udf_bitmap *bitmap, 159 struct udf_bitmap *bitmap,
@@ -194,11 +208,7 @@ do_more:
194 } else { 208 } else {
195 if (inode) 209 if (inode)
196 DQUOT_FREE_BLOCK(inode, 1); 210 DQUOT_FREE_BLOCK(inode, 1);
197 if (sbi->s_lvid_bh) { 211 udf_add_free_space(sbi, sbi->s_partition, 1);
198 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
199 lvid->freeSpaceTable[sbi->s_partition] =
200 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[sbi->s_partition]) + 1);
201 }
202 } 212 }
203 } 213 }
204 mark_buffer_dirty(bh); 214 mark_buffer_dirty(bh);
@@ -268,12 +278,8 @@ repeat:
268 if (block_count > 0) 278 if (block_count > 0)
269 goto repeat; 279 goto repeat;
270out: 280out:
271 if (sbi->s_lvid_bh) { 281 if (udf_add_free_space(sbi, partition, -alloc_count))
272 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
273 lvid->freeSpaceTable[partition] =
274 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - alloc_count);
275 mark_buffer_dirty(sbi->s_lvid_bh); 282 mark_buffer_dirty(sbi->s_lvid_bh);
276 }
277 sb->s_dirt = 1; 283 sb->s_dirt = 1;
278 mutex_unlock(&sbi->s_alloc_mutex); 284 mutex_unlock(&sbi->s_alloc_mutex);
279 return alloc_count; 285 return alloc_count;
@@ -404,12 +410,8 @@ got_block:
404 410
405 mark_buffer_dirty(bh); 411 mark_buffer_dirty(bh);
406 412
407 if (sbi->s_lvid_bh) { 413 if (udf_add_free_space(sbi, partition, -1))
408 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
409 lvid->freeSpaceTable[partition] =
410 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - 1);
411 mark_buffer_dirty(sbi->s_lvid_bh); 414 mark_buffer_dirty(sbi->s_lvid_bh);
412 }
413 sb->s_dirt = 1; 415 sb->s_dirt = 1;
414 mutex_unlock(&sbi->s_alloc_mutex); 416 mutex_unlock(&sbi->s_alloc_mutex);
415 *err = 0; 417 *err = 0;
@@ -450,12 +452,8 @@ static void udf_table_free_blocks(struct super_block *sb,
450 could occure, but.. oh well */ 452 could occure, but.. oh well */
451 if (inode) 453 if (inode)
452 DQUOT_FREE_BLOCK(inode, count); 454 DQUOT_FREE_BLOCK(inode, count);
453 if (sbi->s_lvid_bh) { 455 if (udf_add_free_space(sbi, sbi->s_partition, count))
454 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
455 lvid->freeSpaceTable[sbi->s_partition] =
456 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[sbi->s_partition]) + count);
457 mark_buffer_dirty(sbi->s_lvid_bh); 456 mark_buffer_dirty(sbi->s_lvid_bh);
458 }
459 457
460 start = bloc.logicalBlockNum + offset; 458 start = bloc.logicalBlockNum + offset;
461 end = bloc.logicalBlockNum + offset + count - 1; 459 end = bloc.logicalBlockNum + offset + count - 1;
@@ -719,10 +717,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
719 717
720 brelse(epos.bh); 718 brelse(epos.bh);
721 719
722 if (alloc_count && sbi->s_lvid_bh) { 720 if (alloc_count && udf_add_free_space(sbi, partition, -alloc_count)) {
723 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
724 lvid->freeSpaceTable[partition] =
725 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - alloc_count);
726 mark_buffer_dirty(sbi->s_lvid_bh); 721 mark_buffer_dirty(sbi->s_lvid_bh);
727 sb->s_dirt = 1; 722 sb->s_dirt = 1;
728 } 723 }
@@ -822,12 +817,8 @@ static int udf_table_new_block(struct super_block *sb,
822 udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); 817 udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
823 brelse(goal_epos.bh); 818 brelse(goal_epos.bh);
824 819
825 if (sbi->s_lvid_bh) { 820 if (udf_add_free_space(sbi, partition, -1))
826 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
827 lvid->freeSpaceTable[partition] =
828 cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - 1);
829 mark_buffer_dirty(sbi->s_lvid_bh); 821 mark_buffer_dirty(sbi->s_lvid_bh);
830 }
831 822
832 sb->s_dirt = 1; 823 sb->s_dirt = 1;
833 mutex_unlock(&sbi->s_alloc_mutex); 824 mutex_unlock(&sbi->s_alloc_mutex);