<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Jan Kara &lt;<a href="mailto:jack@suse.cz">jack@suse.cz</a>&gt; 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>
&gt; Also disable page faults during direct I/O requests and implement the same kind<br>
&gt; of retry logic as in the buffered I/O case.<br>
&gt; <br>
&gt; Direct I/O requests differ from buffered I/O requests in that they use<br>
&gt; bio_iov_iter_get_pages for grabbing page references and faulting in pages<br>
&gt; instead of triggering real page faults.  Those manual page faults can be<br>
&gt; disabled with the iocb-&gt;noio flag.<br>
&gt; <br>
&gt; Signed-off-by: Andreas Gruenbacher &lt;<a href="mailto:agruenba@redhat.com" target="_blank" rel="noreferrer">agruenba@redhat.com</a>&gt;<br>
&gt; ---<br>
&gt;  fs/gfs2/file.c | 34 +++++++++++++++++++++++++++++++++-<br>
&gt;  1 file changed, 33 insertions(+), 1 deletion(-)<br>
&gt; <br>
&gt; diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c<br>
&gt; index f66ac7f56f6d..7986f3be69d2 100644<br>
&gt; --- a/fs/gfs2/file.c<br>
&gt; +++ b/fs/gfs2/file.c<br>
&gt; @@ -782,21 +782,41 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,<br>
&gt;       struct file *file = iocb-&gt;ki_filp;<br>
&gt;       struct gfs2_inode *ip = GFS2_I(file-&gt;f_mapping-&gt;host);<br>
&gt;       size_t count = iov_iter_count(to);<br>
&gt; +     size_t written = 0;<br>
&gt;       ssize_t ret;<br>
&gt;  <br>
&gt; +     /*<br>
&gt; +      * In this function, we disable page faults when we&#39;re holding the<br>
&gt; +      * inode glock while doing I/O.  If a page fault occurs, we drop the<br>
&gt; +      * inode glock, fault in the pages manually, and then we retry.  Other<br>
&gt; +      * than in gfs2_file_read_iter, iomap_dio_rw can trigger implicit as<br>
&gt; +      * well as manual page faults, and we need to disable both kinds<br>
&gt; +      * separately.<br>
&gt; +      */<br>
&gt; +<br>
&gt;       if (!count)<br>
&gt;               return 0; /* skip atime */<br>
&gt;  <br>
&gt;       gfs2_holder_init(ip-&gt;i_gl, LM_ST_DEFERRED, 0, gh);<br>
&gt; +retry:<br>
&gt;       ret = gfs2_glock_nq(gh);<br>
&gt;       if (ret)<br>
&gt;               goto out_uninit;<br>
&gt;  <br>
&gt; +     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 &lt;<a href="mailto:jack@suse.com" target="_blank" rel="noreferrer">jack@suse.com</a>&gt;<br>
SUSE Labs, CR<br>
</blockquote></div></div></div>