aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/Locking6
-rw-r--r--fs/ext2/balloc.c12
-rw-r--r--fs/ext2/xattr.c10
-rw-r--r--fs/ext3/balloc.c11
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext3/xattr.c8
-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
-rw-r--r--fs/jfs/jfs_dtree.c28
-rw-r--r--fs/jfs/jfs_extent.c16
-rw-r--r--fs/jfs/jfs_xtree.c21
-rw-r--r--fs/jfs/xattr.c17
-rw-r--r--fs/ocfs2/alloc.c13
-rw-r--r--fs/ocfs2/aops.c11
-rw-r--r--fs/ocfs2/dir.c37
-rw-r--r--fs/ocfs2/file.c11
-rw-r--r--fs/ocfs2/namei.c9
-rw-r--r--fs/ocfs2/quota_global.c2
-rw-r--r--fs/quota/dquot.c79
-rw-r--r--fs/reiserfs/bitmap.c10
-rw-r--r--fs/reiserfs/stree.c20
-rw-r--r--fs/reiserfs/super.c2
-rw-r--r--fs/udf/balloc.c35
-rw-r--r--fs/ufs/balloc.c24
-rw-r--r--include/linux/quota.h8
-rw-r--r--include/linux/quotaops.h208
29 files changed, 258 insertions, 383 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index 18b9d0ca0630..1192fde11638 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -462,9 +462,7 @@ in sys_read() and friends.
462prototypes: 462prototypes:
463 int (*initialize) (struct inode *, int); 463 int (*initialize) (struct inode *, int);
464 int (*drop) (struct inode *); 464 int (*drop) (struct inode *);
465 int (*alloc_space) (struct inode *, qsize_t, int);
466 int (*alloc_inode) (const struct inode *, unsigned long); 465 int (*alloc_inode) (const struct inode *, unsigned long);
467 int (*free_space) (struct inode *, qsize_t);
468 int (*free_inode) (const struct inode *, unsigned long); 466 int (*free_inode) (const struct inode *, unsigned long);
469 int (*transfer) (struct inode *, struct iattr *); 467 int (*transfer) (struct inode *, struct iattr *);
470 int (*write_dquot) (struct dquot *); 468 int (*write_dquot) (struct dquot *);
@@ -481,9 +479,7 @@ What filesystem should expect from the generic quota functions:
481 FS recursion Held locks when called 479 FS recursion Held locks when called
482initialize: yes maybe dqonoff_sem 480initialize: yes maybe dqonoff_sem
483drop: yes - 481drop: yes -
484alloc_space: ->mark_dirty() -
485alloc_inode: ->mark_dirty() - 482alloc_inode: ->mark_dirty() -
486free_space: ->mark_dirty() -
487free_inode: ->mark_dirty() - 483free_inode: ->mark_dirty() -
488transfer: yes - 484transfer: yes -
489write_dquot: yes dqonoff_sem or dqptr_sem 485write_dquot: yes dqonoff_sem or dqptr_sem
@@ -495,7 +491,7 @@ write_info: yes dqonoff_sem
495FS recursion means calling ->quota_read() and ->quota_write() from superblock 491FS recursion means calling ->quota_read() and ->quota_write() from superblock
496operations. 492operations.
497 493
498->alloc_space(), ->alloc_inode(), ->free_space(), ->free_inode() are called 494->alloc_inode(), ->free_inode() are called
499only directly by the filesystem and do not call any fs functions only 495only directly by the filesystem and do not call any fs functions only
500the ->mark_dirty() operation. 496the ->mark_dirty() operation.
501 497
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 7f8d2e5a7ea6..1d081f0cfec2 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -570,7 +570,7 @@ do_more:
570error_return: 570error_return:
571 brelse(bitmap_bh); 571 brelse(bitmap_bh);
572 release_blocks(sb, freed); 572 release_blocks(sb, freed);
573 vfs_dq_free_block(inode, freed); 573 dquot_free_block(inode, freed);
574} 574}
575 575
576/** 576/**
@@ -1236,6 +1236,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
1236 unsigned short windowsz = 0; 1236 unsigned short windowsz = 0;
1237 unsigned long ngroups; 1237 unsigned long ngroups;
1238 unsigned long num = *count; 1238 unsigned long num = *count;
1239 int ret;
1239 1240
1240 *errp = -ENOSPC; 1241 *errp = -ENOSPC;
1241 sb = inode->i_sb; 1242 sb = inode->i_sb;
@@ -1247,8 +1248,9 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
1247 /* 1248 /*
1248 * Check quota for allocation of this block. 1249 * Check quota for allocation of this block.
1249 */ 1250 */
1250 if (vfs_dq_alloc_block(inode, num)) { 1251 ret = dquot_alloc_block(inode, num);
1251 *errp = -EDQUOT; 1252 if (ret) {
1253 *errp = ret;
1252 return 0; 1254 return 0;
1253 } 1255 }
1254 1256
@@ -1409,7 +1411,7 @@ allocated:
1409 1411
1410 *errp = 0; 1412 *errp = 0;
1411 brelse(bitmap_bh); 1413 brelse(bitmap_bh);
1412 vfs_dq_free_block(inode, *count-num); 1414 dquot_free_block(inode, *count-num);
1413 *count = num; 1415 *count = num;
1414 return ret_block; 1416 return ret_block;
1415 1417
@@ -1420,7 +1422,7 @@ out:
1420 * Undo the block allocation 1422 * Undo the block allocation
1421 */ 1423 */
1422 if (!performed_allocation) 1424 if (!performed_allocation)
1423 vfs_dq_free_block(inode, *count); 1425 dquot_free_block(inode, *count);
1424 brelse(bitmap_bh); 1426 brelse(bitmap_bh);
1425 return 0; 1427 return 0;
1426} 1428}
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 904f00642f84..e44dc92609be 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -644,8 +644,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
644 the inode. */ 644 the inode. */
645 ea_bdebug(new_bh, "reusing block"); 645 ea_bdebug(new_bh, "reusing block");
646 646
647 error = -EDQUOT; 647 error = dquot_alloc_block(inode, 1);
648 if (vfs_dq_alloc_block(inode, 1)) { 648 if (error) {
649 unlock_buffer(new_bh); 649 unlock_buffer(new_bh);
650 goto cleanup; 650 goto cleanup;
651 } 651 }
@@ -702,7 +702,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
702 * as if nothing happened and cleanup the unused block */ 702 * as if nothing happened and cleanup the unused block */
703 if (error && error != -ENOSPC) { 703 if (error && error != -ENOSPC) {
704 if (new_bh && new_bh != old_bh) 704 if (new_bh && new_bh != old_bh)
705 vfs_dq_free_block(inode, 1); 705 dquot_free_block(inode, 1);
706 goto cleanup; 706 goto cleanup;
707 } 707 }
708 } else 708 } else
@@ -734,7 +734,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
734 le32_add_cpu(&HDR(old_bh)->h_refcount, -1); 734 le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
735 if (ce) 735 if (ce)
736 mb_cache_entry_release(ce); 736 mb_cache_entry_release(ce);
737 vfs_dq_free_block(inode, 1); 737 dquot_free_block(inode, 1);
738 mark_buffer_dirty(old_bh); 738 mark_buffer_dirty(old_bh);
739 ea_bdebug(old_bh, "refcount now=%d", 739 ea_bdebug(old_bh, "refcount now=%d",
740 le32_to_cpu(HDR(old_bh)->h_refcount)); 740 le32_to_cpu(HDR(old_bh)->h_refcount));
@@ -797,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
797 mark_buffer_dirty(bh); 797 mark_buffer_dirty(bh);
798 if (IS_SYNC(inode)) 798 if (IS_SYNC(inode))
799 sync_dirty_buffer(bh); 799 sync_dirty_buffer(bh);
800 vfs_dq_free_block(inode, 1); 800 dquot_free_block(inode, 1);
801 } 801 }
802 EXT2_I(inode)->i_file_acl = 0; 802 EXT2_I(inode)->i_file_acl = 0;
803 803
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 27967f92e820..161da2d3f890 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
676 } 676 }
677 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); 677 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
678 if (dquot_freed_blocks) 678 if (dquot_freed_blocks)
679 vfs_dq_free_block(inode, dquot_freed_blocks); 679 dquot_free_block(inode, dquot_freed_blocks);
680 return; 680 return;
681} 681}
682 682
@@ -1502,8 +1502,9 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1502 /* 1502 /*
1503 * Check quota for allocation of this block. 1503 * Check quota for allocation of this block.
1504 */ 1504 */
1505 if (vfs_dq_alloc_block(inode, num)) { 1505 err = dquot_alloc_block(inode, num);
1506 *errp = -EDQUOT; 1506 if (err) {
1507 *errp = err;
1507 return 0; 1508 return 0;
1508 } 1509 }
1509 1510
@@ -1713,7 +1714,7 @@ allocated:
1713 1714
1714 *errp = 0; 1715 *errp = 0;
1715 brelse(bitmap_bh); 1716 brelse(bitmap_bh);
1716 vfs_dq_free_block(inode, *count-num); 1717 dquot_free_block(inode, *count-num);
1717 *count = num; 1718 *count = num;
1718 return ret_block; 1719 return ret_block;
1719 1720
@@ -1728,7 +1729,7 @@ out:
1728 * Undo the block allocation 1729 * Undo the block allocation
1729 */ 1730 */
1730 if (!performed_allocation) 1731 if (!performed_allocation)
1731 vfs_dq_free_block(inode, *count); 1732 dquot_free_block(inode, *count);
1732 brelse(bitmap_bh); 1733 brelse(bitmap_bh);
1733 return 0; 1734 return 0;
1734} 1735}
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index eda9121d7d57..20f02d69365c 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -3336,7 +3336,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
3336 * i_size has been changed by generic_commit_write() and we thus need 3336 * i_size has been changed by generic_commit_write() and we thus need
3337 * to include the updated inode in the current transaction. 3337 * to include the updated inode in the current transaction.
3338 * 3338 *
3339 * Also, vfs_dq_alloc_space() will always dirty the inode when blocks 3339 * Also, dquot_alloc_space() will always dirty the inode when blocks
3340 * are allocated to the file. 3340 * are allocated to the file.
3341 * 3341 *
3342 * If the inode is marked synchronous, we don't honour that here - doing 3342 * If the inode is marked synchronous, we don't honour that here - doing
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 5c54e5f685d4..8c13910a3782 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -752,9 +752,7 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
752static const struct dquot_operations ext3_quota_operations = { 752static const struct dquot_operations ext3_quota_operations = {
753 .initialize = dquot_initialize, 753 .initialize = dquot_initialize,
754 .drop = dquot_drop, 754 .drop = dquot_drop,
755 .alloc_space = dquot_alloc_space,
756 .alloc_inode = dquot_alloc_inode, 755 .alloc_inode = dquot_alloc_inode,
757 .free_space = dquot_free_space,
758 .free_inode = dquot_free_inode, 756 .free_inode = dquot_free_inode,
759 .transfer = dquot_transfer, 757 .transfer = dquot_transfer,
760 .write_dquot = ext3_write_dquot, 758 .write_dquot = ext3_write_dquot,
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index 2d2fb2a85961..534a94c3a933 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -500,7 +500,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode,
500 error = ext3_journal_dirty_metadata(handle, bh); 500 error = ext3_journal_dirty_metadata(handle, bh);
501 if (IS_SYNC(inode)) 501 if (IS_SYNC(inode))
502 handle->h_sync = 1; 502 handle->h_sync = 1;
503 vfs_dq_free_block(inode, 1); 503 dquot_free_block(inode, 1);
504 ea_bdebug(bh, "refcount now=%d; releasing", 504 ea_bdebug(bh, "refcount now=%d; releasing",
505 le32_to_cpu(BHDR(bh)->h_refcount)); 505 le32_to_cpu(BHDR(bh)->h_refcount));
506 if (ce) 506 if (ce)
@@ -775,8 +775,8 @@ inserted:
775 else { 775 else {
776 /* The old block is released after updating 776 /* The old block is released after updating
777 the inode. */ 777 the inode. */
778 error = -EDQUOT; 778 error = dquot_alloc_block(inode, 1);
779 if (vfs_dq_alloc_block(inode, 1)) 779 if (error)
780 goto cleanup; 780 goto cleanup;
781 error = ext3_journal_get_write_access(handle, 781 error = ext3_journal_get_write_access(handle,
782 new_bh); 782 new_bh);
@@ -850,7 +850,7 @@ cleanup:
850 return error; 850 return error;
851 851
852cleanup_dquot: 852cleanup_dquot:
853 vfs_dq_free_block(inode, 1); 853 dquot_free_block(inode, 1);
854 goto cleanup; 854 goto cleanup;
855 855
856bad_block: 856bad_block:
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:
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 925871e9887b..0e4623be70ce 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -381,10 +381,10 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
381 * It's time to move the inline table to an external 381 * It's time to move the inline table to an external
382 * page and begin to build the xtree 382 * page and begin to build the xtree
383 */ 383 */
384 if (vfs_dq_alloc_block(ip, sbi->nbperpage)) 384 if (dquot_alloc_block(ip, sbi->nbperpage))
385 goto clean_up; 385 goto clean_up;
386 if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { 386 if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
387 vfs_dq_free_block(ip, sbi->nbperpage); 387 dquot_free_block(ip, sbi->nbperpage);
388 goto clean_up; 388 goto clean_up;
389 } 389 }
390 390
@@ -408,7 +408,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
408 memcpy(&jfs_ip->i_dirtable, temp_table, 408 memcpy(&jfs_ip->i_dirtable, temp_table,
409 sizeof (temp_table)); 409 sizeof (temp_table));
410 dbFree(ip, xaddr, sbi->nbperpage); 410 dbFree(ip, xaddr, sbi->nbperpage);
411 vfs_dq_free_block(ip, sbi->nbperpage); 411 dquot_free_block(ip, sbi->nbperpage);
412 goto clean_up; 412 goto clean_up;
413 } 413 }
414 ip->i_size = PSIZE; 414 ip->i_size = PSIZE;
@@ -1027,10 +1027,9 @@ static int dtSplitUp(tid_t tid,
1027 n = xlen; 1027 n = xlen;
1028 1028
1029 /* Allocate blocks to quota. */ 1029 /* Allocate blocks to quota. */
1030 if (vfs_dq_alloc_block(ip, n)) { 1030 rc = dquot_alloc_block(ip, n);
1031 rc = -EDQUOT; 1031 if (rc)
1032 goto extendOut; 1032 goto extendOut;
1033 }
1034 quota_allocation += n; 1033 quota_allocation += n;
1035 1034
1036 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen, 1035 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
@@ -1308,7 +1307,7 @@ static int dtSplitUp(tid_t tid,
1308 1307
1309 /* Rollback quota allocation */ 1308 /* Rollback quota allocation */
1310 if (rc && quota_allocation) 1309 if (rc && quota_allocation)
1311 vfs_dq_free_block(ip, quota_allocation); 1310 dquot_free_block(ip, quota_allocation);
1312 1311
1313 dtSplitUp_Exit: 1312 dtSplitUp_Exit:
1314 1313
@@ -1369,9 +1368,10 @@ static int dtSplitPage(tid_t tid, struct inode *ip, struct dtsplit * split,
1369 return -EIO; 1368 return -EIO;
1370 1369
1371 /* Allocate blocks to quota. */ 1370 /* Allocate blocks to quota. */
1372 if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { 1371 rc = dquot_alloc_block(ip, lengthPXD(pxd));
1372 if (rc) {
1373 release_metapage(rmp); 1373 release_metapage(rmp);
1374 return -EDQUOT; 1374 return rc;
1375 } 1375 }
1376 1376
1377 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp); 1377 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
@@ -1892,6 +1892,7 @@ static int dtSplitRoot(tid_t tid,
1892 struct dt_lock *dtlck; 1892 struct dt_lock *dtlck;
1893 struct tlock *tlck; 1893 struct tlock *tlck;
1894 struct lv *lv; 1894 struct lv *lv;
1895 int rc;
1895 1896
1896 /* get split root page */ 1897 /* get split root page */
1897 smp = split->mp; 1898 smp = split->mp;
@@ -1916,9 +1917,10 @@ static int dtSplitRoot(tid_t tid,
1916 rp = rmp->data; 1917 rp = rmp->data;
1917 1918
1918 /* Allocate blocks to quota. */ 1919 /* Allocate blocks to quota. */
1919 if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { 1920 rc = dquot_alloc_block(ip, lengthPXD(pxd));
1921 if (rc) {
1920 release_metapage(rmp); 1922 release_metapage(rmp);
1921 return -EDQUOT; 1923 return rc;
1922 } 1924 }
1923 1925
1924 BT_MARK_DIRTY(rmp, ip); 1926 BT_MARK_DIRTY(rmp, ip);
@@ -2287,7 +2289,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
2287 xlen = lengthPXD(&fp->header.self); 2289 xlen = lengthPXD(&fp->header.self);
2288 2290
2289 /* Free quota allocation. */ 2291 /* Free quota allocation. */
2290 vfs_dq_free_block(ip, xlen); 2292 dquot_free_block(ip, xlen);
2291 2293
2292 /* free/invalidate its buffer page */ 2294 /* free/invalidate its buffer page */
2293 discard_metapage(fmp); 2295 discard_metapage(fmp);
@@ -2363,7 +2365,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
2363 xlen = lengthPXD(&p->header.self); 2365 xlen = lengthPXD(&p->header.self);
2364 2366
2365 /* Free quota allocation */ 2367 /* Free quota allocation */
2366 vfs_dq_free_block(ip, xlen); 2368 dquot_free_block(ip, xlen);
2367 2369
2368 /* free/invalidate its buffer page */ 2370 /* free/invalidate its buffer page */
2369 discard_metapage(mp); 2371 discard_metapage(mp);
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c
index 41d6045dbeb0..5d3bbd10f8db 100644
--- a/fs/jfs/jfs_extent.c
+++ b/fs/jfs/jfs_extent.c
@@ -141,10 +141,11 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
141 } 141 }
142 142
143 /* Allocate blocks to quota. */ 143 /* Allocate blocks to quota. */
144 if (vfs_dq_alloc_block(ip, nxlen)) { 144 rc = dquot_alloc_block(ip, nxlen);
145 if (rc) {
145 dbFree(ip, nxaddr, (s64) nxlen); 146 dbFree(ip, nxaddr, (s64) nxlen);
146 mutex_unlock(&JFS_IP(ip)->commit_mutex); 147 mutex_unlock(&JFS_IP(ip)->commit_mutex);
147 return -EDQUOT; 148 return rc;
148 } 149 }
149 150
150 /* determine the value of the extent flag */ 151 /* determine the value of the extent flag */
@@ -164,7 +165,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
164 */ 165 */
165 if (rc) { 166 if (rc) {
166 dbFree(ip, nxaddr, nxlen); 167 dbFree(ip, nxaddr, nxlen);
167 vfs_dq_free_block(ip, nxlen); 168 dquot_free_block(ip, nxlen);
168 mutex_unlock(&JFS_IP(ip)->commit_mutex); 169 mutex_unlock(&JFS_IP(ip)->commit_mutex);
169 return (rc); 170 return (rc);
170 } 171 }
@@ -256,10 +257,11 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
256 goto exit; 257 goto exit;
257 258
258 /* Allocat blocks to quota. */ 259 /* Allocat blocks to quota. */
259 if (vfs_dq_alloc_block(ip, nxlen)) { 260 rc = dquot_alloc_block(ip, nxlen);
261 if (rc) {
260 dbFree(ip, nxaddr, (s64) nxlen); 262 dbFree(ip, nxaddr, (s64) nxlen);
261 mutex_unlock(&JFS_IP(ip)->commit_mutex); 263 mutex_unlock(&JFS_IP(ip)->commit_mutex);
262 return -EDQUOT; 264 return rc;
263 } 265 }
264 266
265 delta = nxlen - xlen; 267 delta = nxlen - xlen;
@@ -297,7 +299,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
297 /* extend the extent */ 299 /* extend the extent */
298 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { 300 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
299 dbFree(ip, xaddr + xlen, delta); 301 dbFree(ip, xaddr + xlen, delta);
300 vfs_dq_free_block(ip, nxlen); 302 dquot_free_block(ip, nxlen);
301 goto exit; 303 goto exit;
302 } 304 }
303 } else { 305 } else {
@@ -308,7 +310,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
308 */ 310 */
309 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { 311 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
310 dbFree(ip, nxaddr, nxlen); 312 dbFree(ip, nxaddr, nxlen);
311 vfs_dq_free_block(ip, nxlen); 313 dquot_free_block(ip, nxlen);
312 goto exit; 314 goto exit;
313 } 315 }
314 } 316 }
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index d654a6458648..6c50871e6220 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -585,10 +585,10 @@ int xtInsert(tid_t tid, /* transaction id */
585 hint = addressXAD(xad) + lengthXAD(xad) - 1; 585 hint = addressXAD(xad) + lengthXAD(xad) - 1;
586 } else 586 } else
587 hint = 0; 587 hint = 0;
588 if ((rc = vfs_dq_alloc_block(ip, xlen))) 588 if ((rc = dquot_alloc_block(ip, xlen)))
589 goto out; 589 goto out;
590 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) { 590 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
591 vfs_dq_free_block(ip, xlen); 591 dquot_free_block(ip, xlen);
592 goto out; 592 goto out;
593 } 593 }
594 } 594 }
@@ -617,7 +617,7 @@ int xtInsert(tid_t tid, /* transaction id */
617 /* undo data extent allocation */ 617 /* undo data extent allocation */
618 if (*xaddrp == 0) { 618 if (*xaddrp == 0) {
619 dbFree(ip, xaddr, (s64) xlen); 619 dbFree(ip, xaddr, (s64) xlen);
620 vfs_dq_free_block(ip, xlen); 620 dquot_free_block(ip, xlen);
621 } 621 }
622 return rc; 622 return rc;
623 } 623 }
@@ -985,10 +985,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
985 rbn = addressPXD(pxd); 985 rbn = addressPXD(pxd);
986 986
987 /* Allocate blocks to quota. */ 987 /* Allocate blocks to quota. */
988 if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { 988 rc = dquot_alloc_block(ip, lengthPXD(pxd));
989 rc = -EDQUOT; 989 if (rc)
990 goto clean_up; 990 goto clean_up;
991 }
992 991
993 quota_allocation += lengthPXD(pxd); 992 quota_allocation += lengthPXD(pxd);
994 993
@@ -1195,7 +1194,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
1195 1194
1196 /* Rollback quota allocation. */ 1195 /* Rollback quota allocation. */
1197 if (quota_allocation) 1196 if (quota_allocation)
1198 vfs_dq_free_block(ip, quota_allocation); 1197 dquot_free_block(ip, quota_allocation);
1199 1198
1200 return (rc); 1199 return (rc);
1201} 1200}
@@ -1235,6 +1234,7 @@ xtSplitRoot(tid_t tid,
1235 struct pxdlist *pxdlist; 1234 struct pxdlist *pxdlist;
1236 struct tlock *tlck; 1235 struct tlock *tlck;
1237 struct xtlock *xtlck; 1236 struct xtlock *xtlck;
1237 int rc;
1238 1238
1239 sp = &JFS_IP(ip)->i_xtroot; 1239 sp = &JFS_IP(ip)->i_xtroot;
1240 1240
@@ -1252,9 +1252,10 @@ xtSplitRoot(tid_t tid,
1252 return -EIO; 1252 return -EIO;
1253 1253
1254 /* Allocate blocks to quota. */ 1254 /* Allocate blocks to quota. */
1255 if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { 1255 rc = dquot_alloc_block(ip, lengthPXD(pxd));
1256 if (rc) {
1256 release_metapage(rmp); 1257 release_metapage(rmp);
1257 return -EDQUOT; 1258 return rc;
1258 } 1259 }
1259 1260
1260 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp); 1261 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
@@ -3680,7 +3681,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
3680 ip->i_size = newsize; 3681 ip->i_size = newsize;
3681 3682
3682 /* update quota allocation to reflect freed blocks */ 3683 /* update quota allocation to reflect freed blocks */
3683 vfs_dq_free_block(ip, nfreed); 3684 dquot_free_block(ip, nfreed);
3684 3685
3685 /* 3686 /*
3686 * free tlock of invalidated pages 3687 * free tlock of invalidated pages
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index fad364548bc9..1f594ab21895 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -260,14 +260,14 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size,
260 nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits; 260 nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits;
261 261
262 /* Allocate new blocks to quota. */ 262 /* Allocate new blocks to quota. */
263 if (vfs_dq_alloc_block(ip, nblocks)) { 263 rc = dquot_alloc_block(ip, nblocks);
264 return -EDQUOT; 264 if (rc)
265 } 265 return rc;
266 266
267 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno); 267 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
268 if (rc) { 268 if (rc) {
269 /*Rollback quota allocation. */ 269 /*Rollback quota allocation. */
270 vfs_dq_free_block(ip, nblocks); 270 dquot_free_block(ip, nblocks);
271 return rc; 271 return rc;
272 } 272 }
273 273
@@ -332,7 +332,7 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size,
332 332
333 failed: 333 failed:
334 /* Rollback quota allocation. */ 334 /* Rollback quota allocation. */
335 vfs_dq_free_block(ip, nblocks); 335 dquot_free_block(ip, nblocks);
336 336
337 dbFree(ip, blkno, nblocks); 337 dbFree(ip, blkno, nblocks);
338 return rc; 338 return rc;
@@ -538,7 +538,8 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
538 538
539 if (blocks_needed > current_blocks) { 539 if (blocks_needed > current_blocks) {
540 /* Allocate new blocks to quota. */ 540 /* Allocate new blocks to quota. */
541 if (vfs_dq_alloc_block(inode, blocks_needed)) 541 rc = dquot_alloc_block(inode, blocks_needed);
542 if (rc)
542 return -EDQUOT; 543 return -EDQUOT;
543 544
544 quota_allocation = blocks_needed; 545 quota_allocation = blocks_needed;
@@ -602,7 +603,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
602 clean_up: 603 clean_up:
603 /* Rollback quota allocation */ 604 /* Rollback quota allocation */
604 if (quota_allocation) 605 if (quota_allocation)
605 vfs_dq_free_block(inode, quota_allocation); 606 dquot_free_block(inode, quota_allocation);
606 607
607 return (rc); 608 return (rc);
608} 609}
@@ -677,7 +678,7 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
677 678
678 /* If old blocks exist, they must be removed from quota allocation. */ 679 /* If old blocks exist, they must be removed from quota allocation. */
679 if (old_blocks) 680 if (old_blocks)
680 vfs_dq_free_block(inode, old_blocks); 681 dquot_free_block(inode, old_blocks);
681 682
682 inode->i_ctime = CURRENT_TIME; 683 inode->i_ctime = CURRENT_TIME;
683 684
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index d17bdc718f74..20538dd832a4 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -5712,7 +5712,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
5712 goto out; 5712 goto out;
5713 } 5713 }
5714 5714
5715 vfs_dq_free_space_nodirty(inode, 5715 dquot_free_space_nodirty(inode,
5716 ocfs2_clusters_to_bytes(inode->i_sb, len)); 5716 ocfs2_clusters_to_bytes(inode->i_sb, len));
5717 5717
5718 ret = ocfs2_remove_extent(handle, et, cpos, len, meta_ac, dealloc); 5718 ret = ocfs2_remove_extent(handle, et, cpos, len, meta_ac, dealloc);
@@ -6935,7 +6935,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
6935 goto bail; 6935 goto bail;
6936 } 6936 }
6937 6937
6938 vfs_dq_free_space_nodirty(inode, 6938 dquot_free_space_nodirty(inode,
6939 ocfs2_clusters_to_bytes(osb->sb, clusters_to_del)); 6939 ocfs2_clusters_to_bytes(osb->sb, clusters_to_del));
6940 spin_lock(&OCFS2_I(inode)->ip_lock); 6940 spin_lock(&OCFS2_I(inode)->ip_lock);
6941 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - 6941 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) -
@@ -7300,11 +7300,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
7300 unsigned int page_end; 7300 unsigned int page_end;
7301 u64 phys; 7301 u64 phys;
7302 7302
7303 if (vfs_dq_alloc_space_nodirty(inode, 7303 ret = dquot_alloc_space_nodirty(inode,
7304 ocfs2_clusters_to_bytes(osb->sb, 1))) { 7304 ocfs2_clusters_to_bytes(osb->sb, 1));
7305 ret = -EDQUOT; 7305 if (ret)
7306 goto out_commit; 7306 goto out_commit;
7307 }
7308 did_quota = 1; 7307 did_quota = 1;
7309 7308
7310 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, 7309 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
@@ -7380,7 +7379,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
7380 7379
7381out_commit: 7380out_commit:
7382 if (ret < 0 && did_quota) 7381 if (ret < 0 && did_quota)
7383 vfs_dq_free_space_nodirty(inode, 7382 dquot_free_space_nodirty(inode,
7384 ocfs2_clusters_to_bytes(osb->sb, 1)); 7383 ocfs2_clusters_to_bytes(osb->sb, 1));
7385 7384
7386 ocfs2_commit_trans(osb, handle); 7385 ocfs2_commit_trans(osb, handle);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 7e9df11260f4..7d04c171567d 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1763,10 +1763,11 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1763 1763
1764 wc->w_handle = handle; 1764 wc->w_handle = handle;
1765 1765
1766 if (clusters_to_alloc && vfs_dq_alloc_space_nodirty(inode, 1766 if (clusters_to_alloc) {
1767 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc))) { 1767 ret = dquot_alloc_space_nodirty(inode,
1768 ret = -EDQUOT; 1768 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
1769 goto out_commit; 1769 if (ret)
1770 goto out_commit;
1770 } 1771 }
1771 /* 1772 /*
1772 * We don't want this to fail in ocfs2_write_end(), so do it 1773 * We don't want this to fail in ocfs2_write_end(), so do it
@@ -1809,7 +1810,7 @@ success:
1809 return 0; 1810 return 0;
1810out_quota: 1811out_quota:
1811 if (clusters_to_alloc) 1812 if (clusters_to_alloc)
1812 vfs_dq_free_space(inode, 1813 dquot_free_space(inode,
1813 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); 1814 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
1814out_commit: 1815out_commit:
1815 ocfs2_commit_trans(osb, handle); 1816 ocfs2_commit_trans(osb, handle);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 28c3ec238796..a63ea4d74e67 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2964,12 +2964,10 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
2964 goto out; 2964 goto out;
2965 } 2965 }
2966 2966
2967 if (vfs_dq_alloc_space_nodirty(dir, 2967 ret = dquot_alloc_space_nodirty(dir,
2968 ocfs2_clusters_to_bytes(osb->sb, 2968 ocfs2_clusters_to_bytes(osb->sb, alloc + dx_alloc));
2969 alloc + dx_alloc))) { 2969 if (ret)
2970 ret = -EDQUOT;
2971 goto out_commit; 2970 goto out_commit;
2972 }
2973 did_quota = 1; 2971 did_quota = 1;
2974 2972
2975 if (ocfs2_supports_indexed_dirs(osb) && !dx_inline) { 2973 if (ocfs2_supports_indexed_dirs(osb) && !dx_inline) {
@@ -3178,7 +3176,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
3178 3176
3179out_commit: 3177out_commit:
3180 if (ret < 0 && did_quota) 3178 if (ret < 0 && did_quota)
3181 vfs_dq_free_space_nodirty(dir, bytes_allocated); 3179 dquot_free_space_nodirty(dir, bytes_allocated);
3182 3180
3183 ocfs2_commit_trans(osb, handle); 3181 ocfs2_commit_trans(osb, handle);
3184 3182
@@ -3221,11 +3219,10 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
3221 if (extend) { 3219 if (extend) {
3222 u32 offset = OCFS2_I(dir)->ip_clusters; 3220 u32 offset = OCFS2_I(dir)->ip_clusters;
3223 3221
3224 if (vfs_dq_alloc_space_nodirty(dir, 3222 status = dquot_alloc_space_nodirty(dir,
3225 ocfs2_clusters_to_bytes(sb, 1))) { 3223 ocfs2_clusters_to_bytes(sb, 1));
3226 status = -EDQUOT; 3224 if (status)
3227 goto bail; 3225 goto bail;
3228 }
3229 did_quota = 1; 3226 did_quota = 1;
3230 3227
3231 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset, 3228 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset,
@@ -3254,7 +3251,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
3254 status = 0; 3251 status = 0;
3255bail: 3252bail:
3256 if (did_quota && status < 0) 3253 if (did_quota && status < 0)
3257 vfs_dq_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1)); 3254 dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
3258 mlog_exit(status); 3255 mlog_exit(status);
3259 return status; 3256 return status;
3260} 3257}
@@ -3889,11 +3886,10 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
3889 goto out; 3886 goto out;
3890 } 3887 }
3891 3888
3892 if (vfs_dq_alloc_space_nodirty(dir, 3889 ret = dquot_alloc_space_nodirty(dir,
3893 ocfs2_clusters_to_bytes(dir->i_sb, 1))) { 3890 ocfs2_clusters_to_bytes(dir->i_sb, 1));
3894 ret = -EDQUOT; 3891 if (ret)
3895 goto out_commit; 3892 goto out_commit;
3896 }
3897 did_quota = 1; 3893 did_quota = 1;
3898 3894
3899 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh, 3895 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh,
@@ -3983,7 +3979,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
3983 3979
3984out_commit: 3980out_commit:
3985 if (ret < 0 && did_quota) 3981 if (ret < 0 && did_quota)
3986 vfs_dq_free_space_nodirty(dir, 3982 dquot_free_space_nodirty(dir,
3987 ocfs2_clusters_to_bytes(dir->i_sb, 1)); 3983 ocfs2_clusters_to_bytes(dir->i_sb, 1));
3988 3984
3989 ocfs2_commit_trans(osb, handle); 3985 ocfs2_commit_trans(osb, handle);
@@ -4165,11 +4161,10 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
4165 goto out; 4161 goto out;
4166 } 4162 }
4167 4163
4168 if (vfs_dq_alloc_space_nodirty(dir, 4164 ret = dquot_alloc_space_nodirty(dir,
4169 ocfs2_clusters_to_bytes(osb->sb, 1))) { 4165 ocfs2_clusters_to_bytes(osb->sb, 1));
4170 ret = -EDQUOT; 4166 if (ret)
4171 goto out_commit; 4167 goto out_commit;
4172 }
4173 did_quota = 1; 4168 did_quota = 1;
4174 4169
4175 /* 4170 /*
@@ -4229,7 +4224,7 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
4229 4224
4230out_commit: 4225out_commit:
4231 if (ret < 0 && did_quota) 4226 if (ret < 0 && did_quota)
4232 vfs_dq_free_space_nodirty(dir, 4227 dquot_free_space_nodirty(dir,
4233 ocfs2_clusters_to_bytes(dir->i_sb, 1)); 4228 ocfs2_clusters_to_bytes(dir->i_sb, 1));
4234 4229
4235 ocfs2_commit_trans(osb, handle); 4230 ocfs2_commit_trans(osb, handle);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 558ce0312421..6cf3d8d18369 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -629,11 +629,10 @@ restart_all:
629 } 629 }
630 630
631restarted_transaction: 631restarted_transaction:
632 if (vfs_dq_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb, 632 status = dquot_alloc_space_nodirty(inode,
633 clusters_to_add))) { 633 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
634 status = -EDQUOT; 634 if (status)
635 goto leave; 635 goto leave;
636 }
637 did_quota = 1; 636 did_quota = 1;
638 637
639 /* reserve a write to the file entry early on - that we if we 638 /* reserve a write to the file entry early on - that we if we
@@ -674,7 +673,7 @@ restarted_transaction:
674 clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); 673 clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters);
675 spin_unlock(&OCFS2_I(inode)->ip_lock); 674 spin_unlock(&OCFS2_I(inode)->ip_lock);
676 /* Release unused quota reservation */ 675 /* Release unused quota reservation */
677 vfs_dq_free_space(inode, 676 dquot_free_space(inode,
678 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); 677 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
679 did_quota = 0; 678 did_quota = 0;
680 679
@@ -710,7 +709,7 @@ restarted_transaction:
710 709
711leave: 710leave:
712 if (status < 0 && did_quota) 711 if (status < 0 && did_quota)
713 vfs_dq_free_space(inode, 712 dquot_free_space(inode,
714 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); 713 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
715 if (handle) { 714 if (handle) {
716 ocfs2_commit_trans(osb, handle); 715 ocfs2_commit_trans(osb, handle);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 50fb26a6a5f5..13adaa1f40cd 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1716,11 +1716,10 @@ static int ocfs2_symlink(struct inode *dir,
1716 u32 offset = 0; 1716 u32 offset = 0;
1717 1717
1718 inode->i_op = &ocfs2_symlink_inode_operations; 1718 inode->i_op = &ocfs2_symlink_inode_operations;
1719 if (vfs_dq_alloc_space_nodirty(inode, 1719 status = dquot_alloc_space_nodirty(inode,
1720 ocfs2_clusters_to_bytes(osb->sb, 1))) { 1720 ocfs2_clusters_to_bytes(osb->sb, 1));
1721 status = -EDQUOT; 1721 if (status)
1722 goto bail; 1722 goto bail;
1723 }
1724 did_quota = 1; 1723 did_quota = 1;
1725 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0, 1724 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
1726 new_fe_bh, 1725 new_fe_bh,
@@ -1788,7 +1787,7 @@ static int ocfs2_symlink(struct inode *dir,
1788 d_instantiate(dentry, inode); 1787 d_instantiate(dentry, inode);
1789bail: 1788bail:
1790 if (status < 0 && did_quota) 1789 if (status < 0 && did_quota)
1791 vfs_dq_free_space_nodirty(inode, 1790 dquot_free_space_nodirty(inode,
1792 ocfs2_clusters_to_bytes(osb->sb, 1)); 1791 ocfs2_clusters_to_bytes(osb->sb, 1));
1793 if (status < 0 && did_quota_inode) 1792 if (status < 0 && did_quota_inode)
1794 vfs_dq_free_inode(inode); 1793 vfs_dq_free_inode(inode);
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index b437dc0c4cad..aa66fb277225 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -853,9 +853,7 @@ static void ocfs2_destroy_dquot(struct dquot *dquot)
853const struct dquot_operations ocfs2_quota_operations = { 853const struct dquot_operations ocfs2_quota_operations = {
854 .initialize = dquot_initialize, 854 .initialize = dquot_initialize,
855 .drop = dquot_drop, 855 .drop = dquot_drop,
856 .alloc_space = dquot_alloc_space,
857 .alloc_inode = dquot_alloc_inode, 856 .alloc_inode = dquot_alloc_inode,
858 .free_space = dquot_free_space,
859 .free_inode = dquot_free_inode, 857 .free_inode = dquot_free_inode,
860 .transfer = dquot_transfer, 858 .transfer = dquot_transfer,
861 .write_dquot = ocfs2_write_dquot, 859 .write_dquot = ocfs2_write_dquot,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 10d021dd37c1..baf202c012cc 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1464,28 +1464,29 @@ static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
1464} 1464}
1465 1465
1466/* 1466/*
1467 * Following four functions update i_blocks+i_bytes fields and 1467 * This functions updates i_blocks+i_bytes fields and quota information
1468 * quota information (together with appropriate checks) 1468 * (together with appropriate checks).
1469 * NOTE: We absolutely rely on the fact that caller dirties 1469 *
1470 * the inode (usually macros in quotaops.h care about this) and 1470 * NOTE: We absolutely rely on the fact that caller dirties the inode
1471 * holds a handle for the current transaction so that dquot write and 1471 * (usually helpers in quotaops.h care about this) and holds a handle for
1472 * inode write go into the same transaction. 1472 * the current transaction so that dquot write and inode write go into the
1473 * same transaction.
1473 */ 1474 */
1474 1475
1475/* 1476/*
1476 * This operation can block, but only after everything is updated 1477 * This operation can block, but only after everything is updated
1477 */ 1478 */
1478int __dquot_alloc_space(struct inode *inode, qsize_t number, 1479int __dquot_alloc_space(struct inode *inode, qsize_t number,
1479 int warn, int reserve) 1480 int warn, int reserve)
1480{ 1481{
1481 int cnt, ret = QUOTA_OK; 1482 int cnt, ret = 0;
1482 char warntype[MAXQUOTAS]; 1483 char warntype[MAXQUOTAS];
1483 1484
1484 /* 1485 /*
1485 * First test before acquiring mutex - solves deadlocks when we 1486 * First test before acquiring mutex - solves deadlocks when we
1486 * re-enter the quota code and are already holding the mutex 1487 * re-enter the quota code and are already holding the mutex
1487 */ 1488 */
1488 if (IS_NOQUOTA(inode)) { 1489 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
1489 inode_incr_space(inode, number, reserve); 1490 inode_incr_space(inode, number, reserve);
1490 goto out; 1491 goto out;
1491 } 1492 }
@@ -1498,9 +1499,9 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
1498 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1499 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1499 if (!inode->i_dquot[cnt]) 1500 if (!inode->i_dquot[cnt])
1500 continue; 1501 continue;
1501 if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) 1502 if (check_bdq(inode->i_dquot[cnt], number, !warn, warntype+cnt)
1502 == NO_QUOTA) { 1503 == NO_QUOTA) {
1503 ret = NO_QUOTA; 1504 ret = -EDQUOT;
1504 spin_unlock(&dq_data_lock); 1505 spin_unlock(&dq_data_lock);
1505 goto out_flush_warn; 1506 goto out_flush_warn;
1506 } 1507 }
@@ -1525,18 +1526,7 @@ out_flush_warn:
1525out: 1526out:
1526 return ret; 1527 return ret;
1527} 1528}
1528 1529EXPORT_SYMBOL(__dquot_alloc_space);
1529int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
1530{
1531 return __dquot_alloc_space(inode, number, warn, 0);
1532}
1533EXPORT_SYMBOL(dquot_alloc_space);
1534
1535int dquot_reserve_space(struct inode *inode, qsize_t number, int warn)
1536{
1537 return __dquot_alloc_space(inode, number, warn, 1);
1538}
1539EXPORT_SYMBOL(dquot_reserve_space);
1540 1530
1541/* 1531/*
1542 * This operation can block, but only after everything is updated 1532 * This operation can block, but only after everything is updated
@@ -1578,14 +1568,16 @@ warn_put_all:
1578} 1568}
1579EXPORT_SYMBOL(dquot_alloc_inode); 1569EXPORT_SYMBOL(dquot_alloc_inode);
1580 1570
1581int dquot_claim_space(struct inode *inode, qsize_t number) 1571/*
1572 * Convert in-memory reserved quotas to real consumed quotas
1573 */
1574int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
1582{ 1575{
1583 int cnt; 1576 int cnt;
1584 int ret = QUOTA_OK;
1585 1577
1586 if (IS_NOQUOTA(inode)) { 1578 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
1587 inode_claim_rsv_space(inode, number); 1579 inode_claim_rsv_space(inode, number);
1588 goto out; 1580 return 0;
1589 } 1581 }
1590 1582
1591 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1583 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1601,24 +1593,23 @@ int dquot_claim_space(struct inode *inode, qsize_t number)
1601 spin_unlock(&dq_data_lock); 1593 spin_unlock(&dq_data_lock);
1602 mark_all_dquot_dirty(inode->i_dquot); 1594 mark_all_dquot_dirty(inode->i_dquot);
1603 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1595 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
1604out: 1596 return 0;
1605 return ret;
1606} 1597}
1607EXPORT_SYMBOL(dquot_claim_space); 1598EXPORT_SYMBOL(dquot_claim_space_nodirty);
1608 1599
1609/* 1600/*
1610 * This operation can block, but only after everything is updated 1601 * This operation can block, but only after everything is updated
1611 */ 1602 */
1612int __dquot_free_space(struct inode *inode, qsize_t number, int reserve) 1603void __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
1613{ 1604{
1614 unsigned int cnt; 1605 unsigned int cnt;
1615 char warntype[MAXQUOTAS]; 1606 char warntype[MAXQUOTAS];
1616 1607
1617 /* First test before acquiring mutex - solves deadlocks when we 1608 /* First test before acquiring mutex - solves deadlocks when we
1618 * re-enter the quota code and are already holding the mutex */ 1609 * re-enter the quota code and are already holding the mutex */
1619 if (IS_NOQUOTA(inode)) { 1610 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
1620 inode_decr_space(inode, number, reserve); 1611 inode_decr_space(inode, number, reserve);
1621 return QUOTA_OK; 1612 return;
1622 } 1613 }
1623 1614
1624 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1615 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1641,24 +1632,8 @@ int __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
1641out_unlock: 1632out_unlock:
1642 flush_warnings(inode->i_dquot, warntype); 1633 flush_warnings(inode->i_dquot, warntype);
1643 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1634 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
1644 return QUOTA_OK;
1645}
1646
1647int dquot_free_space(struct inode *inode, qsize_t number)
1648{
1649 return __dquot_free_space(inode, number, 0);
1650}
1651EXPORT_SYMBOL(dquot_free_space);
1652
1653/*
1654 * Release reserved quota space
1655 */
1656void dquot_release_reserved_space(struct inode *inode, qsize_t number)
1657{
1658 __dquot_free_space(inode, number, 1);
1659
1660} 1635}
1661EXPORT_SYMBOL(dquot_release_reserved_space); 1636EXPORT_SYMBOL(__dquot_free_space);
1662 1637
1663/* 1638/*
1664 * This operation can block, but only after everything is updated 1639 * This operation can block, but only after everything is updated
@@ -1840,9 +1815,7 @@ EXPORT_SYMBOL(dquot_commit_info);
1840const struct dquot_operations dquot_operations = { 1815const struct dquot_operations dquot_operations = {
1841 .initialize = dquot_initialize, 1816 .initialize = dquot_initialize,
1842 .drop = dquot_drop, 1817 .drop = dquot_drop,
1843 .alloc_space = dquot_alloc_space,
1844 .alloc_inode = dquot_alloc_inode, 1818 .alloc_inode = dquot_alloc_inode,
1845 .free_space = dquot_free_space,
1846 .free_inode = dquot_free_inode, 1819 .free_inode = dquot_free_inode,
1847 .transfer = dquot_transfer, 1820 .transfer = dquot_transfer,
1848 .write_dquot = dquot_commit, 1821 .write_dquot = dquot_commit,
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index 65c872761177..dc014f7def05 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -425,7 +425,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
425 425
426 journal_mark_dirty(th, s, sbh); 426 journal_mark_dirty(th, s, sbh);
427 if (for_unformatted) 427 if (for_unformatted)
428 vfs_dq_free_block_nodirty(inode, 1); 428 dquot_free_block_nodirty(inode, 1);
429} 429}
430 430
431void reiserfs_free_block(struct reiserfs_transaction_handle *th, 431void reiserfs_free_block(struct reiserfs_transaction_handle *th,
@@ -1049,7 +1049,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
1049 amount_needed, hint->inode->i_uid); 1049 amount_needed, hint->inode->i_uid);
1050#endif 1050#endif
1051 quota_ret = 1051 quota_ret =
1052 vfs_dq_alloc_block_nodirty(hint->inode, amount_needed); 1052 dquot_alloc_block_nodirty(hint->inode, amount_needed);
1053 if (quota_ret) /* Quota exceeded? */ 1053 if (quota_ret) /* Quota exceeded? */
1054 return QUOTA_EXCEEDED; 1054 return QUOTA_EXCEEDED;
1055 if (hint->preallocate && hint->prealloc_size) { 1055 if (hint->preallocate && hint->prealloc_size) {
@@ -1058,7 +1058,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
1058 "reiserquota: allocating (prealloc) %d blocks id=%u", 1058 "reiserquota: allocating (prealloc) %d blocks id=%u",
1059 hint->prealloc_size, hint->inode->i_uid); 1059 hint->prealloc_size, hint->inode->i_uid);
1060#endif 1060#endif
1061 quota_ret = vfs_dq_prealloc_block_nodirty(hint->inode, 1061 quota_ret = dquot_prealloc_block_nodirty(hint->inode,
1062 hint->prealloc_size); 1062 hint->prealloc_size);
1063 if (quota_ret) 1063 if (quota_ret)
1064 hint->preallocate = hint->prealloc_size = 0; 1064 hint->preallocate = hint->prealloc_size = 0;
@@ -1092,7 +1092,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
1092 hint->inode->i_uid); 1092 hint->inode->i_uid);
1093#endif 1093#endif
1094 /* Free not allocated blocks */ 1094 /* Free not allocated blocks */
1095 vfs_dq_free_block_nodirty(hint->inode, 1095 dquot_free_block_nodirty(hint->inode,
1096 amount_needed + hint->prealloc_size - 1096 amount_needed + hint->prealloc_size -
1097 nr_allocated); 1097 nr_allocated);
1098 } 1098 }
@@ -1125,7 +1125,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
1125 REISERFS_I(hint->inode)->i_prealloc_count, 1125 REISERFS_I(hint->inode)->i_prealloc_count,
1126 hint->inode->i_uid); 1126 hint->inode->i_uid);
1127#endif 1127#endif
1128 vfs_dq_free_block_nodirty(hint->inode, amount_needed + 1128 dquot_free_block_nodirty(hint->inode, amount_needed +
1129 hint->prealloc_size - nr_allocated - 1129 hint->prealloc_size - nr_allocated -
1130 REISERFS_I(hint->inode)-> 1130 REISERFS_I(hint->inode)->
1131 i_prealloc_count); 1131 i_prealloc_count);
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 5fa7118f04e1..313d39d639eb 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -1299,7 +1299,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
1299 "reiserquota delete_item(): freeing %u, id=%u type=%c", 1299 "reiserquota delete_item(): freeing %u, id=%u type=%c",
1300 quota_cut_bytes, inode->i_uid, head2type(&s_ih)); 1300 quota_cut_bytes, inode->i_uid, head2type(&s_ih));
1301#endif 1301#endif
1302 vfs_dq_free_space_nodirty(inode, quota_cut_bytes); 1302 dquot_free_space_nodirty(inode, quota_cut_bytes);
1303 1303
1304 /* Return deleted body length */ 1304 /* Return deleted body length */
1305 return ret_value; 1305 return ret_value;
@@ -1383,7 +1383,7 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
1383 quota_cut_bytes, inode->i_uid, 1383 quota_cut_bytes, inode->i_uid,
1384 key2type(key)); 1384 key2type(key));
1385#endif 1385#endif
1386 vfs_dq_free_space_nodirty(inode, 1386 dquot_free_space_nodirty(inode,
1387 quota_cut_bytes); 1387 quota_cut_bytes);
1388 } 1388 }
1389 break; 1389 break;
@@ -1733,7 +1733,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
1733 "reiserquota cut_from_item(): freeing %u id=%u type=%c", 1733 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
1734 quota_cut_bytes, inode->i_uid, '?'); 1734 quota_cut_bytes, inode->i_uid, '?');
1735#endif 1735#endif
1736 vfs_dq_free_space_nodirty(inode, quota_cut_bytes); 1736 dquot_free_space_nodirty(inode, quota_cut_bytes);
1737 return ret_value; 1737 return ret_value;
1738} 1738}
1739 1739
@@ -1968,9 +1968,10 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
1968 key2type(&(key->on_disk_key))); 1968 key2type(&(key->on_disk_key)));
1969#endif 1969#endif
1970 1970
1971 if (vfs_dq_alloc_space_nodirty(inode, pasted_size)) { 1971 retval = dquot_alloc_space_nodirty(inode, pasted_size);
1972 if (retval) {
1972 pathrelse(search_path); 1973 pathrelse(search_path);
1973 return -EDQUOT; 1974 return retval;
1974 } 1975 }
1975 init_tb_struct(th, &s_paste_balance, th->t_super, search_path, 1976 init_tb_struct(th, &s_paste_balance, th->t_super, search_path,
1976 pasted_size); 1977 pasted_size);
@@ -2024,7 +2025,7 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
2024 pasted_size, inode->i_uid, 2025 pasted_size, inode->i_uid,
2025 key2type(&(key->on_disk_key))); 2026 key2type(&(key->on_disk_key)));
2026#endif 2027#endif
2027 vfs_dq_free_space_nodirty(inode, pasted_size); 2028 dquot_free_space_nodirty(inode, pasted_size);
2028 return retval; 2029 return retval;
2029} 2030}
2030 2031
@@ -2062,9 +2063,10 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
2062#endif 2063#endif
2063 /* We can't dirty inode here. It would be immediately written but 2064 /* We can't dirty inode here. It would be immediately written but
2064 * appropriate stat item isn't inserted yet... */ 2065 * appropriate stat item isn't inserted yet... */
2065 if (vfs_dq_alloc_space_nodirty(inode, quota_bytes)) { 2066 retval = dquot_alloc_space_nodirty(inode, quota_bytes);
2067 if (retval) {
2066 pathrelse(path); 2068 pathrelse(path);
2067 return -EDQUOT; 2069 return retval;
2068 } 2070 }
2069 } 2071 }
2070 init_tb_struct(th, &s_ins_balance, th->t_super, path, 2072 init_tb_struct(th, &s_ins_balance, th->t_super, path,
@@ -2113,6 +2115,6 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
2113 quota_bytes, inode->i_uid, head2type(ih)); 2115 quota_bytes, inode->i_uid, head2type(ih));
2114#endif 2116#endif
2115 if (inode) 2117 if (inode)
2116 vfs_dq_free_space_nodirty(inode, quota_bytes); 2118 dquot_free_space_nodirty(inode, quota_bytes);
2117 return retval; 2119 return retval;
2118} 2120}
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index b4a7dd03bdb9..ea4a77e9d7f5 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -618,9 +618,7 @@ static int reiserfs_quota_on(struct super_block *, int, int, char *, int);
618static const struct dquot_operations reiserfs_quota_operations = { 618static const struct dquot_operations reiserfs_quota_operations = {
619 .initialize = dquot_initialize, 619 .initialize = dquot_initialize,
620 .drop = dquot_drop, 620 .drop = dquot_drop,
621 .alloc_space = dquot_alloc_space,
622 .alloc_inode = dquot_alloc_inode, 621 .alloc_inode = dquot_alloc_inode,
623 .free_space = dquot_free_space,
624 .free_inode = dquot_free_inode, 622 .free_inode = dquot_free_inode,
625 .transfer = dquot_transfer, 623 .transfer = dquot_transfer,
626 .write_dquot = reiserfs_write_dquot, 624 .write_dquot = reiserfs_write_dquot,
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)
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index 54c16ec95dff..5cfa4d85ccf2 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -85,7 +85,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
85 "bit already cleared for fragment %u", i); 85 "bit already cleared for fragment %u", i);
86 } 86 }
87 87
88 vfs_dq_free_block(inode, count); 88 dquot_free_block(inode, count);
89 89
90 90
91 fs32_add(sb, &ucg->cg_cs.cs_nffree, count); 91 fs32_add(sb, &ucg->cg_cs.cs_nffree, count);
@@ -195,7 +195,7 @@ do_more:
195 ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); 195 ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
196 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) 196 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
197 ufs_clusteracct (sb, ucpi, blkno, 1); 197 ufs_clusteracct (sb, ucpi, blkno, 1);
198 vfs_dq_free_block(inode, uspi->s_fpb); 198 dquot_free_block(inode, uspi->s_fpb);
199 199
200 fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); 200 fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1);
201 uspi->cs_total.cs_nbfree++; 201 uspi->cs_total.cs_nbfree++;
@@ -511,6 +511,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
511 struct ufs_cg_private_info * ucpi; 511 struct ufs_cg_private_info * ucpi;
512 struct ufs_cylinder_group * ucg; 512 struct ufs_cylinder_group * ucg;
513 unsigned cgno, fragno, fragoff, count, fragsize, i; 513 unsigned cgno, fragno, fragoff, count, fragsize, i;
514 int ret;
514 515
515 UFSD("ENTER, fragment %llu, oldcount %u, newcount %u\n", 516 UFSD("ENTER, fragment %llu, oldcount %u, newcount %u\n",
516 (unsigned long long)fragment, oldcount, newcount); 517 (unsigned long long)fragment, oldcount, newcount);
@@ -556,8 +557,9 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
556 fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); 557 fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1);
557 for (i = oldcount; i < newcount; i++) 558 for (i = oldcount; i < newcount; i++)
558 ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i); 559 ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i);
559 if (vfs_dq_alloc_block(inode, count)) { 560 ret = dquot_alloc_block(inode, count);
560 *err = -EDQUOT; 561 if (ret) {
562 *err = ret;
561 return 0; 563 return 0;
562 } 564 }
563 565
@@ -596,6 +598,7 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno,
596 struct ufs_cylinder_group * ucg; 598 struct ufs_cylinder_group * ucg;
597 unsigned oldcg, i, j, k, allocsize; 599 unsigned oldcg, i, j, k, allocsize;
598 u64 result; 600 u64 result;
601 int ret;
599 602
600 UFSD("ENTER, ino %lu, cgno %u, goal %llu, count %u\n", 603 UFSD("ENTER, ino %lu, cgno %u, goal %llu, count %u\n",
601 inode->i_ino, cgno, (unsigned long long)goal, count); 604 inode->i_ino, cgno, (unsigned long long)goal, count);
@@ -664,7 +667,7 @@ cg_found:
664 for (i = count; i < uspi->s_fpb; i++) 667 for (i = count; i < uspi->s_fpb; i++)
665 ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i); 668 ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i);
666 i = uspi->s_fpb - count; 669 i = uspi->s_fpb - count;
667 vfs_dq_free_block(inode, i); 670 dquot_free_block(inode, i);
668 671
669 fs32_add(sb, &ucg->cg_cs.cs_nffree, i); 672 fs32_add(sb, &ucg->cg_cs.cs_nffree, i);
670 uspi->cs_total.cs_nffree += i; 673 uspi->cs_total.cs_nffree += i;
@@ -676,8 +679,9 @@ cg_found:
676 result = ufs_bitmap_search (sb, ucpi, goal, allocsize); 679 result = ufs_bitmap_search (sb, ucpi, goal, allocsize);
677 if (result == INVBLOCK) 680 if (result == INVBLOCK)
678 return 0; 681 return 0;
679 if (vfs_dq_alloc_block(inode, count)) { 682 ret = dquot_alloc_block(inode, count);
680 *err = -EDQUOT; 683 if (ret) {
684 *err = ret;
681 return 0; 685 return 0;
682 } 686 }
683 for (i = 0; i < count; i++) 687 for (i = 0; i < count; i++)
@@ -714,6 +718,7 @@ static u64 ufs_alloccg_block(struct inode *inode,
714 struct ufs_super_block_first * usb1; 718 struct ufs_super_block_first * usb1;
715 struct ufs_cylinder_group * ucg; 719 struct ufs_cylinder_group * ucg;
716 u64 result, blkno; 720 u64 result, blkno;
721 int ret;
717 722
718 UFSD("ENTER, goal %llu\n", (unsigned long long)goal); 723 UFSD("ENTER, goal %llu\n", (unsigned long long)goal);
719 724
@@ -747,8 +752,9 @@ gotit:
747 ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); 752 ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
748 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) 753 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
749 ufs_clusteracct (sb, ucpi, blkno, -1); 754 ufs_clusteracct (sb, ucpi, blkno, -1);
750 if (vfs_dq_alloc_block(inode, uspi->s_fpb)) { 755 ret = dquot_alloc_block(inode, uspi->s_fpb);
751 *err = -EDQUOT; 756 if (ret) {
757 *err = ret;
752 return INVBLOCK; 758 return INVBLOCK;
753 } 759 }
754 760
diff --git a/include/linux/quota.h b/include/linux/quota.h
index edf34f2fe87d..1b14ad287fe3 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -297,9 +297,7 @@ struct quota_format_ops {
297struct dquot_operations { 297struct dquot_operations {
298 int (*initialize) (struct inode *, int); 298 int (*initialize) (struct inode *, int);
299 int (*drop) (struct inode *); 299 int (*drop) (struct inode *);
300 int (*alloc_space) (struct inode *, qsize_t, int);
301 int (*alloc_inode) (const struct inode *, qsize_t); 300 int (*alloc_inode) (const struct inode *, qsize_t);
302 int (*free_space) (struct inode *, qsize_t);
303 int (*free_inode) (const struct inode *, qsize_t); 301 int (*free_inode) (const struct inode *, qsize_t);
304 int (*transfer) (struct inode *, qid_t *, unsigned long); 302 int (*transfer) (struct inode *, qid_t *, unsigned long);
305 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */ 303 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
@@ -309,12 +307,6 @@ struct dquot_operations {
309 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */ 307 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
310 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */ 308 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */
311 int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */ 309 int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */
312 /* reserve quota for delayed block allocation */
313 int (*reserve_space) (struct inode *, qsize_t, int);
314 /* claim reserved quota for delayed alloc */
315 int (*claim_space) (struct inode *, qsize_t);
316 /* release rsved quota for delayed alloc */
317 void (*release_rsv) (struct inode *, qsize_t);
318 /* get reserved quota for delayed alloc, value returned is managed by 310 /* get reserved quota for delayed alloc, value returned is managed by
319 * quota code only */ 311 * quota code only */
320 qsize_t *(*get_reserved_space) (struct inode *); 312 qsize_t *(*get_reserved_space) (struct inode *);
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index e1cae204b5d9..47e85682e118 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -33,14 +33,13 @@ int dquot_scan_active(struct super_block *sb,
33struct dquot *dquot_alloc(struct super_block *sb, int type); 33struct dquot *dquot_alloc(struct super_block *sb, int type);
34void dquot_destroy(struct dquot *dquot); 34void dquot_destroy(struct dquot *dquot);
35 35
36int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 36int __dquot_alloc_space(struct inode *inode, qsize_t number,
37int dquot_alloc_inode(const struct inode *inode, qsize_t number); 37 int warn, int reserve);
38void __dquot_free_space(struct inode *inode, qsize_t number, int reserve);
38 39
39int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); 40int dquot_alloc_inode(const struct inode *inode, qsize_t number);
40int dquot_claim_space(struct inode *inode, qsize_t number);
41void dquot_release_reserved_space(struct inode *inode, qsize_t number);
42 41
43int dquot_free_space(struct inode *inode, qsize_t number); 42int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
44int dquot_free_inode(const struct inode *inode, qsize_t number); 43int dquot_free_inode(const struct inode *inode, qsize_t number);
45 44
46int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask); 45int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask);
@@ -149,60 +148,6 @@ static inline void vfs_dq_init(struct inode *inode)
149 inode->i_sb->dq_op->initialize(inode, -1); 148 inode->i_sb->dq_op->initialize(inode, -1);
150} 149}
151 150
152/* The following allocation/freeing/transfer functions *must* be called inside
153 * a transaction (deadlocks possible otherwise) */
154static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
155{
156 if (sb_any_quota_active(inode->i_sb)) {
157 /* Used space is updated in alloc_space() */
158 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
159 return 1;
160 }
161 else
162 inode_add_bytes(inode, nr);
163 return 0;
164}
165
166static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
167{
168 int ret;
169 if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr)))
170 mark_inode_dirty(inode);
171 return ret;
172}
173
174static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
175{
176 if (sb_any_quota_active(inode->i_sb)) {
177 /* Used space is updated in alloc_space() */
178 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
179 return 1;
180 }
181 else
182 inode_add_bytes(inode, nr);
183 return 0;
184}
185
186static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
187{
188 int ret;
189 if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
190 mark_inode_dirty(inode);
191 return ret;
192}
193
194static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
195{
196 if (sb_any_quota_active(inode->i_sb)) {
197 /* Used space is updated in alloc_space() */
198 if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
199 return 1;
200 }
201 else
202 inode_add_rsv_space(inode, nr);
203 return 0;
204}
205
206static inline int vfs_dq_alloc_inode(struct inode *inode) 151static inline int vfs_dq_alloc_inode(struct inode *inode)
207{ 152{
208 if (sb_any_quota_active(inode->i_sb)) { 153 if (sb_any_quota_active(inode->i_sb)) {
@@ -213,47 +158,6 @@ static inline int vfs_dq_alloc_inode(struct inode *inode)
213 return 0; 158 return 0;
214} 159}
215 160
216/*
217 * Convert in-memory reserved quotas to real consumed quotas
218 */
219static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
220{
221 if (sb_any_quota_active(inode->i_sb)) {
222 if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
223 return 1;
224 } else
225 inode_claim_rsv_space(inode, nr);
226
227 mark_inode_dirty(inode);
228 return 0;
229}
230
231/*
232 * Release reserved (in-memory) quotas
233 */
234static inline
235void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
236{
237 if (sb_any_quota_active(inode->i_sb))
238 inode->i_sb->dq_op->release_rsv(inode, nr);
239 else
240 inode_sub_rsv_space(inode, nr);
241}
242
243static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
244{
245 if (sb_any_quota_active(inode->i_sb))
246 inode->i_sb->dq_op->free_space(inode, nr);
247 else
248 inode_sub_bytes(inode, nr);
249}
250
251static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
252{
253 vfs_dq_free_space_nodirty(inode, nr);
254 mark_inode_dirty(inode);
255}
256
257static inline void vfs_dq_free_inode(struct inode *inode) 161static inline void vfs_dq_free_inode(struct inode *inode)
258{ 162{
259 if (sb_any_quota_active(inode->i_sb)) 163 if (sb_any_quota_active(inode->i_sb))
@@ -351,105 +255,109 @@ static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
351 return 0; 255 return 0;
352} 256}
353 257
354static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) 258static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
259 int warn, int reserve)
355{ 260{
356 inode_add_bytes(inode, nr); 261 if (!reserve)
262 inode_add_bytes(inode, number);
357 return 0; 263 return 0;
358} 264}
359 265
360static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) 266static inline void __dquot_free_space(struct inode *inode, qsize_t number,
267 int reserve)
361{ 268{
362 vfs_dq_prealloc_space_nodirty(inode, nr); 269 if (!reserve)
363 mark_inode_dirty(inode); 270 inode_sub_bytes(inode, number);
364 return 0;
365} 271}
366 272
367static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) 273static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
368{ 274{
369 inode_add_bytes(inode, nr); 275 inode_add_bytes(inode, number);
370 return 0; 276 return 0;
371} 277}
372 278
373static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) 279#endif /* CONFIG_QUOTA */
280
281static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
374{ 282{
375 vfs_dq_alloc_space_nodirty(inode, nr); 283 return __dquot_alloc_space(inode, nr, 1, 0);
376 mark_inode_dirty(inode);
377 return 0;
378} 284}
379 285
380static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) 286static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
381{ 287{
382 return 0; 288 int ret;
289
290 ret = dquot_alloc_space_nodirty(inode, nr);
291 if (!ret)
292 mark_inode_dirty(inode);
293 return ret;
383} 294}
384 295
385static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) 296static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
386{ 297{
387 return vfs_dq_alloc_space(inode, nr); 298 return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
388} 299}
389 300
390static inline 301static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
391int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
392{ 302{
393 return 0; 303 return dquot_alloc_space(inode, nr << inode->i_blkbits);
394} 304}
395 305
396static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 306static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
397{ 307{
398 inode_sub_bytes(inode, nr); 308 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0);
399} 309}
400 310
401static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) 311static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
402{ 312{
403 vfs_dq_free_space_nodirty(inode, nr); 313 int ret;
404 mark_inode_dirty(inode);
405}
406
407#endif /* CONFIG_QUOTA */
408 314
409static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) 315 ret = dquot_prealloc_block_nodirty(inode, nr);
410{ 316 if (!ret)
411 return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); 317 mark_inode_dirty(inode);
318 return ret;
412} 319}
413 320
414static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) 321static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
415{ 322{
416 return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); 323 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1);
417} 324}
418 325
419static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) 326static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
420{ 327{
421 return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); 328 int ret;
422}
423 329
424static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) 330 ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits);
425{ 331 if (!ret)
426 return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); 332 mark_inode_dirty(inode);
333 return ret;
427} 334}
428 335
429static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) 336static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr)
430{ 337{
431 return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); 338 __dquot_free_space(inode, nr, 0);
432} 339}
433 340
434static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) 341static inline void dquot_free_space(struct inode *inode, qsize_t nr)
435{ 342{
436 return vfs_dq_claim_space(inode, nr << inode->i_blkbits); 343 dquot_free_space_nodirty(inode, nr);
344 mark_inode_dirty(inode);
437} 345}
438 346
439static inline 347static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr)
440void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr)
441{ 348{
442 vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); 349 dquot_free_space_nodirty(inode, nr << inode->i_blkbits);
443} 350}
444 351
445static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) 352static inline void dquot_free_block(struct inode *inode, qsize_t nr)
446{ 353{
447 vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); 354 dquot_free_space(inode, nr << inode->i_blkbits);
448} 355}
449 356
450static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) 357static inline void dquot_release_reservation_block(struct inode *inode,
358 qsize_t nr)
451{ 359{
452 vfs_dq_free_space(inode, nr << inode->i_blkbits); 360 __dquot_free_space(inode, nr << inode->i_blkbits, 1);
453} 361}
454 362
455#endif /* _LINUX_QUOTAOPS_ */ 363#endif /* _LINUX_QUOTAOPS_ */