1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef _UPCALL_CACHE_H
6 #define _UPCALL_CACHE_H
8 #define UC_CACHE_NEW 0x01
9 #define UC_CACHE_ACQUIRING 0x02
10 #define UC_CACHE_INVALID 0x04
11 #define UC_CACHE_EXPIRED 0x08
13 #define UC_CACHE_IS_NEW(i) ((i)->ue_flags & UC_CACHE_NEW)
14 #define UC_CACHE_IS_INVALID(i) ((i)->ue_flags & UC_CACHE_INVALID)
15 #define UC_CACHE_IS_ACQUIRING(i) ((i)->ue_flags & UC_CACHE_ACQUIRING)
16 #define UC_CACHE_IS_EXPIRED(i) ((i)->ue_flags & UC_CACHE_EXPIRED)
17 #define UC_CACHE_IS_VALID(i) ((i)->ue_flags == 0)
19 #define UC_CACHE_SET_NEW(i) (i)->ue_flags |= UC_CACHE_NEW
20 #define UC_CACHE_SET_INVALID(i) (i)->ue_flags |= UC_CACHE_INVALID
21 #define UC_CACHE_SET_ACQUIRING(i) (i)->ue_flags |= UC_CACHE_ACQUIRING
22 #define UC_CACHE_SET_EXPIRED(i) (i)->ue_flags |= UC_CACHE_EXPIRED
23 #define UC_CACHE_SET_VALID(i) (i)->ue_flags = 0
25 #define UC_CACHE_CLEAR_NEW(i) (i)->ue_flags &= ~UC_CACHE_NEW
26 #define UC_CACHE_CLEAR_ACQUIRING(i) (i)->ue_flags &= ~UC_CACHE_ACQUIRING
27 #define UC_CACHE_CLEAR_INVALID(i) (i)->ue_flags &= ~UC_CACHE_INVALID
28 #define UC_CACHE_CLEAR_EXPIRED(i) (i)->ue_flags &= ~UC_CACHE_EXPIRED
30 struct upcall_cache_entry;
38 struct upcall_cache_entry *mi_uc_entry;
41 struct group_info *mi_ginfo;
43 struct md_perm *mi_perms;
46 struct upcall_cache_entry {
47 struct list_head ue_hash;
52 cfs_time_t ue_acquire_expire;
55 struct md_identity identity;
59 #define UC_CACHE_HASH_SIZE (128)
60 #define UC_CACHE_HASH_INDEX(id) ((id) & (UC_CACHE_HASH_SIZE - 1))
61 #define UC_CACHE_UPCALL_MAXPATH (1024UL)
65 struct upcall_cache_ops {
66 void (*init_entry)(struct upcall_cache_entry *, void *args);
67 void (*free_entry)(struct upcall_cache *,
68 struct upcall_cache_entry *);
69 int (*upcall_compare)(struct upcall_cache *,
70 struct upcall_cache_entry *,
71 __u64 key, void *args);
72 int (*downcall_compare)(struct upcall_cache *,
73 struct upcall_cache_entry *,
74 __u64 key, void *args);
75 int (*do_upcall)(struct upcall_cache *,
76 struct upcall_cache_entry *);
77 int (*parse_downcall)(struct upcall_cache *,
78 struct upcall_cache_entry *, void *);
82 struct list_head uc_hashtable[UC_CACHE_HASH_SIZE];
85 char uc_name[40]; /* for upcall */
86 char uc_upcall[UC_CACHE_UPCALL_MAXPATH];
87 cfs_time_t uc_acquire_expire; /* jiffies */
88 cfs_time_t uc_entry_expire; /* jiffies */
89 struct upcall_cache_ops *uc_ops;
92 struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache,
93 __u64 key, void *args);
94 void upcall_cache_put_entry(struct upcall_cache *cache,
95 struct upcall_cache_entry *entry);
96 int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key,
98 void upcall_cache_flush_idle(struct upcall_cache *cache);
99 void upcall_cache_flush_all(struct upcall_cache *cache);
100 void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args);
101 struct upcall_cache *upcall_cache_init(const char *name, const char *upcall,
102 struct upcall_cache_ops *ops);
103 void upcall_cache_cleanup(struct upcall_cache *cache);
106 struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *hash,
107 __u64 key, __u32 primary,
108 __u32 ngroups, __u32 *groups);
109 void upcall_cache_put_entry(struct upcall_cache *hash,
110 struct upcall_cache_entry *entry);
111 int upcall_cache_downcall(struct upcall_cache *hash, __u32 err, __u64 key,
112 __u32 primary, __u32 ngroups, __u32 *groups);
113 void upcall_cache_flush_idle(struct upcall_cache *cache);
114 void upcall_cache_flush_all(struct upcall_cache *cache);
115 struct upcall_cache *upcall_cache_init(const char *name);
116 void upcall_cache_cleanup(struct upcall_cache *hash);
119 #endif /* _UPCALL_CACHE_H */