Skip to content

Commit 2f55dbe

Browse files
Yang Erkunchucklever
authored andcommitted
SUNRPC: introduce cache_check_rcu to help check in rcu context
This is a prepare patch to add cache_check_rcu, will use it with follow patch. Suggested-by: NeilBrown <[email protected]> Signed-off-by: Yang Erkun <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent cb80ecf commit 2f55dbe

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

include/linux/sunrpc/cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ static inline bool cache_is_expired(struct cache_detail *detail, struct cache_he
222222
return detail->flush_time >= h->last_refresh;
223223
}
224224

225+
extern int cache_check_rcu(struct cache_detail *detail,
226+
struct cache_head *h, struct cache_req *rqstp);
225227
extern int cache_check(struct cache_detail *detail,
226228
struct cache_head *h, struct cache_req *rqstp);
227229
extern void cache_flush(void);

net/sunrpc/cache.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,7 @@ static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h
281281
return rv;
282282
}
283283

284-
/*
285-
* This is the generic cache management routine for all
286-
* the authentication caches.
287-
* It checks the currency of a cache item and will (later)
288-
* initiate an upcall to fill it if needed.
289-
*
290-
*
291-
* Returns 0 if the cache_head can be used, or cache_puts it and returns
292-
* -EAGAIN if upcall is pending and request has been queued
293-
* -ETIMEDOUT if upcall failed or request could not be queue or
294-
* upcall completed but item is still invalid (implying that
295-
* the cache item has been replaced with a newer one).
296-
* -ENOENT if cache entry was negative
297-
*/
298-
int cache_check(struct cache_detail *detail,
284+
int cache_check_rcu(struct cache_detail *detail,
299285
struct cache_head *h, struct cache_req *rqstp)
300286
{
301287
int rv;
@@ -336,6 +322,31 @@ int cache_check(struct cache_detail *detail,
336322
rv = -ETIMEDOUT;
337323
}
338324
}
325+
326+
return rv;
327+
}
328+
EXPORT_SYMBOL_GPL(cache_check_rcu);
329+
330+
/*
331+
* This is the generic cache management routine for all
332+
* the authentication caches.
333+
* It checks the currency of a cache item and will (later)
334+
* initiate an upcall to fill it if needed.
335+
*
336+
*
337+
* Returns 0 if the cache_head can be used, or cache_puts it and returns
338+
* -EAGAIN if upcall is pending and request has been queued
339+
* -ETIMEDOUT if upcall failed or request could not be queue or
340+
* upcall completed but item is still invalid (implying that
341+
* the cache item has been replaced with a newer one).
342+
* -ENOENT if cache entry was negative
343+
*/
344+
int cache_check(struct cache_detail *detail,
345+
struct cache_head *h, struct cache_req *rqstp)
346+
{
347+
int rv;
348+
349+
rv = cache_check_rcu(detail, h, rqstp);
339350
if (rv)
340351
cache_put(h, detail);
341352
return rv;

0 commit comments

Comments
 (0)