diff options
author | Jan Kara <jack@suse.cz> | 2008-10-09 13:38:40 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:40:23 -0500 |
commit | a90714c150e3ce677c57a9dac3ab1ec342c75a95 (patch) | |
tree | 43e3e744d86122940c0db39ac1bfed0d434b3216 /fs/ocfs2/alloc.c | |
parent | 9e33d69f553aaf11377307e8d6f82deb3385e351 (diff) |
ocfs2: Add quota calls for allocation and freeing of inodes and space
Add quota calls for allocation and freeing of inodes and space, also update
estimates on number of needed credits for a transaction. Move out inode
allocation from ocfs2_mknod_locked() because vfs_dq_init() must be called
outside of a transaction.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 69d67ab069bb..84a7bd4db5da 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
30 | #include <linux/swap.h> | 30 | #include <linux/swap.h> |
31 | #include <linux/quotaops.h> | ||
31 | 32 | ||
32 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | 33 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC |
33 | #include <cluster/masklog.h> | 34 | #include <cluster/masklog.h> |
@@ -5322,7 +5323,7 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
5322 | } | 5323 | } |
5323 | } | 5324 | } |
5324 | 5325 | ||
5325 | handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS); | 5326 | handle = ocfs2_start_trans(osb, ocfs2_remove_extent_credits(osb->sb)); |
5326 | if (IS_ERR(handle)) { | 5327 | if (IS_ERR(handle)) { |
5327 | ret = PTR_ERR(handle); | 5328 | ret = PTR_ERR(handle); |
5328 | mlog_errno(ret); | 5329 | mlog_errno(ret); |
@@ -6552,6 +6553,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
6552 | goto bail; | 6553 | goto bail; |
6553 | } | 6554 | } |
6554 | 6555 | ||
6556 | vfs_dq_free_space_nodirty(inode, | ||
6557 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_del)); | ||
6555 | spin_lock(&OCFS2_I(inode)->ip_lock); | 6558 | spin_lock(&OCFS2_I(inode)->ip_lock); |
6556 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - | 6559 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - |
6557 | clusters_to_del; | 6560 | clusters_to_del; |
@@ -6860,6 +6863,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6860 | struct page **pages = NULL; | 6863 | struct page **pages = NULL; |
6861 | loff_t end = osb->s_clustersize; | 6864 | loff_t end = osb->s_clustersize; |
6862 | struct ocfs2_extent_tree et; | 6865 | struct ocfs2_extent_tree et; |
6866 | int did_quota = 0; | ||
6863 | 6867 | ||
6864 | has_data = i_size_read(inode) ? 1 : 0; | 6868 | has_data = i_size_read(inode) ? 1 : 0; |
6865 | 6869 | ||
@@ -6879,7 +6883,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6879 | } | 6883 | } |
6880 | } | 6884 | } |
6881 | 6885 | ||
6882 | handle = ocfs2_start_trans(osb, OCFS2_INLINE_TO_EXTENTS_CREDITS); | 6886 | handle = ocfs2_start_trans(osb, |
6887 | ocfs2_inline_to_extents_credits(osb->sb)); | ||
6883 | if (IS_ERR(handle)) { | 6888 | if (IS_ERR(handle)) { |
6884 | ret = PTR_ERR(handle); | 6889 | ret = PTR_ERR(handle); |
6885 | mlog_errno(ret); | 6890 | mlog_errno(ret); |
@@ -6898,6 +6903,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6898 | unsigned int page_end; | 6903 | unsigned int page_end; |
6899 | u64 phys; | 6904 | u64 phys; |
6900 | 6905 | ||
6906 | if (vfs_dq_alloc_space_nodirty(inode, | ||
6907 | ocfs2_clusters_to_bytes(osb->sb, 1))) { | ||
6908 | ret = -EDQUOT; | ||
6909 | goto out_commit; | ||
6910 | } | ||
6911 | did_quota = 1; | ||
6912 | |||
6901 | ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, | 6913 | ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, |
6902 | &num); | 6914 | &num); |
6903 | if (ret) { | 6915 | if (ret) { |
@@ -6971,6 +6983,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6971 | } | 6983 | } |
6972 | 6984 | ||
6973 | out_commit: | 6985 | out_commit: |
6986 | if (ret < 0 && did_quota) | ||
6987 | vfs_dq_free_space_nodirty(inode, | ||
6988 | ocfs2_clusters_to_bytes(osb->sb, 1)); | ||
6989 | |||
6974 | ocfs2_commit_trans(osb, handle); | 6990 | ocfs2_commit_trans(osb, handle); |
6975 | 6991 | ||
6976 | out_unlock: | 6992 | out_unlock: |