<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfsd/filecache.h, branch linux-6.3.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.3.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.3.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-01-06T18:17:06Z</updated>
<entry>
<title>nfsd: fix handling of cached open files in nfsd4_open codepath</title>
<updated>2023-01-06T18:17:06Z</updated>
<author>
<name>Jeff Layton</name>
</author>
<published>2023-01-05T19:55:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0b3a551fa58b4da941efeb209b3770868e2eddd7'/>
<id>urn:sha1:0b3a551fa58b4da941efeb209b3770868e2eddd7</id>
<content type='text'>
Commit fb70bf124b05 ("NFSD: Instantiate a struct file when creating a
regular NFSv4 file") added the ability to cache an open fd over a
compound. There are a couple of problems with the way this currently
works:

It's racy, as a newly-created nfsd_file can end up with its PENDING bit
cleared while the nf is hashed, and the nf_file pointer is still zeroed
out. Other tasks can find it in this state and they expect to see a
valid nf_file, and can oops if nf_file is NULL.

Also, there is no guarantee that we'll end up creating a new nfsd_file
if one is already in the hash. If an extant entry is in the hash with a
valid nf_file, nfs4_get_vfs_file will clobber its nf_file pointer with
the value of op_file and the old nf_file will leak.

Fix both issues by making a new nfsd_file_acquirei_opened variant that
takes an optional file pointer. If one is present when this is called,
we'll take a new reference to it instead of trying to open the file. If
the nfsd_file already has a valid nf_file, we'll just ignore the
optional file and pass the nfsd_file back as-is.

Also rework the tracepoints a bit to allow for an "opened" variant and
don't try to avoid counting acquisitions in the case where we already
have a cached open file.

Fixes: fb70bf124b05 ("NFSD: Instantiate a struct file when creating a regular NFSv4 file")
Cc: Trond Myklebust &lt;trondmy@hammerspace.com&gt;
Reported-by: Stanislav Saner &lt;ssaner@redhat.com&gt;
Reported-and-Tested-by: Ruben Vestergaard &lt;rubenv@drcmr.dk&gt;
Reported-and-Tested-by: Torkil Svensgaard &lt;torkil@drcmr.dk&gt;
Signed-off-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Add an NFSD_FILE_GC flag to enable nfsd_file garbage collection</title>
<updated>2022-11-28T17:54:45Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-10-28T14:46:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d1ea8455716ca070e3cd85767e6f6a562a58b1b'/>
<id>urn:sha1:4d1ea8455716ca070e3cd85767e6f6a562a58b1b</id>
<content type='text'>
NFSv4 operations manage the lifetime of nfsd_file items they use by
means of NFSv4 OPEN and CLOSE. Hence there's no need for them to be
garbage collected.

Introduce a mechanism to enable garbage collection for nfsd_file
items used only by NFSv2/3 callers.

Note that the change in nfsd_file_put() ensures that both CLOSE and
DELEGRETURN will actually close out and free an nfsd_file on last
reference of a non-garbage-collected file.

Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=394
Suggested-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Tested-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Reviewed-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
</content>
</entry>
<entry>
<title>NFSD: Revert "NFSD: NFSv4 CLOSE should release an nfsd_file immediately"</title>
<updated>2022-11-28T17:54:45Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-10-28T14:46:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dcf3f80965ca787c70def402cdf1553c93c75529'/>
<id>urn:sha1:dcf3f80965ca787c70def402cdf1553c93c75529</id>
<content type='text'>
This reverts commit 5e138c4a750dc140d881dab4a8804b094bbc08d2.

That commit attempted to make files available to other users as soon
as all NFSv4 clients were done with them, rather than waiting until
the filecache LRU had garbage collected them.

It gets the reference counting wrong, for one thing.

But it also misses that DELEGRETURN should release a file in the
same fashion. In fact, any nfsd_file_put() on an file held open
by an NFSv4 client needs potentially to release the file
immediately...

Clear the way for implementing that idea.

Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Reviewed-by: NeilBrown &lt;neilb@suse.de&gt;
</content>
</entry>
<entry>
<title>nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops</title>
<updated>2022-09-26T18:02:50Z</updated>
<author>
<name>ChenXiaoSong</name>
</author>
<published>2022-09-22T16:31:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1342f9dd3fc219089deeb2620f6790f19b4129b1'/>
<id>urn:sha1:1342f9dd3fc219089deeb2620f6790f19b4129b1</id>
<content type='text'>
Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: ChenXiaoSong &lt;chenxiaosong2@huawei.com&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Ensure nf_inode is never dereferenced</title>
<updated>2022-07-30T00:16:56Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:27:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=427f5f83a3191cbf024c5aea6e5b601cdf88d895'/>
<id>urn:sha1:427f5f83a3191cbf024c5aea6e5b601cdf88d895</id>
<content type='text'>
The documenting comment for struct nf_file states:

/*
 * A representation of a file that has been opened by knfsd. These are hashed
 * in the hashtable by inode pointer value. Note that this object doesn't
 * hold a reference to the inode by itself, so the nf_inode pointer should
 * never be dereferenced, only used for comparison.
 */

Replace the two existing dereferences to make the comment always
true.

Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: NFSv4 CLOSE should release an nfsd_file immediately</title>
<updated>2022-07-30T00:16:42Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:27:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5e138c4a750dc140d881dab4a8804b094bbc08d2'/>
<id>urn:sha1:5e138c4a750dc140d881dab4a8804b094bbc08d2</id>
<content type='text'>
The last close of a file should enable other accessors to open and
use that file immediately. Leaving the file open in the filecache
prevents other users from accessing that file until the filecache
garbage-collects the file -- sometimes that takes several seconds.

Reported-by: Wang Yugui &lt;wangyugui@e16-tech.com&gt;
Link: https://bugzilla.linux-nfs.org/show_bug.cgi?387
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Clean up unused code after rhashtable conversion</title>
<updated>2022-07-30T00:15:38Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:26:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0ec8e9d1539a7b8109a554028bbce441052f847e'/>
<id>urn:sha1:0ec8e9d1539a7b8109a554028bbce441052f847e</id>
<content type='text'>
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Set up an rhashtable for the filecache</title>
<updated>2022-07-30T00:12:02Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:26:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fc22945ecc2a0a028f3683115f98a922d506c284'/>
<id>urn:sha1:fc22945ecc2a0a028f3683115f98a922d506c284</id>
<content type='text'>
Add code to initialize and tear down an rhashtable. The rhashtable
is not used yet.

Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Remove nfsd_file::nf_hashval</title>
<updated>2022-07-30T00:12:01Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:26:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f0743c2b25c65debd4f599a7c861428cd9de5906'/>
<id>urn:sha1:f0743c2b25c65debd4f599a7c861428cd9de5906</id>
<content type='text'>
The value in this field can always be computed from nf_inode, thus
it is no longer used.

Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Report average age of filecache items</title>
<updated>2022-07-30T00:09:22Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2022-07-08T18:24:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=904940e94a887701db24401e3ed6928a1d4e329f'/>
<id>urn:sha1:904940e94a887701db24401e3ed6928a1d4e329f</id>
<content type='text'>
This is a measure of how long items stay in the filecache, to help
assess how efficient the cache is.

Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
</feed>
