All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>, "tgraf@suug.ch" <tgraf@suug.ch>,
	Dave Chinner <david@fromorbit.com>,
	Jeff Layton <jlayton@redhat.com>
Subject: Re: [PATCH RFC 29/30] NFSD: Convert the filecache to use rhashtable
Date: Thu, 23 Jun 2022 17:27:20 +0000	[thread overview]
Message-ID: <2F100B0A-04F2-496D-B59F-A90493D20439@oracle.com> (raw)
In-Reply-To: <1BB6647C-799E-463F-BF63-55B48450FF29@oracle.com>


> On Jun 22, 2022, at 8:58 PM, Chuck Lever III <chuck.lever@oracle.com> wrote:
> 
>> On Jun 22, 2022, at 8:38 PM, Dave Chinner <david@fromorbit.com> wrote:
>> 
>> On Wed, Jun 22, 2022 at 10:15:56AM -0400, Chuck Lever wrote:
> 
>>> +
>>> +/*
>>> + * Atomically insert a new nfsd_file item into nfsd_file_rhash_tbl.
>>> + *
>>> + * Return values:
>>> + *   %NULL: @new was inserted successfully
>>> + *   %A valid pointer: @new was not inserted, a matching item is returned
>>> + *   %ERR_PTR: an unexpected error occurred during insertion
>>> + */
>>> +static struct nfsd_file *nfsd_file_insert(struct nfsd_file *new)
>>> +{
>>> +	struct nfsd_file_lookup_key key = {
>>> +		.type	= NFSD_FILE_KEY_FULL,
>>> +		.inode	= new->nf_inode,
>>> +		.need	= new->nf_flags,
>>> +		.net	= new->nf_net,
>>> +		.cred	= current_cred(),
>>> +	};
>>> +	struct nfsd_file *nf;
>>> +
>>> +	nf = rhashtable_lookup_get_insert_key(&nfsd_file_rhash_tbl,
>>> +					      &key, &new->nf_rhash,
>>> +					      nfsd_file_rhash_params);
>>> +	if (!nf)
>>> +		return nf;
>> 
>> The insert can return an error (e.g. -ENOMEM) so need to check
>> IS_ERR(nf) here as well.
> 
> That is likely the cause of the BUG that Wang just reported, as
> that will send a ERR_PTR to nfsd_file_get(), which blows up when
> it tries to defererence it.

Yep, that was it. I've fixed it, but some other doubts have surfaced
in the meantime.

Removing the .max_size cap also helps, and in the long run, I now
feel that cap should be left off. But I would like to be certain that
nfsd_file_acquire's logic works when hard errors occur, so I left the cap
in place for now. I found that the "failed to open newly created file!"
warning fires when insertion fails. I need to work on addressing that
case silently.

Also I just found Neil's nice rhashtable explainer:

   https://lwn.net/Articles/751374/

Where he writes that:

> Sometimes you might want a hash table to potentially contain multiple objects for any given key. In that case you can use "rhltables" — rhashtables with lists of objects.


I believe that is the case for the filecache. The hash value is
computed based on the inode pointer, and therefore there can be more
than one nfsd_file object for a particular inode (depending on who
is opening and for what access). So I think filecache needs to use
rhltable, not rhashtable. Any thoughts from rhashtable experts?


--
Chuck Lever




  reply	other threads:[~2022-06-23 18:26 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 14:12 [PATCH RFC 00/30] Overhaul NFSD filecache Chuck Lever
2022-06-22 14:12 ` [PATCH RFC 01/30] NFSD: Report filecache LRU size Chuck Lever
2022-06-22 14:12 ` [PATCH RFC 02/30] NFSD: Report count of calls to nfsd_file_acquire() Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 03/30] NFSD: Report count of freed filecache items Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 04/30] NFSD: Report average age of " Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 05/30] NFSD: Add nfsd_file_lru_dispose_list() helper Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 06/30] NFSD: Refactor nfsd_file_gc() Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 07/30] NFSD: Refactor nfsd_file_lru_scan() Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 08/30] NFSD: Report the number of items evicted by the LRU walk Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 09/30] NFSD: Record number of flush calls Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 10/30] NFSD: Report filecache item construction failures Chuck Lever
2022-06-22 14:13 ` [PATCH RFC 11/30] NFSD: Zero counters when the filecache is re-initialized Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 12/30] NFSD: Hook up the filecache stat file Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 13/30] NFSD: WARN when freeing an item still linked via nf_lru Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 14/30] NFSD: Trace filecache LRU activity Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 15/30] NFSD: Leave open files out of the filecache LRU Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 16/30] NFSD: Fix the filecache LRU shrinker Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 17/30] NFSD: Never call nfsd_file_gc() in foreground paths Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 18/30] NFSD: No longer record nf_hashval in the trace log Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 19/30] NFSD: Remove lockdep assertion from unhash_and_release_locked() Chuck Lever
2022-06-22 14:14 ` [PATCH RFC 20/30] NFSD: nfsd_file_unhash can compute hashval from nf->nf_inode Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 21/30] NFSD: Refactor __nfsd_file_close_inode() Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 22/30] NFSD: nfsd_file_hash_remove can compute hashval Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 23/30] NFSD: Remove nfsd_file::nf_hashval Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 24/30] NFSD: Remove stale comment from nfsd_file_acquire() Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 25/30] NFSD: Clean up "open file" case in nfsd_file_acquire() Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 26/30] NFSD: Document nfsd_file_cache_purge() API contract Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 27/30] NFSD: Replace the "init once" mechanism Chuck Lever
2022-06-22 14:15 ` [PATCH RFC 28/30] NFSD: Set up an rhashtable for the filecache Chuck Lever
2022-06-23 22:56   ` Al Viro
2022-06-23 23:51     ` Chuck Lever III
2022-06-24  0:14       ` Chuck Lever III
2022-06-24  0:29         ` Al Viro
2022-06-22 14:15 ` [PATCH RFC 29/30] NFSD: Convert the filecache to use rhashtable Chuck Lever
2022-06-23  0:38   ` Dave Chinner
2022-06-23  0:58     ` Chuck Lever III
2022-06-23 17:27       ` Chuck Lever III [this message]
2022-06-23 22:33         ` Dave Chinner
2022-06-23 23:59           ` Chuck Lever III
2022-06-22 14:16 ` [PATCH RFC 30/30] NFSD: Clean up unusued code after rhashtable conversion Chuck Lever
2022-06-22 18:36 ` [PATCH RFC 00/30] Overhaul NFSD filecache Wang Yugui
2022-06-22 19:04   ` Chuck Lever III
2022-06-22 19:59     ` Chuck Lever III
2022-06-23  9:02       ` Wang Yugui
2022-06-23 16:44         ` Chuck Lever III
2022-06-23 17:51           ` Wang Yugui
2022-06-24 15:30             ` Chuck Lever III
2022-06-23  0:21     ` Dave Chinner
2022-06-23  1:01       ` Chuck Lever III
2022-06-23 20:27 ` Frank van der Linden
2022-06-28 17:57   ` Chuck Lever III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2F100B0A-04F2-496D-B59F-A90493D20439@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=david@fromorbit.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.