18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * fs/hmdfs/hmdfs_dentryfile.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef HMDFS_DENTRYFILE_H 98c2ecf20Sopenharmony_ci#define HMDFS_DENTRYFILE_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "hmdfs.h" 128c2ecf20Sopenharmony_ci#include <linux/namei.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* use for escape from hmdfs file system, hmdfs hide follow names */ 158c2ecf20Sopenharmony_ci#define CURRENT_DIR "." 168c2ecf20Sopenharmony_ci#define PARENT_DIR ".." 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* local dentry cache data */ 198c2ecf20Sopenharmony_ci#define DENTRY_FILE_XATTR_NAME "user.hmdfs_cache" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define DENTRY_FILE_NAME_RETRY 10 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define MAX_BUCKET_LEVEL 63 248c2ecf20Sopenharmony_ci#define BUCKET_BLOCKS 2 258c2ecf20Sopenharmony_ci#define MAX_DIR_BUCKETS (1 << ((MAX_BUCKET_LEVEL / 2) - 1)) 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define CONFLICTING_FILE_CONST_SUFFIX "_conflict_dev" 288c2ecf20Sopenharmony_ci#define CONFLICTING_FILE_SUFFIX "_conflict_dev%u" 298c2ecf20Sopenharmony_ci#define CONFLICTING_DIR_SUFFIX "_remote_directory" 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define POS_BIT_NUM 64 328c2ecf20Sopenharmony_ci#define DEV_ID_BIT_NUM 16 338c2ecf20Sopenharmony_ci#define GROUP_ID_BIT_NUM 39 348c2ecf20Sopenharmony_ci#define OFFSET_BIT_NUM 8 358c2ecf20Sopenharmony_ci#define OFFSET_BIT_MASK 0xFF 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define DEFAULT_DCACHE_TIMEOUT 30 388c2ecf20Sopenharmony_ci#define DEFAULT_DCACHE_PRECISION 10 398c2ecf20Sopenharmony_ci#define DEFAULT_DCACHE_THRESHOLD 1000 408c2ecf20Sopenharmony_ci#define HMDFS_STALE_REMOTE_ISIZE ULLONG_MAX 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* Seconds per-week */ 438c2ecf20Sopenharmony_ci#define MAX_DCACHE_TIMEOUT 604800 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct hmdfs_iterate_callback { 468c2ecf20Sopenharmony_ci struct dir_context ctx; 478c2ecf20Sopenharmony_ci struct dir_context *caller; 488c2ecf20Sopenharmony_ci int result; 498c2ecf20Sopenharmony_ci struct rb_root *root; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * 4096 = version(1) + bitmap(10) + reserved(5) 548c2ecf20Sopenharmony_ci * + nsl(80 * 43) + filename(80 * 8) 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#define DENTRYGROUP_SIZE 4096 578c2ecf20Sopenharmony_ci#define DENTRY_NAME_LEN 8 588c2ecf20Sopenharmony_ci#define DENTRY_RESERVED_LENGTH 3 598c2ecf20Sopenharmony_ci#define DENTRY_PER_GROUP 80 608c2ecf20Sopenharmony_ci#define DENTRY_BITMAP_LENGTH 10 618c2ecf20Sopenharmony_ci#define DENTRY_GROUP_RESERVED 5 628c2ecf20Sopenharmony_ci#define DENTRYGROUP_HEADER 4096 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct hmdfs_dentry { 658c2ecf20Sopenharmony_ci __le32 hash; 668c2ecf20Sopenharmony_ci __le16 i_mode; 678c2ecf20Sopenharmony_ci __le16 namelen; 688c2ecf20Sopenharmony_ci __le64 i_size; 698c2ecf20Sopenharmony_ci /* modification time */ 708c2ecf20Sopenharmony_ci __le64 i_mtime; 718c2ecf20Sopenharmony_ci /* modification time in nano scale */ 728c2ecf20Sopenharmony_ci __le32 i_mtime_nsec; 738c2ecf20Sopenharmony_ci /* combination of inode number and generation */ 748c2ecf20Sopenharmony_ci __le64 i_ino; 758c2ecf20Sopenharmony_ci __le32 i_flag; 768c2ecf20Sopenharmony_ci /* reserved bytes for long term extend, total 43 bytes */ 778c2ecf20Sopenharmony_ci __u8 reserved[DENTRY_RESERVED_LENGTH]; 788c2ecf20Sopenharmony_ci} __packed; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* 4K/51 Bytes = 80 dentries for per dentrygroup */ 818c2ecf20Sopenharmony_cistruct hmdfs_dentry_group { 828c2ecf20Sopenharmony_ci __u8 dentry_version; /* dentry version start from 1 */ 838c2ecf20Sopenharmony_ci __u8 bitmap[DENTRY_BITMAP_LENGTH]; 848c2ecf20Sopenharmony_ci struct hmdfs_dentry nsl[DENTRY_PER_GROUP]; 858c2ecf20Sopenharmony_ci __u8 filename[DENTRY_PER_GROUP][DENTRY_NAME_LEN]; 868c2ecf20Sopenharmony_ci __u8 reserved[DENTRY_GROUP_RESERVED]; 878c2ecf20Sopenharmony_ci} __packed; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/** 908c2ecf20Sopenharmony_ci * The content of 1st 4k block in dentryfile.dat. 918c2ecf20Sopenharmony_ci * Used for check whether the dcache can be used directly or 928c2ecf20Sopenharmony_ci * need to rebuild. 938c2ecf20Sopenharmony_ci * 948c2ecf20Sopenharmony_ci * Since the ctime has 10ms or less precision, if the dcache 958c2ecf20Sopenharmony_ci * rebuild at the same time of the dentry inode ctime, maybe 968c2ecf20Sopenharmony_ci * non-consistent in dcache. 978c2ecf20Sopenharmony_ci * eg: create 1.jpg 2.jpg 3.jpg 988c2ecf20Sopenharmony_ci * dcache rebuild may only has 1.jpg 2.jpg 998c2ecf20Sopenharmony_ci * So, we need use these time to verify the dcache. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_cistruct hmdfs_dcache_header { 1028c2ecf20Sopenharmony_ci /* The time of dcache rebuild */ 1038c2ecf20Sopenharmony_ci __le64 dcache_crtime; 1048c2ecf20Sopenharmony_ci __le64 dcache_crtime_nsec; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci /* The directory inode ctime when dcache rebuild */ 1078c2ecf20Sopenharmony_ci __le64 dentry_ctime; 1088c2ecf20Sopenharmony_ci __le64 dentry_ctime_nsec; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /* The dentry count */ 1118c2ecf20Sopenharmony_ci __le64 num; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci /* The case sensitive */ 1148c2ecf20Sopenharmony_ci __u8 case_sensitive; 1158c2ecf20Sopenharmony_ci} __packed; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistatic inline loff_t get_dentry_group_pos(unsigned int bidx) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci return ((loff_t)bidx) * DENTRYGROUP_SIZE + DENTRYGROUP_HEADER; 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic inline unsigned int get_dentry_group_cnt(struct inode *inode) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci loff_t size = i_size_read(inode); 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci return size >= DENTRYGROUP_HEADER ? 1278c2ecf20Sopenharmony_ci (size - DENTRYGROUP_HEADER) / DENTRYGROUP_SIZE : 1288c2ecf20Sopenharmony_ci 0; 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define DENTRY_NAME_MAX_LEN (DENTRY_PER_GROUP * DENTRY_NAME_LEN) 1328c2ecf20Sopenharmony_ci#define BITS_PER_BYTE 8 1338c2ecf20Sopenharmony_ci#define HMDFS_SLOT_LEN_BITS 3 1348c2ecf20Sopenharmony_ci#define get_dentry_slots(x) (((x) + BITS_PER_BYTE - 1) >> HMDFS_SLOT_LEN_BITS) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define INUNUMBER_START 10000000 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci#ifdef CONFIG_HMDFS_FS_PERMISSION 1398c2ecf20Sopenharmony_ci#define DENTRY_FILE_PERM 0660 1408c2ecf20Sopenharmony_ci#else 1418c2ecf20Sopenharmony_ci#define DENTRY_FILE_PERM 0666 1428c2ecf20Sopenharmony_ci#endif 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistruct hmdfs_dcache_lookup_ctx { 1458c2ecf20Sopenharmony_ci struct hmdfs_sb_info *sbi; 1468c2ecf20Sopenharmony_ci const struct qstr *name; 1478c2ecf20Sopenharmony_ci struct file *filp; 1488c2ecf20Sopenharmony_ci __u32 hash; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci /* for case sensitive */ 1518c2ecf20Sopenharmony_ci unsigned int bidx; 1528c2ecf20Sopenharmony_ci struct hmdfs_dentry_group *page; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* for case insensitive */ 1558c2ecf20Sopenharmony_ci struct hmdfs_dentry *insense_de; 1568c2ecf20Sopenharmony_ci unsigned int insense_bidx; 1578c2ecf20Sopenharmony_ci struct hmdfs_dentry_group *insense_page; 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ciextern void hmdfs_init_dcache_lookup_ctx(struct hmdfs_dcache_lookup_ctx *ctx, 1618c2ecf20Sopenharmony_ci struct hmdfs_sb_info *sbi, 1628c2ecf20Sopenharmony_ci const struct qstr *qstr, 1638c2ecf20Sopenharmony_ci struct file *filp); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ciint create_dentry(struct dentry *child_dentry, struct inode *inode, 1668c2ecf20Sopenharmony_ci struct file *file, struct hmdfs_sb_info *sbi); 1678c2ecf20Sopenharmony_ciint read_dentry(struct hmdfs_sb_info *sbi, char *file_name, 1688c2ecf20Sopenharmony_ci struct dir_context *ctx); 1698c2ecf20Sopenharmony_cistruct hmdfs_dentry *hmdfs_find_dentry(struct dentry *child_dentry, 1708c2ecf20Sopenharmony_ci struct hmdfs_dcache_lookup_ctx *ctx); 1718c2ecf20Sopenharmony_civoid hmdfs_delete_dentry(struct dentry *d, struct file *filp); 1728c2ecf20Sopenharmony_ciint hmdfs_rename_dentry(struct dentry *old_dentry, struct dentry *new_dentry, 1738c2ecf20Sopenharmony_ci struct file *old_filp, struct file *new_filp); 1748c2ecf20Sopenharmony_ciint get_inonumber(void); 1758c2ecf20Sopenharmony_cistruct file *create_local_dentry_file_cache(struct hmdfs_sb_info *sbi); 1768c2ecf20Sopenharmony_ciint update_inode_to_dentry(struct dentry *child_dentry, struct inode *inode); 1778c2ecf20Sopenharmony_cistruct file *cache_file_persistent(struct hmdfs_peer *con, struct file *filp, 1788c2ecf20Sopenharmony_ci const char *relative_path, bool server); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#define HMDFS_TYPE_COMMON 0 1818c2ecf20Sopenharmony_ci#define HMDFS_TYPE_DOT 1 1828c2ecf20Sopenharmony_ci#define HMDFS_TYPE_DENTRY 2 1838c2ecf20Sopenharmony_ci#define HMDFS_TYPE_DENTRY_CACHE 3 1848c2ecf20Sopenharmony_ciint hmdfs_file_type(const char *name); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ciloff_t hmdfs_set_pos(unsigned long dev_id, unsigned long group_id, 1878c2ecf20Sopenharmony_ci unsigned long offset); 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistruct getdents_callback_real { 1908c2ecf20Sopenharmony_ci struct dir_context ctx; 1918c2ecf20Sopenharmony_ci struct path *parent_path; 1928c2ecf20Sopenharmony_ci loff_t num; 1938c2ecf20Sopenharmony_ci struct file *file; 1948c2ecf20Sopenharmony_ci struct hmdfs_sb_info *sbi; 1958c2ecf20Sopenharmony_ci const char *dir; 1968c2ecf20Sopenharmony_ci}; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_cistruct file *hmdfs_server_rebuild_dents(struct hmdfs_sb_info *sbi, 1998c2ecf20Sopenharmony_ci struct path *path, loff_t *num, 2008c2ecf20Sopenharmony_ci const char *dir); 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci#define DCACHE_LIFETIME 30 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cistruct clearcache_item { 2058c2ecf20Sopenharmony_ci uint64_t dev_id; 2068c2ecf20Sopenharmony_ci struct file *filp; 2078c2ecf20Sopenharmony_ci unsigned long time; 2088c2ecf20Sopenharmony_ci struct list_head list; 2098c2ecf20Sopenharmony_ci struct kref ref; 2108c2ecf20Sopenharmony_ci struct hmdfs_dentry_info *d_info; 2118c2ecf20Sopenharmony_ci}; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_civoid hmdfs_add_remote_cache_list(struct hmdfs_peer *con, const char *dir_path); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_cistruct remotecache_item { 2168c2ecf20Sopenharmony_ci struct hmdfs_peer *con; 2178c2ecf20Sopenharmony_ci struct list_head list; 2188c2ecf20Sopenharmony_ci __u8 drop_flag; 2198c2ecf20Sopenharmony_ci}; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#define HMDFS_CFN_CID_SIZE 65 2228c2ecf20Sopenharmony_ci#define HMDFS_SERVER_CID "" 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cistruct cache_file_node { 2258c2ecf20Sopenharmony_ci struct list_head list; 2268c2ecf20Sopenharmony_ci struct hmdfs_sb_info *sbi; 2278c2ecf20Sopenharmony_ci char *relative_path; 2288c2ecf20Sopenharmony_ci u8 cid[HMDFS_CFN_CID_SIZE]; 2298c2ecf20Sopenharmony_ci refcount_t ref; 2308c2ecf20Sopenharmony_ci bool server; 2318c2ecf20Sopenharmony_ci struct file *filp; 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistruct cache_file_item { 2358c2ecf20Sopenharmony_ci struct list_head list; 2368c2ecf20Sopenharmony_ci const char *name; 2378c2ecf20Sopenharmony_ci}; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistruct cache_file_callback { 2408c2ecf20Sopenharmony_ci struct dir_context ctx; 2418c2ecf20Sopenharmony_ci const char *dirname; 2428c2ecf20Sopenharmony_ci struct hmdfs_sb_info *sbi; 2438c2ecf20Sopenharmony_ci bool server; 2448c2ecf20Sopenharmony_ci struct list_head list; 2458c2ecf20Sopenharmony_ci}; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ciint hmdfs_drop_remote_cache_dents(struct dentry *dentry); 2488c2ecf20Sopenharmony_civoid hmdfs_send_drop_push(struct hmdfs_peer *con, const char *path); 2498c2ecf20Sopenharmony_civoid hmdfs_mark_drop_flag(uint64_t device_id, struct dentry *dentry); 2508c2ecf20Sopenharmony_civoid hmdfs_clear_drop_flag(struct dentry *dentry); 2518c2ecf20Sopenharmony_civoid delete_in_cache_file(uint64_t dev_id, struct dentry *dentry); 2528c2ecf20Sopenharmony_civoid create_in_cache_file(uint64_t dev_id, struct dentry *dentry); 2538c2ecf20Sopenharmony_cistruct clearcache_item *hmdfs_find_cache_item(uint64_t dev_id, 2548c2ecf20Sopenharmony_ci struct dentry *dentry); 2558c2ecf20Sopenharmony_cibool hmdfs_cache_revalidate(unsigned long conn_time, uint64_t dev_id, 2568c2ecf20Sopenharmony_ci struct dentry *dentry); 2578c2ecf20Sopenharmony_civoid hmdfs_remove_cache_filp(struct hmdfs_peer *con, struct dentry *dentry); 2588c2ecf20Sopenharmony_ciint hmdfs_add_cache_list(uint64_t dev_id, struct dentry *dentry, 2598c2ecf20Sopenharmony_ci struct file *filp); 2608c2ecf20Sopenharmony_ciint hmdfs_clear_cache_dents(struct dentry *dentry, bool remove_cache); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ciint hmdfs_root_unlink(uint64_t device_id, struct path *root_path, 2638c2ecf20Sopenharmony_ci const char *unlink_dir, const char *unlink_name); 2648c2ecf20Sopenharmony_cistruct dentry *hmdfs_root_mkdir(uint64_t device_id, const char *local_dst_path, 2658c2ecf20Sopenharmony_ci const char *mkdir_dir, const char *mkdir_name, 2668c2ecf20Sopenharmony_ci umode_t mode); 2678c2ecf20Sopenharmony_cistruct dentry *hmdfs_root_create(uint64_t device_id, const char *local_dst_path, 2688c2ecf20Sopenharmony_ci const char *create_dir, 2698c2ecf20Sopenharmony_ci const char *create_name, 2708c2ecf20Sopenharmony_ci umode_t mode, bool want_excl); 2718c2ecf20Sopenharmony_ciint hmdfs_root_rmdir(uint64_t device_id, struct path *root_path, 2728c2ecf20Sopenharmony_ci const char *rmdir_dir, const char *rmdir_name); 2738c2ecf20Sopenharmony_ciint hmdfs_root_rename(struct hmdfs_sb_info *sbi, uint64_t device_id, 2748c2ecf20Sopenharmony_ci const char *oldpath, const char *oldname, 2758c2ecf20Sopenharmony_ci const char *newpath, const char *newname, 2768c2ecf20Sopenharmony_ci unsigned int flags); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ciint hmdfs_get_path_in_sb(struct super_block *sb, const char *name, 2798c2ecf20Sopenharmony_ci unsigned int flags, struct path *path); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ciint hmdfs_wlock_file(struct file *filp, loff_t start, loff_t len); 2828c2ecf20Sopenharmony_ciint hmdfs_rlock_file(struct file *filp, loff_t start, loff_t len); 2838c2ecf20Sopenharmony_ciint hmdfs_unlock_file(struct file *filp, loff_t start, loff_t len); 2848c2ecf20Sopenharmony_cilong cache_file_truncate(struct hmdfs_sb_info *sbi, const struct path *path, 2858c2ecf20Sopenharmony_ci loff_t length); 2868c2ecf20Sopenharmony_cissize_t cache_file_read(struct hmdfs_sb_info *sbi, struct file *filp, void *buf, 2878c2ecf20Sopenharmony_ci size_t count, loff_t *pos); 2888c2ecf20Sopenharmony_cissize_t cache_file_write(struct hmdfs_sb_info *sbi, struct file *filp, 2898c2ecf20Sopenharmony_ci const void *buf, size_t count, loff_t *pos); 2908c2ecf20Sopenharmony_ciint hmdfs_metainfo_read_nocred(struct file *filp, 2918c2ecf20Sopenharmony_ci void *buffer, int size, int bidx); 2928c2ecf20Sopenharmony_ciint hmdfs_metainfo_read(struct hmdfs_sb_info *sbi, struct file *filp, 2938c2ecf20Sopenharmony_ci void *buffer, int buffersize, int bidx); 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_cibool get_remote_dentry_file(struct dentry *dentry, struct hmdfs_peer *con); 2968c2ecf20Sopenharmony_civoid get_remote_dentry_file_sync(struct dentry *dentry, struct hmdfs_peer *con); 2978c2ecf20Sopenharmony_ciint get_cloud_cache_file(struct dentry *dentry, struct hmdfs_sb_info *sbi); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_civoid release_cache_item(struct kref *ref); 3008c2ecf20Sopenharmony_civoid remove_cache_item(struct clearcache_item *item); 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_civoid hmdfs_cfn_load(struct hmdfs_sb_info *sbi); 3038c2ecf20Sopenharmony_civoid hmdfs_cfn_destroy(struct hmdfs_sb_info *sbi); 3048c2ecf20Sopenharmony_cistruct cache_file_node *find_cfn(struct hmdfs_sb_info *sbi, const char *cid, 3058c2ecf20Sopenharmony_ci const char *path, bool server); 3068c2ecf20Sopenharmony_civoid release_cfn(struct cache_file_node *cfn); 3078c2ecf20Sopenharmony_civoid destroy_cfn(struct hmdfs_sb_info *sbi); 3088c2ecf20Sopenharmony_civoid remove_cfn(struct cache_file_node *cfn); 3098c2ecf20Sopenharmony_ciint delete_dentry_file(struct file *filp); 3108c2ecf20Sopenharmony_cistruct file *hmdfs_server_cache_revalidate(struct hmdfs_sb_info *sbi, 3118c2ecf20Sopenharmony_ci const char *recvpath, 3128c2ecf20Sopenharmony_ci struct path *path); 3138c2ecf20Sopenharmony_ciint write_header(struct file *filp, struct hmdfs_dcache_header *header); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_cistatic inline struct list_head *get_list_head(struct hmdfs_sb_info *sbi, 3168c2ecf20Sopenharmony_ci bool server) 3178c2ecf20Sopenharmony_ci{ 3188c2ecf20Sopenharmony_ci return ((server) ? &(sbi)->server_cache : &(sbi)->client_cache); 3198c2ecf20Sopenharmony_ci} 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci/* 3228c2ecf20Sopenharmony_ci * generate_u64_ino - generate a new 64 bit inode number 3238c2ecf20Sopenharmony_ci * 3248c2ecf20Sopenharmony_ci * @ino: origin 32 bit inode number 3258c2ecf20Sopenharmony_ci * @generation: origin 32 bit inode generation 3268c2ecf20Sopenharmony_ci * 3278c2ecf20Sopenharmony_ci * We need both remote inode number and generation to ensure the uniqueness of 3288c2ecf20Sopenharmony_ci * the local inode, thus we store inode->i_ino in lower 32 bits, and 3298c2ecf20Sopenharmony_ci * inode->i_generation in higher 32 bits. 3308c2ecf20Sopenharmony_ci */ 3318c2ecf20Sopenharmony_cistatic inline uint64_t generate_u64_ino(unsigned long ino, 3328c2ecf20Sopenharmony_ci unsigned int generation) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci return (uint64_t)ino | ((uint64_t)generation << 32); 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cistatic inline bool cache_item_revalidate(unsigned long conn_time, 3388c2ecf20Sopenharmony_ci unsigned long item_time, 3398c2ecf20Sopenharmony_ci unsigned int timeout) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci return time_before_eq(jiffies, item_time + timeout * HZ) && 3428c2ecf20Sopenharmony_ci time_before_eq(conn_time, item_time); 3438c2ecf20Sopenharmony_ci} 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci__u32 hmdfs_dentry_hash(const struct qstr *qstr, bool case_sense); 3468c2ecf20Sopenharmony_ci__u64 get_bucketaddr(unsigned int level, __u64 buckoffset); 3478c2ecf20Sopenharmony_ci__u64 get_bucket_by_level(unsigned int level); 3488c2ecf20Sopenharmony_ciunsigned int get_max_depth(struct file *filp); 3498c2ecf20Sopenharmony_ci#endif 350