aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 460c0cedab3a..7dabbc31060e 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6106,6 +6106,43 @@ void ocfs2_schedule_truncate_log_flush(struct ocfs2_super *osb,
6106 } 6106 }
6107} 6107}
6108 6108
6109/*
6110 * Try to flush truncate logs if we can free enough clusters from it.
6111 * As for return value, "< 0" means error, "0" no space and "1" means
6112 * we have freed enough spaces and let the caller try to allocate again.
6113 */
6114int ocfs2_try_to_free_truncate_log(struct ocfs2_super *osb,
6115 unsigned int needed)
6116{
6117 tid_t target;
6118 int ret = 0;
6119 unsigned int truncated_clusters;
6120
6121 inode_lock(osb->osb_tl_inode);
6122 truncated_clusters = osb->truncated_clusters;
6123 inode_unlock(osb->osb_tl_inode);
6124
6125 /*
6126 * Check whether we can succeed in allocating if we free
6127 * the truncate log.
6128 */
6129 if (truncated_clusters < needed)
6130 goto out;
6131
6132 ret = ocfs2_flush_truncate_log(osb);
6133 if (ret) {
6134 mlog_errno(ret);
6135 goto out;
6136 }
6137
6138 if (jbd2_journal_start_commit(osb->journal->j_journal, &target)) {
6139 jbd2_log_wait_commit(osb->journal->j_journal, target);
6140 ret = 1;
6141 }
6142out:
6143 return ret;
6144}
6145
6109static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, 6146static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
6110 int slot_num, 6147 int slot_num,
6111 struct inode **tl_inode, 6148 struct inode **tl_inode,