Release 4.11 net/sunrpc/cache.c
/*
* net/sunrpc/cache.c
*
* Generic code for various authentication-related caches
* used by sunrpc clients and servers.
*
* Copyright (C) 2002 Neil Brown <neilb@cse.unsw.edu.au>
*
* Released under terms in GPL version 2. See COPYING.
*
*/
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/slab.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/kmod.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/ctype.h>
#include <linux/string_helpers.h>
#include <linux/uaccess.h>
#include <linux/poll.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/net.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
#include <linux/pagemap.h>
#include <asm/ioctls.h>
#include <linux/sunrpc/types.h>
#include <linux/sunrpc/cache.h>
#include <linux/sunrpc/stats.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
#include "netns.h"
#define RPCDBG_FACILITY RPCDBG_CACHE
static bool cache_defer_req(struct cache_req *req, struct cache_head *item);
static void cache_revisit_request(struct cache_head *item);
static void cache_init(struct cache_head *h, struct cache_detail *detail)
{
time_t now = seconds_since_boot();
INIT_HLIST_NODE(&h->cache_list);
h->flags = 0;
kref_init(&h->ref);
h->expiry_time = now + CACHE_NEW_EXPIRY;
if (now <= detail->flush_time)
/* ensure it isn't already expired */
now = detail->flush_time + 1;
h->last_refresh = now;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 68 | 90.67% | 4 | 57.14% |
Kinglong Mee | 5 | 6.67% | 1 | 14.29% |
Andi Kleen | 1 | 1.33% | 1 | 14.29% |
Adrian Bunk | 1 | 1.33% | 1 | 14.29% |
Total | 75 | 100.00% | 7 | 100.00% |
struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
struct cache_head *key, int hash)
{
struct cache_head *new = NULL, *freeme = NULL, *tmp = NULL;
struct hlist_head *head;
head = &detail->hash_table[hash];
read_lock(&detail->hash_lock);
hlist_for_each_entry(tmp, head, cache_list) {
if (detail->match(tmp, key)) {
if (cache_is_expired(detail, tmp))
/* This entry is expired, we will discard it. */
break;
cache_get(tmp);
read_unlock(&detail->hash_lock);
return tmp;
}
}
read_unlock(&detail->hash_lock);
/* Didn't find anything, insert an empty entry */
new = detail->alloc();
if (!new)
return NULL;
/* must fully initialise 'new', else
* we might get lose if we need to
* cache_put it soon.
*/
cache_init(new, detail);
detail->init(new, key);
write_lock(&detail->hash_lock);
/* check if entry appeared while we slept */
hlist_for_each_entry(tmp, head, cache_list) {
if (detail->match(tmp, key)) {
if (cache_is_expired(detail, tmp)) {
hlist_del_init(&tmp->cache_list);
detail->entries --;
freeme = tmp;
break;
}
cache_get(tmp);
write_unlock(&detail->hash_lock);
cache_put(new, detail);
return tmp;
}
}
hlist_add_head(&new->cache_list, head);
detail->entries++;
cache_get(new);
write_unlock(&detail->hash_lock);
if (freeme)
cache_put(freeme, detail);
return new;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 240 | 86.64% | 4 | 80.00% |
Kinglong Mee | 37 | 13.36% | 1 | 20.00% |
Total | 277 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_lookup);
static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
static void cache_fresh_locked(struct cache_head *head, time_t expiry,
struct cache_detail *detail)
{
time_t now = seconds_since_boot();
if (now <= detail->flush_time)
/* ensure it isn't immediately treated as expired */
now = detail->flush_time + 1;
head->expiry_time = expiry;
head->last_refresh = now;
smp_wmb(); /* paired with smp_rmb() in cache_is_valid() */
set_bit(CACHE_VALID, &head->flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 64 | 94.12% | 3 | 75.00% |
J. Bruce Fields | 4 | 5.88% | 1 | 25.00% |
Total | 68 | 100.00% | 4 | 100.00% |
static void cache_fresh_unlocked(struct cache_head *head,
struct cache_detail *detail)
{
if (test_and_clear_bit(CACHE_PENDING, &head->flags)) {
cache_revisit_request(head);
cache_dequeue(detail, head);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 42 | 100.00% | 2 | 100.00% |
Total | 42 | 100.00% | 2 | 100.00% |
struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
struct cache_head *new, struct cache_head *old, int hash)
{
/* The 'old' entry is to be replaced by 'new'.
* If 'old' is not VALID, we update it directly,
* otherwise we need to replace it
*/
struct cache_head *tmp;
if (!test_bit(CACHE_VALID, &old->flags)) {
write_lock(&detail->hash_lock);
if (!test_bit(CACHE_VALID, &old->flags)) {
if (test_bit(CACHE_NEGATIVE, &new->flags))
set_bit(CACHE_NEGATIVE, &old->flags);
else
detail->update(old, new);
cache_fresh_locked(old, new->expiry_time, detail);
write_unlock(&detail->hash_lock);
cache_fresh_unlocked(old, detail);
return old;
}
write_unlock(&detail->hash_lock);
}
/* We need to insert a new entry */
tmp = detail->alloc();
if (!tmp) {
cache_put(old, detail);
return NULL;
}
cache_init(tmp, detail);
detail->init(tmp, old);
write_lock(&detail->hash_lock);
if (test_bit(CACHE_NEGATIVE, &new->flags))
set_bit(CACHE_NEGATIVE, &tmp->flags);
else
detail->update(tmp, new);
hlist_add_head(&tmp->cache_list, &detail->hash_table[hash]);
detail->entries++;
cache_get(tmp);
cache_fresh_locked(tmp, new->expiry_time, detail);
cache_fresh_locked(old, 0, detail);
write_unlock(&detail->hash_lock);
cache_fresh_unlocked(tmp, detail);
cache_fresh_unlocked(old, detail);
cache_put(old, detail);
return tmp;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 284 | 95.62% | 4 | 80.00% |
Kinglong Mee | 13 | 4.38% | 1 | 20.00% |
Total | 297 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_update);
static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
{
if (cd->cache_upcall)
return cd->cache_upcall(cd, h);
return sunrpc_cache_pipe_upcall(cd, h);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 19 | 47.50% | 1 | 33.33% |
Neil Brown | 13 | 32.50% | 1 | 33.33% |
Stanislav Kinsbursky | 8 | 20.00% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
static inline int cache_is_valid(struct cache_head *h)
{
if (!test_bit(CACHE_VALID, &h->flags))
return -EAGAIN;
else {
/* entry is valid */
if (test_bit(CACHE_NEGATIVE, &h->flags))
return -ENOENT;
else {
/*
* In combination with write barrier in
* sunrpc_cache_update, ensures that anyone
* using the cache entry after this sees the
* updated contents:
*/
smp_rmb();
return 0;
}
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 53 | 89.83% | 2 | 66.67% |
J. Bruce Fields | 6 | 10.17% | 1 | 33.33% |
Total | 59 | 100.00% | 3 | 100.00% |
static int try_to_negate_entry(struct cache_detail *detail, struct cache_head *h)
{
int rv;
write_lock(&detail->hash_lock);
rv = cache_is_valid(h);
if (rv == -EAGAIN) {
set_bit(CACHE_NEGATIVE, &h->flags);
cache_fresh_locked(h, seconds_since_boot()+CACHE_NEW_EXPIRY,
detail);
rv = -ENOENT;
}
write_unlock(&detail->hash_lock);
cache_fresh_unlocked(h, detail);
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
J. Bruce Fields | 78 | 88.64% | 1 | 33.33% |
Neil Brown | 10 | 11.36% | 2 | 66.67% |
Total | 88 | 100.00% | 3 | 100.00% |
/*
* This is the generic cache management routine for all
* the authentication caches.
* It checks the currency of a cache item and will (later)
* initiate an upcall to fill it if needed.
*
*
* Returns 0 if the cache_head can be used, or cache_puts it and returns
* -EAGAIN if upcall is pending and request has been queued
* -ETIMEDOUT if upcall failed or request could not be queue or
* upcall completed but item is still invalid (implying that
* the cache item has been replaced with a newer one).
* -ENOENT if cache entry was negative
*/
int cache_check(struct cache_detail *detail,
struct cache_head *h, struct cache_req *rqstp)
{
int rv;
long refresh_age, age;
/* First decide return status as best we can */
rv = cache_is_valid(h);
/* now see if we want to start an upcall */
refresh_age = (h->expiry_time - h->last_refresh);
age = seconds_since_boot() - h->last_refresh;
if (rqstp == NULL) {
if (rv == -EAGAIN)
rv = -ENOENT;
} else if (rv == -EAGAIN ||
(h->expiry_time != 0 && age > refresh_age/2)) {
dprintk("RPC: Want update, refage=%ld, age=%ld\n",
refresh_age, age);
if (!test_and_set_bit(CACHE_PENDING, &h->flags)) {
switch (cache_make_upcall(detail, h)) {
case -EINVAL:
rv = try_to_negate_entry(detail, h);
break;
case -EAGAIN:
cache_fresh_unlocked(h, detail);
break;
}
}
}
if (rv == -EAGAIN) {
if (!cache_defer_req(rqstp, h)) {
/*
* Request was not deferred; handle it as best
* we can ourselves:
*/
rv = cache_is_valid(h);
if (rv == -EAGAIN)
rv = -ETIMEDOUT;
}
}
if (rv)
cache_put(h, detail);
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 205 | 94.04% | 8 | 61.54% |
J. Bruce Fields | 11 | 5.05% | 3 | 23.08% |
Andi Kleen | 1 | 0.46% | 1 | 7.69% |
Chuck Lever | 1 | 0.46% | 1 | 7.69% |
Total | 218 | 100.00% | 13 | 100.00% |
EXPORT_SYMBOL_GPL(cache_check);
/*
* caches need to be periodically cleaned.
* For this we maintain a list of cache_detail and
* a current pointer into that list and into the table
* for that entry.
*
* Each time cache_clean is called it finds the next non-empty entry
* in the current table and walks the list in that entry
* looking for entries that can be removed.
*
* An entry gets removed if:
* - The expiry is before current time
* - The last_refresh time is before the flush_time for that cache
*
* later we might drop old entries with non-NEVER expiry if that table
* is getting 'full' for some definition of 'full'
*
* The question of "how often to scan a table" is an interesting one
* and is answered in part by the use of the "nextcheck" field in the
* cache_detail.
* When a scan of a table begins, the nextcheck field is set to a time
* that is well into the future.
* While scanning, if an expiry time is found that is earlier than the
* current nextcheck time, nextcheck is set to that expiry time.
* If the flush_time is ever set to a time earlier than the nextcheck
* time, the nextcheck time is then set to that flush_time.
*
* A table is then only scanned if the current time is at least
* the nextcheck time.
*
*/
static LIST_HEAD(cache_list);
static DEFINE_SPINLOCK(cache_list_lock);
static struct cache_detail *current_detail;
static int current_index;
static void do_cache_clean(struct work_struct *work);
static struct delayed_work cache_cleaner;
void sunrpc_init_cache_detail(struct cache_detail *cd)
{
rwlock_init(&cd->hash_lock);
INIT_LIST_HEAD(&cd->queue);
spin_lock(&cache_list_lock);
cd->nextcheck = 0;
cd->entries = 0;
atomic_set(&cd->readers, 0);
cd->last_close = 0;
cd->last_warn = -1;
list_add(&cd->others, &cache_list);
spin_unlock(&cache_list_lock);
/* start the cleaning process */
queue_delayed_work(system_power_efficient_wq, &cache_cleaner, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 55 | 57.89% | 1 | 20.00% |
J. Bruce Fields | 25 | 26.32% | 1 | 20.00% |
Neil Brown | 12 | 12.63% | 2 | 40.00% |
Ke Wang | 3 | 3.16% | 1 | 20.00% |
Total | 95 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_init_cache_detail);
void sunrpc_destroy_cache_detail(struct cache_detail *cd)
{
cache_purge(cd);
spin_lock(&cache_list_lock);
write_lock(&cd->hash_lock);
if (current_detail == cd)
current_detail = NULL;
list_del_init(&cd->others);
write_unlock(&cd->hash_lock);
spin_unlock(&cache_list_lock);
if (list_empty(&cache_list)) {
/* module must be being unloaded so its safe to kill the worker */
cancel_delayed_work_sync(&cache_cleaner);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 43 | 55.13% | 5 | 45.45% |
J. Bruce Fields | 16 | 20.51% | 1 | 9.09% |
Trond Myklebust | 12 | 15.38% | 2 | 18.18% |
Wang Chen | 3 | 3.85% | 1 | 9.09% |
Andrew Morton | 3 | 3.85% | 1 | 9.09% |
Denis V. Lunev | 1 | 1.28% | 1 | 9.09% |
Total | 78 | 100.00% | 11 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_destroy_cache_detail);
/* clean cache tries to find something to clean
* and cleans it.
* It returns 1 if it cleaned something,
* 0 if it didn't find anything this time
* -1 if it fell off the end of the list.
*/
static int cache_clean(void)
{
int rv = 0;
struct list_head *next;
spin_lock(&cache_list_lock);
/* find a suitable table if we don't already have one */
while (current_detail == NULL ||
current_index >= current_detail->hash_size) {
if (current_detail)
next = current_detail->others.next;
else
next = cache_list.next;
if (next == &cache_list) {
current_detail = NULL;
spin_unlock(&cache_list_lock);
return -1;
}
current_detail = list_entry(next, struct cache_detail, others);
if (current_detail->nextcheck > seconds_since_boot())
current_index = current_detail->hash_size;
else {
current_index = 0;
current_detail->nextcheck = seconds_since_boot()+30*60;
}
}
/* find a non-empty bucket in the table */
while (current_detail &&
current_index < current_detail->hash_size &&
hlist_empty(¤t_detail->hash_table[current_index]))
current_index++;
/* find a cleanable entry in the bucket and clean it, or set to next bucket */
if (current_detail && current_index < current_detail->hash_size) {
struct cache_head *ch = NULL;
struct cache_detail *d;
struct hlist_head *head;
struct hlist_node *tmp;
write_lock(¤t_detail->hash_lock);
/* Ok, now to clean this strand */
head = ¤t_detail->hash_table[current_index];
hlist_for_each_entry_safe(ch, tmp, head, cache_list) {
if (current_detail->nextcheck > ch->expiry_time)
current_detail->nextcheck = ch->expiry_time+1;
if (!cache_is_expired(current_detail, ch))
continue;
hlist_del_init(&ch->cache_list);
current_detail->entries--;
rv = 1;
break;
}
write_unlock(¤t_detail->hash_lock);
d = current_detail;
if (!ch)
current_index ++;
spin_unlock(&cache_list_lock);
if (ch) {
set_bit(CACHE_CLEANED, &ch->flags);
cache_fresh_unlocked(ch, d);
cache_put(ch, d);
}
} else
spin_unlock(&cache_list_lock);
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 242 | 72.89% | 10 | 47.62% |
Kinglong Mee | 32 | 9.64% | 1 | 4.76% |
Andrew Morton | 29 | 8.73% | 3 | 14.29% |
J. Bruce Fields | 23 | 6.93% | 4 | 19.05% |
Trond Myklebust | 4 | 1.20% | 2 | 9.52% |
Andi Kleen | 2 | 0.60% | 1 | 4.76% |
Total | 332 | 100.00% | 21 | 100.00% |
/*
* We want to regularly clean the cache, so we need to schedule some work ...
*/
static void do_cache_clean(struct work_struct *work)
{
int delay = 5;
if (cache_clean() == -1)
delay = round_jiffies_relative(30*HZ);
if (list_empty(&cache_list))
delay = 0;
if (delay)
queue_delayed_work(system_power_efficient_wq,
&cache_cleaner, delay);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 49 | 83.05% | 2 | 33.33% |
Ke Wang | 3 | 5.08% | 1 | 16.67% |
David Howells | 3 | 5.08% | 1 | 16.67% |
Anton Blanchard | 3 | 5.08% | 1 | 16.67% |
Adrian Bunk | 1 | 1.69% | 1 | 16.67% |
Total | 59 | 100.00% | 6 | 100.00% |
/*
* Clean all caches promptly. This just calls cache_clean
* repeatedly until we are sure that every cache has had a chance to
* be fully cleaned
*/
void cache_flush(void)
{
while (cache_clean() != -1)
cond_resched();
while (cache_clean() != -1)
cond_resched();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(cache_flush);
void cache_purge(struct cache_detail *detail)
{
struct cache_head *ch = NULL;
struct hlist_head *head = NULL;
struct hlist_node *tmp = NULL;
int i = 0;
write_lock(&detail->hash_lock);
if (!detail->entries) {
write_unlock(&detail->hash_lock);
return;
}
dprintk("RPC: %d entries in %s cache\n", detail->entries, detail->name);
for (i = 0; i < detail->hash_size; i++) {
head = &detail->hash_table[i];
hlist_for_each_entry_safe(ch, tmp, head, cache_list) {
hlist_del_init(&ch->cache_list);
detail->entries--;
set_bit(CACHE_CLEANED, &ch->flags);
write_unlock(&detail->hash_lock);
cache_fresh_unlocked(ch, detail);
cache_put(ch, detail);
write_lock(&detail->hash_lock);
}
}
write_unlock(&detail->hash_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Kinglong Mee | 146 | 83.43% | 1 | 33.33% |
Neil Brown | 29 | 16.57% | 2 | 66.67% |
Total | 175 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(cache_purge);
/*
* Deferral and Revisiting of Requests.
*
* If a cache lookup finds a pending entry, we
* need to defer the request and revisit it later.
* All deferred requests are stored in a hash table,
* indexed by "struct cache_head *".
* As it may be wasteful to store a whole request
* structure, we allow the request to provide a
* deferred form, which must contain a
* 'struct cache_deferred_req'
* This cache_deferred_req contains a method to allow
* it to be revisited when cache info is available
*/
#define DFR_HASHSIZE (PAGE_SIZE/sizeof(struct list_head))
#define DFR_HASH(item) ((((long)item)>>4 ^ (((long)item)>>13)) % DFR_HASHSIZE)
#define DFR_MAX 300
/* ??? */
static DEFINE_SPINLOCK(cache_defer_lock);
static LIST_HEAD(cache_defer_list);
static struct hlist_head cache_defer_hash[DFR_HASHSIZE];
static int cache_defer_cnt;
static void __unhash_deferred_req(struct cache_deferred_req *dreq)
{
hlist_del_init(&dreq->hash);
if (!list_empty(&dreq->recent)) {
list_del_init(&dreq->recent);
cache_defer_cnt--;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 22 | 51.16% | 3 | 60.00% |
J. Bruce Fields | 20 | 46.51% | 1 | 20.00% |
Adrian Bunk | 1 | 2.33% | 1 | 20.00% |
Total | 43 | 100.00% | 5 | 100.00% |
static void __hash_deferred_req(struct cache_deferred_req *dreq, struct cache_head *item)
{
int hash = DFR_HASH(item);
INIT_LIST_HEAD(&dreq->recent);
hlist_add_head(&dreq->hash, &cache_defer_hash[hash]);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
J. Bruce Fields | 25 | 54.35% | 1 | 14.29% |
Neil Brown | 19 | 41.30% | 5 | 71.43% |
Andrew Morton | 2 | 4.35% | 1 | 14.29% |
Total | 46 | 100.00% | 7 | 100.00% |
static void setup_deferral(struct cache_deferred_req *dreq,
struct cache_head *item,
int count_me)
{
dreq->item = item;
spin_lock(&cache_defer_lock);
__hash_deferred_req(dreq, item);
if (count_me) {
cache_defer_cnt++;
list_add(&dreq->recent, &cache_defer_list);
}
spin_unlock(&cache_defer_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 54 | 84.38% | 4 | 50.00% |
J. Bruce Fields | 5 | 7.81% | 2 | 25.00% |
Andrew Morton | 4 | 6.25% | 1 | 12.50% |
Adrian Bunk | 1 | 1.56% | 1 | 12.50% |
Total | 64 | 100.00% | 8 | 100.00% |
struct thread_deferred_req {
struct cache_deferred_req handle;
struct completion completion;
};
static void cache_restart_thread(struct cache_deferred_req *dreq, int too_many)
{
struct thread_deferred_req *dr =
container_of(dreq, struct thread_deferred_req, handle);
complete(&dr->completion);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
J. Bruce Fields | 25 | 67.57% | 1 | 20.00% |
Neil Brown | 12 | 32.43% | 4 | 80.00% |
Total | 37 | 100.00% | 5 | 100.00% |
static void cache_wait_req(struct cache_req *req, struct cache_head *item)
{
struct thread_deferred_req sleeper;
struct cache_deferred_req *dreq = &sleeper.handle;
sleeper.completion = COMPLETION_INITIALIZER_ONSTACK(sleeper.completion);
dreq->revisit = cache_restart_thread;
setup_deferral(dreq, item, 0);
if (!test_bit(CACHE_PENDING, &item->flags) ||
wait_for_completion_interruptible_timeout(
&sleeper.completion, req->thread_wait) <= 0) {
/* The completion wasn't completed, so we need
* to clean up
*/
spin_lock(&cache_defer_lock);
if (!hlist_unhashed(&sleeper.handle.hash)) {
__unhash_deferred_req(&sleeper.handle);
spin_unlock(&cache_defer_lock);
} else {
/* cache_revisit_request already removed
* this from the hash table, but hasn't
* called ->revisit yet. It will very soon
* and we need to wait for it.
*/
spin_unlock(&cache_defer_lock);
wait_for_completion(&sleeper.completion);
}
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 85 | 61.15% | 5 | 71.43% |
J. Bruce Fields | 54 | 38.85% | 2 | 28.57% |
Total | 139 | 100.00% | 7 | 100.00% |
static void cache_limit_defers(void)
{
/* Make sure we haven't exceed the limit of allowed deferred
* requests.
*/
struct cache_deferred_req *discard = NULL;
if (cache_defer_cnt <= DFR_MAX)
return;
spin_lock(&cache_defer_lock);
/* Consider removing either the first or the last */
if (cache_defer_cnt > DFR_MAX) {
if (prandom_u32() & 1)
discard = list_entry(cache_defer_list.next,
struct cache_deferred_req, recent);
else
discard = list_entry(cache_defer_list.prev,
struct cache_deferred_req, recent);
__unhash_deferred_req(discard);
}
spin_unlock(&cache_defer_lock);
if (discard)
discard->revisit(discard, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 74 | 75.51% | 5 | 62.50% |
J. Bruce Fields | 19 | 19.39% | 1 | 12.50% |
Andrew Morton | 4 | 4.08% | 1 | 12.50% |
Aruna-Hewapathirane | 1 | 1.02% | 1 | 12.50% |
Total | 98 | 100.00% | 8 | 100.00% |
/* Return true if and only if a deferred request is queued. */
static bool cache_defer_req(struct cache_req *req, struct cache_head *item)
{
struct cache_deferred_req *dreq;
if (req->thread_wait) {
cache_wait_req(req, item);
if (!test_bit(CACHE_PENDING, &item->flags))
return false;
}
dreq = req->defer(req);
if (dreq == NULL)
return false;
setup_deferral(dreq, item, 1);
if (!test_bit(CACHE_PENDING, &item->flags))
/* Bit could have been cleared before we managed to
* set up the deferral, so need to revisit just in case
*/
cache_revisit_request(item);
cache_limit_defers();
return true;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 67 | 64.42% | 6 | 75.00% |
J. Bruce Fields | 37 | 35.58% | 2 | 25.00% |
Total | 104 | 100.00% | 8 | 100.00% |
static void cache_revisit_request(struct cache_head *item)
{
struct cache_deferred_req *dreq;
struct list_head pending;
struct hlist_node *tmp;
int hash = DFR_HASH(item);
INIT_LIST_HEAD(&pending);
spin_lock(&cache_defer_lock);
hlist_for_each_entry_safe(dreq, tmp, &cache_defer_hash[hash], hash)
if (dreq->item == item) {
__unhash_deferred_req(dreq);
list_add(&dreq->recent, &pending);
}
spin_unlock(&cache_defer_lock);
while (!list_empty(&pending)) {
dreq = list_entry(pending.next, struct cache_deferred_req, recent);
list_del_init(&dreq->recent);
dreq->revisit(dreq, 0);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 115 | 89.15% | 5 | 50.00% |
Trond Myklebust | 6 | 4.65% | 1 | 10.00% |
Thomas Gleixner | 3 | 2.33% | 1 | 10.00% |
J. Bruce Fields | 2 | 1.55% | 1 | 10.00% |
Anton Blanchard | 2 | 1.55% | 1 | 10.00% |
David Howells | 1 | 0.78% | 1 | 10.00% |
Total | 129 | 100.00% | 10 | 100.00% |
void cache_clean_deferred(void *owner)
{
struct cache_deferred_req *dreq, *tmp;
struct list_head pending;
INIT_LIST_HEAD(&pending);
spin_lock(&cache_defer_lock);
list_for_each_entry_safe(dreq, tmp, &cache_defer_list, recent) {
if (dreq->owner == owner) {
__unhash_deferred_req(dreq);
list_add(&dreq->recent, &pending);
}
}
spin_unlock(&cache_defer_lock);
while (!list_empty(&pending)) {
dreq = list_entry(pending.next, struct cache_deferred_req, recent);
list_del_init(&dreq->recent);
dreq->revisit(dreq, 1);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 118 | 99.16% | 3 | 75.00% |
J. Bruce Fields | 1 | 0.84% | 1 | 25.00% |
Total | 119 | 100.00% | 4 | 100.00% |
/*
* communicate with user-space
*
* We have a magic /proc file - /proc/net/rpc/<cachename>/channel.
* On read, you get a full request, or block.
* On write, an update request is processed.
* Poll works if anything to read, and always allows write.
*
* Implemented by linked list of requests. Each open file has
* a ->private that also exists in this list. New requests are added
* to the end and may wakeup and preceding readers.
* New readers are added to the head. If, on read, an item is found with
* CACHE_UPCALLING clear, we free it from the list.
*
*/
static DEFINE_SPINLOCK(queue_lock);
static DEFINE_MUTEX(queue_io_mutex);
struct cache_queue {
struct list_head list;
int reader; /* if 0, then request */
};
struct cache_request {
struct cache_queue q;
struct cache_head *item;
char * buf;
int len;
int readers;
};
struct cache_reader {
struct cache_queue q;
int offset; /* if non-0, we have a refcnt on next request */
};
static int cache_request(struct cache_detail *detail,
struct cache_request *crq)
{
char *bp = crq->buf;
int len = PAGE_SIZE;
detail->cache_request(detail, crq->item, &bp, &len);
if (len < 0)
return -EAGAIN;
return PAGE_SIZE - len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stanislav Kinsbursky | 61 | 100.00% | 1 | 100.00% |
Total | 61 | 100.00% | 1 | 100.00% |
static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
loff_t *ppos, struct cache_detail *cd)
{
struct cache_reader *rp = filp->private_data;
struct cache_request *rq;
struct inode *inode = file_inode(filp);
int err;
if (count == 0)
return 0;
inode_lock(inode); /* protect against multiple concurrent
* readers on this file */
again:
spin_lock(&queue_lock);
/* need to find next request */
while (rp->q.list.next != &cd->queue &&
list_entry(rp->q.list.next, struct cache_queue, list)
->reader) {
struct list_head *next = rp->q.list.next;
list_move(&rp->q.list, next);
}
if (rp->q.list.next == &cd->queue) {
spin_unlock(&queue_lock);
inode_unlock(inode);
WARN_ON_ONCE(rp->offset);
return 0;
}
rq = container_of(rp->q.list.next, struct cache_request, q.list);
WARN_ON_ONCE(rq->q.reader);
if (rp->offset == 0)
rq->readers++;
spin_unlock(&queue_lock);
if (rq->len == 0) {
err = cache_request(cd, rq);
if (err < 0)
goto out;
rq->len = err;
}
if (rp->offset == 0 && !test_bit(CACHE_PENDING, &rq->item->flags)) {
err = -EAGAIN;
spin_lock(&queue_lock);
list_move(&rp->q.list, &rq->q.list);
spin_unlock(&queue_lock);
} else {
if (rp->offset + count > rq->len)
count = rq->len - rp->offset;
err = -EFAULT;
if (copy_to_user(buf, rq->buf + rp->offset, count))
goto out;
rp->offset += count;
if (rp->offset >= rq->len) {
rp->offset = 0;
spin_lock(&queue_lock);
list_move(&rp->q.list, &rq->q.list);
spin_unlock(&queue_lock);
}
err = 0;
}
out:
if (rp->offset == 0) {
/* need to release rq */
spin_lock(&queue_lock);
rq->readers--;
if (rq->readers == 0 &&
!test_bit(CACHE_PENDING, &rq->item->flags)) {
list_del(&rq->q.list);
spin_unlock(&queue_lock);
cache_put(rq->item, cd);
kfree(rq->buf);
kfree(rq);
} else
spin_unlock(&queue_lock);
}
if (err == -EAGAIN)
goto again;
inode_unlock(inode);
return err ? err : count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 479 | 89.37% | 3 | 27.27% |
Stanislav Kinsbursky | 34 | 6.34% | 1 | 9.09% |
Trond Myklebust | 11 | 2.05% | 2 | 18.18% |
Al Viro | 7 | 1.31% | 3 | 27.27% |
Thomas Gleixner | 3 | 0.56% | 1 | 9.09% |
Weston Andros Adamson | 2 | 0.37% | 1 | 9.09% |
Total | 536 | 100.00% | 11 | 100.00% |
static ssize_t cache_do_downcall(char *kaddr, const char __user *buf,
size_t count, struct cache_detail *cd)
{
ssize_t ret;
if (count == 0)
return -EINVAL;
if (copy_from_user(kaddr, buf, count))
return -EFAULT;
kaddr[count] = '\0';
ret = cd->cache_parse(cd, kaddr, count);
if (!ret)
ret = count;
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 45 | 53.57% | 1 | 25.00% |
Neil Brown | 28 | 33.33% | 1 | 25.00% |
Dan Carpenter | 10 | 11.90% | 1 | 25.00% |
Al Viro | 1 | 1.19% | 1 | 25.00% |
Total | 84 | 100.00% | 4 | 100.00% |
static ssize_t cache_slow_downcall(const char __user *buf,
size_t count, struct cache_detail *cd)
{
static char write_buf[8192]; /* protected by queue_io_mutex */
ssize_t ret = -EINVAL;
if (count >= sizeof(write_buf))
goto out;
mutex_lock(&queue_io_mutex);
ret = cache_do_downcall(write_buf, buf, count, cd);
mutex_unlock(&queue_io_mutex);
out:
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 46.05% | 1 | 25.00% |
Neil Brown | 31 | 40.79% | 1 | 25.00% |
Andrew Morton | 6 | 7.89% | 1 | 25.00% |
Arjan van de Ven | 4 | 5.26% | 1 | 25.00% |
Total | 76 | 100.00% | 4 | 100.00% |
static ssize_t cache_downcall(struct address_space *mapping,
const char __user *buf,
size_t count, struct cache_detail *cd)
{
struct page *page;
char *kaddr;
ssize_t ret = -ENOMEM;
if (count >= PAGE_SIZE)
goto out_slow;
page = find_or_create_page(mapping, 0, GFP_KERNEL);
if (!page)
goto out_slow;
kaddr = kmap(page);
ret = cache_do_downcall(kaddr, buf, count, cd);
kunmap(page);
unlock_page(page);
put_page(page);
return ret;
out_slow:
return cache_slow_downcall(buf, count, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 81 | 68.64% | 1 | 25.00% |
Neil Brown | 34 | 28.81% | 1 | 25.00% |
Kirill A. Shutemov | 2 | 1.69% | 1 | 25.00% |
Kris Katterjohn | 1 | 0.85% | 1 | 25.00% |
Total | 118 | 100.00% | 4 | 100.00% |
static ssize_t cache_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos,
struct cache_detail *cd)
{
struct address_space *mapping = filp->f_mapping;
struct inode *inode = file_inode(filp);
ssize_t ret = -EINVAL;
if (!cd->cache_parse)
goto out;
inode_lock(inode);
ret = cache_downcall(mapping, buf, count, cd);
inode_unlock(inode);
out:
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 49 | 53.26% | 1 | 14.29% |
Trond Myklebust | 36 | 39.13% | 2 | 28.57% |
Al Viro | 6 | 6.52% | 3 | 42.86% |
Andrew Morton | 1 | 1.09% | 1 | 14.29% |
Total | 92 | 100.00% | 7 | 100.00% |
static DECLARE_WAIT_QUEUE_HEAD(queue_wait);
static unsigned int cache_poll(struct file *filp, poll_table *wait,
struct cache_detail *cd)
{
unsigned int mask;
struct cache_reader *rp = filp->private_data;
struct cache_queue *cq;
poll_wait(filp, &queue_wait, wait);
/* alway allow write */
mask = POLLOUT | POLLWRNORM;
if (!rp)
return mask;
spin_lock(&queue_lock);
for (cq= &rp->q; &cq->list != &cd->queue;
cq = list_entry(cq->list.next, struct cache_queue, list))
if (!cq->reader) {
mask |= POLLIN | POLLRDNORM;
break;
}
spin_unlock(&queue_lock);
return mask;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 124 | 95.38% | 2 | 50.00% |
Trond Myklebust | 5 | 3.85% | 1 | 25.00% |
Al Viro | 1 | 0.77% | 1 | 25.00% |
Total | 130 | 100.00% | 4 | 100.00% |
static int cache_ioctl(struct inode *ino, struct file *filp,
unsigned int cmd, unsigned long arg,
struct cache_detail *cd)
{
int len = 0;
struct cache_reader *rp = filp->private_data;
struct cache_queue *cq;
if (cmd != FIONREAD || !rp)
return -EINVAL;
spin_lock(&queue_lock);
/* only find the length remaining in current request,
* or the length of the next request
*/
for (cq= &rp->q; &cq->list != &cd->queue;
cq = list_entry(cq->list.next, struct cache_queue, list))
if (!cq->reader) {
struct cache_request *cr =
container_of(cq, struct cache_request, q);
len = cr->len - rp->offset;
break;
}
spin_unlock(&queue_lock);
return put_user(len, (int __user *)arg);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 151 | 96.18% | 2 | 50.00% |
Trond Myklebust | 5 | 3.18% | 1 | 25.00% |
Al Viro | 1 | 0.64% | 1 | 25.00% |
Total | 157 | 100.00% | 4 | 100.00% |
static int cache_open(struct inode *inode, struct file *filp,
struct cache_detail *cd)
{
struct cache_reader *rp = NULL;
if (!cd || !try_module_get(cd->owner))
return -EACCES;
nonseekable_open(inode, filp);
if (filp->f_mode & FMODE_READ) {
rp = kmalloc(sizeof(*rp), GFP_KERNEL);
if (!rp) {
module_put(cd->owner);
return -ENOMEM;
}
rp->offset = 0;
rp->q.reader = 1;
atomic_inc(&cd->readers);
spin_lock(&queue_lock);
list_add(&rp->q.list, &cd->queue);
spin_unlock(&queue_lock);
}
filp->private_data = rp;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 113 | 74.83% | 3 | 42.86% |
Trond Myklebust | 22 | 14.57% | 2 | 28.57% |
Alexey Khoroshilov | 9 | 5.96% | 1 | 14.29% |
Linus Torvalds | 7 | 4.64% | 1 | 14.29% |
Total | 151 | 100.00% | 7 | 100.00% |
static int cache_release(struct inode *inode, struct file *filp,
struct cache_detail *cd)
{
struct cache_reader *rp = filp->private_data;
if (rp) {
spin_lock(&queue_lock);
if (rp->offset) {
struct cache_queue *cq;
for (cq= &rp->q; &cq->list != &cd->queue;
cq = list_entry(cq->list.next, struct cache_queue, list))
if (!cq->reader) {
container_of(cq, struct cache_request, q)
->readers--;
break;
}
rp->offset = 0;
}
list_del(&rp->q.list);
spin_unlock(&queue_lock);
filp->private_data = NULL;
kfree(rp);
cd->last_close = seconds_since_boot();
atomic_dec(&cd->readers);
}
module_put(cd->owner);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 158 | 92.40% | 4 | 57.14% |
Trond Myklebust | 12 | 7.02% | 2 | 28.57% |
Andi Kleen | 1 | 0.58% | 1 | 14.29% |
Total | 171 | 100.00% | 7 | 100.00% |
static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch)
{
struct cache_queue *cq, *tmp;
struct cache_request *cr;
struct list_head dequeued;
INIT_LIST_HEAD(&dequeued);
spin_lock(&queue_lock);
list_for_each_entry_safe(cq, tmp, &detail->queue, list)
if (!cq->reader) {
cr = container_of(cq, struct cache_request, q);
if (cr->item != ch)
continue;
if (test_bit(CACHE_PENDING, &ch->flags))
/* Lost a race and it is pending again */
break;
if (cr->readers != 0)
continue;
list_move(&cr->q.list, &dequeued);
}
spin_unlock(&queue_lock);
while (!list_empty(&dequeued)) {
cr = list_entry(dequeued.next, struct cache_request, q.list);
list_del(&cr->q.list);
cache_put(cr->item, detail);
kfree(cr->buf);
kfree(cr);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 185 | 100.00% | 4 | 100.00% |
Total | 185 | 100.00% | 4 | 100.00% |
/*
* Support routines for text-based upcalls.
* Fields are separated by spaces.
* Fields are either mangled to quote space tab newline slosh with slosh
* or a hexified with a leading \x
* Record is terminated with newline.
*
*/
void qword_add(char **bpp, int *lp, char *str)
{
char *bp = *bpp;
int len = *lp;
int ret;
if (len < 0) return;
ret = string_escape_str(str, bp, len, ESCAPE_OCTAL, "\\ \n\t");
if (ret >= len) {
bp += len;
len = -1;
} else {
bp += ret;
len -= ret;
*bp++ = ' ';
len--;
}
*bpp = bp;
*lp = len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 75 | 72.82% | 2 | 50.00% |
Andy Shevchenko | 17 | 16.50% | 1 | 25.00% |
Rasmus Villemoes | 11 | 10.68% | 1 | 25.00% |
Total | 103 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(qword_add);
void qword_addhex(char **bpp, int *lp, char *buf, int blen)
{
char *bp = *bpp;
int len = *lp;
if (len < 0) return;
if (len > 2) {
*bp++ = '\\';
*bp++ = 'x';
len -= 2;
while (blen && len >= 2) {
bp = hex_byte_pack(bp, *buf++);
len -= 2;
blen--;
}
}
if (blen || len<1) len = -1;
else {
*bp++ = ' ';
len--;
}
*bpp = bp;
*lp = len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 122 | 95.31% | 2 | 66.67% |
Andy Shevchenko | 6 | 4.69% | 1 | 33.33% |
Total | 128 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(qword_addhex);
static void warn_no_listener(struct cache_detail *detail)
{
if (detail->last_warn != detail->last_close) {
detail->last_warn = detail->last_close;
if (detail->warn_no_listener)
detail->warn_no_listener(detail, detail->last_close != 0);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 43 | 86.00% | 2 | 50.00% |
Trond Myklebust | 6 | 12.00% | 1 | 25.00% |
Adrian Bunk | 1 | 2.00% | 1 | 25.00% |
Total | 50 | 100.00% | 4 | 100.00% |
static bool cache_listeners_exist(struct cache_detail *detail)
{
if (atomic_read(&detail->readers))
return true;
if (detail->last_close == 0)
/* This cache was never opened */
return false;
if (detail->last_close < seconds_since_boot() - 30)
/*
* We allow for the possibility that someone might
* restart a userspace daemon without restarting the
* server; but after 30 seconds, we give up.
*/
return false;
return true;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
J. Bruce Fields | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
/*
* register an upcall request to user-space and queue it up for read() by the
* upcall daemon.
*
* Each request is at most one page long.
*/
int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
{
char *buf;
struct cache_request *crq;
int ret = 0;
if (!detail->cache_request)
return -EINVAL;
if (!cache_listeners_exist(detail)) {
warn_no_listener(detail);
return -EINVAL;
}
if (test_bit(CACHE_CLEANED, &h->flags))
/* Too late to make an upcall */
return -EAGAIN;
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf)
return -EAGAIN;
crq = kmalloc(sizeof (*crq), GFP_KERNEL);
if (!crq) {
kfree(buf);
return -EAGAIN;
}
crq->q.reader = 0;
crq->buf = buf;
crq->len = 0;
crq->readers = 0;
spin_lock(&queue_lock);
if (test_bit(CACHE_PENDING, &h->flags)) {
crq->item = cache_get(h);
list_add_tail(&crq->q.list, &detail->queue);
} else
/* Lost a race, no longer PENDING, so don't enqueue */
ret = -EAGAIN;
spin_unlock(&queue_lock);
wake_up(&queue_wait);
if (ret == -EAGAIN) {
kfree(buf);
kfree(crq);
}
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 214 | 91.45% | 4 | 44.44% |
Stanislav Kinsbursky | 9 | 3.85% | 2 | 22.22% |
Andrew Morton | 7 | 2.99% | 1 | 11.11% |
J. Bruce Fields | 3 | 1.28% | 1 | 11.11% |
Trond Myklebust | 1 | 0.43% | 1 | 11.11% |
Total | 234 | 100.00% | 9 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);
/*
* parse a message from user-space and pass it
* to an appropriate cache
* Messages are, like requests, separated into fields by
* spaces and dequotes as \xHEXSTRING or embedded \nnn octal
*
* Message is
* reply cachename expiry key ... content....
*
* key and content are both parsed by cache
*/
int qword_get(char **bpp, char *dest, int bufsize)
{
/* return bytes copied, or -1 on error */
char *bp = *bpp;
int len = 0;
while (*bp == ' ') bp++;
if (bp[0] == '\\' && bp[1] == 'x') {
/* HEX STRING */
bp += 2;
while (len < bufsize - 1) {
int h, l;
h = hex_to_bin(bp[0]);
if (h < 0)
break;
l = hex_to_bin(bp[1]);
if (l < 0)
break;
*dest++ = (h << 4) | l;
bp += 2;
len++;
}
} else {
/* text with \nnn octal quoting */
while (*bp != ' ' && *bp != '\n' && *bp && len < bufsize-1) {
if (*bp == '\\' &&
isodigit(bp[1]) && (bp[1] <= '3') &&
isodigit(bp[2]) &&
isodigit(bp[3])) {
int byte = (*++bp -'0');
bp++;
byte = (byte << 3) | (*bp++ - '0');
byte = (byte << 3) | (*bp++ - '0');
*dest++ = byte;
len++;
} else {
*dest++ = *bp++;
len++;
}
}
}
if (*bp != ' ' && *bp != '\n' && *bp != '\0')
return -1;
while (*bp == ' ') bp++;
*bpp = bp;
*dest = '\0';
return len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 272 | 86.90% | 3 | 60.00% |
Andy Shevchenko | 39 | 12.46% | 1 | 20.00% |
Stefan Hajnoczi | 2 | 0.64% | 1 | 20.00% |
Total | 313 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(qword_get);
/*
* support /proc/net/rpc/$CACHENAME/content
* as a seqfile.
* We call ->cache_show passing NULL for the item to
* get a header, then pass each real item in the cache
*/
void *cache_seq_start(struct seq_file *m, loff_t *pos)
__acquires(cd->hash_lock)
{
loff_t n = *pos;
unsigned int hash, entry;
struct cache_head *ch;
struct cache_detail *cd = m->private;
read_lock(&cd->hash_lock);
if (!n--)
return SEQ_START_TOKEN;
hash = n >> 32;
entry = n & ((1LL<<32) - 1);
hlist_for_each_entry(ch, &cd->hash_table[hash], cache_list)
if (!entry--)
return ch;
n &= ~((1LL<<32) - 1);
do {
hash++;
n += 1LL<<32;
} while(hash < cd->hash_size &&
hlist_empty(&cd->hash_table[hash]));
if (hash >= cd->hash_size)
return NULL;
*pos = n+1;
return hlist_entry_safe(cd->hash_table[hash].first,
struct cache_head, cache_list);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 151 | 82.97% | 1 | 16.67% |
Kinglong Mee | 23 | 12.64% | 2 | 33.33% |
Eric Dumazet | 7 | 3.85% | 2 | 33.33% |
Joe Perches | 1 | 0.55% | 1 | 16.67% |
Total | 182 | 100.00% | 6 | 100.00% |
EXPORT_SYMBOL_GPL(cache_seq_start);
void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
{
struct cache_head *ch = p;
int hash = (*pos >> 32);
struct cache_detail *cd = m->private;
if (p == SEQ_START_TOKEN)
hash = 0;
else if (ch->cache_list.next == NULL) {
hash++;
*pos += 1LL<<32;
} else {
++*pos;
return hlist_entry_safe(ch->cache_list.next,
struct cache_head, cache_list);
}
*pos &= ~((1LL<<32) - 1);
while (hash < cd->hash_size &&
hlist_empty(&cd->hash_table[hash])) {
hash++;
*pos += 1LL<<32;
}
if (hash >= cd->hash_size)
return NULL;
++*pos;
return hlist_entry_safe(cd->hash_table[hash].first,
struct cache_head, cache_list);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 150 | 84.27% | 1 | 25.00% |
Kinglong Mee | 27 | 15.17% | 2 | 50.00% |
Joe Perches | 1 | 0.56% | 1 | 25.00% |
Total | 178 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(cache_seq_next);
void cache_seq_stop(struct seq_file *m, void *p)
__releases(cd->hash_lock)
{
struct cache_detail *cd = m->private;
read_unlock(&cd->hash_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 30 | 81.08% | 1 | 33.33% |
Eric Dumazet | 6 | 16.22% | 1 | 33.33% |
Kinglong Mee | 1 | 2.70% | 1 | 33.33% |
Total | 37 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(cache_seq_stop);
static int c_show(struct seq_file *m, void *p)
{
struct cache_head *cp = p;
struct cache_detail *cd = m->private;
if (p == SEQ_START_TOKEN)
return cd->cache_show(m, cd, NULL);
ifdebug(CACHE)
seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
convert_to_wallclock(cp->expiry_time),
kref_read(&cp->ref), cp->flags);
cache_get(cp);
if (cache_check(cd, cp, NULL))
/* cache_check does a cache_put on failure */
seq_printf(m, "# ");
else {
if (cache_is_expired(cd, cp))
seq_printf(m, "# ");
cache_put(cp, cd);
}
return cd->cache_show(m, cd, cp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 139 | 98.58% | 6 | 75.00% |
Peter Zijlstra | 1 | 0.71% | 1 | 12.50% |
Joe Perches | 1 | 0.71% | 1 | 12.50% |
Total | 141 | 100.00% | 8 | 100.00% |
static const struct seq_operations cache_content_op = {
.start = cache_seq_start,
.next = cache_seq_next,
.stop = cache_seq_stop,
.show = c_show,
};
static int content_open(struct inode *inode, struct file *file,
struct cache_detail *cd)
{
struct seq_file *seq;
int err;
if (!cd || !try_module_get(cd->owner))
return -EACCES;
err = seq_open(file, &cache_content_op);
if (err) {
module_put(cd->owner);
return err;
}
seq = file->private_data;
seq->private = cd;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 34 | 39.08% | 1 | 16.67% |
Trond Myklebust | 22 | 25.29% | 2 | 33.33% |
Kinglong Mee | 17 | 19.54% | 1 | 16.67% |
Li Zefan | 9 | 10.34% | 1 | 16.67% |
Pavel Emelyanov | 5 | 5.75% | 1 | 16.67% |
Total | 87 | 100.00% | 6 | 100.00% |
static int content_release(struct inode *inode, struct file *file,
struct cache_detail *cd)
{
int ret = seq_release(inode, file);
module_put(cd->owner);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 40 | 97.56% | 1 | 50.00% |
Kinglong Mee | 1 | 2.44% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
static int open_flush(struct inode *inode, struct file *file,
struct cache_detail *cd)
{
if (!cd || !try_module_get(cd->owner))
return -EACCES;
return nonseekable_open(inode, file);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 46 | 100.00% | 1 | 100.00% |
Total | 46 | 100.00% | 1 | 100.00% |
static int release_flush(struct inode *inode, struct file *file,
struct cache_detail *cd)
{
module_put(cd->owner);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
static ssize_t read_flush(struct file *file, char __user *buf,
size_t count, loff_t *ppos,
struct cache_detail *cd)
{
char tbuf[22];
size_t len;
len = snprintf(tbuf, sizeof(tbuf), "%lu\n",
convert_to_wallclock(cd->flush_time));
return simple_read_from_buffer(buf, count, ppos, tbuf, len);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 53 | 73.61% | 2 | 28.57% |
Kinglong Mee | 7 | 9.72% | 1 | 14.29% |
Sasha Levin | 7 | 9.72% | 1 | 14.29% |
Trond Myklebust | 3 | 4.17% | 1 | 14.29% |
Chuck Lever | 1 | 1.39% | 1 | 14.29% |
Al Viro | 1 | 1.39% | 1 | 14.29% |
Total | 72 | 100.00% | 7 | 100.00% |
static ssize_t write_flush(struct file *file, const char __user *buf,
size_t count, loff_t *ppos,
struct cache_detail *cd)
{
char tbuf[20];
char *bp, *ep;
time_t then, now;
if (*ppos || count > sizeof(tbuf)-1)
return -EINVAL;
if (copy_from_user(tbuf, buf, count))
return -EFAULT;
tbuf[count] = 0;
simple_strtoul(tbuf, &ep, 0);
if (*ep && *ep != '\n')
return -EINVAL;
bp = tbuf;
then = get_expiry(&bp);
now = seconds_since_boot();
cd->nextcheck = now;
/* Can only set flush_time to 1 second beyond "now", or
* possibly 1 second beyond flushtime. This is because
* flush_time never goes backwards so it mustn't get too far
* ahead of time.
*/
if (then >= now) {
/* Want to flush everything, so behave like cache_purge() */
if (cd->flush_time >= now)
now = cd->flush_time + 1;
then = now;
}
cd->flush_time = then;
cache_flush();
*ppos += count;
return count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 177 | 97.79% | 3 | 60.00% |
Trond Myklebust | 3 | 1.66% | 1 | 20.00% |
Al Viro | 1 | 0.55% | 1 | 20.00% |
Total | 181 | 100.00% | 5 | 100.00% |
static ssize_t cache_read_procfs(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = PDE_DATA(file_inode(filp));
return cache_read(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 43 | 86.00% | 1 | 25.00% |
Al Viro | 4 | 8.00% | 2 | 50.00% |
Neil Brown | 3 | 6.00% | 1 | 25.00% |
Total | 50 | 100.00% | 4 | 100.00% |
static ssize_t cache_write_procfs(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = PDE_DATA(file_inode(filp));
return cache_write(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 47 | 92.16% | 1 | 33.33% |
Al Viro | 4 | 7.84% | 2 | 66.67% |
Total | 51 | 100.00% | 3 | 100.00% |
static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
{
struct cache_detail *cd = PDE_DATA(file_inode(filp));
return cache_poll(filp, wait, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 34 | 87.18% | 1 | 25.00% |
Al Viro | 4 | 10.26% | 2 | 50.00% |
Neil Brown | 1 | 2.56% | 1 | 25.00% |
Total | 39 | 100.00% | 4 | 100.00% |
static long cache_ioctl_procfs(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(filp);
struct cache_detail *cd = PDE_DATA(inode);
return cache_ioctl(inode, filp, cmd, arg, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 40 | 75.47% | 1 | 20.00% |
Frédéric Weisbecker | 8 | 15.09% | 1 | 20.00% |
Al Viro | 4 | 7.55% | 2 | 40.00% |
Arnd Bergmann | 1 | 1.89% | 1 | 20.00% |
Total | 53 | 100.00% | 5 | 100.00% |
static int cache_open_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return cache_open(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static int cache_release_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return cache_release(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static const struct file_operations cache_file_operations_procfs = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = cache_read_procfs,
.write = cache_write_procfs,
.poll = cache_poll_procfs,
.unlocked_ioctl = cache_ioctl_procfs, /* for FIONREAD */
.open = cache_open_procfs,
.release = cache_release_procfs,
};
static int content_open_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return content_open(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static int content_release_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return content_release(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static const struct file_operations content_file_operations_procfs = {
.open = content_open_procfs,
.read = seq_read,
.llseek = seq_lseek,
.release = content_release_procfs,
};
static int open_flush_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return open_flush(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static int release_flush_procfs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = PDE_DATA(inode);
return release_flush(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 35 | 97.22% | 1 | 50.00% |
Al Viro | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static ssize_t read_flush_procfs(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = PDE_DATA(file_inode(filp));
return read_flush(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 46 | 92.00% | 1 | 33.33% |
Al Viro | 4 | 8.00% | 2 | 66.67% |
Total | 50 | 100.00% | 3 | 100.00% |
static ssize_t write_flush_procfs(struct file *filp,
const char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = PDE_DATA(file_inode(filp));
return write_flush(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 47 | 92.16% | 1 | 33.33% |
Al Viro | 4 | 7.84% | 2 | 66.67% |
Total | 51 | 100.00% | 3 | 100.00% |
static const struct file_operations cache_flush_operations_procfs = {
.open = open_flush_procfs,
.read = read_flush_procfs,
.write = write_flush_procfs,
.release = release_flush_procfs,
.llseek = no_llseek,
};
static void remove_cache_proc_entries(struct cache_detail *cd)
{
if (cd->procfs) {
proc_remove(cd->procfs);
cd->procfs = NULL;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 29 | 90.62% | 1 | 50.00% |
Kinglong Mee | 3 | 9.38% | 1 | 50.00% |
Total | 32 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_PROC_FS
static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
{
struct proc_dir_entry *p;
struct sunrpc_net *sn;
sn = net_generic(net, sunrpc_net_id);
cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc);
if (cd->procfs == NULL)
goto out_nomem;
p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
cd->procfs, &cache_flush_operations_procfs, cd);
if (p == NULL)
goto out_nomem;
if (cd->cache_request || cd->cache_parse) {
p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
cd->procfs, &cache_file_operations_procfs, cd);
if (p == NULL)
goto out_nomem;
}
if (cd->cache_show) {
p = proc_create_data("content", S_IFREG|S_IRUSR,
cd->procfs, &content_file_operations_procfs, cd);
if (p == NULL)
goto out_nomem;
}
return 0;
out_nomem:
remove_cache_proc_entries(cd);
return -ENOMEM;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 162 | 87.10% | 2 | 33.33% |
Pavel Emelyanov | 21 | 11.29% | 2 | 33.33% |
Neil Brown | 2 | 1.08% | 1 | 16.67% |
Stanislav Kinsbursky | 1 | 0.54% | 1 | 16.67% |
Total | 186 | 100.00% | 6 | 100.00% |
#else /* CONFIG_PROC_FS */
static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
{
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 7 | 36.84% | 1 | 25.00% |
Neil Brown | 5 | 26.32% | 1 | 25.00% |
Pavel Emelyanov | 5 | 26.32% | 1 | 25.00% |
Eric Dumazet | 2 | 10.53% | 1 | 25.00% |
Total | 19 | 100.00% | 4 | 100.00% |
#endif
void __init cache_initialize(void)
{
INIT_DEFERRABLE_WORK(&cache_cleaner, do_cache_clean);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Artem B. Bityutskiy | 15 | 93.75% | 1 | 50.00% |
Tejun Heo | 1 | 6.25% | 1 | 50.00% |
Total | 16 | 100.00% | 2 | 100.00% |
int cache_register_net(struct cache_detail *cd, struct net *net)
{
int ret;
sunrpc_init_cache_detail(cd);
ret = create_cache_proc_entries(cd, net);
if (ret)
sunrpc_destroy_cache_detail(cd);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 19 | 43.18% | 1 | 33.33% |
Trond Myklebust | 17 | 38.64% | 1 | 33.33% |
Pavel Emelyanov | 8 | 18.18% | 1 | 33.33% |
Total | 44 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(cache_register_net);
void cache_unregister_net(struct cache_detail *cd, struct net *net)
{
remove_cache_proc_entries(cd);
sunrpc_destroy_cache_detail(cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pavel Emelyanov | 17 | 68.00% | 1 | 33.33% |
Trond Myklebust | 7 | 28.00% | 1 | 33.33% |
Neil Brown | 1 | 4.00% | 1 | 33.33% |
Total | 25 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(cache_unregister_net);
struct cache_detail *cache_create_net(struct cache_detail *tmpl, struct net *net)
{
struct cache_detail *cd;
int i;
cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL);
if (cd == NULL)
return ERR_PTR(-ENOMEM);
cd->hash_table = kzalloc(cd->hash_size * sizeof(struct hlist_head),
GFP_KERNEL);
if (cd->hash_table == NULL) {
kfree(cd);
return ERR_PTR(-ENOMEM);
}
for (i = 0; i < cd->hash_size; i++)
INIT_HLIST_HEAD(&cd->hash_table[i]);
cd->net = net;
return cd;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stanislav Kinsbursky | 78 | 60.47% | 1 | 20.00% |
Kinglong Mee | 30 | 23.26% | 1 | 20.00% |
Trond Myklebust | 14 | 10.85% | 1 | 20.00% |
Pavel Emelyanov | 6 | 4.65% | 1 | 20.00% |
Neil Brown | 1 | 0.78% | 1 | 20.00% |
Total | 129 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(cache_create_net);
void cache_destroy_net(struct cache_detail *cd, struct net *net)
{
kfree(cd->hash_table);
kfree(cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stanislav Kinsbursky | 14 | 51.85% | 1 | 50.00% |
Pavel Emelyanov | 13 | 48.15% | 1 | 50.00% |
Total | 27 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(cache_destroy_net);
static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return cache_read(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 30 | 57.69% | 1 | 33.33% |
Neil Brown | 19 | 36.54% | 1 | 33.33% |
Al Viro | 3 | 5.77% | 1 | 33.33% |
Total | 52 | 100.00% | 3 | 100.00% |
static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return cache_write(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 45 | 84.91% | 1 | 33.33% |
Neil Brown | 5 | 9.43% | 1 | 33.33% |
Al Viro | 3 | 5.66% | 1 | 33.33% |
Total | 53 | 100.00% | 3 | 100.00% |
static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return cache_poll(filp, wait, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 20 | 48.78% | 1 | 25.00% |
Neil Brown | 17 | 41.46% | 1 | 25.00% |
Al Viro | 3 | 7.32% | 1 | 25.00% |
Eric Dumazet | 1 | 2.44% | 1 | 25.00% |
Total | 41 | 100.00% | 4 | 100.00% |
static long cache_ioctl_pipefs(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(filp);
struct cache_detail *cd = RPC_I(inode)->private;
return cache_ioctl(inode, filp, cmd, arg, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 22 | 40.00% | 1 | 14.29% |
Neil Brown | 21 | 38.18% | 3 | 42.86% |
Frédéric Weisbecker | 8 | 14.55% | 1 | 14.29% |
Al Viro | 3 | 5.45% | 1 | 14.29% |
Arnd Bergmann | 1 | 1.82% | 1 | 14.29% |
Total | 55 | 100.00% | 7 | 100.00% |
static int cache_open_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return cache_open(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 32 | 84.21% | 1 | 33.33% |
Neil Brown | 6 | 15.79% | 2 | 66.67% |
Total | 38 | 100.00% | 3 | 100.00% |
static int cache_release_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return cache_release(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 30 | 78.95% | 1 | 50.00% |
Neil Brown | 8 | 21.05% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
const struct file_operations cache_file_operations_pipefs = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = cache_read_pipefs,
.write = cache_write_pipefs,
.poll = cache_poll_pipefs,
.unlocked_ioctl = cache_ioctl_pipefs, /* for FIONREAD */
.open = cache_open_pipefs,
.release = cache_release_pipefs,
};
static int content_open_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return content_open(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 26 | 68.42% | 1 | 33.33% |
Trond Myklebust | 10 | 26.32% | 1 | 33.33% |
Pavel Emelyanov | 2 | 5.26% | 1 | 33.33% |
Total | 38 | 100.00% | 3 | 100.00% |
static int content_release_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return content_release(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 34 | 89.47% | 1 | 50.00% |
Neil Brown | 4 | 10.53% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
const struct file_operations content_file_operations_pipefs = {
.open = content_open_pipefs,
.read = seq_read,
.llseek = seq_lseek,
.release = content_release_pipefs,
};
static int open_flush_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return open_flush(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 37 | 97.37% | 1 | 50.00% |
Neil Brown | 1 | 2.63% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static int release_flush_pipefs(struct inode *inode, struct file *filp)
{
struct cache_detail *cd = RPC_I(inode)->private;
return release_flush(inode, filp, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 34 | 89.47% | 1 | 50.00% |
Neil Brown | 4 | 10.53% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return read_flush(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 30 | 57.69% | 1 | 25.00% |
Trond Myklebust | 18 | 34.62% | 1 | 25.00% |
Al Viro | 4 | 7.69% | 2 | 50.00% |
Total | 52 | 100.00% | 4 | 100.00% |
static ssize_t write_flush_pipefs(struct file *filp,
const char __user *buf,
size_t count, loff_t *ppos)
{
struct cache_detail *cd = RPC_I(file_inode(filp))->private;
return write_flush(filp, buf, count, ppos, cd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 37 | 69.81% | 1 | 25.00% |
Trond Myklebust | 12 | 22.64% | 1 | 25.00% |
Al Viro | 4 | 7.55% | 2 | 50.00% |
Total | 53 | 100.00% | 4 | 100.00% |
const struct file_operations cache_flush_operations_pipefs = {
.open = open_flush_pipefs,
.read = read_flush_pipefs,
.write = write_flush_pipefs,
.release = release_flush_pipefs,
.llseek = no_llseek,
};
int sunrpc_cache_register_pipefs(struct dentry *parent,
const char *name, umode_t umode,
struct cache_detail *cd)
{
struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd);
if (IS_ERR(dir))
return PTR_ERR(dir);
cd->pipefs = dir;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 38 | 62.30% | 1 | 25.00% |
Neil Brown | 13 | 21.31% | 1 | 25.00% |
Al Viro | 10 | 16.39% | 2 | 50.00% |
Total | 61 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
{
if (cd->pipefs) {
rpc_remove_cache_dir(cd->pipefs);
cd->pipefs = NULL;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Trond Myklebust | 20 | 64.52% | 1 | 33.33% |
Kinglong Mee | 8 | 25.81% | 1 | 33.33% |
Neil Brown | 3 | 9.68% | 1 | 33.33% |
Total | 31 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)
{
write_lock(&cd->hash_lock);
if (!hlist_unhashed(&h->cache_list)){
hlist_del_init(&h->cache_list);
cd->entries--;
write_unlock(&cd->hash_lock);
cache_put(h, cd);
} else
write_unlock(&cd->hash_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 73 | 100.00% | 1 | 100.00% |
Total | 73 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(sunrpc_cache_unhash);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Brown | 5303 | 61.06% | 43 | 32.58% |
Trond Myklebust | 1814 | 20.89% | 9 | 6.82% |
J. Bruce Fields | 422 | 4.86% | 11 | 8.33% |
Kinglong Mee | 370 | 4.26% | 7 | 5.30% |
Stanislav Kinsbursky | 227 | 2.61% | 5 | 3.79% |
Andrew Morton | 99 | 1.14% | 5 | 3.79% |
Pavel Emelyanov | 80 | 0.92% | 3 | 2.27% |
Al Viro | 78 | 0.90% | 7 | 5.30% |
Andy Shevchenko | 65 | 0.75% | 3 | 2.27% |
Adrian Bunk | 31 | 0.36% | 2 | 1.52% |
Frédéric Weisbecker | 20 | 0.23% | 3 | 2.27% |
Artem B. Bityutskiy | 18 | 0.21% | 1 | 0.76% |
Thomas Gleixner | 16 | 0.18% | 1 | 0.76% |
Eric Dumazet | 16 | 0.18% | 2 | 1.52% |
Arnd Bergmann | 12 | 0.14% | 2 | 1.52% |
Rasmus Villemoes | 11 | 0.13% | 1 | 0.76% |
Arjan van de Ven | 10 | 0.12% | 2 | 1.52% |
Dan Carpenter | 10 | 0.12% | 1 | 0.76% |
Li Zefan | 9 | 0.10% | 1 | 0.76% |
Alexey Khoroshilov | 9 | 0.10% | 1 | 0.76% |
Linus Torvalds | 8 | 0.09% | 2 | 1.52% |
Sasha Levin | 7 | 0.08% | 1 | 0.76% |
David Howells | 7 | 0.08% | 1 | 0.76% |
Ke Wang | 6 | 0.07% | 1 | 0.76% |
Anton Blanchard | 5 | 0.06% | 1 | 0.76% |
Andi Kleen | 5 | 0.06% | 1 | 0.76% |
Joe Perches | 3 | 0.03% | 1 | 0.76% |
Christoph Hellwig | 3 | 0.03% | 1 | 0.76% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 0.03% | 1 | 0.76% |
Wang Chen | 3 | 0.03% | 1 | 0.76% |
Philippe De Muyter | 2 | 0.02% | 1 | 0.76% |
Stefan Hajnoczi | 2 | 0.02% | 1 | 0.76% |
Weston Andros Adamson | 2 | 0.02% | 1 | 0.76% |
Chuck Lever | 2 | 0.02% | 2 | 1.52% |
Kirill A. Shutemov | 2 | 0.02% | 1 | 0.76% |
Aruna-Hewapathirane | 1 | 0.01% | 1 | 0.76% |
Kris Katterjohn | 1 | 0.01% | 1 | 0.76% |
Tejun Heo | 1 | 0.01% | 1 | 0.76% |
Peter Zijlstra | 1 | 0.01% | 1 | 0.76% |
Denis V. Lunev | 1 | 0.01% | 1 | 0.76% |
Total | 8685 | 100.00% | 132 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.