alex chen 28f5a8a7c0 ocfs2: should wait dio before inode lock in ocfs2_setattr()
we should wait dio requests to finish before inode lock in
ocfs2_setattr(), otherwise the following deadlock will happen:

process 1                  process 2                    process 3
truncate file 'A'          end_io of writing file 'A'   receiving the bast messages
ocfs2_setattr
 ocfs2_inode_lock_tracker
  ocfs2_inode_lock_full
 inode_dio_wait
  __inode_dio_wait
  -->waiting for all dio
  requests finish
                                                        dlm_proxy_ast_handler
                                                         dlm_do_local_bast
                                                          ocfs2_blocking_ast
                                                           ocfs2_generic_handle_bast
                                                            set OCFS2_LOCK_BLOCKED flag
                        dio_end_io
                         dio_bio_end_aio
                          dio_complete
                           ocfs2_dio_end_io
                            ocfs2_dio_end_io_write
                             ocfs2_inode_lock
                              __ocfs2_cluster_lock
                               ocfs2_wait_for_mask
                               -->waiting for OCFS2_LOCK_BLOCKED
                               flag to be cleared, that is waiting
                               for 'process 1' unlocking the inode lock
                           inode_dio_end
                           -->here dec the i_dio_count, but will never
                           be called, so a deadlock happened.

Link: http://lkml.kernel.org/r/59F81636.70508@huawei.com
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
Acked-by: Changwei Ge <ge.changwei@h3c.com>
Cc: Mark Fasheh <mfasheh@versity.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-15 18:21:01 -08:00
..
2017-09-06 17:27:24 -07:00
2017-09-06 17:27:24 -07:00
2017-09-06 17:27:24 -07:00
2017-02-27 18:43:46 -08:00
2017-09-06 17:27:24 -07:00
2011-07-25 14:58:15 -07:00
2017-07-06 16:24:30 -07:00
2017-09-06 17:27:24 -07:00
2015-12-29 17:45:49 -08:00
2017-09-06 17:27:24 -07:00
2016-12-12 18:55:06 -08:00
2017-07-06 16:24:30 -07:00
2017-09-06 17:27:24 -07:00
2017-09-06 17:27:24 -07:00
2011-03-31 11:26:23 -03:00
2017-09-06 17:27:24 -07:00
2012-05-29 23:28:40 -04:00
2017-09-06 17:27:24 -07:00
2016-05-12 15:52:50 -07:00