1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Functions to handle the cached directory entries
5 * Copyright (c) 2022, Ronnie Sahlberg <lsahlber@redhat.com>
12 struct cached_dirent {
13 struct list_head entry;
18 struct cifs_fattr fattr;
21 struct cached_dirents {
24 struct dir_context *ctx; /*
25 * Only used to make sure we only take entries
26 * from a single context. Never dereferenced.
28 struct mutex de_mutex;
29 int pos; /* Expected ctx->pos */
30 struct list_head entries;
34 struct list_head entry;
35 struct cached_fids *cfids;
40 bool file_all_info_is_valid:1;
41 unsigned long time; /* jiffies of when lease was taken */
45 struct cifs_tcon *tcon;
46 struct dentry *dentry;
47 struct work_struct lease_break;
48 struct smb2_file_all_info file_all_info;
49 struct cached_dirents dirents;
52 #define MAX_CACHED_FIDS 16
55 * - accessing the cfids->entries list
57 spinlock_t cfid_list_lock;
59 struct list_head entries;
62 extern struct cached_fids *init_cached_dirs(void);
63 extern void free_cached_dirs(struct cached_fids *cfids);
64 extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
66 struct cifs_sb_info *cifs_sb,
67 bool lookup_only, struct cached_fid **cfid);
68 extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
69 struct dentry *dentry,
70 struct cached_fid **cfid);
71 extern void close_cached_dir(struct cached_fid *cfid);
72 extern void drop_cached_dir_by_name(const unsigned int xid,
73 struct cifs_tcon *tcon,
75 struct cifs_sb_info *cifs_sb);
76 extern void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
77 extern void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
78 extern int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
80 #endif /* _CACHED_DIR_H */