diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-03-03 09:05:00 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:28 -0500 |
commit | 5dd4056db84387975140ff2568eaa0406f07985e (patch) | |
tree | 03c26d7f6e3367b167bfeeb1a01654c6619573f4 /fs/udf/balloc.c | |
parent | 49792c806d0bfd53afc789dcdf50dc9bed2c5b83 (diff) |
dquot: cleanup space allocation / freeing routines
Get rid of the alloc_space, free_space, reserve_space, claim_space and
release_rsv dquot operations - they are always called from the filesystem
and if a filesystem really needs their own (which none currently does)
it can just call into it's own routine directly.
Move shared logic into the common __dquot_alloc_space,
dquot_claim_space_nodirty and __dquot_free_space low-level methods,
and rationalize the wrappers around it to move as much as possible
code into the common block for CONFIG_QUOTA vs not. Also rename
all these helpers to be named dquot_* instead of vfs_dq_*.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/balloc.c')
-rw-r--r-- | fs/udf/balloc.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 82372e332f08..e2ff180173a2 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -208,7 +208,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
208 | ((char *)bh->b_data)[(bit + i) >> 3]); | 208 | ((char *)bh->b_data)[(bit + i) >> 3]); |
209 | } else { | 209 | } else { |
210 | if (inode) | 210 | if (inode) |
211 | vfs_dq_free_block(inode, 1); | 211 | dquot_free_block(inode, 1); |
212 | udf_add_free_space(sb, sbi->s_partition, 1); | 212 | udf_add_free_space(sb, sbi->s_partition, 1); |
213 | } | 213 | } |
214 | } | 214 | } |
@@ -260,11 +260,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
260 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { | 260 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { |
261 | if (!udf_test_bit(bit, bh->b_data)) | 261 | if (!udf_test_bit(bit, bh->b_data)) |
262 | goto out; | 262 | goto out; |
263 | else if (vfs_dq_prealloc_block(inode, 1)) | 263 | else if (dquot_prealloc_block(inode, 1)) |
264 | goto out; | 264 | goto out; |
265 | else if (!udf_clear_bit(bit, bh->b_data)) { | 265 | else if (!udf_clear_bit(bit, bh->b_data)) { |
266 | udf_debug("bit already cleared for block %d\n", bit); | 266 | udf_debug("bit already cleared for block %d\n", bit); |
267 | vfs_dq_free_block(inode, 1); | 267 | dquot_free_block(inode, 1); |
268 | goto out; | 268 | goto out; |
269 | } | 269 | } |
270 | block_count--; | 270 | block_count--; |
@@ -390,10 +390,14 @@ got_block: | |||
390 | /* | 390 | /* |
391 | * Check quota for allocation of this block. | 391 | * Check quota for allocation of this block. |
392 | */ | 392 | */ |
393 | if (inode && vfs_dq_alloc_block(inode, 1)) { | 393 | if (inode) { |
394 | mutex_unlock(&sbi->s_alloc_mutex); | 394 | int ret = dquot_alloc_block(inode, 1); |
395 | *err = -EDQUOT; | 395 | |
396 | return 0; | 396 | if (ret) { |
397 | mutex_unlock(&sbi->s_alloc_mutex); | ||
398 | *err = ret; | ||
399 | return 0; | ||
400 | } | ||
397 | } | 401 | } |
398 | 402 | ||
399 | newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - | 403 | newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - |
@@ -449,7 +453,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
449 | /* We do this up front - There are some error conditions that | 453 | /* We do this up front - There are some error conditions that |
450 | could occure, but.. oh well */ | 454 | could occure, but.. oh well */ |
451 | if (inode) | 455 | if (inode) |
452 | vfs_dq_free_block(inode, count); | 456 | dquot_free_block(inode, count); |
453 | udf_add_free_space(sb, sbi->s_partition, count); | 457 | udf_add_free_space(sb, sbi->s_partition, count); |
454 | 458 | ||
455 | start = bloc->logicalBlockNum + offset; | 459 | start = bloc->logicalBlockNum + offset; |
@@ -694,7 +698,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
694 | epos.offset -= adsize; | 698 | epos.offset -= adsize; |
695 | 699 | ||
696 | alloc_count = (elen >> sb->s_blocksize_bits); | 700 | alloc_count = (elen >> sb->s_blocksize_bits); |
697 | if (inode && vfs_dq_prealloc_block(inode, | 701 | if (inode && dquot_prealloc_block(inode, |
698 | alloc_count > block_count ? block_count : alloc_count)) | 702 | alloc_count > block_count ? block_count : alloc_count)) |
699 | alloc_count = 0; | 703 | alloc_count = 0; |
700 | else if (alloc_count > block_count) { | 704 | else if (alloc_count > block_count) { |
@@ -797,12 +801,13 @@ static int udf_table_new_block(struct super_block *sb, | |||
797 | newblock = goal_eloc.logicalBlockNum; | 801 | newblock = goal_eloc.logicalBlockNum; |
798 | goal_eloc.logicalBlockNum++; | 802 | goal_eloc.logicalBlockNum++; |
799 | goal_elen -= sb->s_blocksize; | 803 | goal_elen -= sb->s_blocksize; |
800 | 804 | if (inode) { | |
801 | if (inode && vfs_dq_alloc_block(inode, 1)) { | 805 | *err = dquot_alloc_block(inode, 1); |
802 | brelse(goal_epos.bh); | 806 | if (*err) { |
803 | mutex_unlock(&sbi->s_alloc_mutex); | 807 | brelse(goal_epos.bh); |
804 | *err = -EDQUOT; | 808 | mutex_unlock(&sbi->s_alloc_mutex); |
805 | return 0; | 809 | return 0; |
810 | } | ||
806 | } | 811 | } |
807 | 812 | ||
808 | if (goal_elen) | 813 | if (goal_elen) |