diff options
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 77 |
1 files changed, 3 insertions, 74 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 592fae5007d1..e4984e259cb6 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -565,7 +565,6 @@ static inline int ocfs2_et_sanity_check(struct ocfs2_extent_tree *et) | |||
565 | return ret; | 565 | return ret; |
566 | } | 566 | } |
567 | 567 | ||
568 | static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); | ||
569 | static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, | 568 | static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, |
570 | struct ocfs2_extent_block *eb); | 569 | struct ocfs2_extent_block *eb); |
571 | static void ocfs2_adjust_rightmost_records(handle_t *handle, | 570 | static void ocfs2_adjust_rightmost_records(handle_t *handle, |
@@ -5858,6 +5857,7 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
5858 | 5857 | ||
5859 | ocfs2_journal_dirty(handle, tl_bh); | 5858 | ocfs2_journal_dirty(handle, tl_bh); |
5860 | 5859 | ||
5860 | osb->truncated_clusters += num_clusters; | ||
5861 | bail: | 5861 | bail: |
5862 | mlog_exit(status); | 5862 | mlog_exit(status); |
5863 | return status; | 5863 | return status; |
@@ -5929,6 +5929,8 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
5929 | i--; | 5929 | i--; |
5930 | } | 5930 | } |
5931 | 5931 | ||
5932 | osb->truncated_clusters = 0; | ||
5933 | |||
5932 | bail: | 5934 | bail: |
5933 | mlog_exit(status); | 5935 | mlog_exit(status); |
5934 | return status; | 5936 | return status; |
@@ -7139,64 +7141,6 @@ bail: | |||
7139 | } | 7141 | } |
7140 | 7142 | ||
7141 | /* | 7143 | /* |
7142 | * Expects the inode to already be locked. | ||
7143 | */ | ||
7144 | int ocfs2_prepare_truncate(struct ocfs2_super *osb, | ||
7145 | struct inode *inode, | ||
7146 | struct buffer_head *fe_bh, | ||
7147 | struct ocfs2_truncate_context **tc) | ||
7148 | { | ||
7149 | int status; | ||
7150 | unsigned int new_i_clusters; | ||
7151 | struct ocfs2_dinode *fe; | ||
7152 | struct ocfs2_extent_block *eb; | ||
7153 | struct buffer_head *last_eb_bh = NULL; | ||
7154 | |||
7155 | mlog_entry_void(); | ||
7156 | |||
7157 | *tc = NULL; | ||
7158 | |||
7159 | new_i_clusters = ocfs2_clusters_for_bytes(osb->sb, | ||
7160 | i_size_read(inode)); | ||
7161 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | ||
7162 | |||
7163 | mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size =" | ||
7164 | "%llu\n", le32_to_cpu(fe->i_clusters), new_i_clusters, | ||
7165 | (unsigned long long)le64_to_cpu(fe->i_size)); | ||
7166 | |||
7167 | *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL); | ||
7168 | if (!(*tc)) { | ||
7169 | status = -ENOMEM; | ||
7170 | mlog_errno(status); | ||
7171 | goto bail; | ||
7172 | } | ||
7173 | ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); | ||
7174 | |||
7175 | if (fe->id2.i_list.l_tree_depth) { | ||
7176 | status = ocfs2_read_extent_block(INODE_CACHE(inode), | ||
7177 | le64_to_cpu(fe->i_last_eb_blk), | ||
7178 | &last_eb_bh); | ||
7179 | if (status < 0) { | ||
7180 | mlog_errno(status); | ||
7181 | goto bail; | ||
7182 | } | ||
7183 | eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; | ||
7184 | } | ||
7185 | |||
7186 | (*tc)->tc_last_eb_bh = last_eb_bh; | ||
7187 | |||
7188 | status = 0; | ||
7189 | bail: | ||
7190 | if (status < 0) { | ||
7191 | if (*tc) | ||
7192 | ocfs2_free_truncate_context(*tc); | ||
7193 | *tc = NULL; | ||
7194 | } | ||
7195 | mlog_exit_void(); | ||
7196 | return status; | ||
7197 | } | ||
7198 | |||
7199 | /* | ||
7200 | * 'start' is inclusive, 'end' is not. | 7144 | * 'start' is inclusive, 'end' is not. |
7201 | */ | 7145 | */ |
7202 | int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, | 7146 | int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, |
@@ -7270,18 +7214,3 @@ out_commit: | |||
7270 | out: | 7214 | out: |
7271 | return ret; | 7215 | return ret; |
7272 | } | 7216 | } |
7273 | |||
7274 | static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc) | ||
7275 | { | ||
7276 | /* | ||
7277 | * The caller is responsible for completing deallocation | ||
7278 | * before freeing the context. | ||
7279 | */ | ||
7280 | if (tc->tc_dealloc.c_first_suballocator != NULL) | ||
7281 | mlog(ML_NOTICE, | ||
7282 | "Truncate completion has non-empty dealloc context\n"); | ||
7283 | |||
7284 | brelse(tc->tc_last_eb_bh); | ||
7285 | |||
7286 | kfree(tc); | ||
7287 | } | ||