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
9 #include <linux/sched.h>
14 #define UC_CACHE_NEW 0x01
15 #define UC_CACHE_ACQUIRING 0x02
16 #define UC_CACHE_INVALID 0x04
17 #define UC_CACHE_EXPIRED 0x08
19 #define UC_CACHE_IS_NEW(i) ((i)->ue_flags & UC_CACHE_NEW)
20 #define UC_CACHE_IS_INVALID(i) ((i)->ue_flags & UC_CACHE_INVALID)
21 #define UC_CACHE_IS_ACQUIRING(i) ((i)->ue_flags & UC_CACHE_ACQUIRING)
22 #define UC_CACHE_IS_EXPIRED(i) ((i)->ue_flags & UC_CACHE_EXPIRED)
23 #define UC_CACHE_IS_VALID(i) ((i)->ue_flags == 0)
25 #define UC_CACHE_SET_NEW(i) (i)->ue_flags |= UC_CACHE_NEW
26 #define UC_CACHE_SET_INVALID(i) (i)->ue_flags |= UC_CACHE_INVALID
27 #define UC_CACHE_SET_ACQUIRING(i) (i)->ue_flags |= UC_CACHE_ACQUIRING
28 #define UC_CACHE_SET_EXPIRED(i) (i)->ue_flags |= UC_CACHE_EXPIRED
29 #define UC_CACHE_SET_VALID(i) (i)->ue_flags = 0
31 #define UC_CACHE_CLEAR_NEW(i) (i)->ue_flags &= ~UC_CACHE_NEW
32 #define UC_CACHE_CLEAR_ACQUIRING(i) (i)->ue_flags &= ~UC_CACHE_ACQUIRING
33 #define UC_CACHE_CLEAR_INVALID(i) (i)->ue_flags &= ~UC_CACHE_INVALID
34 #define UC_CACHE_CLEAR_EXPIRED(i) (i)->ue_flags &= ~UC_CACHE_EXPIRED
36 struct upcall_cache_entry;
38 struct mdt_setxid_perm {
44 struct upcall_cache_entry *mi_uc_entry;
47 struct group_info *mi_ginfo;
49 struct mdt_setxid_perm *mi_perms;
52 struct rmtacl_upcall_data {
63 struct upcall_cache_entry {
64 struct list_head ue_hash;
67 // struct group_info *ue_group_info;
71 cfs_time_t ue_acquire_expire;
74 struct mdt_identity identity;
75 struct mdt_rmtacl acl;
79 #define UC_CACHE_HASH_SIZE (128)
80 #define UC_CACHE_HASH_INDEX(id) ((id) & (UC_CACHE_HASH_SIZE - 1))
81 #define UC_CACHE_UPCALL_MAXPATH (1024UL)
85 struct upcall_cache_ops {
86 void (*init_entry)(struct upcall_cache_entry *, void *args);
87 void (*free_entry)(struct upcall_cache *,
88 struct upcall_cache_entry *);
89 int (*upcall_compare)(struct upcall_cache *,
90 struct upcall_cache_entry *,
91 __u64 key, void *args);
92 int (*downcall_compare)(struct upcall_cache *,
93 struct upcall_cache_entry *,
94 __u64 key, void *args);
95 int (*do_upcall)(struct upcall_cache *,
96 struct upcall_cache_entry *);
97 int (*parse_downcall)(struct upcall_cache *,
98 struct upcall_cache_entry *, void *);
101 struct upcall_cache {
102 struct list_head uc_hashtable[UC_CACHE_HASH_SIZE];
105 char uc_name[40]; /* for upcall */
106 char uc_upcall[UC_CACHE_UPCALL_MAXPATH];
107 cfs_time_t uc_acquire_expire; /* jiffies */
108 cfs_time_t uc_entry_expire; /* jiffies */
109 struct upcall_cache_ops *uc_ops;
112 struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache,
113 __u64 key, void *args);
114 void upcall_cache_put_entry(struct upcall_cache *cache,
115 struct upcall_cache_entry *entry);
116 int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key,
118 void upcall_cache_flush_idle(struct upcall_cache *cache);
119 void upcall_cache_flush_all(struct upcall_cache *cache);
120 void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args);
121 struct upcall_cache *upcall_cache_init(const char *name, const char *upcall,
122 struct upcall_cache_ops *ops);
123 void upcall_cache_cleanup(struct upcall_cache *cache);
126 struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *hash,
127 __u64 key, __u32 primary,
128 __u32 ngroups, __u32 *groups);
129 void upcall_cache_put_entry(struct upcall_cache *hash,
130 struct upcall_cache_entry *entry);
131 int upcall_cache_downcall(struct upcall_cache *hash, __u32 err, __u64 key,
132 __u32 primary, __u32 ngroups, __u32 *groups);
133 void upcall_cache_flush_idle(struct upcall_cache *cache);
134 void upcall_cache_flush_all(struct upcall_cache *cache);
135 struct upcall_cache *upcall_cache_init(const char *name);
136 void upcall_cache_cleanup(struct upcall_cache *hash);
139 #endif /* _UPCALL_CACHE_H */