<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfsd, branch linux-6.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-04-03T13:11:29Z</updated>
<entry>
<title>NFSD: Fix nfsd_clid_class use of __string_len() macro</title>
<updated>2024-04-03T13:11:29Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
</author>
<published>2024-02-22T17:28:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=12c04627dfa1545c9fb86a63cc7c67fde84d111b'/>
<id>urn:sha1:12c04627dfa1545c9fb86a63cc7c67fde84d111b</id>
<content type='text'>
[ Upstream commit 9388a2aa453321bcf1ad2603959debea9e6ab6d4 ]

I'm working on restructuring the __string* macros so that it doesn't need
to recalculate the string twice. That is, it will save it off when
processing __string() and the __assign_str() will not need to do the work
again as it currently does.

Currently __string_len(item, src, len) doesn't actually use "src", but my
changes will require src to be correct as that is where the __assign_str()
will get its value from.

The event class nfsd_clid_class has:

  __string_len(name, name, clp-&gt;cl_name.len)

But the second "name" does not exist and causes my changes to fail to
build. That second parameter should be: clp-&gt;cl_name.data.

Link: https://lore.kernel.org/linux-trace-kernel/20240222122828.3d8d213c@gandalf.local.home

Cc: Neil Brown &lt;neilb@suse.de&gt;
Cc: Olga Kornievskaia &lt;kolga@netapp.com&gt;
Cc: Dai Ngo &lt;Dai.Ngo@oracle.com&gt;
Cc: Tom Talpey &lt;tom@talpey.com&gt;
Cc: stable@vger.kernel.org
Fixes: d27b74a8675ca ("NFSD: Use new __string_len C macros for nfsd_clid_class")
Acked-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Acked-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>nfsd: don't take fi_lock in nfsd_break_deleg_cb()</title>
<updated>2024-02-23T08:51:59Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2024-02-05T02:22:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=205b66842c7f4ff659b94790af2d3cc1dd300561'/>
<id>urn:sha1:205b66842c7f4ff659b94790af2d3cc1dd300561</id>
<content type='text'>
commit 5ea9a7c5fe4149f165f0e3b624fe08df02b6c301 upstream.

A recent change to check_for_locks() changed it to take -&gt;flc_lock while
holding -&gt;fi_lock.  This creates a lock inversion (reported by lockdep)
because there is a case where -&gt;fi_lock is taken while holding
-&gt;flc_lock.

-&gt;flc_lock is held across -&gt;fl_lmops callbacks, and
nfsd_break_deleg_cb() is one of those and does take -&gt;fi_lock.  However
it doesn't need to.

Prior to v4.17-rc1~110^2~22 ("nfsd: create a separate lease for each
delegation") nfsd_break_deleg_cb() would walk the -&gt;fi_delegations list
and so needed the lock.  Since then it doesn't walk the list and doesn't
need the lock.

Two actions are performed under the lock.  One is to call
nfsd_break_one_deleg which calls nfsd4_run_cb().  These doesn't act on
the nfs4_file at all, so don't need the lock.

The other is to set -&gt;fi_had_conflict which is in the nfs4_file.
This field is only ever set here (except when initialised to false)
so there is no possible problem will multiple threads racing when
setting it.

The field is tested twice in nfs4_set_delegation().  The first test does
not hold a lock and is documented as an opportunistic optimisation, so
it doesn't impose any need to hold -&gt;fi_lock while setting
-&gt;fi_had_conflict.

The second test in nfs4_set_delegation() *is* make under -&gt;fi_lock, so
removing the locking when -&gt;fi_had_conflict is set could make a change.
The change could only be interesting if -&gt;fi_had_conflict tested as
false even though nfsd_break_one_deleg() ran before -&gt;fi_lock was
unlocked.  i.e. while hash_delegation_locked() was running.
As hash_delegation_lock() doesn't interact in any way with nfs4_run_cb()
there can be no importance to this interaction.

So this patch removes the locking from nfsd_break_one_deleg() and moves
the final test on -&gt;fi_had_conflict out of the locked region to make it
clear that locking isn't important to the test.  It is still tested
*after* vfs_setlease() has succeeded.  This might be significant and as
vfs_setlease() takes -&gt;flc_lock, and nfsd_break_one_deleg() is called
under -&gt;flc_lock this "after" is a true ordering provided by a spinlock.

Fixes: edcf9725150e ("nfsd: fix RELEASE_LOCKOWNER")
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nfsd: fix RELEASE_LOCKOWNER</title>
<updated>2024-02-01T00:21:11Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2024-01-22T03:58:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8f5b860de87039b007e84a28a5eefc888154e098'/>
<id>urn:sha1:8f5b860de87039b007e84a28a5eefc888154e098</id>
<content type='text'>
commit edcf9725150e42beeca42d085149f4c88fa97afd upstream.

The test on so_count in nfsd4_release_lockowner() is nonsense and
harmful.  Revert to using check_for_locks(), changing that to not sleep.

First: harmful.
As is documented in the kdoc comment for nfsd4_release_lockowner(), the
test on so_count can transiently return a false positive resulting in a
return of NFS4ERR_LOCKS_HELD when in fact no locks are held.  This is
clearly a protocol violation and with the Linux NFS client it can cause
incorrect behaviour.

If RELEASE_LOCKOWNER is sent while some other thread is still
processing a LOCK request which failed because, at the time that request
was received, the given owner held a conflicting lock, then the nfsd
thread processing that LOCK request can hold a reference (conflock) to
the lock owner that causes nfsd4_release_lockowner() to return an
incorrect error.

The Linux NFS client ignores that NFS4ERR_LOCKS_HELD error because it
never sends NFS4_RELEASE_LOCKOWNER without first releasing any locks, so
it knows that the error is impossible.  It assumes the lock owner was in
fact released so it feels free to use the same lock owner identifier in
some later locking request.

When it does reuse a lock owner identifier for which a previous RELEASE
failed, it will naturally use a lock_seqid of zero.  However the server,
which didn't release the lock owner, will expect a larger lock_seqid and
so will respond with NFS4ERR_BAD_SEQID.

So clearly it is harmful to allow a false positive, which testing
so_count allows.

The test is nonsense because ... well... it doesn't mean anything.

so_count is the sum of three different counts.
1/ the set of states listed on so_stateids
2/ the set of active vfs locks owned by any of those states
3/ various transient counts such as for conflicting locks.

When it is tested against '2' it is clear that one of these is the
transient reference obtained by find_lockowner_str_locked().  It is not
clear what the other one is expected to be.

In practice, the count is often 2 because there is precisely one state
on so_stateids.  If there were more, this would fail.

In my testing I see two circumstances when RELEASE_LOCKOWNER is called.
In one case, CLOSE is called before RELEASE_LOCKOWNER.  That results in
all the lock states being removed, and so the lockowner being discarded
(it is removed when there are no more references which usually happens
when the lock state is discarded).  When nfsd4_release_lockowner() finds
that the lock owner doesn't exist, it returns success.

The other case shows an so_count of '2' and precisely one state listed
in so_stateid.  It appears that the Linux client uses a separate lock
owner for each file resulting in one lock state per lock owner, so this
test on '2' is safe.  For another client it might not be safe.

So this patch changes check_for_locks() to use the (newish)
find_any_file_locked() so that it doesn't take a reference on the
nfs4_file and so never calls nfsd_file_put(), and so never sleeps.  With
this check is it safe to restore the use of check_for_locks() rather
than testing so_count against the mysterious '2'.

Fixes: ce3c4ad7f4ce ("NFSD: Fix possible sleep during nfsd4_release_lockowner()")
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'nfsd-6.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux</title>
<updated>2024-01-05T21:12:29Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2024-01-05T21:12:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d3ac66ed81cb7c0aa78fceec9fb0dbe384992ed'/>
<id>urn:sha1:0d3ac66ed81cb7c0aa78fceec9fb0dbe384992ed</id>
<content type='text'>
Pull nfsd fix from Chuck Lever:

 - Fix another regression in the NFSD administrative API

* tag 'nfsd-6.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
  nfsd: drop the nfsd_put helper
</content>
</entry>
<entry>
<title>nfsd: drop the nfsd_put helper</title>
<updated>2024-01-05T03:52:27Z</updated>
<author>
<name>Jeff Layton</name>
</author>
<published>2024-01-03T13:36:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=64e6304169f1e1f078e7f0798033f80a7fb0ea46'/>
<id>urn:sha1:64e6304169f1e1f078e7f0798033f80a7fb0ea46</id>
<content type='text'>
It's not safe to call nfsd_put once nfsd_last_thread has been called, as
that function will zero out the nn-&gt;nfsd_serv pointer.

Drop the nfsd_put helper altogether and open-code the svc_put in its
callers instead. That allows us to not be reliant on the value of that
pointer when handling an error.

Fixes: 2a501f55cd64 ("nfsd: call nfsd_last_thread() before final nfsd_put()")
Reported-by: Zhi Li &lt;yieli@redhat.com&gt;
Cc: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Jeffrey Layton &lt;jlayton@redhat.com&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'nfsd-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux</title>
<updated>2023-12-20T19:16:50Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2023-12-20T19:16:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ac1c13e257c798510a60559c2cd50f1828f89c4e'/>
<id>urn:sha1:ac1c13e257c798510a60559c2cd50f1828f89c4e</id>
<content type='text'>
Pull nfsd fixes from Chuck Lever:

 - Address a few recently-introduced issues

* tag 'nfsd-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
  SUNRPC: Revert 5f7fc5d69f6e92ec0b38774c387f5cf7812c5806
  NFSD: Revert 738401a9bd1ac34ccd5723d69640a4adbb1a4bc0
  NFSD: Revert 6c41d9a9bd0298002805758216a9c44e38a8500d
  nfsd: hold nfsd_mutex across entire netlink operation
  nfsd: call nfsd_last_thread() before final nfsd_put()
</content>
</entry>
<entry>
<title>NFSD: Revert 738401a9bd1ac34ccd5723d69640a4adbb1a4bc0</title>
<updated>2023-12-18T16:22:19Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2023-12-16T17:12:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1227561c2ffb81ab09ead21cce6438f59276aa6e'/>
<id>urn:sha1:1227561c2ffb81ab09ead21cce6438f59276aa6e</id>
<content type='text'>
There's nothing wrong with this commit, but this is dead code now
that nothing triggers a CB_GETATTR callback. It can be re-introduced
once the issues with handling conflicting GETATTRs are resolved.

Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>NFSD: Revert 6c41d9a9bd0298002805758216a9c44e38a8500d</title>
<updated>2023-12-18T16:22:16Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2023-12-16T16:57:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=862bee84d77fa01cc8929656ae77781abf917863'/>
<id>urn:sha1:862bee84d77fa01cc8929656ae77781abf917863</id>
<content type='text'>
For some reason, the wait_on_bit() in nfsd4_deleg_getattr_conflict()
is waiting forever, preventing a clean server shutdown. The
requesting client might also hang waiting for a reply to the
conflicting GETATTR.

Invoking wait_on_bit() in an nfsd thread context is a hazard. The
correct fix is to replace this wait_on_bit() call site with a
mechanism that defers the conflicting GETATTR until the CB_GETATTR
completes or is known to have failed.

That will require some surgery and extended testing and it's late
in the v6.7-rc cycle, so I'm reverting now in favor of trying again
in a subsequent kernel release.

This is my fault: I should have recognized the ramifications of
calling wait_on_bit() in here before accepting this patch.

Thanks to Dai Ngo &lt;dai.ngo@oracle.com&gt; for diagnosing the issue.

Reported-by: Wolfgang Walter &lt;linux-nfs@stwm.de&gt;
Closes: https://lore.kernel.org/linux-nfs/e3d43ecdad554fbdcaa7181833834f78@stwm.de/
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>cred: get rid of CONFIG_DEBUG_CREDENTIALS</title>
<updated>2023-12-15T22:19:48Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-12-15T20:40:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ae1914174a63a558113e80d24ccac2773f9f7b2b'/>
<id>urn:sha1:ae1914174a63a558113e80d24ccac2773f9f7b2b</id>
<content type='text'>
This code is rarely (never?) enabled by distros, and it hasn't caught
anything in decades. Let's kill off this legacy debug code.

Suggested-by: Linus Torvalds &lt;torvalds@linuxfoundation.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>nfsd: hold nfsd_mutex across entire netlink operation</title>
<updated>2023-12-15T15:23:52Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2023-12-15T00:56:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1bd773b4f0c90123af19a853244be61518ae0556'/>
<id>urn:sha1:1bd773b4f0c90123af19a853244be61518ae0556</id>
<content type='text'>
Rather than using svc_get() and svc_put() to hold a stable reference to
the nfsd_svc for netlink lookups, simply hold the mutex for the entire
time.

The "entire" time isn't very long, and the mutex is not often contented.

This makes way for us to remove the refcounts of svc, which is more
confusing than useful.

Reported-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Closes: https://lore.kernel.org/linux-nfs/5d9bbb599569ce29f16e4e0eef6b291eda0f375b.camel@kernel.org/T/#u
Fixes: bd9d6a3efa97 ("NFSD: add rpc_status netlink support")
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
</feed>
