25
25
#include "ocfs2_ioctl.h"
26
26
27
27
#include "alloc.h"
28
+ #include "localalloc.h"
28
29
#include "aops.h"
29
30
#include "dlmglue.h"
30
31
#include "extent_map.h"
@@ -233,6 +234,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
233
234
struct ocfs2_refcount_tree * ref_tree = NULL ;
234
235
u32 new_phys_cpos , new_len ;
235
236
u64 phys_blkno = ocfs2_clusters_to_blocks (inode -> i_sb , phys_cpos );
237
+ int need_free = 0 ;
236
238
237
239
if ((ext_flags & OCFS2_EXT_REFCOUNTED ) && * len ) {
238
240
BUG_ON (!ocfs2_is_refcount_inode (inode ));
@@ -308,6 +310,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
308
310
if (!partial ) {
309
311
context -> range -> me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE ;
310
312
ret = - ENOSPC ;
313
+ need_free = 1 ;
311
314
goto out_commit ;
312
315
}
313
316
}
@@ -332,6 +335,20 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
332
335
mlog_errno (ret );
333
336
334
337
out_commit :
338
+ if (need_free && context -> data_ac ) {
339
+ struct ocfs2_alloc_context * data_ac = context -> data_ac ;
340
+
341
+ if (context -> data_ac -> ac_which == OCFS2_AC_USE_LOCAL )
342
+ ocfs2_free_local_alloc_bits (osb , handle , data_ac ,
343
+ new_phys_cpos , new_len );
344
+ else
345
+ ocfs2_free_clusters (handle ,
346
+ data_ac -> ac_inode ,
347
+ data_ac -> ac_bh ,
348
+ ocfs2_clusters_to_blocks (osb -> sb , new_phys_cpos ),
349
+ new_len );
350
+ }
351
+
335
352
ocfs2_commit_trans (osb , handle );
336
353
337
354
out_unlock_mutex :
0 commit comments