1 /* SPDX-License-Identifier: GPL-2.0 */
3 * DFS referral cache routines
8 #ifndef _CIFS_DFS_CACHE_H
9 #define _CIFS_DFS_CACHE_H
11 #include <linux/nls.h>
12 #include <linux/list.h>
13 #include <linux/uuid.h>
16 extern struct workqueue_struct *dfscache_wq;
17 extern atomic_t dfs_cache_ttl;
19 #define DFS_CACHE_TGT_LIST_INIT(var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }
21 struct dfs_cache_tgt_list {
23 struct list_head tl_list;
26 struct dfs_cache_tgt_iterator {
29 struct list_head it_list;
32 int dfs_cache_init(void);
33 void dfs_cache_destroy(void);
34 extern const struct proc_ops dfscache_proc_ops;
36 int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses, const struct nls_table *cp,
37 int remap, const char *path, struct dfs_info3_param *ref,
38 struct dfs_cache_tgt_list *tgt_list);
39 int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
40 struct dfs_cache_tgt_list *tgt_list);
41 void dfs_cache_noreq_update_tgthint(const char *path, const struct dfs_cache_tgt_iterator *it);
42 int dfs_cache_get_tgt_referral(const char *path, const struct dfs_cache_tgt_iterator *it,
43 struct dfs_info3_param *ref);
44 int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
46 char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp, int remap);
47 int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb);
48 void dfs_cache_refresh(struct work_struct *work);
50 static inline struct dfs_cache_tgt_iterator *
51 dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl,
52 struct dfs_cache_tgt_iterator *it)
54 if (!tl || list_empty(&tl->tl_list) || !it ||
55 list_is_last(&it->it_list, &tl->tl_list))
57 return list_next_entry(it, it_list);
60 static inline struct dfs_cache_tgt_iterator *
61 dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list *tl)
65 return list_first_entry_or_null(&tl->tl_list,
66 struct dfs_cache_tgt_iterator,
70 static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list *tl)
72 struct dfs_cache_tgt_iterator *it, *nit;
74 if (!tl || list_empty(&tl->tl_list))
76 list_for_each_entry_safe(it, nit, &tl->tl_list, it_list) {
77 list_del(&it->it_list);
84 static inline const char *
85 dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator *it)
87 return it ? it->it_name : NULL;
91 dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl)
93 return tl ? tl->tl_numtgts : 0;
96 static inline int dfs_cache_get_ttl(void)
98 return atomic_read(&dfs_cache_ttl);
101 #endif /* _CIFS_DFS_CACHE_H */