diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-03-03 09:05:00 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:28 -0500 |
commit | 5dd4056db84387975140ff2568eaa0406f07985e (patch) | |
tree | 03c26d7f6e3367b167bfeeb1a01654c6619573f4 /fs/ocfs2 | |
parent | 49792c806d0bfd53afc789dcdf50dc9bed2c5b83 (diff) |
dquot: cleanup space allocation / freeing routines
Get rid of the alloc_space, free_space, reserve_space, claim_space and
release_rsv dquot operations - they are always called from the filesystem
and if a filesystem really needs their own (which none currently does)
it can just call into it's own routine directly.
Move shared logic into the common __dquot_alloc_space,
dquot_claim_space_nodirty and __dquot_free_space low-level methods,
and rationalize the wrappers around it to move as much as possible
code into the common block for CONFIG_QUOTA vs not. Also rename
all these helpers to be named dquot_* instead of vfs_dq_*.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/alloc.c | 13 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 37 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 9 | ||||
-rw-r--r-- | fs/ocfs2/quota_global.c | 2 |
6 files changed, 37 insertions, 46 deletions
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 | ||
7381 | out_commit: | 7380 | out_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; |
1810 | out_quota: | 1811 | out_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)); |
1814 | out_commit: | 1815 | out_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 | ||
3179 | out_commit: | 3177 | out_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; |
3255 | bail: | 3252 | bail: |
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 | ||
3984 | out_commit: | 3980 | out_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 | ||
4230 | out_commit: | 4225 | out_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 | ||
631 | restarted_transaction: | 631 | restarted_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 | ||
711 | leave: | 710 | leave: |
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); |
1789 | bail: | 1788 | bail: |
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) | |||
853 | const struct dquot_operations ocfs2_quota_operations = { | 853 | const 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, |