Re: [RFC 9/9] gfs2: Fix mmap + page fault deadlocks (part 2)

From: Linus Torvalds
Date: Tue Jun 01 2021 - 01:48:04 EST


On Mon, May 31, 2021 at 7:02 AM Andreas Gruenbacher <agruenba@xxxxxxxxxx> wrote:
>
> @@ -807,13 +824,20 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
> [...]
> ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL, 0);
> gfs2_glock_dq(gh);
> + if (unlikely(current_needs_retry())) {
> + set_current_needs_retry(false);
> + if (ret == -EFAULT &&
> + !iov_iter_fault_in_writeable(to, PAGE_SIZE))
> + goto retry;
> + }

Hmm. I haven't walked through this all, but is that "ret == -EFAULT"
test the right thing to do?

Can iomap_dio_rw() not instead just return a partial success if it hit
a missing page half-way?

Shouldn't you retry for that case too?

Linus