bcachefs: Deadlock prevention for ei_pagecache_lock
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 11 Nov 2020 17:33:12 +0000 (12:33 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:46 +0000 (17:08 -0400)
commiteb8e6e9ccbb4ba37c04a7cff032975b4df7d63c7
tree946041b0c3ce44e48e4968840527b11e2d1c25d8
parent6d9378f3dcd7b91effdc4ffe1da1a2e8987e9f1e
bcachefs: Deadlock prevention for ei_pagecache_lock

In the dio write path, when get_user_pages() invokes the fault handler
we have a recursive locking situation - we have to handle the lock
ordering ourselves or we have a deadlock: this patch addresses that by
checking for locking ordering violations and doing the unlock/relock
dance if necessary.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io.c
fs/bcachefs/fs.c
fs/bcachefs/fs.h