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>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/quotaops.h>
|
||||
|
||||
#define MLOG_MASK_PREFIX ML_DISK_ALLOC
|
||||
#include <cluster/masklog.h>
|
||||
@@ -5322,7 +5323,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
|
||||
}
|
||||
}
|
||||
|
||||
handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS);
|
||||
handle = ocfs2_start_trans(osb, ocfs2_remove_extent_credits(osb->sb));
|
||||
if (IS_ERR(handle)) {
|
||||
ret = PTR_ERR(handle);
|
||||
mlog_errno(ret);
|
||||
@@ -6552,6 +6553,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
|
||||
goto bail;
|
||||
}
|
||||
|
||||
vfs_dq_free_space_nodirty(inode,
|
||||
ocfs2_clusters_to_bytes(osb->sb, clusters_to_del));
|
||||
spin_lock(&OCFS2_I(inode)->ip_lock);
|
||||
OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) -
|
||||
clusters_to_del;
|
||||
@@ -6860,6 +6863,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
|
||||
struct page **pages = NULL;
|
||||
loff_t end = osb->s_clustersize;
|
||||
struct ocfs2_extent_tree et;
|
||||
int did_quota = 0;
|
||||
|
||||
has_data = i_size_read(inode) ? 1 : 0;
|
||||
|
||||
@@ -6879,7 +6883,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
|
||||
}
|
||||
}
|
||||
|
||||
handle = ocfs2_start_trans(osb, OCFS2_INLINE_TO_EXTENTS_CREDITS);
|
||||
handle = ocfs2_start_trans(osb,
|
||||
ocfs2_inline_to_extents_credits(osb->sb));
|
||||
if (IS_ERR(handle)) {
|
||||
ret = PTR_ERR(handle);
|
||||
mlog_errno(ret);
|
||||
@@ -6898,6 +6903,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
|
||||
unsigned int page_end;
|
||||
u64 phys;
|
||||
|
||||
if (vfs_dq_alloc_space_nodirty(inode,
|
||||
ocfs2_clusters_to_bytes(osb->sb, 1))) {
|
||||
ret = -EDQUOT;
|
||||
goto out_commit;
|
||||
}
|
||||
did_quota = 1;
|
||||
|
||||
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
|
||||
&num);
|
||||
if (ret) {
|
||||
@@ -6971,6 +6983,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
|
||||
}
|
||||
|
||||
out_commit:
|
||||
if (ret < 0 && did_quota)
|
||||
vfs_dq_free_space_nodirty(inode,
|
||||
ocfs2_clusters_to_bytes(osb->sb, 1));
|
||||
|
||||
ocfs2_commit_trans(osb, handle);
|
||||
|
||||
out_unlock:
|
||||
|
Reference in New Issue
Block a user