Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.4 101 lines 2.8 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * DFS referral cache routines 4 * 5 * Copyright (c) 2018-2019 Paulo Alcantara <palcantara@suse.de> 6 */ 7 8#ifndef _CIFS_DFS_CACHE_H 9#define _CIFS_DFS_CACHE_H 10 11#include <linux/nls.h> 12#include <linux/list.h> 13#include <linux/uuid.h> 14#include "cifsglob.h" 15 16extern struct workqueue_struct *dfscache_wq; 17extern atomic_t dfs_cache_ttl; 18 19#define DFS_CACHE_TGT_LIST_INIT(var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), } 20 21struct dfs_cache_tgt_list { 22 int tl_numtgts; 23 struct list_head tl_list; 24}; 25 26struct dfs_cache_tgt_iterator { 27 char *it_name; 28 int it_path_consumed; 29 struct list_head it_list; 30}; 31 32int dfs_cache_init(void); 33void dfs_cache_destroy(void); 34extern const struct proc_ops dfscache_proc_ops; 35 36int 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); 39int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref, 40 struct dfs_cache_tgt_list *tgt_list); 41void dfs_cache_noreq_update_tgthint(const char *path, const struct dfs_cache_tgt_iterator *it); 42int dfs_cache_get_tgt_referral(const char *path, const struct dfs_cache_tgt_iterator *it, 43 struct dfs_info3_param *ref); 44int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share, 45 char **prefix); 46char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp, int remap); 47int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb); 48void dfs_cache_refresh(struct work_struct *work); 49 50static inline struct dfs_cache_tgt_iterator * 51dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl, 52 struct dfs_cache_tgt_iterator *it) 53{ 54 if (!tl || list_empty(&tl->tl_list) || !it || 55 list_is_last(&it->it_list, &tl->tl_list)) 56 return NULL; 57 return list_next_entry(it, it_list); 58} 59 60static inline struct dfs_cache_tgt_iterator * 61dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list *tl) 62{ 63 if (!tl) 64 return NULL; 65 return list_first_entry_or_null(&tl->tl_list, 66 struct dfs_cache_tgt_iterator, 67 it_list); 68} 69 70static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list *tl) 71{ 72 struct dfs_cache_tgt_iterator *it, *nit; 73 74 if (!tl || list_empty(&tl->tl_list)) 75 return; 76 list_for_each_entry_safe(it, nit, &tl->tl_list, it_list) { 77 list_del(&it->it_list); 78 kfree(it->it_name); 79 kfree(it); 80 } 81 tl->tl_numtgts = 0; 82} 83 84static inline const char * 85dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator *it) 86{ 87 return it ? it->it_name : NULL; 88} 89 90static inline int 91dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl) 92{ 93 return tl ? tl->tl_numtgts : 0; 94} 95 96static inline int dfs_cache_get_ttl(void) 97{ 98 return atomic_read(&dfs_cache_ttl); 99} 100 101#endif /* _CIFS_DFS_CACHE_H */