aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-27 17:48:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-27 17:48:34 -0400
commit2c9e15a011c55ff96b2b8d2b126d1b9a96abba20 (patch)
tree6d9b27a07f88ad4509dcd86aa74a2cdecd0d5f4b /fs/ext4
parent805de022b100bcf796860fe88d7db4164066d1c3 (diff)
parentc16831b4cc9b0805adf8ca3001752a7ec10a17bf (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-quota-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-quota-2.6: (27 commits) ext2: Zero our b_size in ext2_quota_read() trivial: fix typos/grammar errors in fs/Kconfig quota: Coding style fixes quota: Remove superfluous inlines quota: Remove uppercase aliases for quota functions. nfsd: Use lowercase names of quota functions jfs: Use lowercase names of quota functions udf: Use lowercase names of quota functions ufs: Use lowercase names of quota functions reiserfs: Use lowercase names of quota functions ext4: Use lowercase names of quota functions ext3: Use lowercase names of quota functions ext2: Use lowercase names of quota functions ramfs: Remove quota call vfs: Use lowercase names of quota functions quota: Remove dqbuf_t and other cleanups quota: Remove NODQUOT macro quota: Make global quota locks cacheline aligned quota: Move quota files into separate directory ext4: quota reservation for delayed allocation ...
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/balloc.c2
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/ialloc.c12
-rw-r--r--fs/ext4/inode.c40
-rw-r--r--fs/ext4/mballoc.c46
-rw-r--r--fs/ext4/namei.c6
-rw-r--r--fs/ext4/super.c54
-rw-r--r--fs/ext4/xattr.c6
8 files changed, 86 insertions, 82 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index de9459b4cb94..38f40d55899c 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -536,7 +536,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
536 ext4_mb_free_blocks(handle, inode, block, count, 536 ext4_mb_free_blocks(handle, inode, block, count,
537 metadata, &dquot_freed_blocks); 537 metadata, &dquot_freed_blocks);
538 if (dquot_freed_blocks) 538 if (dquot_freed_blocks)
539 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks); 539 vfs_dq_free_block(inode, dquot_freed_blocks);
540 return; 540 return;
541} 541}
542 542
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b0c87dce66a3..6083bb38057b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -20,6 +20,7 @@
20#include <linux/blkdev.h> 20#include <linux/blkdev.h>
21#include <linux/magic.h> 21#include <linux/magic.h>
22#include <linux/jbd2.h> 22#include <linux/jbd2.h>
23#include <linux/quota.h>
23#include "ext4_i.h" 24#include "ext4_i.h"
24 25
25/* 26/*
@@ -1098,6 +1099,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
1098extern int ext4_block_truncate_page(handle_t *handle, 1099extern int ext4_block_truncate_page(handle_t *handle,
1099 struct address_space *mapping, loff_t from); 1100 struct address_space *mapping, loff_t from);
1100extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); 1101extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page);
1102extern qsize_t ext4_get_reserved_space(struct inode *inode);
1101 1103
1102/* ioctl.c */ 1104/* ioctl.c */
1103extern long ext4_ioctl(struct file *, unsigned int, unsigned long); 1105extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 2d2b3585ee91..fb51b40e3e8f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -220,10 +220,10 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
220 * Note: we must free any quota before locking the superblock, 220 * Note: we must free any quota before locking the superblock,
221 * as writing the quota to disk may need the lock as well. 221 * as writing the quota to disk may need the lock as well.
222 */ 222 */
223 DQUOT_INIT(inode); 223 vfs_dq_init(inode);
224 ext4_xattr_delete_inode(handle, inode); 224 ext4_xattr_delete_inode(handle, inode);
225 DQUOT_FREE_INODE(inode); 225 vfs_dq_free_inode(inode);
226 DQUOT_DROP(inode); 226 vfs_dq_drop(inode);
227 227
228 is_directory = S_ISDIR(inode->i_mode); 228 is_directory = S_ISDIR(inode->i_mode);
229 229
@@ -915,7 +915,7 @@ got:
915 ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; 915 ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
916 916
917 ret = inode; 917 ret = inode;
918 if (DQUOT_ALLOC_INODE(inode)) { 918 if (vfs_dq_alloc_inode(inode)) {
919 err = -EDQUOT; 919 err = -EDQUOT;
920 goto fail_drop; 920 goto fail_drop;
921 } 921 }
@@ -956,10 +956,10 @@ really_out:
956 return ret; 956 return ret;
957 957
958fail_free_drop: 958fail_free_drop:
959 DQUOT_FREE_INODE(inode); 959 vfs_dq_free_inode(inode);
960 960
961fail_drop: 961fail_drop:
962 DQUOT_DROP(inode); 962 vfs_dq_drop(inode);
963 inode->i_flags |= S_NOQUOTA; 963 inode->i_flags |= S_NOQUOTA;
964 inode->i_nlink = 0; 964 inode->i_nlink = 0;
965 unlock_new_inode(inode); 965 unlock_new_inode(inode);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c7fed5b18745..71d3ecd5db79 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -975,6 +975,17 @@ out:
975 return err; 975 return err;
976} 976}
977 977
978qsize_t ext4_get_reserved_space(struct inode *inode)
979{
980 unsigned long long total;
981
982 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
983 total = EXT4_I(inode)->i_reserved_data_blocks +
984 EXT4_I(inode)->i_reserved_meta_blocks;
985 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
986
987 return total;
988}
978/* 989/*
979 * Calculate the number of metadata blocks need to reserve 990 * Calculate the number of metadata blocks need to reserve
980 * to allocate @blocks for non extent file based file 991 * to allocate @blocks for non extent file based file
@@ -1036,8 +1047,14 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used)
1036 /* update per-inode reservations */ 1047 /* update per-inode reservations */
1037 BUG_ON(used > EXT4_I(inode)->i_reserved_data_blocks); 1048 BUG_ON(used > EXT4_I(inode)->i_reserved_data_blocks);
1038 EXT4_I(inode)->i_reserved_data_blocks -= used; 1049 EXT4_I(inode)->i_reserved_data_blocks -= used;
1039
1040 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 1050 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1051
1052 /*
1053 * free those over-booking quota for metadata blocks
1054 */
1055
1056 if (mdb_free)
1057 vfs_dq_release_reservation_block(inode, mdb_free);
1041} 1058}
1042 1059
1043/* 1060/*
@@ -1553,8 +1570,8 @@ static int ext4_journalled_write_end(struct file *file,
1553static int ext4_da_reserve_space(struct inode *inode, int nrblocks) 1570static int ext4_da_reserve_space(struct inode *inode, int nrblocks)
1554{ 1571{
1555 int retries = 0; 1572 int retries = 0;
1556 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 1573 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
1557 unsigned long md_needed, mdblocks, total = 0; 1574 unsigned long md_needed, mdblocks, total = 0;
1558 1575
1559 /* 1576 /*
1560 * recalculate the amount of metadata blocks to reserve 1577 * recalculate the amount of metadata blocks to reserve
@@ -1570,12 +1587,23 @@ repeat:
1570 md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks; 1587 md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks;
1571 total = md_needed + nrblocks; 1588 total = md_needed + nrblocks;
1572 1589
1590 /*
1591 * Make quota reservation here to prevent quota overflow
1592 * later. Real quota accounting is done at pages writeout
1593 * time.
1594 */
1595 if (vfs_dq_reserve_block(inode, total)) {
1596 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1597 return -EDQUOT;
1598 }
1599
1573 if (ext4_claim_free_blocks(sbi, total)) { 1600 if (ext4_claim_free_blocks(sbi, total)) {
1574 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 1601 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1575 if (ext4_should_retry_alloc(inode->i_sb, &retries)) { 1602 if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
1576 yield(); 1603 yield();
1577 goto repeat; 1604 goto repeat;
1578 } 1605 }
1606 vfs_dq_release_reservation_block(inode, total);
1579 return -ENOSPC; 1607 return -ENOSPC;
1580 } 1608 }
1581 EXT4_I(inode)->i_reserved_data_blocks += nrblocks; 1609 EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
@@ -1629,6 +1657,8 @@ static void ext4_da_release_space(struct inode *inode, int to_free)
1629 BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks); 1657 BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
1630 EXT4_I(inode)->i_reserved_meta_blocks = mdb; 1658 EXT4_I(inode)->i_reserved_meta_blocks = mdb;
1631 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 1659 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1660
1661 vfs_dq_release_reservation_block(inode, release);
1632} 1662}
1633 1663
1634static void ext4_da_page_release_reservation(struct page *page, 1664static void ext4_da_page_release_reservation(struct page *page,
@@ -4612,7 +4642,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4612 error = PTR_ERR(handle); 4642 error = PTR_ERR(handle);
4613 goto err_out; 4643 goto err_out;
4614 } 4644 }
4615 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; 4645 error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
4616 if (error) { 4646 if (error) {
4617 ext4_journal_stop(handle); 4647 ext4_journal_stop(handle);
4618 return error; 4648 return error;
@@ -4991,7 +5021,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
4991 * i_size has been changed by generic_commit_write() and we thus need 5021 * i_size has been changed by generic_commit_write() and we thus need
4992 * to include the updated inode in the current transaction. 5022 * to include the updated inode in the current transaction.
4993 * 5023 *
4994 * Also, DQUOT_ALLOC_SPACE() will always dirty the inode when blocks 5024 * Also, vfs_dq_alloc_block() will always dirty the inode when blocks
4995 * are allocated to the file. 5025 * are allocated to the file.
4996 * 5026 *
4997 * If the inode is marked synchronous, we don't honour that here - doing 5027 * 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 9f61e62f435f..b038188bd039 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3086,9 +3086,12 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
3086 if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED)) 3086 if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED))
3087 /* release all the reserved blocks if non delalloc */ 3087 /* release all the reserved blocks if non delalloc */
3088 percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks); 3088 percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks);
3089 else 3089 else {
3090 percpu_counter_sub(&sbi->s_dirtyblocks_counter, 3090 percpu_counter_sub(&sbi->s_dirtyblocks_counter,
3091 ac->ac_b_ex.fe_len); 3091 ac->ac_b_ex.fe_len);
3092 /* convert reserved quota blocks to real quota blocks */
3093 vfs_dq_claim_block(ac->ac_inode, ac->ac_b_ex.fe_len);
3094 }
3092 3095
3093 if (sbi->s_log_groups_per_flex) { 3096 if (sbi->s_log_groups_per_flex) {
3094 ext4_group_t flex_group = ext4_flex_group(sbi, 3097 ext4_group_t flex_group = ext4_flex_group(sbi,
@@ -4544,7 +4547,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4544 struct ext4_sb_info *sbi; 4547 struct ext4_sb_info *sbi;
4545 struct super_block *sb; 4548 struct super_block *sb;
4546 ext4_fsblk_t block = 0; 4549 ext4_fsblk_t block = 0;
4547 unsigned int inquota; 4550 unsigned int inquota = 0;
4548 unsigned int reserv_blks = 0; 4551 unsigned int reserv_blks = 0;
4549 4552
4550 sb = ar->inode->i_sb; 4553 sb = ar->inode->i_sb;
@@ -4562,9 +4565,17 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4562 (unsigned long long) ar->pleft, 4565 (unsigned long long) ar->pleft,
4563 (unsigned long long) ar->pright); 4566 (unsigned long long) ar->pright);
4564 4567
4565 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) { 4568 /*
4566 /* 4569 * For delayed allocation, we could skip the ENOSPC and
4567 * With delalloc we already reserved the blocks 4570 * EDQUOT check, as blocks and quotas have been already
4571 * reserved when data being copied into pagecache.
4572 */
4573 if (EXT4_I(ar->inode)->i_delalloc_reserved_flag)
4574 ar->flags |= EXT4_MB_DELALLOC_RESERVED;
4575 else {
4576 /* Without delayed allocation we need to verify
4577 * there is enough free blocks to do block allocation
4578 * and verify allocation doesn't exceed the quota limits.
4568 */ 4579 */
4569 while (ar->len && ext4_claim_free_blocks(sbi, ar->len)) { 4580 while (ar->len && ext4_claim_free_blocks(sbi, ar->len)) {
4570 /* let others to free the space */ 4581 /* let others to free the space */
@@ -4576,19 +4587,16 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4576 return 0; 4587 return 0;
4577 } 4588 }
4578 reserv_blks = ar->len; 4589 reserv_blks = ar->len;
4590 while (ar->len && vfs_dq_alloc_block(ar->inode, ar->len)) {
4591 ar->flags |= EXT4_MB_HINT_NOPREALLOC;
4592 ar->len--;
4593 }
4594 inquota = ar->len;
4595 if (ar->len == 0) {
4596 *errp = -EDQUOT;
4597 goto out3;
4598 }
4579 } 4599 }
4580 while (ar->len && DQUOT_ALLOC_BLOCK(ar->inode, ar->len)) {
4581 ar->flags |= EXT4_MB_HINT_NOPREALLOC;
4582 ar->len--;
4583 }
4584 if (ar->len == 0) {
4585 *errp = -EDQUOT;
4586 goto out3;
4587 }
4588 inquota = ar->len;
4589
4590 if (EXT4_I(ar->inode)->i_delalloc_reserved_flag)
4591 ar->flags |= EXT4_MB_DELALLOC_RESERVED;
4592 4600
4593 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); 4601 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
4594 if (!ac) { 4602 if (!ac) {
@@ -4654,8 +4662,8 @@ repeat:
4654out2: 4662out2:
4655 kmem_cache_free(ext4_ac_cachep, ac); 4663 kmem_cache_free(ext4_ac_cachep, ac);
4656out1: 4664out1:
4657 if (ar->len < inquota) 4665 if (inquota && ar->len < inquota)
4658 DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); 4666 vfs_dq_free_block(ar->inode, inquota - ar->len);
4659out3: 4667out3:
4660 if (!ar->len) { 4668 if (!ar->len) {
4661 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) 4669 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index ba702bd7910d..83410244d3ee 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2092,7 +2092,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
2092 2092
2093 /* Initialize quotas before so that eventual writes go in 2093 /* Initialize quotas before so that eventual writes go in
2094 * separate transaction */ 2094 * separate transaction */
2095 DQUOT_INIT(dentry->d_inode); 2095 vfs_dq_init(dentry->d_inode);
2096 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2096 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2097 if (IS_ERR(handle)) 2097 if (IS_ERR(handle))
2098 return PTR_ERR(handle); 2098 return PTR_ERR(handle);
@@ -2151,7 +2151,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
2151 2151
2152 /* Initialize quotas before so that eventual writes go 2152 /* Initialize quotas before so that eventual writes go
2153 * in separate transaction */ 2153 * in separate transaction */
2154 DQUOT_INIT(dentry->d_inode); 2154 vfs_dq_init(dentry->d_inode);
2155 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2155 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2156 if (IS_ERR(handle)) 2156 if (IS_ERR(handle))
2157 return PTR_ERR(handle); 2157 return PTR_ERR(handle);
@@ -2318,7 +2318,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2318 /* Initialize quotas before so that eventual writes go 2318 /* Initialize quotas before so that eventual writes go
2319 * in separate transaction */ 2319 * in separate transaction */
2320 if (new_dentry->d_inode) 2320 if (new_dentry->d_inode)
2321 DQUOT_INIT(new_dentry->d_inode); 2321 vfs_dq_init(new_dentry->d_inode);
2322 handle = ext4_journal_start(old_dir, 2 * 2322 handle = ext4_journal_start(old_dir, 2 *
2323 EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + 2323 EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) +
2324 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); 2324 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 39d1993cfa13..f7371a6a923d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -926,8 +926,6 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_
926#define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group") 926#define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group")
927#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) 927#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
928 928
929static int ext4_dquot_initialize(struct inode *inode, int type);
930static int ext4_dquot_drop(struct inode *inode);
931static int ext4_write_dquot(struct dquot *dquot); 929static int ext4_write_dquot(struct dquot *dquot);
932static int ext4_acquire_dquot(struct dquot *dquot); 930static int ext4_acquire_dquot(struct dquot *dquot);
933static int ext4_release_dquot(struct dquot *dquot); 931static int ext4_release_dquot(struct dquot *dquot);
@@ -942,9 +940,13 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
942 const char *data, size_t len, loff_t off); 940 const char *data, size_t len, loff_t off);
943 941
944static struct dquot_operations ext4_quota_operations = { 942static struct dquot_operations ext4_quota_operations = {
945 .initialize = ext4_dquot_initialize, 943 .initialize = dquot_initialize,
946 .drop = ext4_dquot_drop, 944 .drop = dquot_drop,
947 .alloc_space = dquot_alloc_space, 945 .alloc_space = dquot_alloc_space,
946 .reserve_space = dquot_reserve_space,
947 .claim_space = dquot_claim_space,
948 .release_rsv = dquot_release_reserved_space,
949 .get_reserved_space = ext4_get_reserved_space,
948 .alloc_inode = dquot_alloc_inode, 950 .alloc_inode = dquot_alloc_inode,
949 .free_space = dquot_free_space, 951 .free_space = dquot_free_space,
950 .free_inode = dquot_free_inode, 952 .free_inode = dquot_free_inode,
@@ -1802,7 +1804,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
1802 } 1804 }
1803 1805
1804 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); 1806 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
1805 DQUOT_INIT(inode); 1807 vfs_dq_init(inode);
1806 if (inode->i_nlink) { 1808 if (inode->i_nlink) {
1807 printk(KERN_DEBUG 1809 printk(KERN_DEBUG
1808 "%s: truncating inode %lu to %lld bytes\n", 1810 "%s: truncating inode %lu to %lld bytes\n",
@@ -3367,8 +3369,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
3367 * is locked for write. Otherwise the are possible deadlocks: 3369 * is locked for write. Otherwise the are possible deadlocks:
3368 * Process 1 Process 2 3370 * Process 1 Process 2
3369 * ext4_create() quota_sync() 3371 * ext4_create() quota_sync()
3370 * jbd2_journal_start() write_dquot() 3372 * jbd2_journal_start() write_dquot()
3371 * DQUOT_INIT() down(dqio_mutex) 3373 * vfs_dq_init() down(dqio_mutex)
3372 * down(dqio_mutex) jbd2_journal_start() 3374 * down(dqio_mutex) jbd2_journal_start()
3373 * 3375 *
3374 */ 3376 */
@@ -3380,44 +3382,6 @@ static inline struct inode *dquot_to_inode(struct dquot *dquot)
3380 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; 3382 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
3381} 3383}
3382 3384
3383static int ext4_dquot_initialize(struct inode *inode, int type)
3384{
3385 handle_t *handle;
3386 int ret, err;
3387
3388 /* We may create quota structure so we need to reserve enough blocks */
3389 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_INIT_BLOCKS(inode->i_sb));
3390 if (IS_ERR(handle))
3391 return PTR_ERR(handle);
3392 ret = dquot_initialize(inode, type);
3393 err = ext4_journal_stop(handle);
3394 if (!ret)
3395 ret = err;
3396 return ret;
3397}
3398
3399static int ext4_dquot_drop(struct inode *inode)
3400{
3401 handle_t *handle;
3402 int ret, err;
3403
3404 /* We may delete quota structure so we need to reserve enough blocks */
3405 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_DEL_BLOCKS(inode->i_sb));
3406 if (IS_ERR(handle)) {
3407 /*
3408 * We call dquot_drop() anyway to at least release references
3409 * to quota structures so that umount does not hang.
3410 */
3411 dquot_drop(inode);
3412 return PTR_ERR(handle);
3413 }
3414 ret = dquot_drop(inode);
3415 err = ext4_journal_stop(handle);
3416 if (!ret)
3417 ret = err;
3418 return ret;
3419}
3420
3421static int ext4_write_dquot(struct dquot *dquot) 3385static int ext4_write_dquot(struct dquot *dquot)
3422{ 3386{
3423 int ret, err; 3387 int ret, err;
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 157ce6589c54..62b31c246994 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -490,7 +490,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
490 error = ext4_handle_dirty_metadata(handle, inode, bh); 490 error = ext4_handle_dirty_metadata(handle, inode, bh);
491 if (IS_SYNC(inode)) 491 if (IS_SYNC(inode))
492 ext4_handle_sync(handle); 492 ext4_handle_sync(handle);
493 DQUOT_FREE_BLOCK(inode, 1); 493 vfs_dq_free_block(inode, 1);
494 ea_bdebug(bh, "refcount now=%d; releasing", 494 ea_bdebug(bh, "refcount now=%d; releasing",
495 le32_to_cpu(BHDR(bh)->h_refcount)); 495 le32_to_cpu(BHDR(bh)->h_refcount));
496 if (ce) 496 if (ce)
@@ -784,7 +784,7 @@ inserted:
784 /* The old block is released after updating 784 /* The old block is released after updating
785 the inode. */ 785 the inode. */
786 error = -EDQUOT; 786 error = -EDQUOT;
787 if (DQUOT_ALLOC_BLOCK(inode, 1)) 787 if (vfs_dq_alloc_block(inode, 1))
788 goto cleanup; 788 goto cleanup;
789 error = ext4_journal_get_write_access(handle, 789 error = ext4_journal_get_write_access(handle,
790 new_bh); 790 new_bh);
@@ -860,7 +860,7 @@ cleanup:
860 return error; 860 return error;
861 861
862cleanup_dquot: 862cleanup_dquot:
863 DQUOT_FREE_BLOCK(inode, 1); 863 vfs_dq_free_block(inode, 1);
864 goto cleanup; 864 goto cleanup;
865 865
866bad_block: 866bad_block: