diff options
author | Mark Fasheh <mfasheh@suse.com> | 2008-11-12 18:16:38 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:34:19 -0500 |
commit | fecc01126d7a244b7e9b563c80663ffdca35343b (patch) | |
tree | dbc9144a0f4b6e6997928b2fa2ddeb483f8fd2d7 /fs/ocfs2/alloc.c | |
parent | 85db90e77806d48a19fda77dabe8897d369a1710 (diff) |
ocfs2: turn __ocfs2_remove_inode_range() into ocfs2_remove_btree_range()
This patch genericizes the high level handling of extent removal.
ocfs2_remove_btree_range() is nearly identical to
__ocfs2_remove_inode_range(), except that extent tree operations have been
used where necessary. We update ocfs2_remove_inode_range() to use the
generic helper. Now extent tree based structures have an easy way to
truncate ranges.
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Acked-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 4614614084dd..5592a2f6335b 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -5255,6 +5255,78 @@ out: | |||
5255 | return ret; | 5255 | return ret; |
5256 | } | 5256 | } |
5257 | 5257 | ||
5258 | int ocfs2_remove_btree_range(struct inode *inode, | ||
5259 | struct ocfs2_extent_tree *et, | ||
5260 | u32 cpos, u32 phys_cpos, u32 len, | ||
5261 | struct ocfs2_cached_dealloc_ctxt *dealloc) | ||
5262 | { | ||
5263 | int ret; | ||
5264 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | ||
5265 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
5266 | struct inode *tl_inode = osb->osb_tl_inode; | ||
5267 | handle_t *handle; | ||
5268 | struct ocfs2_alloc_context *meta_ac = NULL; | ||
5269 | |||
5270 | ret = ocfs2_lock_allocators(inode, et, 0, 1, NULL, &meta_ac); | ||
5271 | if (ret) { | ||
5272 | mlog_errno(ret); | ||
5273 | return ret; | ||
5274 | } | ||
5275 | |||
5276 | mutex_lock(&tl_inode->i_mutex); | ||
5277 | |||
5278 | if (ocfs2_truncate_log_needs_flush(osb)) { | ||
5279 | ret = __ocfs2_flush_truncate_log(osb); | ||
5280 | if (ret < 0) { | ||
5281 | mlog_errno(ret); | ||
5282 | goto out; | ||
5283 | } | ||
5284 | } | ||
5285 | |||
5286 | handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS); | ||
5287 | if (IS_ERR(handle)) { | ||
5288 | ret = PTR_ERR(handle); | ||
5289 | mlog_errno(ret); | ||
5290 | goto out; | ||
5291 | } | ||
5292 | |||
5293 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | ||
5294 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
5295 | if (ret) { | ||
5296 | mlog_errno(ret); | ||
5297 | goto out; | ||
5298 | } | ||
5299 | |||
5300 | ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac, | ||
5301 | dealloc); | ||
5302 | if (ret) { | ||
5303 | mlog_errno(ret); | ||
5304 | goto out_commit; | ||
5305 | } | ||
5306 | |||
5307 | ocfs2_et_update_clusters(inode, et, -len); | ||
5308 | |||
5309 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); | ||
5310 | if (ret) { | ||
5311 | mlog_errno(ret); | ||
5312 | goto out_commit; | ||
5313 | } | ||
5314 | |||
5315 | ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len); | ||
5316 | if (ret) | ||
5317 | mlog_errno(ret); | ||
5318 | |||
5319 | out_commit: | ||
5320 | ocfs2_commit_trans(osb, handle); | ||
5321 | out: | ||
5322 | mutex_unlock(&tl_inode->i_mutex); | ||
5323 | |||
5324 | if (meta_ac) | ||
5325 | ocfs2_free_alloc_context(meta_ac); | ||
5326 | |||
5327 | return ret; | ||
5328 | } | ||
5329 | |||
5258 | int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) | 5330 | int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) |
5259 | { | 5331 | { |
5260 | struct buffer_head *tl_bh = osb->osb_tl_bh; | 5332 | struct buffer_head *tl_bh = osb->osb_tl_bh; |