]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Fix dio write path with loopback dio mode
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 9 Mar 2022 20:37:42 +0000 (15:37 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:27 +0000 (17:09 -0400)
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 <kent.overstreet@gmail.com>
fs/bcachefs/fs-io.c

index 8231c29a753470b553c3ff1b2dd6295755ead0c5..77a893260fd8bef98314734b10e3fa7d30788998 100644 (file)
@@ -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);
 
                /*