diff -drupN a/fs/fat/fat.h b/fs/fat/fat.h --- a/fs/fat/fat.h 2018-08-06 17:23:04.000000000 +0300 +++ b/fs/fat/fat.h 2022-06-12 05:28:14.000000000 +0300 @@ -56,6 +56,7 @@ struct fat_mount_options { #define FAT_HASH_BITS 8 #define FAT_HASH_SIZE (1UL << FAT_HASH_BITS) + /* * MS-DOS file system in-core superblock data */ @@ -118,6 +119,10 @@ struct msdos_inode_info { /* NOTE: mmu_private is 64bits, so must hold ->i_mutex to access */ loff_t mmu_private; /* physically allocated size */ +#ifdef CONFIG_PRELLOCATE_FLAG + int i_prealloc; /* for prealloc */ +#endif + int i_start; /* first cluster or 0 */ int i_logstart; /* logical first cluster */ int i_attrs; /* unused attribute bits */ @@ -146,6 +151,20 @@ static inline struct msdos_inode_info *M return container_of(inode, struct msdos_inode_info, vfs_inode); } +#ifdef CONFIG_PRELLOCATE_FLAG +static inline int check_prealloc(struct inode *inode) +{ + return MSDOS_I(inode)->i_prealloc; +} + +static inline void mark_prealloc(struct inode *inode) +{ + MSDOS_I(inode)->i_prealloc = 1; +} + +extern int fat_caculate_cluster(struct inode *inode); +#endif + /* * If ->i_mode can't hold S_IWUGO (i.e. ATTR_RO), we use ->i_attrs to * save ATTR_RO instead of ->i_mode. @@ -355,7 +374,11 @@ extern int fat_ent_write(struct inode *i extern int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster); extern int fat_free_clusters(struct inode *inode, int cluster); +#ifdef CONFIG_TRUNCATE_NOMEM_RECLAIM_DISCARD +extern int fat_discard_clusters(struct inode *inode, int cluster); +#endif extern int fat_count_free_clusters(struct super_block *sb); +extern int fat_trim_fs(struct inode *inode, struct fstrim_range *range); /* fat/file.c */ extern long fat_generic_ioctl(struct file *filp, unsigned int cmd,