When the buffer passed to a read or write system call is memory mapped to the
same file, a page fault can occur in gfs2_fault. In that case, the task will
already be holding the inode glock, and trying to take it again will result in
a BUG in add_to_queue(). Fix that by recognizing the self-recursion case and
either skipping the lock taking (when the glock is held in a compatible way),
or failing the operation.
Likewise, gfs2_page_mkwrite can be called in similar situations, so
treat the locking there in the same way.
A future patch will handle this case more gracefully, along with addressing
more complex deadlock scenarios.
Reported-by: Jan Kara <jack@suse.cz> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>