<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfs/read.c, branch linux-6.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-08-03T07:00:05Z</updated>
<entry>
<title>nfs: pass explicit offset/count to trace events</title>
<updated>2024-08-03T07:00:05Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2024-07-11T07:17:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=387e6e9d110250946df4d4ebef9c2def5c7a4722'/>
<id>urn:sha1:387e6e9d110250946df4d4ebef9c2def5c7a4722</id>
<content type='text'>
[ Upstream commit fada32ed6dbc748f447c8d050a961b75d946055a ]

nfs_folio_length is unsafe to use without having the folio locked and a
check for a NULL -&gt;f_mapping that protects against truncations and can
lead to kernel crashes.  E.g. when running xfstests generic/065 with
all nfs trace points enabled.

Follow the model of the XFS trace points and pass in an explіcit offset
and length.  This has the additional benefit that these values can
be more accurate as some of the users touch partial folio ranges.

Fixes: eb5654b3b89d ("NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()")
Reported-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>NFS: Read unlock folio on nfs_page_create_from_folio() error</title>
<updated>2024-03-09T14:14:51Z</updated>
<author>
<name>Benjamin Coddington</name>
</author>
<published>2024-03-07T14:41:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=11974eec839c167362af685aae5f5e1baaf979eb'/>
<id>urn:sha1:11974eec839c167362af685aae5f5e1baaf979eb</id>
<content type='text'>
The netfs conversion lost a folio_unlock() for the case where
nfs_page_create_from_folio() returns an error (usually -ENOMEM).  Restore
it.

Reported-by: David Jeffery &lt;djeffery@redhat.com&gt;
Cc: &lt;stable@vger.kernel.org&gt; # 6.4+
Fixes: 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")
Signed-off-by: Benjamin Coddington &lt;bcodding@redhat.com&gt;
Acked-by: Dave Wysochanski &lt;dwysocha@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>NFSv4.2: Rework scratch handling for READ_PLUS (again)</title>
<updated>2023-08-23T19:58:47Z</updated>
<author>
<name>Anna Schumaker</name>
</author>
<published>2023-06-09T19:26:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=303a78052091c81e9003915c521fdca1c7e117af'/>
<id>urn:sha1:303a78052091c81e9003915c521fdca1c7e117af</id>
<content type='text'>
I found that the read code might send multiple requests using the same
nfs_pgio_header, but nfs4_proc_read_setup() is only called once. This is
how we ended up occasionally double-freeing the scratch buffer, but also
means we set a NULL pointer but non-zero length to the xdr scratch
buffer. This results in an oops the first time decoding needs to copy
something to scratch, which frequently happens when decoding READ_PLUS
hole segments.

I fix this by moving scratch handling into the pageio read code. I
provide a function to allocate scratch space for decoding read replies,
and free the scratch buffer when the nfs_pgio_header is freed.

Fixes: fbd2a05f29a9 (NFSv4.2: Rework scratch handling for READ_PLUS)
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Convert buffered read paths to use netfs when fscache is enabled</title>
<updated>2023-04-11T17:08:26Z</updated>
<author>
<name>Dave Wysochanski</name>
</author>
<published>2023-02-20T13:43:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=000dbe0bec058cbf2ca9e156e4a5584f5158b0f9'/>
<id>urn:sha1:000dbe0bec058cbf2ca9e156e4a5584f5158b0f9</id>
<content type='text'>
Convert the NFS buffered read code paths to corresponding netfs APIs,
but only when fscache is configured and enabled.

The netfs API defines struct netfs_request_ops which must be filled
in by the network filesystem.  For NFS, we only need to define 5 of
the functions, the main one being the issue_read() function.
The issue_read() function is called by the netfs layer when a read
cannot be fulfilled locally, and must be sent to the server (either
the cache is not active, or it is active but the data is not available).
Once the read from the server is complete, netfs requires a call to
netfs_subreq_terminated() which conveys either how many bytes were read
successfully, or an error.  Note that issue_read() is called with a
structure, netfs_io_subrequest, which defines the IO requested, and
contains a start and a length (both in bytes), and assumes the underlying
netfs will return a either an error on the whole region, or the number
of bytes successfully read.

The NFS IO path is page based and the main APIs are the pgio APIs defined
in pagelist.c.  For the pgio APIs, there is no way for the caller to
know how many RPCs will be sent and how the pages will be broken up
into underlying RPCs, each of which will have their own completion and
return code.  In contrast, netfs is subrequest based, a single
subrequest may contain multiple pages, and a single subrequest is
initiated with issue_read() and terminated with netfs_subreq_terminated().
Thus, to utilze the netfs APIs, NFS needs some way to accommodate
the netfs API requirement on the single response to the whole
subrequest, while also minimizing disruptive changes to the NFS
pgio layer.

The approach taken with this patch is to allocate a small structure
for each nfs_netfs_issue_read() call, store the final error and number
of bytes successfully transferred in the structure, and update these values
as each RPC completes.  The refcount on the structure is used as a marker
for the last RPC completion, is incremented in nfs_netfs_read_initiate(),
and decremented inside nfs_netfs_read_completion(), when a nfs_pgio_header
contains a valid pointer to the data.  On the final put (which signals
the final outstanding RPC is complete) in nfs_netfs_read_completion(),
call netfs_subreq_terminated() with either the final error value (if
one or more READs complete with an error) or the number of bytes
successfully transferred (if all RPCs complete successfully).  Note
that when all RPCs complete successfully, the number of bytes transferred
is capped to the length of the subrequest.  Capping the transferred length
to the subrequest length prevents "Subreq overread" warnings from netfs.
This is due to the "aligned_len" in nfs_pageio_add_page(), and the
corner case where NFS requests a full page at the end of the file,
even when i_size reflects only a partial page (NFS overread).

Signed-off-by: Dave Wysochanski &lt;dwysocha@redhat.com&gt;
Tested-by: Daire Byrne &lt;daire@dneg.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Rename readpage_async_filler to nfs_read_add_folio</title>
<updated>2023-04-11T16:59:23Z</updated>
<author>
<name>Dave Wysochanski</name>
</author>
<published>2023-02-20T13:43:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=01c3a40084a42b7a242776d1e9f8e10d4e96c6ef'/>
<id>urn:sha1:01c3a40084a42b7a242776d1e9f8e10d4e96c6ef</id>
<content type='text'>
Rename readpage_async_filler to nfs_read_add_folio to
better reflect what this function does (add a folio to
the nfs_pageio_descriptor), and simplify arguments to
this function by removing struct nfs_readdesc.

Signed-off-by: Dave Wysochanski &lt;dwysocha@redhat.com&gt;
Tested-by: Daire Byrne &lt;daire@dneg.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Fix /proc/PID/io read_bytes for buffered reads</title>
<updated>2023-03-14T17:47:43Z</updated>
<author>
<name>Dave Wysochanski</name>
</author>
<published>2023-03-09T18:58:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c88ea00fef03031ce6554531e89be82f6a42835'/>
<id>urn:sha1:9c88ea00fef03031ce6554531e89be82f6a42835</id>
<content type='text'>
Prior to commit 8786fde8421c ("Convert NFS from readpages to
readahead"), nfs_readpages() used the old mm interface read_cache_pages()
which called task_io_account_read() for each NFS page read.  After
this commit, nfs_readpages() is converted to nfs_readahead(), which
now uses the new mm interface readahead_page().  The new interface
requires callers to call task_io_account_read() themselves.
In addition, to nfs_readahead() task_io_account_read() should also
be called from nfs_read_folio().

Fixes: 8786fde8421c ("Convert NFS from readpages to readahead")
Link: https://lore.kernel.org/linux-nfs/CAPt2mGNEYUk5u8V4abe=5MM5msZqmvzCVrtCP4Qw1n=gCHCnww@mail.gmail.com/
Signed-off-by: Dave Wysochanski &lt;dwysocha@redhat.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Remove unnecessary check in nfs_read_folio()</title>
<updated>2023-02-14T19:22:33Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-01-19T21:33:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2de3d04b3bcba3ae0474373cbd0c85f4f09ed9d2'/>
<id>urn:sha1:2de3d04b3bcba3ae0474373cbd0c85f4f09ed9d2</id>
<content type='text'>
All the callers are expected to supply a valid struct file argument, so
there is no need for the NULL check.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Reported-by: Dan Carpenter &lt;error27@gmail.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Convert buffered reads to use folios</title>
<updated>2023-02-14T19:22:32Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-01-19T21:33:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ab75bff1140733f1b43e81f055acd7d27af7ac05'/>
<id>urn:sha1:ab75bff1140733f1b43e81f055acd7d27af7ac05</id>
<content type='text'>
Perform a largely mechanical conversion of references to struct page and
page-specific functions to use the folio equivalents.

Note that the fscache functionality remains untouched. Instead we just
pass in the folio page. This should be OK, as long as we use order 0
folios together with fscache.

Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>nfs: Leave pages in the pagecache if readpage failed</title>
<updated>2022-06-29T12:51:07Z</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
</author>
<published>2022-05-16T14:30:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0b768a9610c6de9811c6d33900bebfb665192ee1'/>
<id>urn:sha1:0b768a9610c6de9811c6d33900bebfb665192ee1</id>
<content type='text'>
The pagecache handles readpage failing by itself; it doesn't want
filesystems to remove pages from under it.

Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
</content>
</entry>
<entry>
<title>nfs: Convert nfs to read_folio</title>
<updated>2022-05-09T20:21:46Z</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
</author>
<published>2022-04-29T15:12:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=65d023af7f29eb1250a6105141a74776bae7e1f8'/>
<id>urn:sha1:65d023af7f29eb1250a6105141a74776bae7e1f8</id>
<content type='text'>
This is a "weak" conversion which converts straight back to using pages.
A full conversion should be performed at some point, hopefully by
someone familiar with the filesystem.

Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
</content>
</entry>
</feed>
