<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Jan Kara <<a href="mailto:jack@suse.cz">jack@suse.cz</a>> schrieb am Mo., 26. Juli 2021, 19:10:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri 23-07-21 22:58:40, Andreas Gruenbacher wrote:<br>
> Also disable page faults during direct I/O requests and implement the same kind<br>
> of retry logic as in the buffered I/O case.<br>
> <br>
> Direct I/O requests differ from buffered I/O requests in that they use<br>
> bio_iov_iter_get_pages for grabbing page references and faulting in pages<br>
> instead of triggering real page faults.  Those manual page faults can be<br>
> disabled with the iocb->noio flag.<br>
> <br>
> Signed-off-by: Andreas Gruenbacher <<a href="mailto:agruenba@redhat.com" target="_blank" rel="noreferrer">agruenba@redhat.com</a>><br>
> ---<br>
>  fs/gfs2/file.c | 34 +++++++++++++++++++++++++++++++++-<br>
>  1 file changed, 33 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c<br>
> index f66ac7f56f6d..7986f3be69d2 100644<br>
> --- a/fs/gfs2/file.c<br>
> +++ b/fs/gfs2/file.c<br>
> @@ -782,21 +782,41 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,<br>
>       struct file *file = iocb->ki_filp;<br>
>       struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);<br>
>       size_t count = iov_iter_count(to);<br>
> +     size_t written = 0;<br>
>       ssize_t ret;<br>
>  <br>
> +     /*<br>
> +      * In this function, we disable page faults when we're holding the<br>
> +      * inode glock while doing I/O.  If a page fault occurs, we drop the<br>
> +      * inode glock, fault in the pages manually, and then we retry.  Other<br>
> +      * than in gfs2_file_read_iter, iomap_dio_rw can trigger implicit as<br>
> +      * well as manual page faults, and we need to disable both kinds<br>
> +      * separately.<br>
> +      */<br>
> +<br>
>       if (!count)<br>
>               return 0; /* skip atime */<br>
>  <br>
>       gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, 0, gh);<br>
> +retry:<br>
>       ret = gfs2_glock_nq(gh);<br>
>       if (ret)<br>
>               goto out_uninit;<br>
>  <br>
> +     pagefault_disable();<br>
<br>
Is there any use in pagefault_disable() here? iomap_dio_rw() should not<br>
trigger any page faults anyway, should it?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It can trigger physical page faults when reading from holes.</div><div dir="auto"><br></div><div dir="auto">Andreas</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
                                                                Honza<br>
-- <br>
Jan Kara <<a href="mailto:jack@suse.com" target="_blank" rel="noreferrer">jack@suse.com</a>><br>
SUSE Labs, CR<br>
</blockquote></div></div></div>