1 /* SPDX-License-Identifier: GPL-2.0 */
3 * DFS referral cache routines
5 * Copyright (c) 2018-2019 Paulo Alcantara <palcantara@suse.de>
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) \
20 { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }
22 #define DFS_CACHE_TGT_LIST(var) \
23 struct dfs_cache_tgt_list var = DFS_CACHE_TGT_LIST_INIT(var)
25 struct dfs_cache_tgt_list
{
27 struct list_head tl_list
;
30 struct dfs_cache_tgt_iterator
{
33 struct list_head it_list
;
36 int dfs_cache_init(void);
37 void dfs_cache_destroy(void);
38 extern const struct proc_ops dfscache_proc_ops
;
40 int dfs_cache_find(const unsigned int xid
, struct cifs_ses
*ses
, const struct nls_table
*cp
,
41 int remap
, const char *path
, struct dfs_info3_param
*ref
,
42 struct dfs_cache_tgt_list
*tgt_list
);
43 int dfs_cache_noreq_find(const char *path
, struct dfs_info3_param
*ref
,
44 struct dfs_cache_tgt_list
*tgt_list
);
45 void dfs_cache_noreq_update_tgthint(const char *path
, const struct dfs_cache_tgt_iterator
*it
);
46 int dfs_cache_get_tgt_referral(const char *path
, const struct dfs_cache_tgt_iterator
*it
,
47 struct dfs_info3_param
*ref
);
48 int dfs_cache_get_tgt_share(char *path
, const struct dfs_cache_tgt_iterator
*it
, char **share
,
50 char *dfs_cache_canonical_path(const char *path
, const struct nls_table
*cp
, int remap
);
51 int dfs_cache_remount_fs(struct cifs_sb_info
*cifs_sb
);
52 void dfs_cache_refresh(struct work_struct
*work
);
54 static inline struct dfs_cache_tgt_iterator
*
55 dfs_cache_get_next_tgt(struct dfs_cache_tgt_list
*tl
,
56 struct dfs_cache_tgt_iterator
*it
)
58 if (!tl
|| !tl
->tl_numtgts
|| list_empty(&tl
->tl_list
) ||
59 !it
|| list_is_last(&it
->it_list
, &tl
->tl_list
))
61 return list_next_entry(it
, it_list
);
64 static inline struct dfs_cache_tgt_iterator
*
65 dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list
*tl
)
69 return list_first_entry_or_null(&tl
->tl_list
,
70 struct dfs_cache_tgt_iterator
,
74 static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list
*tl
)
76 struct dfs_cache_tgt_iterator
*it
, *nit
;
78 if (!tl
|| !tl
->tl_numtgts
|| list_empty(&tl
->tl_list
))
80 list_for_each_entry_safe(it
, nit
, &tl
->tl_list
, it_list
) {
81 list_del(&it
->it_list
);
88 static inline const char *
89 dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator
*it
)
91 return it
? it
->it_name
: NULL
;
95 dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list
*tl
)
97 return tl
? tl
->tl_numtgts
: 0;
100 static inline int dfs_cache_get_ttl(void)
102 return atomic_read(&dfs_cache_ttl
);
105 #endif /* _CIFS_DFS_CACHE_H */