From: Trond Myklebust <trondmy@gmail.com>
To: "J. Bruce Fields" <bfields@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH RESEND 6/6] nfsd: Reduce the number of calls to nfsd_file_gc()
Date: Mon, 6 Jan 2020 13:18:08 -0500 [thread overview]
Message-ID: <20200106181808.562969-7-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20200106181808.562969-6-trond.myklebust@hammerspace.com>
Don't call nfsd_file_gc() on every put of the reference in nfsd_file_put().
Instead, do it only when we're expecting the refcount to go to 1.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfsd/filecache.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 4cef03a7726c..9c2b29e07975 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -282,27 +282,32 @@ nfsd_file_unhash_and_release_locked(struct nfsd_file *nf, struct list_head *disp
return true;
}
-static int
+static void
nfsd_file_put_noref(struct nfsd_file *nf)
{
- int count;
trace_nfsd_file_put(nf);
- count = atomic_dec_return(&nf->nf_ref);
- if (!count) {
+ if (atomic_dec_and_test(&nf->nf_ref)) {
WARN_ON(test_bit(NFSD_FILE_HASHED, &nf->nf_flags));
nfsd_file_free(nf);
}
- return count;
}
void
nfsd_file_put(struct nfsd_file *nf)
{
- bool is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
+ bool is_hashed;
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
- if (nfsd_file_put_noref(nf) == 1 && is_hashed)
+ if (atomic_read(&nf->nf_ref) > 2 || !nf->nf_file) {
+ nfsd_file_put_noref(nf);
+ return;
+ }
+
+ filemap_flush(nf->nf_file->f_mapping);
+ is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
+ nfsd_file_put_noref(nf);
+ if (is_hashed)
nfsd_file_schedule_laundrette();
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
nfsd_file_gc();
--
2.24.1
next prev parent reply other threads:[~2020-01-06 18:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-06 18:18 [PATCH RESEND 0/6] Improve performance of containerised knfsd Trond Myklebust
2020-01-06 18:18 ` [PATCH RESEND 1/6] nfsd: fix filecache lookup Trond Myklebust
2020-01-06 18:18 ` [PATCH RESEND 2/6] nfsd: cleanup nfsd_file_lru_dispose() Trond Myklebust
2020-01-06 18:18 ` [PATCH RESEND 3/6] nfsd: Containerise filecache laundrette Trond Myklebust
2020-01-06 18:18 ` [PATCH RESEND 4/6] nfsd: Remove unused constant NFSD_FILE_LRU_RESCAN Trond Myklebust
2020-01-06 18:18 ` [PATCH RESEND 5/6] nfsd: Schedule the laundrette regularly irrespective of file errors Trond Myklebust
2020-01-06 18:18 ` Trond Myklebust [this message]
2020-01-21 21:28 ` [PATCH RESEND 1/6] nfsd: fix filecache lookup J. Bruce Fields
2020-01-21 23:07 ` Trond Myklebust
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=20200106181808.562969-7-trond.myklebust@hammerspace.com \
--to=trondmy@gmail.com \
--cc=bfields@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).