The patch titled Subject: ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent-v2 has been added to the -mm tree. Its filename is ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Larry Chen <lchen@xxxxxxxx> Subject: ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent-v2 rename ocfs2_lock_allocators_move_extents() to ocfs2_lock_meta_allocator_move_extents(), add some comments Link: http://lkml.kernel.org/r/20180902091455.23862-1-lchen@xxxxxxxx Signed-off-by: Larry Chen <lchen@xxxxxxxx> Cc: Mark Fasheh <mark@xxxxxxxxxx> Cc: Joel Becker <jlbec@xxxxxxxxxxxx> Cc: Junxiao Bi <junxiao.bi@xxxxxxxxxx> Cc: Joseph Qi <jiangqi903@xxxxxxxxx> Cc: Changwei Ge <ge.changwei@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN fs/ocfs2/move_extents.c~ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent fs/ocfs2/move_extents.c --- a/fs/ocfs2/move_extents.c~ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent +++ a/fs/ocfs2/move_extents.c @@ -162,7 +162,7 @@ out: * in some cases, we don't need to reserve clusters, just let data_ac * be NULL. */ -static int ocfs2_lock_allocators_move_extents(struct inode *inode, +static int ocfs2_lock_meta_allocator_move_extents(struct inode *inode, struct ocfs2_extent_tree *et, u32 clusters_to_move, u32 extents_to_split, @@ -250,10 +250,11 @@ static int ocfs2_defrag_extent(struct oc } } - ret = ocfs2_lock_allocators_move_extents(inode, &context->et, *len, 1, - &context->meta_ac, - &context->data_ac, - extra_blocks, &credits); + ret = ocfs2_lock_meta_allocator_move_extents(inode, &context->et, + *len, 1, + &context->meta_ac, + &context->data_ac, + extra_blocks, &credits); if (ret) { mlog_errno(ret); goto out; @@ -276,6 +277,15 @@ static int ocfs2_defrag_extent(struct oc } } + /* + * Make sure ocfs2_reserve_cluster is called after + * __ocfs2_flush_truncate_log, otherwise, dead lock may happen. + * + * If ocfs2_reserve_cluster is called + * before __ocfs2_flush_truncate_log, dead lock on global bitmap + * may happen. + * + */ ret = ocfs2_reserve_clusters(osb, *len, &context->data_ac); if (ret) { mlog_errno(ret); @@ -599,9 +609,10 @@ static int ocfs2_move_extent(struct ocfs } } - ret = ocfs2_lock_allocators_move_extents(inode, &context->et, len, 1, - &context->meta_ac, - NULL, extra_blocks, &credits); + ret = ocfs2_lock_meta_allocator_move_extents(inode, &context->et, + len, 1, + &context->meta_ac, + NULL, extra_blocks, &credits); if (ret) { mlog_errno(ret); goto out; _ Patches currently in -mm which might be from lchen@xxxxxxxx are fix-crash-on-ocfs2_duplicate_clusters_by_page.patch fix-crash-on-ocfs2_duplicate_clusters_by_page-v5.patch fix-dead-lock-caused-by-ocfs2_defrag_extent.patch ocfs2-fix-dead-lock-caused-by-ocfs2_defrag_extent.patch