aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-03-03 09:05:00 -0500
committerJan Kara <jack@suse.cz>2010-03-04 18:20:28 -0500
commit5dd4056db84387975140ff2568eaa0406f07985e (patch)
tree03c26d7f6e3367b167bfeeb1a01654c6619573f4 /fs/ext4
parent49792c806d0bfd53afc789dcdf50dc9bed2c5b83 (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/ext4')
-rw-r--r--fs/ext4/inode.c20
-rw-r--r--fs/ext4/mballoc.c6
-rw-r--r--fs/ext4/super.c5
-rw-r--r--fs/ext4/xattr.c8
4 files changed, 18 insertions, 21 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e11952404e02..9f607ea411c8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1093,9 +1093,9 @@ void ext4_da_update_reserve_space(struct inode *inode,
1093 1093
1094 /* Update quota subsystem */ 1094 /* Update quota subsystem */
1095 if (quota_claim) { 1095 if (quota_claim) {
1096 vfs_dq_claim_block(inode, used); 1096 dquot_claim_block(inode, used);
1097 if (mdb_free) 1097 if (mdb_free)
1098 vfs_dq_release_reservation_block(inode, mdb_free); 1098 dquot_release_reservation_block(inode, mdb_free);
1099 } else { 1099 } else {
1100 /* 1100 /*
1101 * We did fallocate with an offset that is already delayed 1101 * We did fallocate with an offset that is already delayed
@@ -1106,8 +1106,8 @@ void ext4_da_update_reserve_space(struct inode *inode,
1106 * that 1106 * that
1107 */ 1107 */
1108 if (allocated_meta_blocks) 1108 if (allocated_meta_blocks)
1109 vfs_dq_claim_block(inode, allocated_meta_blocks); 1109 dquot_claim_block(inode, allocated_meta_blocks);
1110 vfs_dq_release_reservation_block(inode, mdb_free + used); 1110 dquot_release_reservation_block(inode, mdb_free + used);
1111 } 1111 }
1112 1112
1113 /* 1113 /*
@@ -1836,6 +1836,7 @@ static int ext4_da_reserve_space(struct inode *inode, sector_t lblock)
1836 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 1836 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
1837 struct ext4_inode_info *ei = EXT4_I(inode); 1837 struct ext4_inode_info *ei = EXT4_I(inode);
1838 unsigned long md_needed, md_reserved; 1838 unsigned long md_needed, md_reserved;
1839 int ret;
1839 1840
1840 /* 1841 /*
1841 * recalculate the amount of metadata blocks to reserve 1842 * recalculate the amount of metadata blocks to reserve
@@ -1853,11 +1854,12 @@ repeat:
1853 * later. Real quota accounting is done at pages writeout 1854 * later. Real quota accounting is done at pages writeout
1854 * time. 1855 * time.
1855 */ 1856 */
1856 if (vfs_dq_reserve_block(inode, md_needed + 1)) 1857 ret = dquot_reserve_block(inode, md_needed + 1);
1857 return -EDQUOT; 1858 if (ret)
1859 return ret;
1858 1860
1859 if (ext4_claim_free_blocks(sbi, md_needed + 1)) { 1861 if (ext4_claim_free_blocks(sbi, md_needed + 1)) {
1860 vfs_dq_release_reservation_block(inode, md_needed + 1); 1862 dquot_release_reservation_block(inode, md_needed + 1);
1861 if (ext4_should_retry_alloc(inode->i_sb, &retries)) { 1863 if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
1862 yield(); 1864 yield();
1863 goto repeat; 1865 goto repeat;
@@ -1914,7 +1916,7 @@ static void ext4_da_release_space(struct inode *inode, int to_free)
1914 1916
1915 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 1917 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1916 1918
1917 vfs_dq_release_reservation_block(inode, to_free); 1919 dquot_release_reservation_block(inode, to_free);
1918} 1920}
1919 1921
1920static void ext4_da_page_release_reservation(struct page *page, 1922static void ext4_da_page_release_reservation(struct page *page,
@@ -5641,7 +5643,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
5641 * i_size has been changed by generic_commit_write() and we thus need 5643 * i_size has been changed by generic_commit_write() and we thus need
5642 * to include the updated inode in the current transaction. 5644 * to include the updated inode in the current transaction.
5643 * 5645 *
5644 * Also, vfs_dq_alloc_block() will always dirty the inode when blocks 5646 * Also, dquot_alloc_block() will always dirty the inode when blocks
5645 * are allocated to the file. 5647 * are allocated to the file.
5646 * 5648 *
5647 * If the inode is marked synchronous, we don't honour that here - doing 5649 * If the inode is marked synchronous, we don't honour that here - doing
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index d34afad3e137..0b905781e8e6 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4254,7 +4254,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4254 return 0; 4254 return 0;
4255 } 4255 }
4256 reserv_blks = ar->len; 4256 reserv_blks = ar->len;
4257 while (ar->len && vfs_dq_alloc_block(ar->inode, ar->len)) { 4257 while (ar->len && dquot_alloc_block(ar->inode, ar->len)) {
4258 ar->flags |= EXT4_MB_HINT_NOPREALLOC; 4258 ar->flags |= EXT4_MB_HINT_NOPREALLOC;
4259 ar->len--; 4259 ar->len--;
4260 } 4260 }
@@ -4331,7 +4331,7 @@ out2:
4331 kmem_cache_free(ext4_ac_cachep, ac); 4331 kmem_cache_free(ext4_ac_cachep, ac);
4332out1: 4332out1:
4333 if (inquota && ar->len < inquota) 4333 if (inquota && ar->len < inquota)
4334 vfs_dq_free_block(ar->inode, inquota - ar->len); 4334 dquot_free_block(ar->inode, inquota - ar->len);
4335out3: 4335out3:
4336 if (!ar->len) { 4336 if (!ar->len) {
4337 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) 4337 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag)
@@ -4646,7 +4646,7 @@ do_more:
4646 sb->s_dirt = 1; 4646 sb->s_dirt = 1;
4647error_return: 4647error_return:
4648 if (freed) 4648 if (freed)
4649 vfs_dq_free_block(inode, freed); 4649 dquot_free_block(inode, freed);
4650 brelse(bitmap_bh); 4650 brelse(bitmap_bh);
4651 ext4_std_error(sb, err); 4651 ext4_std_error(sb, err);
4652 if (ac) 4652 if (ac)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 735c20d5fd56..fa8f4deda652 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1014,15 +1014,10 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
1014static const struct dquot_operations ext4_quota_operations = { 1014static const struct dquot_operations ext4_quota_operations = {
1015 .initialize = dquot_initialize, 1015 .initialize = dquot_initialize,
1016 .drop = dquot_drop, 1016 .drop = dquot_drop,
1017 .alloc_space = dquot_alloc_space,
1018 .reserve_space = dquot_reserve_space,
1019 .claim_space = dquot_claim_space,
1020 .release_rsv = dquot_release_reserved_space,
1021#ifdef CONFIG_QUOTA 1017#ifdef CONFIG_QUOTA
1022 .get_reserved_space = ext4_get_reserved_space, 1018 .get_reserved_space = ext4_get_reserved_space,
1023#endif 1019#endif
1024 .alloc_inode = dquot_alloc_inode, 1020 .alloc_inode = dquot_alloc_inode,
1025 .free_space = dquot_free_space,
1026 .free_inode = dquot_free_inode, 1021 .free_inode = dquot_free_inode,
1027 .transfer = dquot_transfer, 1022 .transfer = dquot_transfer,
1028 .write_dquot = ext4_write_dquot, 1023 .write_dquot = ext4_write_dquot,
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index f3a2f7ed45aa..ab3a95ee5e7e 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -494,7 +494,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
494 error = ext4_handle_dirty_metadata(handle, inode, bh); 494 error = ext4_handle_dirty_metadata(handle, inode, bh);
495 if (IS_SYNC(inode)) 495 if (IS_SYNC(inode))
496 ext4_handle_sync(handle); 496 ext4_handle_sync(handle);
497 vfs_dq_free_block(inode, 1); 497 dquot_free_block(inode, 1);
498 ea_bdebug(bh, "refcount now=%d; releasing", 498 ea_bdebug(bh, "refcount now=%d; releasing",
499 le32_to_cpu(BHDR(bh)->h_refcount)); 499 le32_to_cpu(BHDR(bh)->h_refcount));
500 if (ce) 500 if (ce)
@@ -787,8 +787,8 @@ inserted:
787 else { 787 else {
788 /* The old block is released after updating 788 /* The old block is released after updating
789 the inode. */ 789 the inode. */
790 error = -EDQUOT; 790 error = dquot_alloc_block(inode, 1);
791 if (vfs_dq_alloc_block(inode, 1)) 791 if (error)
792 goto cleanup; 792 goto cleanup;
793 error = ext4_journal_get_write_access(handle, 793 error = ext4_journal_get_write_access(handle,
794 new_bh); 794 new_bh);
@@ -876,7 +876,7 @@ cleanup:
876 return error; 876 return error;
877 877
878cleanup_dquot: 878cleanup_dquot:
879 vfs_dq_free_block(inode, 1); 879 dquot_free_block(inode, 1);
880 goto cleanup; 880 goto cleanup;
881 881
882bad_block: 882bad_block: