NFSD: Trace filecache LRU activity
[ Upstream commit c46203acddd9b9200dbc53d0603c97355fd3a03b ] Observe the operation of garbage collection and the lifetime of filecache items. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
7cca6908fa
commit
c15db0869e
@@ -260,6 +260,18 @@ nfsd_file_flush(struct nfsd_file *nf)
|
|||||||
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
|
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nfsd_file_lru_add(struct nfsd_file *nf)
|
||||||
|
{
|
||||||
|
if (list_lru_add(&nfsd_file_lru, &nf->nf_lru))
|
||||||
|
trace_nfsd_file_lru_add(nf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nfsd_file_lru_remove(struct nfsd_file *nf)
|
||||||
|
{
|
||||||
|
if (list_lru_del(&nfsd_file_lru, &nf->nf_lru))
|
||||||
|
trace_nfsd_file_lru_del(nf);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nfsd_file_do_unhash(struct nfsd_file *nf)
|
nfsd_file_do_unhash(struct nfsd_file *nf)
|
||||||
{
|
{
|
||||||
@@ -279,8 +291,7 @@ nfsd_file_unhash(struct nfsd_file *nf)
|
|||||||
{
|
{
|
||||||
if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
|
if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
|
||||||
nfsd_file_do_unhash(nf);
|
nfsd_file_do_unhash(nf);
|
||||||
if (!list_empty(&nf->nf_lru))
|
nfsd_file_lru_remove(nf);
|
||||||
list_lru_del(&nfsd_file_lru, &nf->nf_lru);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -443,27 +454,34 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,
|
|||||||
* counter. Here we check the counter and then test and clear the flag.
|
* counter. Here we check the counter and then test and clear the flag.
|
||||||
* That order is deliberate to ensure that we can do this locklessly.
|
* That order is deliberate to ensure that we can do this locklessly.
|
||||||
*/
|
*/
|
||||||
if (refcount_read(&nf->nf_ref) > 1)
|
if (refcount_read(&nf->nf_ref) > 1) {
|
||||||
goto out_skip;
|
trace_nfsd_file_gc_in_use(nf);
|
||||||
|
return LRU_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't throw out files that are still undergoing I/O or
|
* Don't throw out files that are still undergoing I/O or
|
||||||
* that have uncleared errors pending.
|
* that have uncleared errors pending.
|
||||||
*/
|
*/
|
||||||
if (nfsd_file_check_writeback(nf))
|
if (nfsd_file_check_writeback(nf)) {
|
||||||
goto out_skip;
|
trace_nfsd_file_gc_writeback(nf);
|
||||||
|
return LRU_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags))
|
if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) {
|
||||||
goto out_skip;
|
trace_nfsd_file_gc_referenced(nf);
|
||||||
|
return LRU_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
if (!test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags))
|
if (!test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
|
||||||
goto out_skip;
|
trace_nfsd_file_gc_hashed(nf);
|
||||||
|
return LRU_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
list_lru_isolate_move(lru, &nf->nf_lru, head);
|
list_lru_isolate_move(lru, &nf->nf_lru, head);
|
||||||
this_cpu_inc(nfsd_file_evictions);
|
this_cpu_inc(nfsd_file_evictions);
|
||||||
|
trace_nfsd_file_gc_disposed(nf);
|
||||||
return LRU_REMOVED;
|
return LRU_REMOVED;
|
||||||
out_skip:
|
|
||||||
return LRU_SKIP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1016,7 +1034,7 @@ open_file:
|
|||||||
refcount_inc(&nf->nf_ref);
|
refcount_inc(&nf->nf_ref);
|
||||||
__set_bit(NFSD_FILE_HASHED, &nf->nf_flags);
|
__set_bit(NFSD_FILE_HASHED, &nf->nf_flags);
|
||||||
__set_bit(NFSD_FILE_PENDING, &nf->nf_flags);
|
__set_bit(NFSD_FILE_PENDING, &nf->nf_flags);
|
||||||
list_lru_add(&nfsd_file_lru, &nf->nf_lru);
|
nfsd_file_lru_add(nf);
|
||||||
hlist_add_head_rcu(&nf->nf_node, &nfsd_file_hashtbl[hashval].nfb_head);
|
hlist_add_head_rcu(&nf->nf_node, &nfsd_file_hashtbl[hashval].nfb_head);
|
||||||
++nfsd_file_hashtbl[hashval].nfb_count;
|
++nfsd_file_hashtbl[hashval].nfb_count;
|
||||||
nfsd_file_hashtbl[hashval].nfb_maxcount = max(nfsd_file_hashtbl[hashval].nfb_maxcount,
|
nfsd_file_hashtbl[hashval].nfb_maxcount = max(nfsd_file_hashtbl[hashval].nfb_maxcount,
|
||||||
|
@@ -860,6 +860,45 @@ TRACE_EVENT(nfsd_file_fsnotify_handle_event,
|
|||||||
__entry->nlink, __entry->mode, __entry->mask)
|
__entry->nlink, __entry->mode, __entry->mask)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DECLARE_EVENT_CLASS(nfsd_file_gc_class,
|
||||||
|
TP_PROTO(
|
||||||
|
const struct nfsd_file *nf
|
||||||
|
),
|
||||||
|
TP_ARGS(nf),
|
||||||
|
TP_STRUCT__entry(
|
||||||
|
__field(void *, nf_inode)
|
||||||
|
__field(void *, nf_file)
|
||||||
|
__field(int, nf_ref)
|
||||||
|
__field(unsigned long, nf_flags)
|
||||||
|
),
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->nf_inode = nf->nf_inode;
|
||||||
|
__entry->nf_file = nf->nf_file;
|
||||||
|
__entry->nf_ref = refcount_read(&nf->nf_ref);
|
||||||
|
__entry->nf_flags = nf->nf_flags;
|
||||||
|
),
|
||||||
|
TP_printk("inode=%p ref=%d nf_flags=%s nf_file=%p",
|
||||||
|
__entry->nf_inode, __entry->nf_ref,
|
||||||
|
show_nf_flags(__entry->nf_flags),
|
||||||
|
__entry->nf_file
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
#define DEFINE_NFSD_FILE_GC_EVENT(name) \
|
||||||
|
DEFINE_EVENT(nfsd_file_gc_class, name, \
|
||||||
|
TP_PROTO( \
|
||||||
|
const struct nfsd_file *nf \
|
||||||
|
), \
|
||||||
|
TP_ARGS(nf))
|
||||||
|
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_hashed);
|
||||||
|
DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_disposed);
|
||||||
|
|
||||||
DECLARE_EVENT_CLASS(nfsd_file_lruwalk_class,
|
DECLARE_EVENT_CLASS(nfsd_file_lruwalk_class,
|
||||||
TP_PROTO(
|
TP_PROTO(
|
||||||
unsigned long removed,
|
unsigned long removed,
|
||||||
|
Reference in New Issue
Block a user