Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Functions to handle the cached directory entries
0004  *
0005  *  Copyright (c) 2022, Ronnie Sahlberg <lsahlber@redhat.com>
0006  */
0007 
0008 #ifndef _CACHED_DIR_H
0009 #define _CACHED_DIR_H
0010 
0011 
0012 struct cached_dirent {
0013     struct list_head entry;
0014     char *name;
0015     int namelen;
0016     loff_t pos;
0017 
0018     struct cifs_fattr fattr;
0019 };
0020 
0021 struct cached_dirents {
0022     bool is_valid:1;
0023     bool is_failed:1;
0024     struct dir_context *ctx; /*
0025                   * Only used to make sure we only take entries
0026                   * from a single context. Never dereferenced.
0027                   */
0028     struct mutex de_mutex;
0029     int pos;         /* Expected ctx->pos */
0030     struct list_head entries;
0031 };
0032 
0033 struct cached_fid {
0034     bool is_valid:1;    /* Do we have a useable root fid */
0035     bool file_all_info_is_valid:1;
0036     bool has_lease:1;
0037     unsigned long time; /* jiffies of when lease was taken */
0038     struct kref refcount;
0039     struct cifs_fid fid;
0040     struct mutex fid_mutex;
0041     struct cifs_tcon *tcon;
0042     struct dentry *dentry;
0043     struct work_struct lease_break;
0044     struct smb2_file_all_info file_all_info;
0045     struct cached_dirents dirents;
0046 };
0047 
0048 extern struct cached_fid *init_cached_dir(void);
0049 extern void free_cached_dir(struct cifs_tcon *tcon);
0050 extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
0051                const char *path,
0052                struct cifs_sb_info *cifs_sb,
0053                bool lookup_only, struct cached_fid **cfid);
0054 extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
0055                      struct dentry *dentry,
0056                      struct cached_fid **cfid);
0057 extern void close_cached_dir(struct cached_fid *cfid);
0058 extern void close_cached_dir_lease(struct cached_fid *cfid);
0059 extern void close_cached_dir_lease_locked(struct cached_fid *cfid);
0060 extern void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
0061 extern void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
0062 extern int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
0063 
0064 #endif          /* _CACHED_DIR_H */