|
@@ -25,6 +25,7 @@
|
|
#include "ocfs2_ioctl.h"
|
|
#include "ocfs2_ioctl.h"
|
|
|
|
|
|
#include "alloc.h"
|
|
#include "alloc.h"
|
|
|
|
+#include "localalloc.h"
|
|
#include "aops.h"
|
|
#include "aops.h"
|
|
#include "dlmglue.h"
|
|
#include "dlmglue.h"
|
|
#include "extent_map.h"
|
|
#include "extent_map.h"
|
|
@@ -233,6 +234,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
|
|
struct ocfs2_refcount_tree *ref_tree = NULL;
|
|
struct ocfs2_refcount_tree *ref_tree = NULL;
|
|
u32 new_phys_cpos, new_len;
|
|
u32 new_phys_cpos, new_len;
|
|
u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
|
|
u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
|
|
|
|
+ int need_free = 0;
|
|
|
|
|
|
if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) {
|
|
if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) {
|
|
BUG_ON(!ocfs2_is_refcount_inode(inode));
|
|
BUG_ON(!ocfs2_is_refcount_inode(inode));
|
|
@@ -308,6 +310,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
|
|
if (!partial) {
|
|
if (!partial) {
|
|
context->range->me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE;
|
|
context->range->me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE;
|
|
ret = -ENOSPC;
|
|
ret = -ENOSPC;
|
|
|
|
+ need_free = 1;
|
|
goto out_commit;
|
|
goto out_commit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -332,6 +335,20 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
|
|
mlog_errno(ret);
|
|
mlog_errno(ret);
|
|
|
|
|
|
out_commit:
|
|
out_commit:
|
|
|
|
+ if (need_free && context->data_ac) {
|
|
|
|
+ struct ocfs2_alloc_context *data_ac = context->data_ac;
|
|
|
|
+
|
|
|
|
+ if (context->data_ac->ac_which == OCFS2_AC_USE_LOCAL)
|
|
|
|
+ ocfs2_free_local_alloc_bits(osb, handle, data_ac,
|
|
|
|
+ new_phys_cpos, new_len);
|
|
|
|
+ else
|
|
|
|
+ ocfs2_free_clusters(handle,
|
|
|
|
+ data_ac->ac_inode,
|
|
|
|
+ data_ac->ac_bh,
|
|
|
|
+ ocfs2_clusters_to_blocks(osb->sb, new_phys_cpos),
|
|
|
|
+ new_len);
|
|
|
|
+ }
|
|
|
|
+
|
|
ocfs2_commit_trans(osb, handle);
|
|
ocfs2_commit_trans(osb, handle);
|
|
|
|
|
|
out_unlock_mutex:
|
|
out_unlock_mutex:
|