]> www.infradead.org Git - users/dwmw2/linux.git/log
users/dwmw2/linux.git
15 months agonfsd: fix net-namespace logic in __nfsd_file_cache_purge
Jeff Layton [Mon, 31 Oct 2022 15:49:21 +0000 (11:49 -0400)]
nfsd: fix net-namespace logic in __nfsd_file_cache_purge

[ Upstream commit d3aefd2b29ff5ffdeb5c06a7d3191a027a18cdb8 ]

If the namespace doesn't match the one in "net", then we'll continue,
but that doesn't cause another rhashtable_walk_next call, so it will
loop infinitely.

Fixes: ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable")
Reported-by: Petr Vorel <pvorel@suse.cz>
Link: https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: ensure we always call fh_verify_error tracepoint
Jeff Layton [Wed, 12 Oct 2022 18:42:54 +0000 (14:42 -0400)]
nfsd: ensure we always call fh_verify_error tracepoint

[ Upstream commit 93c128e709aec23b10f3a2f78a824080d4085318 ]

This is a conditional tracepoint. Call it every time, not just when
nfs_permission fails.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: unregister shrinker when nfsd_init_net() fails
Tetsuo Handa [Mon, 10 Oct 2022 05:59:02 +0000 (14:59 +0900)]
NFSD: unregister shrinker when nfsd_init_net() fails

[ Upstream commit bd86c69dae65de30f6d47249418ba7889809e31a ]

syzbot is reporting UAF read at register_shrinker_prepared() [1], for
commit 7746b32f467b3813 ("NFSD: add shrinker to reap courtesy clients on
low memory condition") missed that nfsd4_leases_net_shutdown() from
nfsd_exit_net() is called only when nfsd_init_net() succeeded.
If nfsd_init_net() fails due to nfsd_reply_cache_init() failure,
register_shrinker() from nfsd4_init_leases_net() has to be undone
before nfsd_init_net() returns.

Link: https://syzkaller.appspot.com/bug?extid=ff796f04613b4c84ad89
Reported-by: syzbot <syzbot+ff796f04613b4c84ad89@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 7746b32f467b3813 ("NFSD: add shrinker to reap courtesy clients on low memory condition")
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: rework hashtable handling in nfsd_do_file_acquire
Jeff Layton [Tue, 4 Oct 2022 19:41:10 +0000 (15:41 -0400)]
nfsd: rework hashtable handling in nfsd_do_file_acquire

[ Upstream commit 243a5263014a30436c93ed3f1f864c1da845455e ]

nfsd_file is RCU-freed, so we need to hold the rcu_read_lock long enough
to get a reference after finding it in the hash. Take the
rcu_read_lock() and call rhashtable_lookup directly.

Switch to using rhashtable_lookup_insert_key as well, and use the usual
retry mechanism if we hit an -EEXIST. Rename the "retry" bool to
open_retry, and eliminiate the insert_err goto target.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: fix nfsd_file_unhash_and_dispose
Jeff Layton [Fri, 30 Sep 2022 20:56:02 +0000 (16:56 -0400)]
nfsd: fix nfsd_file_unhash_and_dispose

[ Upstream commit 8d0d254b15cc5b7d46d85fb7ab8ecede9575e672 ]

nfsd_file_unhash_and_dispose() is called for two reasons:

We're either shutting down and purging the filecache, or we've gotten a
notification about a file delete, so we want to go ahead and unhash it
so that it'll get cleaned up when we close.

We're either walking the hashtable or doing a lookup in it and we
don't take a reference in either case. What we want to do in both cases
is to try and unhash the object and put it on the dispose list if that
was successful. If it's no longer hashed, then we don't want to touch
it, with the assumption being that something else is already cleaning
up the sentinel reference.

Instead of trying to selectively decrement the refcount in this
function, just unhash it, and if that was successful, move it to the
dispose list. Then, the disposal routine will just clean that up as
usual.

Also, just make this a void function, drop the WARN_ON_ONCE, and the
comments about deadlocking since the nature of the purported deadlock
is no longer clear.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agofanotify: Remove obsoleted fanotify_event_has_path()
Gaosheng Cui [Mon, 26 Sep 2022 02:30:18 +0000 (10:30 +0800)]
fanotify: Remove obsoleted fanotify_event_has_path()

[ Upstream commit 7a80bf902d2bc722b4477442ee772e8574603185 ]

All uses of fanotify_event_has_path() have
been removed since commit 9c61f3b560f5 ("fanotify: break up
fanotify_alloc_event()"), now it is useless, so remove it.

Link: https://lore.kernel.org/r/20220926023018.1505270-1-cuigaosheng1@huawei.com
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
15 months agofsnotify: remove unused declaration
Gaosheng Cui [Fri, 9 Sep 2022 03:38:28 +0000 (11:38 +0800)]
fsnotify: remove unused declaration

[ Upstream commit f847c74d6e89f10926db58649a05b99237258691 ]

fsnotify_alloc_event_holder() and fsnotify_destroy_event_holder()
has been removed since commit 7053aee26a35 ("fsnotify: do not share
events between notification groups"), so remove it.

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agofs/notify: constify path
Al Viro [Thu, 4 Aug 2022 16:57:38 +0000 (12:57 -0400)]
fs/notify: constify path

[ Upstream commit d5bf88895f24686641c39420ee6df716dc1d95d8 ]

Reviewed-by: Matthew Bobrowski <repnop@google.com>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: extra checks when freeing delegation stateids
Jeff Layton [Mon, 26 Sep 2022 18:41:02 +0000 (14:41 -0400)]
nfsd: extra checks when freeing delegation stateids

[ Upstream commit 895ddf5ed4c54ea9e3533606d7a8b4e4f27f95ef ]

We've had some reports of problems in the refcounting for delegation
stateids that we've yet to track down. Add some extra checks to ensure
that we've removed the object from various lists before freeing it.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=2127067
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: make nfsd4_run_cb a bool return function
Jeff Layton [Mon, 26 Sep 2022 18:41:01 +0000 (14:41 -0400)]
nfsd: make nfsd4_run_cb a bool return function

[ Upstream commit b95239ca4954a0d48b19c09ce7e8f31b453b4216 ]

queue_work can return false and not queue anything, if the work is
already queued. If that happens in the case of a CB_RECALL, we'll have
taken an extra reference to the stid that will never be put. Ensure we
throw a warning in that case.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: fix comments about spinlock handling with delegations
Jeff Layton [Mon, 26 Sep 2022 16:38:45 +0000 (12:38 -0400)]
nfsd: fix comments about spinlock handling with delegations

[ Upstream commit 25fbe1fca14142beae6c882f7906510363d42bff ]

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: only fill out return pointer on success in nfsd4_lookup_stateid
Jeff Layton [Mon, 26 Sep 2022 16:38:44 +0000 (12:38 -0400)]
nfsd: only fill out return pointer on success in nfsd4_lookup_stateid

[ Upstream commit 4d01416ab41540bb13ec4a39ac4e6c4aa5934bc9 ]

In the case of a revoked delegation, we still fill out the pointer even
when returning an error, which is bad form. Only overwrite the pointer
on success.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Cap rsize_bop result based on send buffer size
Chuck Lever [Thu, 1 Sep 2022 19:29:55 +0000 (15:29 -0400)]
NFSD: Cap rsize_bop result based on send buffer size

[ Upstream commit 76ce4dcec0dc08a032db916841ddc4e3998be317 ]

Since before the git era, NFSD has conserved the number of pages
held by each nfsd thread by combining the RPC receive and send
buffers into a single array of pages. This works because there are
no cases where an operation needs a large RPC Call message and a
large RPC Reply at the same time.

Once an RPC Call has been received, svc_process() updates
svc_rqst::rq_res to describe the part of rq_pages that can be
used for constructing the Reply. This means that the send buffer
(rq_res) shrinks when the received RPC record containing the RPC
Call is large.

Add an NFSv4 helper that computes the size of the send buffer. It
replaces svc_max_payload() in spots where svc_max_payload() returns
a value that might be larger than the remaining send buffer space.
Callers who need to know the transport's actual maximum payload size
will continue to use svc_max_payload().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Rename the fields in copy_stateid_t
Chuck Lever [Thu, 22 Sep 2022 17:10:35 +0000 (13:10 -0400)]
NFSD: Rename the fields in copy_stateid_t

[ Upstream commit 781fde1a2ba2391f31142f46f964cf1148ca1791 ]

Code maintenance: The name of the copy_stateid_t::sc_count field
collides with the sc_count field in struct nfs4_stid, making the
latter difficult to grep for when auditing stateid reference
counting.

No behavior change expected.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops
ChenXiaoSong [Thu, 22 Sep 2022 16:31:56 +0000 (00:31 +0800)]
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops

[ Upstream commit 1342f9dd3fc219089deeb2620f6790f19b4129b1 ]

Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops
ChenXiaoSong [Thu, 22 Sep 2022 16:31:55 +0000 (00:31 +0800)]
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops

[ Upstream commit 64776611a06322b99386f8dfe3b3ba1aa0347a38 ]

Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

nfsd_net is converted from seq_file->file instead of seq_file->private in
nfsd_reply_cache_stats_show().

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
[ cel: reduce line length ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: use DEFINE_SHOW_ATTRIBUTE to define client_info_fops
ChenXiaoSong [Thu, 22 Sep 2022 16:31:54 +0000 (00:31 +0800)]
nfsd: use DEFINE_SHOW_ATTRIBUTE to define client_info_fops

[ Upstream commit 1d7f6b302b75ff7acb9eb3cab0c631b10cfa7542 ]

Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

inode is converted from seq_file->file instead of seq_file->private in
client_info_show().

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: use DEFINE_SHOW_ATTRIBUTE to define export_features_fops and supported_enctypes...
ChenXiaoSong [Thu, 22 Sep 2022 16:31:53 +0000 (00:31 +0800)]
nfsd: use DEFINE_SHOW_ATTRIBUTE to define export_features_fops and supported_enctypes_fops

[ Upstream commit 9beeaab8e05d353d709103cafa1941714b4d5d94 ]

Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
[ cel: reduce line length ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: use DEFINE_PROC_SHOW_ATTRIBUTE to define nfsd_proc_ops
ChenXiaoSong [Thu, 22 Sep 2022 16:31:52 +0000 (00:31 +0800)]
nfsd: use DEFINE_PROC_SHOW_ATTRIBUTE to define nfsd_proc_ops

[ Upstream commit 0cfb0c4228a5c8e2ed2b58f8309b660b187cef02 ]

Use DEFINE_PROC_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Pack struct nfsd4_compoundres
Chuck Lever [Mon, 12 Sep 2022 21:23:36 +0000 (17:23 -0400)]
NFSD: Pack struct nfsd4_compoundres

[ Upstream commit 9f553e61bd36c1048543ac2f6945103dd2f742be ]

Remove a couple of 4-byte holes on platforms with 64-bit pointers.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Remove unused nfsd4_compoundargs::cachetype field
Chuck Lever [Mon, 12 Sep 2022 21:23:30 +0000 (17:23 -0400)]
NFSD: Remove unused nfsd4_compoundargs::cachetype field

[ Upstream commit 77e378cf2a595d8e39cddf28a31efe6afd9394a0 ]

This field was added by commit 1091006c5eb1 ("nfsd: turn on reply
cache for NFSv4") but was never put to use.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Remove "inline" directives on op_rsize_bop helpers
Chuck Lever [Mon, 12 Sep 2022 21:23:25 +0000 (17:23 -0400)]
NFSD: Remove "inline" directives on op_rsize_bop helpers

[ Upstream commit 6604148cf961b57fc735e4204f8996536da9253c ]

These helpers are always invoked indirectly, so the compiler can't
inline these anyway. While we're updating the synopses of these
helpers, defensively convert their parameters to const pointers.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Clean up nfs4svc_encode_compoundres()
Chuck Lever [Mon, 12 Sep 2022 21:23:19 +0000 (17:23 -0400)]
NFSD: Clean up nfs4svc_encode_compoundres()

[ Upsteam commit 9993a66317fc9951322483a9edbfae95a640b210 ]

In today's Linux NFS server implementation, the NFS dispatcher
initializes each XDR result stream, and the NFSv4 .pc_func and
.pc_encode methods all use xdr_stream-based encoding. This keeps
rq_res.len automatically updated. There is no longer a need for
the WARN_ON_ONCE() check in nfs4svc_encode_compoundres().

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Clean up WRITE arg decoders
Chuck Lever [Mon, 12 Sep 2022 21:23:07 +0000 (17:23 -0400)]
NFSD: Clean up WRITE arg decoders

[ Upstream commit d4da5baa533215b14625458e645056baf646bb2e ]

xdr_stream_subsegment() already returns a boolean value.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Use xdr_inline_decode() to decode NFSv3 symlinks
Chuck Lever [Mon, 12 Sep 2022 21:23:02 +0000 (17:23 -0400)]
NFSD: Use xdr_inline_decode() to decode NFSv3 symlinks

[ Upstream commit c3d2a04f05c590303c125a176e6e43df4a436fdb ]

Replace the check for buffer over/underflow with a helper that is
commonly used for this purpose. The helper also sets xdr->nwords
correctly after successfully linearizing the symlink argument into
the stream's scratch buffer.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor common code out of dirlist helpers
Chuck Lever [Mon, 12 Sep 2022 21:22:56 +0000 (17:22 -0400)]
NFSD: Refactor common code out of dirlist helpers

[ Upstream commit 98124f5bd6c76699d514fbe491dd95265369cc99 ]

The dust has settled a bit and it's become obvious what code is
totally common between nfsd_init_dirlist_pages() and
nfsd3_init_dirlist_pages(). Move that common code to SUNRPC.

The new helper brackets the existing xdr_init_decode_pages() API.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Reduce amount of struct nfsd4_compoundargs that needs clearing
Chuck Lever [Mon, 12 Sep 2022 21:22:44 +0000 (17:22 -0400)]
NFSD: Reduce amount of struct nfsd4_compoundargs that needs clearing

[ Upstream commit 3fdc546462348b8a497c72bc894e0cde9f10fc40 ]

Have SunRPC clear everything except for the iops array. Then have
each NFSv4 XDR decoder clear it's own argument before decoding.

Now individual operations may have a large argument struct while not
penalizing the vast majority of operations with a small struct.

And, clearing the argument structure occurs as the argument fields
are initialized, enabling the CPU to do write combining on that
memory. In some cases, clearing is not even necessary because all
of the fields in the argument structure are initialized by the
decoder.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoSUNRPC: Parametrize how much of argsize should be zeroed
Chuck Lever [Mon, 12 Sep 2022 21:22:38 +0000 (17:22 -0400)]
SUNRPC: Parametrize how much of argsize should be zeroed

[ Upstream commit 103cc1fafee48adb91fca0e19deb869fd23e46ab ]

Currently, SUNRPC clears the whole of .pc_argsize before processing
each incoming RPC transaction. Add an extra parameter to struct
svc_procedure to enable upper layers to reduce the amount of each
operation's argument structure that is zeroed by SUNRPC.

The size of struct nfsd4_compoundargs, in particular, is a lot to
clear on each incoming RPC Call. A subsequent patch will cut this
down to something closer to what NFSv2 and NFSv3 uses.

This patch should cause no behavior changes.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: add shrinker to reap courtesy clients on low memory condition
Dai Ngo [Wed, 14 Sep 2022 15:54:26 +0000 (08:54 -0700)]
NFSD: add shrinker to reap courtesy clients on low memory condition

[ Upstream commit 7746b32f467b3813fb61faaab3258de35806a7ac ]

Add courtesy_client_reaper to react to low memory condition triggered
by the system memory shrinker.

The delayed_work for the courtesy_client_reaper is scheduled on
the shrinker's count callback using the laundry_wq.

The shrinker's scan callback is not used for expiring the courtesy
clients due to potential deadlocks.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: keep track of the number of courtesy clients in the system
Dai Ngo [Wed, 14 Sep 2022 15:54:25 +0000 (08:54 -0700)]
NFSD: keep track of the number of courtesy clients in the system

[ Upstream commit 3a4ea23d86a317c4b68b9a69d51f7e84e1e04357 ]

Add counter nfs4_courtesy_client_count to nfsd_net to keep track
of the number of courtesy clients in the system.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Make nfsd4_remove() wait before returning NFS4ERR_DELAY
Chuck Lever [Thu, 8 Sep 2022 22:14:25 +0000 (18:14 -0400)]
NFSD: Make nfsd4_remove() wait before returning NFS4ERR_DELAY

[ Upstream commit 5f5f8b6d655fd947e899b1771c2f7cb581a06764 ]

nfsd_unlink() can kick off a CB_RECALL (via
vfs_unlink() -> leases_conflict()) if a delegation is present.
Before returning NFS4ERR_DELAY, give the client holding that
delegation a chance to return it and then retry the nfsd_unlink()
again, once.

Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Make nfsd4_rename() wait before returning NFS4ERR_DELAY
Chuck Lever [Thu, 8 Sep 2022 22:14:19 +0000 (18:14 -0400)]
NFSD: Make nfsd4_rename() wait before returning NFS4ERR_DELAY

[ Upstream commit 68c522afd0b1936b48a03a4c8b81261e7597c62d ]

nfsd_rename() can kick off a CB_RECALL (via
vfs_rename() -> leases_conflict()) if a delegation is present.
Before returning NFS4ERR_DELAY, give the client holding that
delegation a chance to return it and then retry the nfsd_rename()
again, once.

This version of the patch handles renaming an existing file,
but does not deal with renaming onto an existing file. That
case will still always trigger an NFS4ERR_DELAY.

Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY
Chuck Lever [Thu, 8 Sep 2022 22:14:13 +0000 (18:14 -0400)]
NFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY

[ Upstream commit 34b91dda7124fc3259e4b2ae53e0c933dedfec01 ]

nfsd_setattr() can kick off a CB_RECALL (via
notify_change() -> break_lease()) if a delegation is present. Before
returning NFS4ERR_DELAY, give the client holding that delegation a
chance to return it and then retry the nfsd_setattr() again, once.

Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor nfsd_setattr()
Chuck Lever [Thu, 8 Sep 2022 22:14:07 +0000 (18:14 -0400)]
NFSD: Refactor nfsd_setattr()

[ Upstream commit c0aa1913db57219e91a0a8832363cbafb3a9cf8f ]

Move code that will be retried (in a subsequent patch) into a helper
function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Add a mechanism to wait for a DELEGRETURN
Chuck Lever [Thu, 8 Sep 2022 22:14:00 +0000 (18:14 -0400)]
NFSD: Add a mechanism to wait for a DELEGRETURN

[ Upstream commit c035362eb935fe9381d9d1cc453bc2a37460e24c ]

Subsequent patches will use this mechanism to wake up an operation
that is waiting for a client to return a delegation.

The new tracepoint records whether the wait timed out or was
properly awoken by the expected DELEGRETURN:

            nfsd-1155  [002] 83799.493199: nfsd_delegret_wakeup: xid=0x14b7d6ef fh_hash=0xf6826792 (timed out)

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Add tracepoints to report NFSv4 callback completions
Chuck Lever [Thu, 8 Sep 2022 22:13:54 +0000 (18:13 -0400)]
NFSD: Add tracepoints to report NFSv4 callback completions

[ Upstream commit 1035d65446a018ca2dd179e29a2fcd6d29057781 ]

Wireshark has always been lousy about dissecting NFSv4 callbacks,
especially NFSv4.0 backchannel requests. Add tracepoints so we
can surgically capture these events in the trace log.

Tracepoints are time-stamped and ordered so that we can now observe
the timing relationship between a CB_RECALL Reply and the client's
DELEGRETURN Call. Example:

            nfsd-1153  [002]   211.986391: nfsd_cb_recall:       addr=192.168.1.67:45767 client 62ea82e4:fee7492a stateid 00000003:00000001

            nfsd-1153  [002]   212.095634: nfsd_compound:        xid=0x0000002c opcnt=2
            nfsd-1153  [002]   212.095647: nfsd_compound_status: op=1/2 OP_PUTFH status=0
            nfsd-1153  [002]   212.095658: nfsd_file_put:        hash=0xf72 inode=0xffff9291148c7410 ref=3 flags=HASHED|REFERENCED may=READ file=0xffff929103b3ea00
            nfsd-1153  [002]   212.095661: nfsd_compound_status: op=2/2 OP_DELEGRETURN status=0
   kworker/u25:8-148   [002]   212.096713: nfsd_cb_recall_done:  client 62ea82e4:fee7492a stateid 00000003:00000001 status=0

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Trace NFSv4 COMPOUND tags
Chuck Lever [Thu, 8 Sep 2022 22:13:48 +0000 (18:13 -0400)]
NFSD: Trace NFSv4 COMPOUND tags

[ Upstream commit de29cf7e6cbbe236c3a51999c188fcd467762899 ]

The Linux NFSv4 client implementation does not use COMPOUND tags,
but the Solaris and MacOS implementations do, and so does pynfs.
Record these eye-catchers in the server's trace buffer to annotate
client requests while troubleshooting.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Replace dprintk() call site in fh_verify()
Chuck Lever [Thu, 8 Sep 2022 22:13:42 +0000 (18:13 -0400)]
NFSD: Replace dprintk() call site in fh_verify()

[ Upstream commit 948755efc951de75c87d4fa916d9d36b58299295 ]

Record permission errors in the trace log. Note that the new trace
event is conditional, so it will only record non-zero return values
from nfsd_permission().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: remove nfsd4_prepare_cb_recall() declaration
Gaosheng Cui [Fri, 9 Sep 2022 06:59:10 +0000 (14:59 +0800)]
nfsd: remove nfsd4_prepare_cb_recall() declaration

[ Upstream commit 18224dc58d960c65446971930d0487fc72d00598 ]

nfsd4_prepare_cb_recall() has been removed since
commit 0162ac2b978e ("nfsd: introduce nfsd4_callback_ops"),
so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: clean up mounted_on_fileid handling
Jeff Layton [Thu, 8 Sep 2022 16:31:07 +0000 (12:31 -0400)]
nfsd: clean up mounted_on_fileid handling

[ Upstream commit 6106d9119b6599fa23dc556b429d887b4c2d9f62 ]

We only need the inode number for this, not a full rack of attributes.
Rename this function make it take a pointer to a u64 instead of
struct kstat, and change it to just request STATX_INO.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
[ cel: renamed get_mounted_on_ino() ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: drop fname and flen args from nfsd_create_locked()
NeilBrown [Tue, 6 Sep 2022 00:42:19 +0000 (10:42 +1000)]
NFSD: drop fname and flen args from nfsd_create_locked()

[ Upstream commit 9558f9304ca1903090fa5d995a3269a8e82804b4 ]

nfsd_create_locked() does not use the "fname" and "flen" arguments, so
drop them from declaration and all callers.

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Increase NFSD_MAX_OPS_PER_COMPOUND
Chuck Lever [Fri, 2 Sep 2022 22:18:16 +0000 (18:18 -0400)]
NFSD: Increase NFSD_MAX_OPS_PER_COMPOUND

[ Upstream commit 80e591ce636f3ae6855a0ca26963da1fdd6d4508 ]

When attempting an NFSv4 mount, a Solaris NFSv4 client builds a
single large COMPOUND that chains a series of LOOKUPs to get to the
pseudo filesystem root directory that is to be mounted. The Linux
NFS server's current maximum of 16 operations per NFSv4 COMPOUND is
not large enough to ensure that this works for paths that are more
than a few components deep.

Since NFSD_MAX_OPS_PER_COMPOUND is mostly a sanity check, and most
NFSv4 COMPOUNDS are between 3 and 6 operations (thus they do not
trigger any re-allocation of the operation array on the server),
increasing this maximum should result in little to no impact.

The ops array can get large now, so allocate it via vmalloc() to
help ensure memory fragmentation won't cause an allocation failure.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216383
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: Propagate some error code returned by memdup_user()
Christophe JAILLET [Thu, 1 Sep 2022 05:27:19 +0000 (07:27 +0200)]
nfsd: Propagate some error code returned by memdup_user()

[ Upstream commit 30a30fcc3fc1ad4c5d017c9fcb75dc8f59e7bdad ]

Propagate the error code returned by memdup_user() instead of a hard coded
-EFAULT.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: Avoid some useless tests
Christophe JAILLET [Thu, 1 Sep 2022 05:27:11 +0000 (07:27 +0200)]
nfsd: Avoid some useless tests

[ Upstream commit d44899b8bb0b919f923186c616a84f0e70e04772 ]

memdup_user() can't return NULL, so there is no point for checking for it.

Simplify some tests accordingly.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: remove redundant variable status
Jinpeng Cui [Wed, 31 Aug 2022 14:20:02 +0000 (14:20 +0000)]
NFSD: remove redundant variable status

[ Upstream commit 4ab3442ca384a02abf8b1f2b3449a6c547851873 ]

Return value directly from fh_verify() do_open_permission()
exp_pseudoroot() instead of getting value from
redundant variable status.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD enforce filehandle check for source file in COPY
Olga Kornievskaia [Fri, 19 Aug 2022 19:16:36 +0000 (15:16 -0400)]
NFSD enforce filehandle check for source file in COPY

[ Upstream commit 754035ff79a14886e68c0c9f6fa80adb21f12b53 ]

If the passed in filehandle for the source file in the COPY operation
is not a regular file, the server MUST return NFS4ERR_WRONG_TYPE.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
[ cel: adjusted to apply to v5.15.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agolockd: move from strlcpy with unused retval to strscpy
Wolfram Sang [Thu, 18 Aug 2022 21:01:16 +0000 (23:01 +0200)]
lockd: move from strlcpy with unused retval to strscpy

[ Upstream commit 97f8e62572555f8ad578d7b1739ba64d5d2cac0f ]

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: move from strlcpy with unused retval to strscpy
Wolfram Sang [Thu, 18 Aug 2022 21:01:14 +0000 (23:01 +0200)]
NFSD: move from strlcpy with unused retval to strscpy

[ Upstream commit 72f78ae00a8e5d7abe13abac8305a300f6afd74b ]

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd_splice_actor(): handle compound pages
Al Viro [Sat, 10 Sep 2022 21:14:02 +0000 (22:14 +0100)]
nfsd_splice_actor(): handle compound pages

[ Upstream commit bfbfb6182ad1d7d184b16f25165faad879147f79 ]

pipe_buffer might refer to a compound page (and contain more than a PAGE_SIZE
worth of data).  Theoretically it had been possible since way back, but
nfsd_splice_actor() hadn't run into that until copy_page_to_iter() change.
Fortunately, the only thing that changes for compound pages is that we
need to stuff each relevant subpage in and convert the offset into offset
in the first subpage.

Acked-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Benjamin Coddington <bcodding@redhat.com>
Fixes: f0f6b614f83d "copy_page_to_iter(): don't split high-order page in case of ITER_PIPE"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: fix regression with setting ACLs.
NeilBrown [Thu, 8 Sep 2022 02:08:40 +0000 (12:08 +1000)]
NFSD: fix regression with setting ACLs.

[ Upstream commit 00801cd92d91e94aa04d687f9bb9a9104e7c3d46 ]

A recent patch moved ACL setting into nfsd_setattr().
Unfortunately it didn't work as nfsd_setattr() aborts early if
iap->ia_valid is 0.

Remove this test, and instead avoid calling notify_change() when
ia_valid is 0.

This means that nfsd_setattr() will now *always* lock the inode.
Previously it didn't if only a ATTR_MODE change was requested on a
symlink (see Commit 15b7a1b86d66 ("[PATCH] knfsd: fix setattr-on-symlink
error return")). I don't think this change really matters.

Fixes: c0cbe70742f4 ("NFSD: add posix ACLs to struct nfsd_attrs")
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: discard fh_locked flag and fh_lock/fh_unlock
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: discard fh_locked flag and fh_lock/fh_unlock

[ Upstream commit dd8dd403d7b223cc77ee89d8d09caf045e90e648 ]

As all inode locking is now fully balanced, fh_put() does not need to
call fh_unlock().
fh_lock() and fh_unlock() are no longer used, so discard them.
These are the only real users of ->fh_locked, so discard that too.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: use (un)lock_inode instead of fh_(un)lock for file operations
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: use (un)lock_inode instead of fh_(un)lock for file operations

[ Upstream commit bb4d53d66e4b8c8b8e5634802262e53851a2d2db ]

When locking a file to access ACLs and xattrs etc, use explicit locking
with inode_lock() instead of fh_lock().  This means that the calls to
fh_fill_pre/post_attr() are also explicit which improves readability and
allows us to place them only where they are needed.  Only the xattr
calls need pre/post information.

When locking a file we don't need I_MUTEX_PARENT as the file is not a
parent of anything, so we can use inode_lock() directly rather than the
inode_lock_nested() call that fh_lock() uses.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: use explicit lock/unlock for directory ops
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: use explicit lock/unlock for directory ops

[ Upstream commit debf16f0c671cb8db154a9ebcd6014cfff683b80 ]

When creating or unlinking a name in a directory use explicit
inode_lock_nested() instead of fh_lock(), and explicit calls to
fh_fill_pre_attrs() and fh_fill_post_attrs().  This is already done
for renames, with lock_rename() as the explicit locking.

Also move the 'fill' calls closer to the operation that might change the
attributes.  This way they are avoided on some error paths.

For the v2-only code in nfsproc.c, the fill calls are not replaced as
they aren't needed.

Making the locking explicit will simplify proposed future changes to
locking for directories.  It also makes it easily visible exactly where
pre/post attributes are used - not all callers of fh_lock() actually
need the pre/post attributes.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: reduce locking in nfsd_lookup()
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: reduce locking in nfsd_lookup()

[ Upstream commit 19d008b46941b8c668402170522e0f7a9258409c ]

nfsd_lookup() takes an exclusive lock on the parent inode, but no
callers want the lock and it may not be needed at all if the
result is in the dcache.

Change nfsd_lookup_dentry() to not take the lock, and call
lookup_one_len_locked() which takes lock only if needed.

nfsd4_open() currently expects the lock to still be held, but that isn't
necessary as nfsd_validate_delegated_dentry() provides required
guarantees without the lock.

NOTE: NFSv4 requires directory changeinfo for OPEN even when a create
  wasn't requested and no change happened.  Now that nfsd_lookup()
  doesn't use fh_lock(), we need to explicitly fill the attributes
  when no create happens.  A new fh_fill_both_attrs() is provided
  for that task.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: only call fh_unlock() once in nfsd_link()
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: only call fh_unlock() once in nfsd_link()

[ Upstream commit e18bcb33bc5b69bccc2b532075aa00bb49cc01c5 ]

On non-error paths, nfsd_link() calls fh_unlock() twice.  This is safe
because fh_unlock() records that the unlock has been done and doesn't
repeat it.
However it makes the code a little confusing and interferes with changes
that are planned for directory locking.

So rearrange the code to ensure fh_unlock() is called exactly once if
fh_lock() was called.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: always drop directory lock in nfsd_unlink()
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: always drop directory lock in nfsd_unlink()

[ Upstream commit b677c0c63a135a916493c064906582e9f3ed4802 ]

Some error paths in nfsd_unlink() allow it to exit without unlocking the
directory.  This is not a problem in practice as the directory will be
locked with an fh_put(), but it is untidy and potentially confusing.

This allows us to remove all the fh_unlock() calls that are immediately
after nfsd_unlink() calls.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: change nfsd_create()/nfsd_symlink() to unlock directory before returning.
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: change nfsd_create()/nfsd_symlink() to unlock directory before returning.

[ Upstream commit 927bfc5600cd6333c9ef9f090f19e66b7d4c8ee1 ]

nfsd_create() usually returns with the directory still locked.
nfsd_symlink() usually returns with it unlocked.  This is clumsy.

Until recently nfsd_create() needed to keep the directory locked until
ACLs and security label had been set.  These are now set inside
nfsd_create() (in nfsd_setattr()) so this need is gone.

So change nfsd_create() and nfsd_symlink() to always unlock, and remove
any fh_unlock() calls that follow calls to these functions.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: add posix ACLs to struct nfsd_attrs
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: add posix ACLs to struct nfsd_attrs

[ Upstream commit c0cbe70742f4a70893cd6e5f6b10b6e89b6db95b ]

pacl and dpacl pointers are added to struct nfsd_attrs, which requires
that we have an nfsd_attrs_free() function to free them.
Those nfsv4 functions that can set ACLs now set up these pointers
based on the passed in NFSv4 ACL.

nfsd_setattr() sets the acls as appropriate.

Errors are handled as with security labels.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: add security label to struct nfsd_attrs
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: add security label to struct nfsd_attrs

[ Upstream commit d6a97d3f589a3a46a16183e03f3774daee251317 ]

nfsd_setattr() now sets a security label if provided, and nfsv4 provides
it in the 'open' and 'create' paths and the 'setattr' path.
If setting the label failed (including because the kernel doesn't
support labels), an error field in 'struct nfsd_attrs' is set, and the
caller can respond.  The open/create callers clear
FATTR4_WORD2_SECURITY_LABEL in the returned attr set in this case.
The setattr caller returns the error.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: set attributes when creating symlinks
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: set attributes when creating symlinks

[ Upstream commit 93adc1e391a761441d783828b93979b38093d011 ]

The NFS protocol includes attributes when creating symlinks.
Linux does store attributes for symlinks and allows them to be set,
though they are not used for permission checking.

NFSD currently doesn't set standard (struct iattr) attributes when
creating symlinks, but for NFSv4 it does set ACLs and security labels.
This is inconsistent.

To improve consistency, pass the provided attributes into nfsd_symlink()
and call nfsd_create_setattr() to set them.

NOTE: this results in a behaviour change for all NFS versions when the
client sends non-default attributes with a SYMLINK request. With the
Linux client, the only attributes are:
        attr.ia_mode = S_IFLNK | S_IRWXUGO;
        attr.ia_valid = ATTR_MODE;
so the final outcome will be unchanged. Other clients might sent
different attributes, and if they did they probably expect them to be
honoured.

We ignore any error from nfsd_create_setattr().  It isn't really clear
what should be done if a file is successfully created, but the
attributes cannot be set.  NFS doesn't allow partial success to be
reported.  Reporting failure is probably more misleading than reporting
success, so the status is ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: introduce struct nfsd_attrs
NeilBrown [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: introduce struct nfsd_attrs

[ Upstream commit 7fe2a71dda349a1afa75781f0cc7975be9784d15 ]

The attributes that nfsd might want to set on a file include 'struct
iattr' as well as an ACL and security label.
The latter two are passed around quite separately from the first, in
part because they are only needed for NFSv4.  This leads to some
clumsiness in the code, such as the attributes NOT being set in
nfsd_create_setattr().

We need to keep the directory locked until all attributes are set to
ensure the file is never visibile without all its attributes.  This need
combined with the inconsistent handling of attributes leads to more
clumsiness.

As a first step towards tidying this up, introduce 'struct nfsd_attrs'.
This is passed (by reference) to vfs.c functions that work with
attributes, and is assembled by the various nfs*proc functions which
call them.  As yet only iattr is included, but future patches will
expand this.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: verify the opened dentry after setting a delegation
Jeff Layton [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: verify the opened dentry after setting a delegation

[ Upstream commit 876c553cb41026cb6ad3cef970a35e5f69c42a25 ]

Between opening a file and setting a delegation on it, someone could
rename or unlink the dentry. If this happens, we do not want to grant a
delegation on the open.

On a CLAIM_NULL open, we're opening by filename, and we may (in the
non-create case) or may not (in the create case) be holding i_rwsem
when attempting to set a delegation.  The latter case allows a
race.

After getting a lease, redo the lookup of the file being opened and
validate that the resulting dentry matches the one in the open file
description.

To properly redo the lookup we need an rqst pointer to pass to
nfsd_lookup_dentry(), so make sure that is available.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: drop fh argument from alloc_init_deleg
Jeff Layton [Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)]
NFSD: drop fh argument from alloc_init_deleg

[ Upstream commit bbf936edd543e7220f60f9cbd6933b916550396d ]

Currently, we pass the fh of the opened file down through several
functions so that alloc_init_deleg can pass it to delegation_blocked.
The filehandle of the open file is available in the nfs4_file however,
so there's no need to pass it in a separate argument.

Drop the argument from alloc_init_deleg, nfs4_open_delegation and
nfs4_set_delegation.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Move copy offload callback arguments into a separate structure
Chuck Lever [Wed, 27 Jul 2022 18:41:18 +0000 (14:41 -0400)]
NFSD: Move copy offload callback arguments into a separate structure

[ Upstream commit a11ada99ce93a79393dc6683d22f7915748c8f6b ]

Refactor so that CB_OFFLOAD arguments can be passed without
allocating a whole struct nfsd4_copy object. On my system (x86_64)
this removes another 96 bytes from struct nfsd4_copy.

[ cel: adjusted to apply to v5.15.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Add nfsd4_send_cb_offload()
Chuck Lever [Wed, 27 Jul 2022 18:41:12 +0000 (14:41 -0400)]
NFSD: Add nfsd4_send_cb_offload()

[ Upstream commit e72f9bc006c08841c46d27747a4debc747a8fe13 ]

Refactor for legibility.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Remove kmalloc from nfsd4_do_async_copy()
Chuck Lever [Wed, 27 Jul 2022 18:41:06 +0000 (14:41 -0400)]
NFSD: Remove kmalloc from nfsd4_do_async_copy()

[ Upstream commit ad1e46c9b07b13659635ee5405f83ad0df143116 ]

Instead of manufacturing a phony struct nfsd_file, pass the
struct file returned by nfs42_ssc_open() directly to
nfsd4_do_copy().

[ cel: adjusted to apply to v5.15.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor nfsd4_do_copy()
Chuck Lever [Wed, 27 Jul 2022 18:40:59 +0000 (14:40 -0400)]
NFSD: Refactor nfsd4_do_copy()

[ Upstream commit 3b7bf5933cada732783554edf0dc61283551c6cf ]

Refactor: Now that nfsd4_do_copy() no longer calls the cleanup
helpers, plumb the use of struct file pointers all the way down to
_nfsd_copy_file_range().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor nfsd4_cleanup_inter_ssc() (2/2)
Chuck Lever [Wed, 27 Jul 2022 18:40:53 +0000 (14:40 -0400)]
NFSD: Refactor nfsd4_cleanup_inter_ssc() (2/2)

[ Upstream commit 478ed7b10d875da2743d1a22822b9f8a82df8f12 ]

Move the nfsd4_cleanup_*() call sites out of nfsd4_do_copy(). A
subsequent patch will modify one of the new call sites to avoid
the need to manufacture the phony struct nfsd_file.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor nfsd4_cleanup_inter_ssc() (1/2)
Chuck Lever [Wed, 27 Jul 2022 18:40:47 +0000 (14:40 -0400)]
NFSD: Refactor nfsd4_cleanup_inter_ssc() (1/2)

[ Upstream commit 24d796ea383b8a4c8234e06d1b14bbcd371192ea ]

The @src parameter is sometimes a pointer to a struct nfsd_file and
sometimes a pointer to struct file hiding in a phony struct
nfsd_file. Refactor nfsd4_cleanup_inter_ssc() so the @src parameter
is always an explicit struct file.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Replace boolean fields in struct nfsd4_copy
Chuck Lever [Wed, 27 Jul 2022 18:40:41 +0000 (14:40 -0400)]
NFSD: Replace boolean fields in struct nfsd4_copy

[ Upstream commit 1913cdf56cb5bfbc8170873728d13598cbecda23 ]

Clean up: saves 8 bytes, and we can replace check_and_set_stop_copy()
with an atomic bitop.

[ cel: adjusted to apply to v5.15.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Make nfs4_put_copy() static
Chuck Lever [Wed, 27 Jul 2022 18:40:35 +0000 (14:40 -0400)]
NFSD: Make nfs4_put_copy() static

[ Upstream commit 8ea6e2c90bb0eb74a595a12e23a1dff9abbc760a ]

Clean up: All call sites are in fs/nfsd/nfs4proc.c.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Reorder the fields in struct nfsd4_op
Chuck Lever [Wed, 27 Jul 2022 18:40:28 +0000 (14:40 -0400)]
NFSD: Reorder the fields in struct nfsd4_op

[ Upstream commit d314309425ad5dc1b6facdb2d456580fb5fa5e3a ]

Pack the fields to reduce the size of struct nfsd4_op, which is used
an array in struct nfsd4_compoundargs.

sizeof(struct nfsd4_op):
Before: /* size: 672, cachelines: 11, members: 5 */
After:  /* size: 640, cachelines: 10, members: 5 */

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Shrink size of struct nfsd4_copy
Chuck Lever [Wed, 27 Jul 2022 18:40:22 +0000 (14:40 -0400)]
NFSD: Shrink size of struct nfsd4_copy

[ Upstream commit 87689df694916c40e8e6c179ab1c8710f65cb6c6 ]

struct nfsd4_copy is part of struct nfsd4_op, which resides in an
8-element array.

sizeof(struct nfsd4_op):
Before: /* size: 1696, cachelines: 27, members: 5 */
After:  /* size: 672, cachelines: 11, members: 5 */

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Shrink size of struct nfsd4_copy_notify
Chuck Lever [Wed, 27 Jul 2022 18:40:16 +0000 (14:40 -0400)]
NFSD: Shrink size of struct nfsd4_copy_notify

[ Upstream commit 09426ef2a64ee189ca1e3298f1e874842dbf35ea ]

struct nfsd4_copy_notify is part of struct nfsd4_op, which resides
in an 8-element array.

sizeof(struct nfsd4_op):
Before: /* size: 2208, cachelines: 35, members: 5 */
After:  /* size: 1696, cachelines: 27, members: 5 */

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: nfserrno(-ENOMEM) is nfserr_jukebox
Chuck Lever [Wed, 27 Jul 2022 18:40:09 +0000 (14:40 -0400)]
NFSD: nfserrno(-ENOMEM) is nfserr_jukebox

[ Upstream commit bb4d842722b84a2731257054b6405f2d866fc5f3 ]

Suggested-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Fix strncpy() fortify warning
Chuck Lever [Wed, 27 Jul 2022 18:40:03 +0000 (14:40 -0400)]
NFSD: Fix strncpy() fortify warning

[ Upstream commit 5304877936c0a67e1a01464d113bae4c81eacdb6 ]

In function ‘strncpy’,
    inlined from ‘nfsd4_ssc_setup_dul’ at /home/cel/src/linux/manet/fs/nfsd/nfs4proc.c:1392:3,
    inlined from ‘nfsd4_interssc_connect’ at /home/cel/src/linux/manet/fs/nfsd/nfs4proc.c:1489:11:
/home/cel/src/linux/manet/include/linux/fortify-string.h:52:33: warning: ‘__builtin_strncpy’ specified bound 63 equals destination size [-Wstringop-truncation]
   52 | #define __underlying_strncpy    __builtin_strncpy
      |                                 ^
/home/cel/src/linux/manet/include/linux/fortify-string.h:89:16: note: in expansion of macro ‘__underlying_strncpy’
   89 |         return __underlying_strncpy(p, q, size);
      |                ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Clean up nfsd4_encode_readlink()
Chuck Lever [Fri, 22 Jul 2022 20:09:23 +0000 (16:09 -0400)]
NFSD: Clean up nfsd4_encode_readlink()

[ Upstream commit 99b002a1fa00d90e66357315757e7277447ce973 ]

Similar changes to nfsd4_encode_readv(), all bundled into a single
patch.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Use xdr_pad_size()
Chuck Lever [Fri, 22 Jul 2022 20:09:16 +0000 (16:09 -0400)]
NFSD: Use xdr_pad_size()

[ Upstream commit 5e64d85c7d0c59cfcd61d899720b8ccfe895d743 ]

Clean up: Use a helper instead of open-coding the calculation of
the XDR pad size.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Simplify starting_len
Chuck Lever [Fri, 22 Jul 2022 20:09:10 +0000 (16:09 -0400)]
NFSD: Simplify starting_len

[ Upstream commit 071ae99feadfc55979f89287d6ad2c6a315cb46d ]

Clean-up: Now that nfsd4_encode_readv() does not have to encode the
EOF or rd_length values, it no longer needs to subtract 8 from
@starting_len.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Optimize nfsd4_encode_readv()
Chuck Lever [Fri, 22 Jul 2022 20:09:04 +0000 (16:09 -0400)]
NFSD: Optimize nfsd4_encode_readv()

[ Upstream commit 28d5bc468efe74b790e052f758ce083a5015c665 ]

write_bytes_to_xdr_buf() is pretty expensive to use for inserting
an XDR data item that is always 1 XDR_UNIT at an address that is
always XDR word-aligned.

Since both the readv and splice read paths encode EOF and maxcount
values, move both to a common code path.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Add an nfsd4_read::rd_eof field
Chuck Lever [Fri, 22 Jul 2022 20:08:57 +0000 (16:08 -0400)]
NFSD: Add an nfsd4_read::rd_eof field

[ Upstream commit 24c7fb85498eda1d4c6b42cc4886328429814990 ]

Refactor: Make the EOF result available in the entire NFSv4 READ
path.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Clean up SPLICE_OK in nfsd4_encode_read()
Chuck Lever [Fri, 22 Jul 2022 20:08:51 +0000 (16:08 -0400)]
NFSD: Clean up SPLICE_OK in nfsd4_encode_read()

[ Upstream commit c738b218a2e5a753a336b4b7fee6720b902c7ace ]

Do the test_bit() once -- this reduces the number of locked-bus
operations and makes the function a little easier to read.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Optimize nfsd4_encode_fattr()
Chuck Lever [Fri, 22 Jul 2022 20:08:45 +0000 (16:08 -0400)]
NFSD: Optimize nfsd4_encode_fattr()

[ Upstream commit ab04de60ae1cc64ae16b77feae795311b97720c7 ]

write_bytes_to_xdr_buf() is a generic way to place a variable-length
data item in an already-reserved spot in the encoding buffer.

However, it is costly. In nfsd4_encode_fattr(), it is unnecessary
because the data item is fixed in size and the buffer destination
address is always word-aligned.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Optimize nfsd4_encode_operation()
Chuck Lever [Fri, 22 Jul 2022 20:08:38 +0000 (16:08 -0400)]
NFSD: Optimize nfsd4_encode_operation()

[ Upstream commit 095a764b7afb06c9499b798c04eaa3cbf70ebe2d ]

write_bytes_to_xdr_buf() is a generic way to place a variable-length
data item in an already-reserved spot in the encoding buffer.
However, it is costly, and here, it is unnecessary because the
data item is fixed in size, the buffer destination address is
always word-aligned, and the destination location is already in
@p.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agonfsd: silence extraneous printk on nfsd.ko insertion
Jeff Layton [Wed, 20 Jul 2022 12:39:23 +0000 (08:39 -0400)]
nfsd: silence extraneous printk on nfsd.ko insertion

[ Upstream commit 3a5940bfa17fb9964bf9688b4356ca643a8f5e2d ]

This printk pops every time nfsd.ko gets plugged in. Most kmods don't do
that and this one is not very informative. Olaf's email address seems to
be defunct at this point anyway. Just drop it.

Cc: Olaf Kirch <okir@suse.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: limit the number of v4 clients to 1024 per 1GB of system memory
Dai Ngo [Fri, 15 Jul 2022 23:54:53 +0000 (16:54 -0700)]
NFSD: limit the number of v4 clients to 1024 per 1GB of system memory

[ Upstream commit 4271c2c0887562318a0afef97d32d8a71cbe0743 ]

Currently there is no limit on how many v4 clients are supported
by the system. This can be a problem in systems with small memory
configuration to function properly when a very large number of
clients exist that creates memory shortage conditions.

This patch enforces a limit of 1024 NFSv4 clients, including courtesy
clients, per 1GB of system memory.  When the number of the clients
reaches the limit, requests that create new clients are returned
with NFS4ERR_DELAY and the laundromat is kicked start to trim old
clients. Due to the overhead of the upcall to remove the client
record, the maximun number of clients the laundromat removes on
each run is limited to 128. This is done to ensure the laundromat
can still process the other tasks in a timely manner.

Since there is now a limit of the number of clients, the 24-hr
idle time limit of courtesy client is no longer needed and was
removed.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: keep track of the number of v4 clients in the system
Dai Ngo [Fri, 15 Jul 2022 23:54:52 +0000 (16:54 -0700)]
NFSD: keep track of the number of v4 clients in the system

[ Upstream commit 0926c39515aa065a296e97dfc8790026f1e53f86 ]

Add counter nfs4_client_count to keep track of the total number
of v4 clients, including courtesy clients, in the system.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: refactoring v4 specific code to a helper in nfs4state.c
Dai Ngo [Fri, 15 Jul 2022 23:54:51 +0000 (16:54 -0700)]
NFSD: refactoring v4 specific code to a helper in nfs4state.c

[ Upstream commit 6867137ebcf4155fe25f2ecf7c29b9fb90a76d1d ]

This patch moves the v4 specific code from nfsd_init_net() to
nfsd4_init_leases_net() helper in nfs4state.c

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Ensure nf_inode is never dereferenced
Chuck Lever [Fri, 8 Jul 2022 18:27:09 +0000 (14:27 -0400)]
NFSD: Ensure nf_inode is never dereferenced

[ Upstream commit 427f5f83a3191cbf024c5aea6e5b601cdf88d895 ]

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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: NFSv4 CLOSE should release an nfsd_file immediately
Chuck Lever [Fri, 8 Jul 2022 18:27:02 +0000 (14:27 -0400)]
NFSD: NFSv4 CLOSE should release an nfsd_file immediately

[ Upstream commit 5e138c4a750dc140d881dab4a8804b094bbc08d2 ]

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 <wangyugui@e16-tech.com>
Link: https://bugzilla.linux-nfs.org/show_bug.cgi?387
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Move nfsd_file_trace_alloc() tracepoint
Chuck Lever [Fri, 8 Jul 2022 18:26:49 +0000 (14:26 -0400)]
NFSD: Move nfsd_file_trace_alloc() tracepoint

[ Upstream commit b40a2839470cd62ed68c4a32d72a18ee8975b1ac ]

Avoid recording the allocation of an nfsd_file item that is
immediately released because a matching item was already
inserted in the hash.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Separate tracepoints for acquire and create
Chuck Lever [Fri, 8 Jul 2022 18:26:43 +0000 (14:26 -0400)]
NFSD: Separate tracepoints for acquire and create

[ Upstream commit be0230069fcbf7d332d010b57c1d0cfd623a84d6 ]

These tracepoints collect different information: the create case does
not open a file, so there's no nf_file available.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Clean up unused code after rhashtable conversion
Chuck Lever [Fri, 8 Jul 2022 18:26:36 +0000 (14:26 -0400)]
NFSD: Clean up unused code after rhashtable conversion

[ Upstream commit 0ec8e9d1539a7b8109a554028bbce441052f847e ]

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Convert the filecache to use rhashtable
Chuck Lever [Fri, 8 Jul 2022 18:26:30 +0000 (14:26 -0400)]
NFSD: Convert the filecache to use rhashtable

[ Upstream commit ce502f81ba884c1fe45dc0ebddbcaaa4ec0fc5fb ]

Enable the filecache hash table to start small, then grow with the
workload. Smaller server deployments benefit because there should
be lower memory utilization. Larger server deployments should see
improved scaling with the number of open files.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Suggested-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Set up an rhashtable for the filecache
Chuck Lever [Fri, 8 Jul 2022 18:26:23 +0000 (14:26 -0400)]
NFSD: Set up an rhashtable for the filecache

[ Upstream commit fc22945ecc2a0a028f3683115f98a922d506c284 ]

Add code to initialize and tear down an rhashtable. The rhashtable
is not used yet.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Replace the "init once" mechanism
Chuck Lever [Fri, 8 Jul 2022 18:26:16 +0000 (14:26 -0400)]
NFSD: Replace the "init once" mechanism

[ Upstream commit c7b824c3d06c85e054caf86e227255112c5e3c38 ]

In a moment, the nfsd_file_hashtbl global will be replaced with an
rhashtable. Replace the one or two spots that need to check if the
hash table is available. We can easily reuse the SHUTDOWN flag for
this purpose.

Document that this mechanism relies on callers to hold the
nfsd_mutex to prevent init, shutdown, and purging to run
concurrently.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Remove nfsd_file::nf_hashval
Chuck Lever [Fri, 8 Jul 2022 18:26:10 +0000 (14:26 -0400)]
NFSD: Remove nfsd_file::nf_hashval

[ Upstream commit f0743c2b25c65debd4f599a7c861428cd9de5906 ]

The value in this field can always be computed from nf_inode, thus
it is no longer used.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: nfsd_file_hash_remove can compute hashval
Chuck Lever [Fri, 8 Jul 2022 18:26:03 +0000 (14:26 -0400)]
NFSD: nfsd_file_hash_remove can compute hashval

[ Upstream commit cb7ec76e73ff6640241c8f1f2f35c81d4005a2d6 ]

Remove an unnecessary use of nf_hashval.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: Refactor __nfsd_file_close_inode()
Chuck Lever [Fri, 8 Jul 2022 18:25:57 +0000 (14:25 -0400)]
NFSD: Refactor __nfsd_file_close_inode()

[ Upstream commit a845511007a63467fee575353c706806c21218b1 ]

The code that computes the hashval is the same in both callers.

To prevent them from going stale, reframe the documenting comments
to remove descriptions of the underlying hash table structure, which
is about to be replaced.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 months agoNFSD: nfsd_file_unhash can compute hashval from nf->nf_inode
Chuck Lever [Fri, 8 Jul 2022 18:25:50 +0000 (14:25 -0400)]
NFSD: nfsd_file_unhash can compute hashval from nf->nf_inode

[ Upstream commit 8755326399f471ec3b31e2ab8c5074c0d28a0fb5 ]

Remove an unnecessary usage of nf_hashval.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>