From: Kent Overstreet Date: Wed, 9 Mar 2022 20:37:42 +0000 (-0500) Subject: bcachefs: Fix dio write path with loopback dio mode X-Git-Tag: v6.7-rc1~201^2~1071 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9552e19f6fff86d9907bb088f8b1eb786562f9d3;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Fix dio write path with loopback dio mode When the iov_iter is a bvec iter, it's possible the IO was submitted from a kthread that didn't have an mm to switch to. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 8231c29a75347..77a893260fd8b 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2110,7 +2110,7 @@ static long bch2_dio_write_loop(struct dio_write *dio) while (1) { iter_count = dio->iter.count; - if (kthread) + if (kthread && dio->mm) kthread_use_mm(dio->mm); BUG_ON(current->faults_disabled_mapping); current->faults_disabled_mapping = mapping; @@ -2120,7 +2120,7 @@ static long bch2_dio_write_loop(struct dio_write *dio) dropped_locks = fdm_dropped_locks(); current->faults_disabled_mapping = NULL; - if (kthread) + if (kthread && dio->mm) kthread_unuse_mm(dio->mm); /*