32
32
#include <linux/sunrpc/cache.h>
33
33
#include <linux/sunrpc/stats.h>
34
34
#include <linux/sunrpc/rpc_pipe_fs.h>
35
+ #include <trace/events/sunrpc.h>
35
36
#include "netns.h"
36
37
37
38
#define RPCDBG_FACILITY RPCDBG_CACHE
@@ -120,6 +121,7 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
120
121
if (test_bit (CACHE_VALID , & tmp -> flags ) &&
121
122
cache_is_expired (detail , tmp )) {
122
123
sunrpc_begin_cache_remove_entry (tmp , detail );
124
+ trace_cache_entry_expired (detail , tmp );
123
125
freeme = tmp ;
124
126
break ;
125
127
}
@@ -176,6 +178,25 @@ static void cache_fresh_unlocked(struct cache_head *head,
176
178
}
177
179
}
178
180
181
+ static void cache_make_negative (struct cache_detail * detail ,
182
+ struct cache_head * h )
183
+ {
184
+ set_bit (CACHE_NEGATIVE , & h -> flags );
185
+ trace_cache_entry_make_negative (detail , h );
186
+ }
187
+
188
+ static void cache_entry_update (struct cache_detail * detail ,
189
+ struct cache_head * h ,
190
+ struct cache_head * new )
191
+ {
192
+ if (!test_bit (CACHE_NEGATIVE , & new -> flags )) {
193
+ detail -> update (h , new );
194
+ trace_cache_entry_update (detail , h );
195
+ } else {
196
+ cache_make_negative (detail , h );
197
+ }
198
+ }
199
+
179
200
struct cache_head * sunrpc_cache_update (struct cache_detail * detail ,
180
201
struct cache_head * new , struct cache_head * old , int hash )
181
202
{
@@ -188,10 +209,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
188
209
if (!test_bit (CACHE_VALID , & old -> flags )) {
189
210
spin_lock (& detail -> hash_lock );
190
211
if (!test_bit (CACHE_VALID , & old -> flags )) {
191
- if (test_bit (CACHE_NEGATIVE , & new -> flags ))
192
- set_bit (CACHE_NEGATIVE , & old -> flags );
193
- else
194
- detail -> update (old , new );
212
+ cache_entry_update (detail , old , new );
195
213
cache_fresh_locked (old , new -> expiry_time , detail );
196
214
spin_unlock (& detail -> hash_lock );
197
215
cache_fresh_unlocked (old , detail );
@@ -209,10 +227,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
209
227
detail -> init (tmp , old );
210
228
211
229
spin_lock (& detail -> hash_lock );
212
- if (test_bit (CACHE_NEGATIVE , & new -> flags ))
213
- set_bit (CACHE_NEGATIVE , & tmp -> flags );
214
- else
215
- detail -> update (tmp , new );
230
+ cache_entry_update (detail , tmp , new );
216
231
hlist_add_head (& tmp -> cache_list , & detail -> hash_table [hash ]);
217
232
detail -> entries ++ ;
218
233
cache_get (tmp );
@@ -254,7 +269,7 @@ static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h
254
269
spin_lock (& detail -> hash_lock );
255
270
rv = cache_is_valid (h );
256
271
if (rv == - EAGAIN ) {
257
- set_bit ( CACHE_NEGATIVE , & h -> flags );
272
+ cache_make_negative ( detail , h );
258
273
cache_fresh_locked (h , seconds_since_boot ()+ CACHE_NEW_EXPIRY ,
259
274
detail );
260
275
rv = - ENOENT ;
@@ -460,6 +475,7 @@ static int cache_clean(void)
460
475
continue ;
461
476
462
477
sunrpc_begin_cache_remove_entry (ch , current_detail );
478
+ trace_cache_entry_expired (current_detail , ch );
463
479
rv = 1 ;
464
480
break ;
465
481
}
@@ -1215,6 +1231,7 @@ static int cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
1215
1231
if (test_bit (CACHE_PENDING , & h -> flags )) {
1216
1232
crq -> item = cache_get (h );
1217
1233
list_add_tail (& crq -> q .list , & detail -> queue );
1234
+ trace_cache_entry_upcall (detail , h );
1218
1235
} else
1219
1236
/* Lost a race, no longer PENDING, so don't enqueue */
1220
1237
ret = - EAGAIN ;
@@ -1240,6 +1257,7 @@ int sunrpc_cache_pipe_upcall_timeout(struct cache_detail *detail,
1240
1257
{
1241
1258
if (!cache_listeners_exist (detail )) {
1242
1259
warn_no_listener (detail );
1260
+ trace_cache_entry_no_listener (detail , h );
1243
1261
return - EINVAL ;
1244
1262
}
1245
1263
return sunrpc_cache_pipe_upcall (detail , h );
0 commit comments