/* Every cache item has a common header that is used *forexpiringandrefreshingentries. *
*/ struct cache_head { struct hlist_node cache_list;
time64_t expiry_time; /* After time expiry_time, don't use
* the data */
time64_t last_refresh; /* If CACHE_PENDING, this is when upcall was *sent,elsethisiswhenupdatewas *received,thoughitisalwaysetto *be*after*->flush_time.
*/ struct kref ref; unsignedlong flags;
};
/* cache_head.flags */ enum {
CACHE_VALID, /* Entry contains valid data */
CACHE_NEGATIVE, /* Negative entry - there is no match for the key */
CACHE_PENDING, /* An upcall has been sent but no reply received yet*/
CACHE_CLEANED, /* Entry has been cleaned from cache */
};
#define CACHE_NEW_EXPIRY 120/* keep new things pending confirmation for 120 seconds */
/* fields below this comment are for internal use *andshouldnotbetouchedbycacheowners
*/
time64_t flush_time; /* flush all cache items with *last_refreshatorearlier *thanthis.last_refresh *isneversetatorearlier *thanthis.
*/ struct list_head others;
time64_t nextcheck; int entries;
/* fields for communication over channel */ struct list_head queue;
atomic_t writers; /* how many time is /channel open */
time64_t last_close; /* if no writers, when did last close */
time64_t last_warn; /* when we last warned about no writers */
union { struct proc_dir_entry *procfs; struct dentry *pipefs;
}; struct net *net;
};
/* this must be embedded in any request structure that *identifiesanobjectthatwillwantacallbackon *acachefill
*/ struct cache_req { struct cache_deferred_req *(*defer)(struct cache_req *req); unsignedlong thread_wait; /* How long (jiffies) we can block the *currentthreadtowaitforupdates.
*/
};
/* this must be embedded in a deferred_request that is being *delayedawaitingcache-fill
*/ struct cache_deferred_req { struct hlist_node hash; /* on hash chain */ struct list_head recent; /* on fifo */ struct cache_head *item; /* cache item we wait on */ void *owner; /* we might need to discard all defered requests
* owned by someone */ void (*revisit)(struct cache_deferred_req *req, int too_many);
};
/* Must store cache_detail in seq_file->private if using next three functions */ externvoid *cache_seq_start_rcu(struct seq_file *file, loff_t *pos); externvoid *cache_seq_next_rcu(struct seq_file *file, void *p, loff_t *pos); externvoid cache_seq_stop_rcu(struct seq_file *file, void *p);
externvoid qword_add(char **bpp, int *lp, char *str); externvoid qword_addhex(char **bpp, int *lp, char *buf, int blen); externint qword_get(char **bpp, char *dest, int bufsize);
staticinlineint get_int(char **bpp, int *anint)
{ char buf[50]; char *ep; int rv; int len = qword_get(bpp, buf, sizeof(buf));
if (len < 0) return -EINVAL; if (len == 0) return -ENOENT;
rv = simple_strtol(buf, &ep, 0); if (*ep) return -EINVAL;
*anint = rv; return0;
}
staticinlineint get_uint(char **bpp, unsignedint *anint)
{ char buf[50]; int len = qword_get(bpp, buf, sizeof(buf));
if (len < 0) return -EINVAL; if (len == 0) return -ENOENT;
if (kstrtouint(buf, 0, anint)) return -EINVAL;
return0;
}
staticinlineint get_time(char **bpp, time64_t *time)
{ char buf[50]; longlong ll; int len = qword_get(bpp, buf, sizeof(buf));
if (len < 0) return -EINVAL; if (len == 0) return -ENOENT;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.