19eefe2a2SStefan Roese /* 29eefe2a2SStefan Roese * This file is part of UBIFS. 39eefe2a2SStefan Roese * 49eefe2a2SStefan Roese * Copyright (C) 2006-2008 Nokia Corporation 59eefe2a2SStefan Roese * 69eefe2a2SStefan Roese * (C) Copyright 2008-2009 79eefe2a2SStefan Roese * Stefan Roese, DENX Software Engineering, sr@denx.de. 89eefe2a2SStefan Roese * 9*ff94bc40SHeiko Schocher * SPDX-License-Identifier: GPL-2.0+ 109eefe2a2SStefan Roese * 119eefe2a2SStefan Roese * Authors: Artem Bityutskiy (Битюцкий Артём) 129eefe2a2SStefan Roese * Adrian Hunter 139eefe2a2SStefan Roese */ 149eefe2a2SStefan Roese 159eefe2a2SStefan Roese #ifndef __UBIFS_H__ 169eefe2a2SStefan Roese #define __UBIFS_H__ 179eefe2a2SStefan Roese 18*ff94bc40SHeiko Schocher #define __UBOOT__ 19*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 20*ff94bc40SHeiko Schocher #include <asm/div64.h> 21*ff94bc40SHeiko Schocher #include <linux/statfs.h> 22*ff94bc40SHeiko Schocher #include <linux/fs.h> 23*ff94bc40SHeiko Schocher #include <linux/err.h> 24*ff94bc40SHeiko Schocher #include <linux/sched.h> 25*ff94bc40SHeiko Schocher #include <linux/slab.h> 26*ff94bc40SHeiko Schocher #include <linux/vmalloc.h> 27*ff94bc40SHeiko Schocher #include <linux/spinlock.h> 28*ff94bc40SHeiko Schocher #include <linux/mutex.h> 29*ff94bc40SHeiko Schocher #include <linux/rwsem.h> 30*ff94bc40SHeiko Schocher #include <linux/mtd/ubi.h> 31*ff94bc40SHeiko Schocher #include <linux/pagemap.h> 32*ff94bc40SHeiko Schocher #include <linux/backing-dev.h> 33*ff94bc40SHeiko Schocher #include "ubifs-media.h" 34*ff94bc40SHeiko Schocher #else 359eefe2a2SStefan Roese #include <ubi_uboot.h> 36*ff94bc40SHeiko Schocher 379eefe2a2SStefan Roese #include <linux/ctype.h> 389eefe2a2SStefan Roese #include <linux/time.h> 399eefe2a2SStefan Roese #include <linux/math64.h> 409eefe2a2SStefan Roese #include "ubifs-media.h" 419eefe2a2SStefan Roese 429eefe2a2SStefan Roese struct dentry; 439eefe2a2SStefan Roese struct file; 449eefe2a2SStefan Roese struct iattr; 459eefe2a2SStefan Roese struct kstat; 469eefe2a2SStefan Roese struct vfsmount; 479eefe2a2SStefan Roese 489eefe2a2SStefan Roese extern struct super_block *ubifs_sb; 499eefe2a2SStefan Roese 509eefe2a2SStefan Roese extern unsigned int ubifs_msg_flags; 519eefe2a2SStefan Roese extern unsigned int ubifs_chk_flags; 529eefe2a2SStefan Roese extern unsigned int ubifs_tst_flags; 539eefe2a2SStefan Roese 549eefe2a2SStefan Roese #define pgoff_t unsigned long 559eefe2a2SStefan Roese 569eefe2a2SStefan Roese /* 579eefe2a2SStefan Roese * We "simulate" the Linux page struct much simpler here 589eefe2a2SStefan Roese */ 599eefe2a2SStefan Roese struct page { 609eefe2a2SStefan Roese pgoff_t index; 619eefe2a2SStefan Roese void *addr; 629eefe2a2SStefan Roese struct inode *inode; 639eefe2a2SStefan Roese }; 649eefe2a2SStefan Roese 659eefe2a2SStefan Roese void iput(struct inode *inode); 669eefe2a2SStefan Roese 679eefe2a2SStefan Roese /* 689eefe2a2SStefan Roese * The atomic operations are used for budgeting etc which is not 699eefe2a2SStefan Roese * needed for the read-only U-Boot implementation: 709eefe2a2SStefan Roese */ 719eefe2a2SStefan Roese #define atomic_long_inc(a) 729eefe2a2SStefan Roese #define atomic_long_dec(a) 739eefe2a2SStefan Roese #define atomic_long_sub(a, b) 749eefe2a2SStefan Roese 75*ff94bc40SHeiko Schocher typedef unsigned long atomic_long_t; 76*ff94bc40SHeiko Schocher 779eefe2a2SStefan Roese /* linux/include/time.h */ 78*ff94bc40SHeiko Schocher #define NSEC_PER_SEC 1000000000L 79*ff94bc40SHeiko Schocher #define get_seconds() 0 80*ff94bc40SHeiko Schocher #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) 819eefe2a2SStefan Roese 829eefe2a2SStefan Roese struct timespec { 839eefe2a2SStefan Roese time_t tv_sec; /* seconds */ 849eefe2a2SStefan Roese long tv_nsec; /* nanoseconds */ 859eefe2a2SStefan Roese }; 869eefe2a2SStefan Roese 87*ff94bc40SHeiko Schocher static struct timespec current_fs_time(struct super_block *sb) 88*ff94bc40SHeiko Schocher { 89*ff94bc40SHeiko Schocher struct timespec now; 90*ff94bc40SHeiko Schocher now.tv_sec = 0; 91*ff94bc40SHeiko Schocher now.tv_nsec = 0; 92*ff94bc40SHeiko Schocher return now; 93*ff94bc40SHeiko Schocher }; 94*ff94bc40SHeiko Schocher 959eefe2a2SStefan Roese /* linux/include/dcache.h */ 969eefe2a2SStefan Roese 979eefe2a2SStefan Roese /* 989eefe2a2SStefan Roese * "quick string" -- eases parameter passing, but more importantly 999eefe2a2SStefan Roese * saves "metadata" about the string (ie length and the hash). 1009eefe2a2SStefan Roese * 1019eefe2a2SStefan Roese * hash comes first so it snuggles against d_parent in the 1029eefe2a2SStefan Roese * dentry. 1039eefe2a2SStefan Roese */ 1049eefe2a2SStefan Roese struct qstr { 1059eefe2a2SStefan Roese unsigned int hash; 1069eefe2a2SStefan Roese unsigned int len; 107*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 1089eefe2a2SStefan Roese const char *name; 109*ff94bc40SHeiko Schocher #else 110*ff94bc40SHeiko Schocher char *name; 111*ff94bc40SHeiko Schocher #endif 1129eefe2a2SStefan Roese }; 1139eefe2a2SStefan Roese 114*ff94bc40SHeiko Schocher /* include/linux/fs.h */ 115*ff94bc40SHeiko Schocher 116*ff94bc40SHeiko Schocher /* Possible states of 'frozen' field */ 117*ff94bc40SHeiko Schocher enum { 118*ff94bc40SHeiko Schocher SB_UNFROZEN = 0, /* FS is unfrozen */ 119*ff94bc40SHeiko Schocher SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ 120*ff94bc40SHeiko Schocher SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ 121*ff94bc40SHeiko Schocher SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop 122*ff94bc40SHeiko Schocher * internal threads if needed) */ 123*ff94bc40SHeiko Schocher SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ 124*ff94bc40SHeiko Schocher }; 125*ff94bc40SHeiko Schocher 126*ff94bc40SHeiko Schocher #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) 127*ff94bc40SHeiko Schocher 128*ff94bc40SHeiko Schocher struct sb_writers { 129*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 130*ff94bc40SHeiko Schocher /* Counters for counting writers at each level */ 131*ff94bc40SHeiko Schocher struct percpu_counter counter[SB_FREEZE_LEVELS]; 132*ff94bc40SHeiko Schocher #endif 133*ff94bc40SHeiko Schocher wait_queue_head_t wait; /* queue for waiting for 134*ff94bc40SHeiko Schocher writers / faults to finish */ 135*ff94bc40SHeiko Schocher int frozen; /* Is sb frozen? */ 136*ff94bc40SHeiko Schocher wait_queue_head_t wait_unfrozen; /* queue for waiting for 137*ff94bc40SHeiko Schocher sb to be thawed */ 138*ff94bc40SHeiko Schocher #ifdef CONFIG_DEBUG_LOCK_ALLOC 139*ff94bc40SHeiko Schocher struct lockdep_map lock_map[SB_FREEZE_LEVELS]; 140*ff94bc40SHeiko Schocher #endif 141*ff94bc40SHeiko Schocher }; 142*ff94bc40SHeiko Schocher 143*ff94bc40SHeiko Schocher struct address_space { 144*ff94bc40SHeiko Schocher struct inode *host; /* owner: inode, block_device */ 145*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 146*ff94bc40SHeiko Schocher struct radix_tree_root page_tree; /* radix tree of all pages */ 147*ff94bc40SHeiko Schocher #endif 148*ff94bc40SHeiko Schocher spinlock_t tree_lock; /* and lock protecting it */ 149*ff94bc40SHeiko Schocher unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 150*ff94bc40SHeiko Schocher struct rb_root i_mmap; /* tree of private and shared mappings */ 151*ff94bc40SHeiko Schocher struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 152*ff94bc40SHeiko Schocher struct mutex i_mmap_mutex; /* protect tree, count, list */ 153*ff94bc40SHeiko Schocher /* Protected by tree_lock together with the radix tree */ 154*ff94bc40SHeiko Schocher unsigned long nrpages; /* number of total pages */ 155*ff94bc40SHeiko Schocher pgoff_t writeback_index;/* writeback starts here */ 156*ff94bc40SHeiko Schocher const struct address_space_operations *a_ops; /* methods */ 157*ff94bc40SHeiko Schocher unsigned long flags; /* error bits/gfp mask */ 158*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 159*ff94bc40SHeiko Schocher struct backing_dev_info *backing_dev_info; /* device readahead, etc */ 160*ff94bc40SHeiko Schocher #endif 161*ff94bc40SHeiko Schocher spinlock_t private_lock; /* for use by the address_space */ 162*ff94bc40SHeiko Schocher struct list_head private_list; /* ditto */ 163*ff94bc40SHeiko Schocher void *private_data; /* ditto */ 164*ff94bc40SHeiko Schocher } __attribute__((aligned(sizeof(long)))); 165*ff94bc40SHeiko Schocher 166*ff94bc40SHeiko Schocher /* 167*ff94bc40SHeiko Schocher * Keep mostly read-only and often accessed (especially for 168*ff94bc40SHeiko Schocher * the RCU path lookup and 'stat' data) fields at the beginning 169*ff94bc40SHeiko Schocher * of the 'struct inode' 170*ff94bc40SHeiko Schocher */ 1719eefe2a2SStefan Roese struct inode { 1729eefe2a2SStefan Roese umode_t i_mode; 173*ff94bc40SHeiko Schocher unsigned short i_opflags; 174*ff94bc40SHeiko Schocher kuid_t i_uid; 175*ff94bc40SHeiko Schocher kgid_t i_gid; 1769eefe2a2SStefan Roese unsigned int i_flags; 1779eefe2a2SStefan Roese 178*ff94bc40SHeiko Schocher #ifdef CONFIG_FS_POSIX_ACL 179*ff94bc40SHeiko Schocher struct posix_acl *i_acl; 180*ff94bc40SHeiko Schocher struct posix_acl *i_default_acl; 181*ff94bc40SHeiko Schocher #endif 182*ff94bc40SHeiko Schocher 183*ff94bc40SHeiko Schocher const struct inode_operations *i_op; 184*ff94bc40SHeiko Schocher struct super_block *i_sb; 185*ff94bc40SHeiko Schocher struct address_space *i_mapping; 186*ff94bc40SHeiko Schocher 1879eefe2a2SStefan Roese #ifdef CONFIG_SECURITY 1889eefe2a2SStefan Roese void *i_security; 1899eefe2a2SStefan Roese #endif 190*ff94bc40SHeiko Schocher 191*ff94bc40SHeiko Schocher /* Stat data, not accessed from path walking */ 192*ff94bc40SHeiko Schocher unsigned long i_ino; 193*ff94bc40SHeiko Schocher /* 194*ff94bc40SHeiko Schocher * Filesystems may only read i_nlink directly. They shall use the 195*ff94bc40SHeiko Schocher * following functions for modification: 196*ff94bc40SHeiko Schocher * 197*ff94bc40SHeiko Schocher * (set|clear|inc|drop)_nlink 198*ff94bc40SHeiko Schocher * inode_(inc|dec)_link_count 199*ff94bc40SHeiko Schocher */ 200*ff94bc40SHeiko Schocher union { 201*ff94bc40SHeiko Schocher const unsigned int i_nlink; 202*ff94bc40SHeiko Schocher unsigned int __i_nlink; 203*ff94bc40SHeiko Schocher }; 204*ff94bc40SHeiko Schocher dev_t i_rdev; 205*ff94bc40SHeiko Schocher loff_t i_size; 206*ff94bc40SHeiko Schocher struct timespec i_atime; 207*ff94bc40SHeiko Schocher struct timespec i_mtime; 208*ff94bc40SHeiko Schocher struct timespec i_ctime; 209*ff94bc40SHeiko Schocher spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 210*ff94bc40SHeiko Schocher unsigned short i_bytes; 211*ff94bc40SHeiko Schocher unsigned int i_blkbits; 212*ff94bc40SHeiko Schocher blkcnt_t i_blocks; 213*ff94bc40SHeiko Schocher 214*ff94bc40SHeiko Schocher #ifdef __NEED_I_SIZE_ORDERED 215*ff94bc40SHeiko Schocher seqcount_t i_size_seqcount; 216*ff94bc40SHeiko Schocher #endif 217*ff94bc40SHeiko Schocher 218*ff94bc40SHeiko Schocher /* Misc */ 219*ff94bc40SHeiko Schocher unsigned long i_state; 220*ff94bc40SHeiko Schocher struct mutex i_mutex; 221*ff94bc40SHeiko Schocher 222*ff94bc40SHeiko Schocher unsigned long dirtied_when; /* jiffies of first dirtying */ 223*ff94bc40SHeiko Schocher 224*ff94bc40SHeiko Schocher struct hlist_node i_hash; 225*ff94bc40SHeiko Schocher struct list_head i_wb_list; /* backing dev IO list */ 226*ff94bc40SHeiko Schocher struct list_head i_lru; /* inode LRU list */ 227*ff94bc40SHeiko Schocher struct list_head i_sb_list; 228*ff94bc40SHeiko Schocher union { 229*ff94bc40SHeiko Schocher struct hlist_head i_dentry; 230*ff94bc40SHeiko Schocher struct rcu_head i_rcu; 231*ff94bc40SHeiko Schocher }; 232*ff94bc40SHeiko Schocher u64 i_version; 233*ff94bc40SHeiko Schocher atomic_t i_count; 234*ff94bc40SHeiko Schocher atomic_t i_dio_count; 235*ff94bc40SHeiko Schocher atomic_t i_writecount; 236*ff94bc40SHeiko Schocher const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 237*ff94bc40SHeiko Schocher struct file_lock *i_flock; 238*ff94bc40SHeiko Schocher struct address_space i_data; 239*ff94bc40SHeiko Schocher #ifdef CONFIG_QUOTA 240*ff94bc40SHeiko Schocher struct dquot *i_dquot[MAXQUOTAS]; 241*ff94bc40SHeiko Schocher #endif 242*ff94bc40SHeiko Schocher struct list_head i_devices; 243*ff94bc40SHeiko Schocher union { 244*ff94bc40SHeiko Schocher struct pipe_inode_info *i_pipe; 245*ff94bc40SHeiko Schocher struct block_device *i_bdev; 246*ff94bc40SHeiko Schocher struct cdev *i_cdev; 247*ff94bc40SHeiko Schocher }; 248*ff94bc40SHeiko Schocher 249*ff94bc40SHeiko Schocher __u32 i_generation; 250*ff94bc40SHeiko Schocher 251*ff94bc40SHeiko Schocher #ifdef CONFIG_FSNOTIFY 252*ff94bc40SHeiko Schocher __u32 i_fsnotify_mask; /* all events this inode cares about */ 253*ff94bc40SHeiko Schocher struct hlist_head i_fsnotify_marks; 254*ff94bc40SHeiko Schocher #endif 255*ff94bc40SHeiko Schocher 256*ff94bc40SHeiko Schocher #ifdef CONFIG_IMA 257*ff94bc40SHeiko Schocher atomic_t i_readcount; /* struct files open RO */ 258*ff94bc40SHeiko Schocher #endif 2599eefe2a2SStefan Roese void *i_private; /* fs or device private pointer */ 2609eefe2a2SStefan Roese }; 2619eefe2a2SStefan Roese 262*ff94bc40SHeiko Schocher struct super_operations { 263*ff94bc40SHeiko Schocher struct inode *(*alloc_inode)(struct super_block *sb); 264*ff94bc40SHeiko Schocher void (*destroy_inode)(struct inode *); 265*ff94bc40SHeiko Schocher 266*ff94bc40SHeiko Schocher void (*dirty_inode) (struct inode *, int flags); 267*ff94bc40SHeiko Schocher int (*write_inode) (struct inode *, struct writeback_control *wbc); 268*ff94bc40SHeiko Schocher int (*drop_inode) (struct inode *); 269*ff94bc40SHeiko Schocher void (*evict_inode) (struct inode *); 270*ff94bc40SHeiko Schocher void (*put_super) (struct super_block *); 271*ff94bc40SHeiko Schocher int (*sync_fs)(struct super_block *sb, int wait); 272*ff94bc40SHeiko Schocher int (*freeze_fs) (struct super_block *); 273*ff94bc40SHeiko Schocher int (*unfreeze_fs) (struct super_block *); 274*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 275*ff94bc40SHeiko Schocher int (*statfs) (struct dentry *, struct kstatfs *); 276*ff94bc40SHeiko Schocher #endif 277*ff94bc40SHeiko Schocher int (*remount_fs) (struct super_block *, int *, char *); 278*ff94bc40SHeiko Schocher void (*umount_begin) (struct super_block *); 279*ff94bc40SHeiko Schocher 280*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 281*ff94bc40SHeiko Schocher int (*show_options)(struct seq_file *, struct dentry *); 282*ff94bc40SHeiko Schocher int (*show_devname)(struct seq_file *, struct dentry *); 283*ff94bc40SHeiko Schocher int (*show_path)(struct seq_file *, struct dentry *); 284*ff94bc40SHeiko Schocher int (*show_stats)(struct seq_file *, struct dentry *); 285*ff94bc40SHeiko Schocher #endif 286*ff94bc40SHeiko Schocher #ifdef CONFIG_QUOTA 287*ff94bc40SHeiko Schocher ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 288*ff94bc40SHeiko Schocher ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 289*ff94bc40SHeiko Schocher #endif 290*ff94bc40SHeiko Schocher int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 291*ff94bc40SHeiko Schocher long (*nr_cached_objects)(struct super_block *, int); 292*ff94bc40SHeiko Schocher long (*free_cached_objects)(struct super_block *, long, int); 293*ff94bc40SHeiko Schocher }; 294*ff94bc40SHeiko Schocher 2959eefe2a2SStefan Roese struct super_block { 2969eefe2a2SStefan Roese struct list_head s_list; /* Keep this first */ 2979eefe2a2SStefan Roese dev_t s_dev; /* search index; _not_ kdev_t */ 2989eefe2a2SStefan Roese unsigned char s_blocksize_bits; 299*ff94bc40SHeiko Schocher unsigned long s_blocksize; 300*ff94bc40SHeiko Schocher loff_t s_maxbytes; /* Max file size */ 3019eefe2a2SStefan Roese struct file_system_type *s_type; 3029eefe2a2SStefan Roese const struct super_operations *s_op; 303*ff94bc40SHeiko Schocher const struct dquot_operations *dq_op; 304*ff94bc40SHeiko Schocher const struct quotactl_ops *s_qcop; 3059eefe2a2SStefan Roese const struct export_operations *s_export_op; 3069eefe2a2SStefan Roese unsigned long s_flags; 3079eefe2a2SStefan Roese unsigned long s_magic; 3089eefe2a2SStefan Roese struct dentry *s_root; 3099eefe2a2SStefan Roese struct rw_semaphore s_umount; 3109eefe2a2SStefan Roese int s_count; 311*ff94bc40SHeiko Schocher atomic_t s_active; 3129eefe2a2SStefan Roese #ifdef CONFIG_SECURITY 3139eefe2a2SStefan Roese void *s_security; 3149eefe2a2SStefan Roese #endif 315*ff94bc40SHeiko Schocher const struct xattr_handler **s_xattr; 3169eefe2a2SStefan Roese 3179eefe2a2SStefan Roese struct list_head s_inodes; /* all inodes */ 318*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 319*ff94bc40SHeiko Schocher struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ 320*ff94bc40SHeiko Schocher #endif 321*ff94bc40SHeiko Schocher struct list_head s_mounts; /* list of mounts; _not_ for fs use */ 3229eefe2a2SStefan Roese struct block_device *s_bdev; 323*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 324*ff94bc40SHeiko Schocher struct backing_dev_info *s_bdi; 325*ff94bc40SHeiko Schocher #endif 3269eefe2a2SStefan Roese struct mtd_info *s_mtd; 327*ff94bc40SHeiko Schocher struct hlist_node s_instances; 328*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 329*ff94bc40SHeiko Schocher struct quota_info s_dquot; /* Diskquota specific options */ 330*ff94bc40SHeiko Schocher #endif 3319eefe2a2SStefan Roese 332*ff94bc40SHeiko Schocher struct sb_writers s_writers; 3339eefe2a2SStefan Roese 3349eefe2a2SStefan Roese char s_id[32]; /* Informational name */ 335*ff94bc40SHeiko Schocher u8 s_uuid[16]; /* UUID */ 3369eefe2a2SStefan Roese 3379eefe2a2SStefan Roese void *s_fs_info; /* Filesystem private info */ 338*ff94bc40SHeiko Schocher unsigned int s_max_links; 339*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 340*ff94bc40SHeiko Schocher fmode_t s_mode; 341*ff94bc40SHeiko Schocher #endif 342*ff94bc40SHeiko Schocher 343*ff94bc40SHeiko Schocher /* Granularity of c/m/atime in ns. 344*ff94bc40SHeiko Schocher Cannot be worse than a second */ 345*ff94bc40SHeiko Schocher u32 s_time_gran; 3469eefe2a2SStefan Roese 3479eefe2a2SStefan Roese /* 3489eefe2a2SStefan Roese * The next field is for VFS *only*. No filesystems have any business 3499eefe2a2SStefan Roese * even looking at it. You had been warned. 3509eefe2a2SStefan Roese */ 3519eefe2a2SStefan Roese struct mutex s_vfs_rename_mutex; /* Kludge */ 3529eefe2a2SStefan Roese 3539eefe2a2SStefan Roese /* 3549eefe2a2SStefan Roese * Filesystem subtype. If non-empty the filesystem type field 3559eefe2a2SStefan Roese * in /proc/mounts will be "type.subtype" 3569eefe2a2SStefan Roese */ 3579eefe2a2SStefan Roese char *s_subtype; 3589eefe2a2SStefan Roese 359*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 3609eefe2a2SStefan Roese /* 3619eefe2a2SStefan Roese * Saved mount options for lazy filesystems using 3629eefe2a2SStefan Roese * generic_show_options() 3639eefe2a2SStefan Roese */ 364*ff94bc40SHeiko Schocher char __rcu *s_options; 365*ff94bc40SHeiko Schocher #endif 366*ff94bc40SHeiko Schocher const struct dentry_operations *s_d_op; /* default d_op for dentries */ 367*ff94bc40SHeiko Schocher 368*ff94bc40SHeiko Schocher /* 369*ff94bc40SHeiko Schocher * Saved pool identifier for cleancache (-1 means none) 370*ff94bc40SHeiko Schocher */ 371*ff94bc40SHeiko Schocher int cleancache_poolid; 372*ff94bc40SHeiko Schocher 373*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 374*ff94bc40SHeiko Schocher struct shrinker s_shrink; /* per-sb shrinker handle */ 375*ff94bc40SHeiko Schocher #endif 376*ff94bc40SHeiko Schocher 377*ff94bc40SHeiko Schocher /* Number of inodes with nlink == 0 but still referenced */ 378*ff94bc40SHeiko Schocher atomic_long_t s_remove_count; 379*ff94bc40SHeiko Schocher 380*ff94bc40SHeiko Schocher /* Being remounted read-only */ 381*ff94bc40SHeiko Schocher int s_readonly_remount; 382*ff94bc40SHeiko Schocher 383*ff94bc40SHeiko Schocher /* AIO completions deferred from interrupt context */ 384*ff94bc40SHeiko Schocher struct workqueue_struct *s_dio_done_wq; 385*ff94bc40SHeiko Schocher 386*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 387*ff94bc40SHeiko Schocher /* 388*ff94bc40SHeiko Schocher * Keep the lru lists last in the structure so they always sit on their 389*ff94bc40SHeiko Schocher * own individual cachelines. 390*ff94bc40SHeiko Schocher */ 391*ff94bc40SHeiko Schocher struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; 392*ff94bc40SHeiko Schocher struct list_lru s_inode_lru ____cacheline_aligned_in_smp; 393*ff94bc40SHeiko Schocher #endif 394*ff94bc40SHeiko Schocher struct rcu_head rcu; 3959eefe2a2SStefan Roese }; 3969eefe2a2SStefan Roese 3979eefe2a2SStefan Roese struct file_system_type { 3989eefe2a2SStefan Roese const char *name; 3999eefe2a2SStefan Roese int fs_flags; 400*ff94bc40SHeiko Schocher #define FS_REQUIRES_DEV 1 401*ff94bc40SHeiko Schocher #define FS_BINARY_MOUNTDATA 2 402*ff94bc40SHeiko Schocher #define FS_HAS_SUBTYPE 4 403*ff94bc40SHeiko Schocher #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ 404*ff94bc40SHeiko Schocher #define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */ 405*ff94bc40SHeiko Schocher #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ 406*ff94bc40SHeiko Schocher struct dentry *(*mount) (struct file_system_type *, int, 407*ff94bc40SHeiko Schocher const char *, void *); 4089eefe2a2SStefan Roese void (*kill_sb) (struct super_block *); 4099eefe2a2SStefan Roese struct module *owner; 4109eefe2a2SStefan Roese struct file_system_type * next; 411*ff94bc40SHeiko Schocher struct hlist_head fs_supers; 412*ff94bc40SHeiko Schocher 413*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 414*ff94bc40SHeiko Schocher struct lock_class_key s_lock_key; 415*ff94bc40SHeiko Schocher struct lock_class_key s_umount_key; 416*ff94bc40SHeiko Schocher struct lock_class_key s_vfs_rename_key; 417*ff94bc40SHeiko Schocher struct lock_class_key s_writers_key[SB_FREEZE_LEVELS]; 418*ff94bc40SHeiko Schocher 419*ff94bc40SHeiko Schocher struct lock_class_key i_lock_key; 420*ff94bc40SHeiko Schocher struct lock_class_key i_mutex_key; 421*ff94bc40SHeiko Schocher struct lock_class_key i_mutex_dir_key; 422*ff94bc40SHeiko Schocher #endif 4239eefe2a2SStefan Roese }; 4249eefe2a2SStefan Roese 425*ff94bc40SHeiko Schocher /* include/linux/mount.h */ 4269eefe2a2SStefan Roese struct vfsmount { 4279eefe2a2SStefan Roese struct dentry *mnt_root; /* root of the mounted tree */ 4289eefe2a2SStefan Roese struct super_block *mnt_sb; /* pointer to superblock */ 4299eefe2a2SStefan Roese int mnt_flags; 4309eefe2a2SStefan Roese }; 4319eefe2a2SStefan Roese 4329eefe2a2SStefan Roese struct path { 4339eefe2a2SStefan Roese struct vfsmount *mnt; 4349eefe2a2SStefan Roese struct dentry *dentry; 4359eefe2a2SStefan Roese }; 4369eefe2a2SStefan Roese 4379eefe2a2SStefan Roese struct file { 4389eefe2a2SStefan Roese struct path f_path; 4399eefe2a2SStefan Roese #define f_dentry f_path.dentry 4409eefe2a2SStefan Roese #define f_vfsmnt f_path.mnt 4419eefe2a2SStefan Roese const struct file_operations *f_op; 4429eefe2a2SStefan Roese unsigned int f_flags; 4439eefe2a2SStefan Roese loff_t f_pos; 4449eefe2a2SStefan Roese unsigned int f_uid, f_gid; 4459eefe2a2SStefan Roese 4469eefe2a2SStefan Roese u64 f_version; 4479eefe2a2SStefan Roese #ifdef CONFIG_SECURITY 4489eefe2a2SStefan Roese void *f_security; 4499eefe2a2SStefan Roese #endif 4509eefe2a2SStefan Roese /* needed for tty driver, and maybe others */ 4519eefe2a2SStefan Roese void *private_data; 4529eefe2a2SStefan Roese 4539eefe2a2SStefan Roese #ifdef CONFIG_EPOLL 4549eefe2a2SStefan Roese /* Used by fs/eventpoll.c to link all the hooks to this file */ 4559eefe2a2SStefan Roese struct list_head f_ep_links; 4569eefe2a2SStefan Roese spinlock_t f_ep_lock; 4579eefe2a2SStefan Roese #endif /* #ifdef CONFIG_EPOLL */ 4589eefe2a2SStefan Roese #ifdef CONFIG_DEBUG_WRITECOUNT 4599eefe2a2SStefan Roese unsigned long f_mnt_write_state; 4609eefe2a2SStefan Roese #endif 4619eefe2a2SStefan Roese }; 4629eefe2a2SStefan Roese 4639eefe2a2SStefan Roese /* 4649eefe2a2SStefan Roese * get_seconds() not really needed in the read-only implmentation 4659eefe2a2SStefan Roese */ 4669eefe2a2SStefan Roese #define get_seconds() 0 4679eefe2a2SStefan Roese 4689eefe2a2SStefan Roese /* 4k page size */ 4699eefe2a2SStefan Roese #define PAGE_CACHE_SHIFT 12 4709eefe2a2SStefan Roese #define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT) 4719eefe2a2SStefan Roese 4729eefe2a2SStefan Roese /* Page cache limit. The filesystems should put that into their s_maxbytes 4739eefe2a2SStefan Roese limits, otherwise bad things can happen in VM. */ 4749eefe2a2SStefan Roese #if BITS_PER_LONG==32 4759eefe2a2SStefan Roese #define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 4769eefe2a2SStefan Roese #elif BITS_PER_LONG==64 4779eefe2a2SStefan Roese #define MAX_LFS_FILESIZE 0x7fffffffffffffffUL 4789eefe2a2SStefan Roese #endif 4799eefe2a2SStefan Roese 4809eefe2a2SStefan Roese #define INT_MAX ((int)(~0U>>1)) 4819eefe2a2SStefan Roese #define INT_MIN (-INT_MAX - 1) 4829eefe2a2SStefan Roese #define LLONG_MAX ((long long)(~0ULL>>1)) 4839eefe2a2SStefan Roese 4849eefe2a2SStefan Roese /* 4859eefe2a2SStefan Roese * These are the fs-independent mount-flags: up to 32 flags are supported 4869eefe2a2SStefan Roese */ 4879eefe2a2SStefan Roese #define MS_RDONLY 1 /* Mount read-only */ 4889eefe2a2SStefan Roese #define MS_NOSUID 2 /* Ignore suid and sgid bits */ 4899eefe2a2SStefan Roese #define MS_NODEV 4 /* Disallow access to device special files */ 4909eefe2a2SStefan Roese #define MS_NOEXEC 8 /* Disallow program execution */ 4919eefe2a2SStefan Roese #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ 4929eefe2a2SStefan Roese #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ 4939eefe2a2SStefan Roese #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ 4949eefe2a2SStefan Roese #define MS_DIRSYNC 128 /* Directory modifications are synchronous */ 4959eefe2a2SStefan Roese #define MS_NOATIME 1024 /* Do not update access times. */ 4969eefe2a2SStefan Roese #define MS_NODIRATIME 2048 /* Do not update directory access times */ 4979eefe2a2SStefan Roese #define MS_BIND 4096 4989eefe2a2SStefan Roese #define MS_MOVE 8192 4999eefe2a2SStefan Roese #define MS_REC 16384 5009eefe2a2SStefan Roese #define MS_VERBOSE 32768 /* War is peace. Verbosity is silence. 5019eefe2a2SStefan Roese MS_VERBOSE is deprecated. */ 5029eefe2a2SStefan Roese #define MS_SILENT 32768 5039eefe2a2SStefan Roese #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ 5049eefe2a2SStefan Roese #define MS_UNBINDABLE (1<<17) /* change to unbindable */ 5059eefe2a2SStefan Roese #define MS_PRIVATE (1<<18) /* change to private */ 5069eefe2a2SStefan Roese #define MS_SLAVE (1<<19) /* change to slave */ 5079eefe2a2SStefan Roese #define MS_SHARED (1<<20) /* change to shared */ 5089eefe2a2SStefan Roese #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ 5099eefe2a2SStefan Roese #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ 5109eefe2a2SStefan Roese #define MS_I_VERSION (1<<23) /* Update inode I_version field */ 5119eefe2a2SStefan Roese #define MS_ACTIVE (1<<30) 5129eefe2a2SStefan Roese #define MS_NOUSER (1<<31) 5139eefe2a2SStefan Roese 5149eefe2a2SStefan Roese #define I_NEW 8 5159eefe2a2SStefan Roese 5169eefe2a2SStefan Roese /* Inode flags - they have nothing to superblock flags now */ 5179eefe2a2SStefan Roese 5189eefe2a2SStefan Roese #define S_SYNC 1 /* Writes are synced at once */ 5199eefe2a2SStefan Roese #define S_NOATIME 2 /* Do not update access times */ 5209eefe2a2SStefan Roese #define S_APPEND 4 /* Append-only file */ 5219eefe2a2SStefan Roese #define S_IMMUTABLE 8 /* Immutable file */ 5229eefe2a2SStefan Roese #define S_DEAD 16 /* removed, but still open directory */ 5239eefe2a2SStefan Roese #define S_NOQUOTA 32 /* Inode is not counted to quota */ 5249eefe2a2SStefan Roese #define S_DIRSYNC 64 /* Directory modifications are synchronous */ 5259eefe2a2SStefan Roese #define S_NOCMTIME 128 /* Do not update file c/mtime */ 5269eefe2a2SStefan Roese #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ 5279eefe2a2SStefan Roese #define S_PRIVATE 512 /* Inode is fs-internal */ 5289eefe2a2SStefan Roese 5299eefe2a2SStefan Roese /* include/linux/stat.h */ 5309eefe2a2SStefan Roese 5319eefe2a2SStefan Roese #define S_IFMT 00170000 5329eefe2a2SStefan Roese #define S_IFSOCK 0140000 5339eefe2a2SStefan Roese #define S_IFLNK 0120000 5349eefe2a2SStefan Roese #define S_IFREG 0100000 5359eefe2a2SStefan Roese #define S_IFBLK 0060000 5369eefe2a2SStefan Roese #define S_IFDIR 0040000 5379eefe2a2SStefan Roese #define S_IFCHR 0020000 5389eefe2a2SStefan Roese #define S_IFIFO 0010000 5399eefe2a2SStefan Roese #define S_ISUID 0004000 5409eefe2a2SStefan Roese #define S_ISGID 0002000 5419eefe2a2SStefan Roese #define S_ISVTX 0001000 5429eefe2a2SStefan Roese 5439eefe2a2SStefan Roese /* include/linux/fs.h */ 5449eefe2a2SStefan Roese 5459eefe2a2SStefan Roese /* 5469eefe2a2SStefan Roese * File types 5479eefe2a2SStefan Roese * 5489eefe2a2SStefan Roese * NOTE! These match bits 12..15 of stat.st_mode 5499eefe2a2SStefan Roese * (ie "(i_mode >> 12) & 15"). 5509eefe2a2SStefan Roese */ 5519eefe2a2SStefan Roese #define DT_UNKNOWN 0 5529eefe2a2SStefan Roese #define DT_FIFO 1 5539eefe2a2SStefan Roese #define DT_CHR 2 5549eefe2a2SStefan Roese #define DT_DIR 4 5559eefe2a2SStefan Roese #define DT_BLK 6 5569eefe2a2SStefan Roese #define DT_REG 8 5579eefe2a2SStefan Roese #define DT_LNK 10 5589eefe2a2SStefan Roese #define DT_SOCK 12 5599eefe2a2SStefan Roese #define DT_WHT 14 5609eefe2a2SStefan Roese 5619eefe2a2SStefan Roese #define I_DIRTY_SYNC 1 5629eefe2a2SStefan Roese #define I_DIRTY_DATASYNC 2 5639eefe2a2SStefan Roese #define I_DIRTY_PAGES 4 5649eefe2a2SStefan Roese #define I_NEW 8 5659eefe2a2SStefan Roese #define I_WILL_FREE 16 5669eefe2a2SStefan Roese #define I_FREEING 32 5679eefe2a2SStefan Roese #define I_CLEAR 64 5689eefe2a2SStefan Roese #define __I_LOCK 7 5699eefe2a2SStefan Roese #define I_LOCK (1 << __I_LOCK) 5709eefe2a2SStefan Roese #define __I_SYNC 8 5719eefe2a2SStefan Roese #define I_SYNC (1 << __I_SYNC) 5729eefe2a2SStefan Roese 5739eefe2a2SStefan Roese #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 5749eefe2a2SStefan Roese 5759eefe2a2SStefan Roese /* linux/include/dcache.h */ 5769eefe2a2SStefan Roese 5779eefe2a2SStefan Roese #define DNAME_INLINE_LEN_MIN 36 5789eefe2a2SStefan Roese 5799eefe2a2SStefan Roese struct dentry { 5809eefe2a2SStefan Roese unsigned int d_flags; /* protected by d_lock */ 5819eefe2a2SStefan Roese spinlock_t d_lock; /* per dentry lock */ 5829eefe2a2SStefan Roese struct inode *d_inode; /* Where the name belongs to - NULL is 5839eefe2a2SStefan Roese * negative */ 5849eefe2a2SStefan Roese /* 5859eefe2a2SStefan Roese * The next three fields are touched by __d_lookup. Place them here 5869eefe2a2SStefan Roese * so they all fit in a cache line. 5879eefe2a2SStefan Roese */ 5889eefe2a2SStefan Roese struct hlist_node d_hash; /* lookup hash list */ 5899eefe2a2SStefan Roese struct dentry *d_parent; /* parent directory */ 5909eefe2a2SStefan Roese struct qstr d_name; 5919eefe2a2SStefan Roese 5929eefe2a2SStefan Roese struct list_head d_lru; /* LRU list */ 5939eefe2a2SStefan Roese /* 5949eefe2a2SStefan Roese * d_child and d_rcu can share memory 5959eefe2a2SStefan Roese */ 5969eefe2a2SStefan Roese struct list_head d_subdirs; /* our children */ 5979eefe2a2SStefan Roese struct list_head d_alias; /* inode alias list */ 5989eefe2a2SStefan Roese unsigned long d_time; /* used by d_revalidate */ 5999eefe2a2SStefan Roese struct super_block *d_sb; /* The root of the dentry tree */ 6009eefe2a2SStefan Roese void *d_fsdata; /* fs-specific data */ 6019eefe2a2SStefan Roese #ifdef CONFIG_PROFILING 6029eefe2a2SStefan Roese struct dcookie_struct *d_cookie; /* cookie, if any */ 6039eefe2a2SStefan Roese #endif 6049eefe2a2SStefan Roese int d_mounted; 6059eefe2a2SStefan Roese unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ 6069eefe2a2SStefan Roese }; 6079eefe2a2SStefan Roese 6089eefe2a2SStefan Roese static inline ino_t parent_ino(struct dentry *dentry) 6099eefe2a2SStefan Roese { 6109eefe2a2SStefan Roese ino_t res; 6119eefe2a2SStefan Roese 6129eefe2a2SStefan Roese spin_lock(&dentry->d_lock); 6139eefe2a2SStefan Roese res = dentry->d_parent->d_inode->i_ino; 6149eefe2a2SStefan Roese spin_unlock(&dentry->d_lock); 6159eefe2a2SStefan Roese return res; 6169eefe2a2SStefan Roese } 6179eefe2a2SStefan Roese 6189eefe2a2SStefan Roese /* debug.c */ 6199eefe2a2SStefan Roese 6209eefe2a2SStefan Roese #define module_param_named(...) 6219eefe2a2SStefan Roese 6229eefe2a2SStefan Roese /* misc.h */ 6239eefe2a2SStefan Roese #define mutex_lock_nested(...) 6249eefe2a2SStefan Roese #define mutex_unlock_nested(...) 6259eefe2a2SStefan Roese #define mutex_is_locked(...) 0 626*ff94bc40SHeiko Schocher #endif 6279eefe2a2SStefan Roese 6289eefe2a2SStefan Roese /* Version of this UBIFS implementation */ 6299eefe2a2SStefan Roese #define UBIFS_VERSION 1 6309eefe2a2SStefan Roese 6319eefe2a2SStefan Roese /* Normal UBIFS messages */ 632*ff94bc40SHeiko Schocher #define ubifs_msg(fmt, ...) pr_notice("UBIFS: " fmt "\n", ##__VA_ARGS__) 6339eefe2a2SStefan Roese /* UBIFS error messages */ 634*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 6359eefe2a2SStefan Roese #define ubifs_err(fmt, ...) \ 636*ff94bc40SHeiko Schocher pr_err("UBIFS error (pid %d): %s: " fmt "\n", current->pid, \ 6379eefe2a2SStefan Roese __func__, ##__VA_ARGS__) 6389eefe2a2SStefan Roese /* UBIFS warning messages */ 6399eefe2a2SStefan Roese #define ubifs_warn(fmt, ...) \ 640*ff94bc40SHeiko Schocher pr_warn("UBIFS warning (pid %d): %s: " fmt "\n", \ 641*ff94bc40SHeiko Schocher current->pid, __func__, ##__VA_ARGS__) 642*ff94bc40SHeiko Schocher #else 643*ff94bc40SHeiko Schocher #define ubifs_err(fmt, ...) \ 644*ff94bc40SHeiko Schocher pr_err("UBIFS error: %s: " fmt "\n", __func__, ##__VA_ARGS__) 645*ff94bc40SHeiko Schocher /* UBIFS warning messages */ 646*ff94bc40SHeiko Schocher #define ubifs_warn(fmt, ...) \ 647*ff94bc40SHeiko Schocher pr_warn("UBIFS warning: %s: " fmt "\n", __func__, ##__VA_ARGS__) 648*ff94bc40SHeiko Schocher #endif 6499eefe2a2SStefan Roese 6509eefe2a2SStefan Roese /* UBIFS file system VFS magic number */ 6519eefe2a2SStefan Roese #define UBIFS_SUPER_MAGIC 0x24051905 6529eefe2a2SStefan Roese 6539eefe2a2SStefan Roese /* Number of UBIFS blocks per VFS page */ 6549eefe2a2SStefan Roese #define UBIFS_BLOCKS_PER_PAGE (PAGE_CACHE_SIZE / UBIFS_BLOCK_SIZE) 6559eefe2a2SStefan Roese #define UBIFS_BLOCKS_PER_PAGE_SHIFT (PAGE_CACHE_SHIFT - UBIFS_BLOCK_SHIFT) 6569eefe2a2SStefan Roese 6579eefe2a2SStefan Roese /* "File system end of life" sequence number watermark */ 6589eefe2a2SStefan Roese #define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL 6599eefe2a2SStefan Roese #define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL 6609eefe2a2SStefan Roese 6619eefe2a2SStefan Roese /* 6629eefe2a2SStefan Roese * Minimum amount of LEBs reserved for the index. At present the index needs at 6639eefe2a2SStefan Roese * least 2 LEBs: one for the index head and one for in-the-gaps method (which 6649eefe2a2SStefan Roese * currently does not cater for the index head and so excludes it from 6659eefe2a2SStefan Roese * consideration). 6669eefe2a2SStefan Roese */ 6679eefe2a2SStefan Roese #define MIN_INDEX_LEBS 2 6689eefe2a2SStefan Roese 6699eefe2a2SStefan Roese /* Minimum amount of data UBIFS writes to the flash */ 6709eefe2a2SStefan Roese #define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8) 6719eefe2a2SStefan Roese 6729eefe2a2SStefan Roese /* 6739eefe2a2SStefan Roese * Currently we do not support inode number overlapping and re-using, so this 6749eefe2a2SStefan Roese * watermark defines dangerous inode number level. This should be fixed later, 6759eefe2a2SStefan Roese * although it is difficult to exceed current limit. Another option is to use 6769eefe2a2SStefan Roese * 64-bit inode numbers, but this means more overhead. 6779eefe2a2SStefan Roese */ 6789eefe2a2SStefan Roese #define INUM_WARN_WATERMARK 0xFFF00000 6799eefe2a2SStefan Roese #define INUM_WATERMARK 0xFFFFFF00 6809eefe2a2SStefan Roese 6819eefe2a2SStefan Roese /* Maximum number of entries in each LPT (LEB category) heap */ 6829eefe2a2SStefan Roese #define LPT_HEAP_SZ 256 6839eefe2a2SStefan Roese 6849eefe2a2SStefan Roese /* 6859eefe2a2SStefan Roese * Background thread name pattern. The numbers are UBI device and volume 6869eefe2a2SStefan Roese * numbers. 6879eefe2a2SStefan Roese */ 6889eefe2a2SStefan Roese #define BGT_NAME_PATTERN "ubifs_bgt%d_%d" 6899eefe2a2SStefan Roese 690*ff94bc40SHeiko Schocher /* Write-buffer synchronization timeout interval in seconds */ 691*ff94bc40SHeiko Schocher #define WBUF_TIMEOUT_SOFTLIMIT 3 692*ff94bc40SHeiko Schocher #define WBUF_TIMEOUT_HARDLIMIT 5 6939eefe2a2SStefan Roese 6949eefe2a2SStefan Roese /* Maximum possible inode number (only 32-bit inodes are supported now) */ 6959eefe2a2SStefan Roese #define MAX_INUM 0xFFFFFFFF 6969eefe2a2SStefan Roese 6979eefe2a2SStefan Roese /* Number of non-data journal heads */ 6989eefe2a2SStefan Roese #define NONDATA_JHEADS_CNT 2 6999eefe2a2SStefan Roese 700*ff94bc40SHeiko Schocher /* Shorter names for journal head numbers for internal usage */ 701*ff94bc40SHeiko Schocher #define GCHD UBIFS_GC_HEAD 702*ff94bc40SHeiko Schocher #define BASEHD UBIFS_BASE_HEAD 703*ff94bc40SHeiko Schocher #define DATAHD UBIFS_DATA_HEAD 7049eefe2a2SStefan Roese 7059eefe2a2SStefan Roese /* 'No change' value for 'ubifs_change_lp()' */ 7069eefe2a2SStefan Roese #define LPROPS_NC 0x80000001 7079eefe2a2SStefan Roese 7089eefe2a2SStefan Roese /* 7099eefe2a2SStefan Roese * There is no notion of truncation key because truncation nodes do not exist 7109eefe2a2SStefan Roese * in TNC. However, when replaying, it is handy to introduce fake "truncation" 7119eefe2a2SStefan Roese * keys for truncation nodes because the code becomes simpler. So we define 7129eefe2a2SStefan Roese * %UBIFS_TRUN_KEY type. 713*ff94bc40SHeiko Schocher * 714*ff94bc40SHeiko Schocher * But otherwise, out of the journal reply scope, the truncation keys are 715*ff94bc40SHeiko Schocher * invalid. 7169eefe2a2SStefan Roese */ 7179eefe2a2SStefan Roese #define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT 718*ff94bc40SHeiko Schocher #define UBIFS_INVALID_KEY UBIFS_KEY_TYPES_CNT 7199eefe2a2SStefan Roese 7209eefe2a2SStefan Roese /* 7219eefe2a2SStefan Roese * How much a directory entry/extended attribute entry adds to the parent/host 7229eefe2a2SStefan Roese * inode. 7239eefe2a2SStefan Roese */ 7249eefe2a2SStefan Roese #define CALC_DENT_SIZE(name_len) ALIGN(UBIFS_DENT_NODE_SZ + (name_len) + 1, 8) 7259eefe2a2SStefan Roese 7269eefe2a2SStefan Roese /* How much an extended attribute adds to the host inode */ 7279eefe2a2SStefan Roese #define CALC_XATTR_BYTES(data_len) ALIGN(UBIFS_INO_NODE_SZ + (data_len) + 1, 8) 7289eefe2a2SStefan Roese 7299eefe2a2SStefan Roese /* 7309eefe2a2SStefan Roese * Znodes which were not touched for 'OLD_ZNODE_AGE' seconds are considered 7319eefe2a2SStefan Roese * "old", and znode which were touched last 'YOUNG_ZNODE_AGE' seconds ago are 7329eefe2a2SStefan Roese * considered "young". This is used by shrinker when selecting znode to trim 7339eefe2a2SStefan Roese * off. 7349eefe2a2SStefan Roese */ 7359eefe2a2SStefan Roese #define OLD_ZNODE_AGE 20 7369eefe2a2SStefan Roese #define YOUNG_ZNODE_AGE 5 7379eefe2a2SStefan Roese 7389eefe2a2SStefan Roese /* 7399eefe2a2SStefan Roese * Some compressors, like LZO, may end up with more data then the input buffer. 7409eefe2a2SStefan Roese * So UBIFS always allocates larger output buffer, to be sure the compressor 7419eefe2a2SStefan Roese * will not corrupt memory in case of worst case compression. 7429eefe2a2SStefan Roese */ 7439eefe2a2SStefan Roese #define WORST_COMPR_FACTOR 2 7449eefe2a2SStefan Roese 745*ff94bc40SHeiko Schocher /* 746*ff94bc40SHeiko Schocher * How much memory is needed for a buffer where we comress a data node. 747*ff94bc40SHeiko Schocher */ 748*ff94bc40SHeiko Schocher #define COMPRESSED_DATA_NODE_BUF_SZ \ 749*ff94bc40SHeiko Schocher (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR) 750*ff94bc40SHeiko Schocher 7519eefe2a2SStefan Roese /* Maximum expected tree height for use by bottom_up_buf */ 7529eefe2a2SStefan Roese #define BOTTOM_UP_HEIGHT 64 7539eefe2a2SStefan Roese 7549eefe2a2SStefan Roese /* Maximum number of data nodes to bulk-read */ 7559eefe2a2SStefan Roese #define UBIFS_MAX_BULK_READ 32 7569eefe2a2SStefan Roese 7579eefe2a2SStefan Roese /* 7589eefe2a2SStefan Roese * Lockdep classes for UBIFS inode @ui_mutex. 7599eefe2a2SStefan Roese */ 7609eefe2a2SStefan Roese enum { 7619eefe2a2SStefan Roese WB_MUTEX_1 = 0, 7629eefe2a2SStefan Roese WB_MUTEX_2 = 1, 7639eefe2a2SStefan Roese WB_MUTEX_3 = 2, 7649eefe2a2SStefan Roese }; 7659eefe2a2SStefan Roese 7669eefe2a2SStefan Roese /* 7679eefe2a2SStefan Roese * Znode flags (actually, bit numbers which store the flags). 7689eefe2a2SStefan Roese * 7699eefe2a2SStefan Roese * DIRTY_ZNODE: znode is dirty 7709eefe2a2SStefan Roese * COW_ZNODE: znode is being committed and a new instance of this znode has to 7719eefe2a2SStefan Roese * be created before changing this znode 7729eefe2a2SStefan Roese * OBSOLETE_ZNODE: znode is obsolete, which means it was deleted, but it is 7739eefe2a2SStefan Roese * still in the commit list and the ongoing commit operation 7749eefe2a2SStefan Roese * will commit it, and delete this znode after it is done 7759eefe2a2SStefan Roese */ 7769eefe2a2SStefan Roese enum { 7779eefe2a2SStefan Roese DIRTY_ZNODE = 0, 7789eefe2a2SStefan Roese COW_ZNODE = 1, 7799eefe2a2SStefan Roese OBSOLETE_ZNODE = 2, 7809eefe2a2SStefan Roese }; 7819eefe2a2SStefan Roese 7829eefe2a2SStefan Roese /* 7839eefe2a2SStefan Roese * Commit states. 7849eefe2a2SStefan Roese * 7859eefe2a2SStefan Roese * COMMIT_RESTING: commit is not wanted 7869eefe2a2SStefan Roese * COMMIT_BACKGROUND: background commit has been requested 7879eefe2a2SStefan Roese * COMMIT_REQUIRED: commit is required 7889eefe2a2SStefan Roese * COMMIT_RUNNING_BACKGROUND: background commit is running 7899eefe2a2SStefan Roese * COMMIT_RUNNING_REQUIRED: commit is running and it is required 7909eefe2a2SStefan Roese * COMMIT_BROKEN: commit failed 7919eefe2a2SStefan Roese */ 7929eefe2a2SStefan Roese enum { 7939eefe2a2SStefan Roese COMMIT_RESTING = 0, 7949eefe2a2SStefan Roese COMMIT_BACKGROUND, 7959eefe2a2SStefan Roese COMMIT_REQUIRED, 7969eefe2a2SStefan Roese COMMIT_RUNNING_BACKGROUND, 7979eefe2a2SStefan Roese COMMIT_RUNNING_REQUIRED, 7989eefe2a2SStefan Roese COMMIT_BROKEN, 7999eefe2a2SStefan Roese }; 8009eefe2a2SStefan Roese 8019eefe2a2SStefan Roese /* 8029eefe2a2SStefan Roese * 'ubifs_scan_a_node()' return values. 8039eefe2a2SStefan Roese * 8049eefe2a2SStefan Roese * SCANNED_GARBAGE: scanned garbage 8059eefe2a2SStefan Roese * SCANNED_EMPTY_SPACE: scanned empty space 8069eefe2a2SStefan Roese * SCANNED_A_NODE: scanned a valid node 8079eefe2a2SStefan Roese * SCANNED_A_CORRUPT_NODE: scanned a corrupted node 8089eefe2a2SStefan Roese * SCANNED_A_BAD_PAD_NODE: scanned a padding node with invalid pad length 8099eefe2a2SStefan Roese * 8109eefe2a2SStefan Roese * Greater than zero means: 'scanned that number of padding bytes' 8119eefe2a2SStefan Roese */ 8129eefe2a2SStefan Roese enum { 8139eefe2a2SStefan Roese SCANNED_GARBAGE = 0, 8149eefe2a2SStefan Roese SCANNED_EMPTY_SPACE = -1, 8159eefe2a2SStefan Roese SCANNED_A_NODE = -2, 8169eefe2a2SStefan Roese SCANNED_A_CORRUPT_NODE = -3, 8179eefe2a2SStefan Roese SCANNED_A_BAD_PAD_NODE = -4, 8189eefe2a2SStefan Roese }; 8199eefe2a2SStefan Roese 8209eefe2a2SStefan Roese /* 8219eefe2a2SStefan Roese * LPT cnode flag bits. 8229eefe2a2SStefan Roese * 8239eefe2a2SStefan Roese * DIRTY_CNODE: cnode is dirty 8249eefe2a2SStefan Roese * OBSOLETE_CNODE: cnode is being committed and has been copied (or deleted), 8259eefe2a2SStefan Roese * so it can (and must) be freed when the commit is finished 826*ff94bc40SHeiko Schocher * COW_CNODE: cnode is being committed and must be copied before writing 8279eefe2a2SStefan Roese */ 8289eefe2a2SStefan Roese enum { 8299eefe2a2SStefan Roese DIRTY_CNODE = 0, 830*ff94bc40SHeiko Schocher OBSOLETE_CNODE = 1, 831*ff94bc40SHeiko Schocher COW_CNODE = 2, 8329eefe2a2SStefan Roese }; 8339eefe2a2SStefan Roese 8349eefe2a2SStefan Roese /* 8359eefe2a2SStefan Roese * Dirty flag bits (lpt_drty_flgs) for LPT special nodes. 8369eefe2a2SStefan Roese * 8379eefe2a2SStefan Roese * LTAB_DIRTY: ltab node is dirty 8389eefe2a2SStefan Roese * LSAVE_DIRTY: lsave node is dirty 8399eefe2a2SStefan Roese */ 8409eefe2a2SStefan Roese enum { 8419eefe2a2SStefan Roese LTAB_DIRTY = 1, 8429eefe2a2SStefan Roese LSAVE_DIRTY = 2, 8439eefe2a2SStefan Roese }; 8449eefe2a2SStefan Roese 8459eefe2a2SStefan Roese /* 8469eefe2a2SStefan Roese * Return codes used by the garbage collector. 8479eefe2a2SStefan Roese * @LEB_FREED: the logical eraseblock was freed and is ready to use 8489eefe2a2SStefan Roese * @LEB_FREED_IDX: indexing LEB was freed and can be used only after the commit 8499eefe2a2SStefan Roese * @LEB_RETAINED: the logical eraseblock was freed and retained for GC purposes 8509eefe2a2SStefan Roese */ 8519eefe2a2SStefan Roese enum { 8529eefe2a2SStefan Roese LEB_FREED, 8539eefe2a2SStefan Roese LEB_FREED_IDX, 8549eefe2a2SStefan Roese LEB_RETAINED, 8559eefe2a2SStefan Roese }; 8569eefe2a2SStefan Roese 8579eefe2a2SStefan Roese /** 8589eefe2a2SStefan Roese * struct ubifs_old_idx - index node obsoleted since last commit start. 8599eefe2a2SStefan Roese * @rb: rb-tree node 8609eefe2a2SStefan Roese * @lnum: LEB number of obsoleted index node 8619eefe2a2SStefan Roese * @offs: offset of obsoleted index node 8629eefe2a2SStefan Roese */ 8639eefe2a2SStefan Roese struct ubifs_old_idx { 8649eefe2a2SStefan Roese struct rb_node rb; 8659eefe2a2SStefan Roese int lnum; 8669eefe2a2SStefan Roese int offs; 8679eefe2a2SStefan Roese }; 8689eefe2a2SStefan Roese 8699eefe2a2SStefan Roese /* The below union makes it easier to deal with keys */ 8709eefe2a2SStefan Roese union ubifs_key { 871*ff94bc40SHeiko Schocher uint8_t u8[UBIFS_SK_LEN]; 872*ff94bc40SHeiko Schocher uint32_t u32[UBIFS_SK_LEN/4]; 873*ff94bc40SHeiko Schocher uint64_t u64[UBIFS_SK_LEN/8]; 874*ff94bc40SHeiko Schocher __le32 j32[UBIFS_SK_LEN/4]; 8759eefe2a2SStefan Roese }; 8769eefe2a2SStefan Roese 8779eefe2a2SStefan Roese /** 8789eefe2a2SStefan Roese * struct ubifs_scan_node - UBIFS scanned node information. 8799eefe2a2SStefan Roese * @list: list of scanned nodes 8809eefe2a2SStefan Roese * @key: key of node scanned (if it has one) 8819eefe2a2SStefan Roese * @sqnum: sequence number 8829eefe2a2SStefan Roese * @type: type of node scanned 8839eefe2a2SStefan Roese * @offs: offset with LEB of node scanned 8849eefe2a2SStefan Roese * @len: length of node scanned 8859eefe2a2SStefan Roese * @node: raw node 8869eefe2a2SStefan Roese */ 8879eefe2a2SStefan Roese struct ubifs_scan_node { 8889eefe2a2SStefan Roese struct list_head list; 8899eefe2a2SStefan Roese union ubifs_key key; 8909eefe2a2SStefan Roese unsigned long long sqnum; 8919eefe2a2SStefan Roese int type; 8929eefe2a2SStefan Roese int offs; 8939eefe2a2SStefan Roese int len; 8949eefe2a2SStefan Roese void *node; 8959eefe2a2SStefan Roese }; 8969eefe2a2SStefan Roese 8979eefe2a2SStefan Roese /** 8989eefe2a2SStefan Roese * struct ubifs_scan_leb - UBIFS scanned LEB information. 8999eefe2a2SStefan Roese * @lnum: logical eraseblock number 9009eefe2a2SStefan Roese * @nodes_cnt: number of nodes scanned 9019eefe2a2SStefan Roese * @nodes: list of struct ubifs_scan_node 9029eefe2a2SStefan Roese * @endpt: end point (and therefore the start of empty space) 9039eefe2a2SStefan Roese * @ecc: read returned -EBADMSG 9049eefe2a2SStefan Roese * @buf: buffer containing entire LEB scanned 9059eefe2a2SStefan Roese */ 9069eefe2a2SStefan Roese struct ubifs_scan_leb { 9079eefe2a2SStefan Roese int lnum; 9089eefe2a2SStefan Roese int nodes_cnt; 9099eefe2a2SStefan Roese struct list_head nodes; 9109eefe2a2SStefan Roese int endpt; 9119eefe2a2SStefan Roese int ecc; 9129eefe2a2SStefan Roese void *buf; 9139eefe2a2SStefan Roese }; 9149eefe2a2SStefan Roese 9159eefe2a2SStefan Roese /** 9169eefe2a2SStefan Roese * struct ubifs_gced_idx_leb - garbage-collected indexing LEB. 9179eefe2a2SStefan Roese * @list: list 9189eefe2a2SStefan Roese * @lnum: LEB number 9199eefe2a2SStefan Roese * @unmap: OK to unmap this LEB 9209eefe2a2SStefan Roese * 9219eefe2a2SStefan Roese * This data structure is used to temporary store garbage-collected indexing 9229eefe2a2SStefan Roese * LEBs - they are not released immediately, but only after the next commit. 9239eefe2a2SStefan Roese * This is needed to guarantee recoverability. 9249eefe2a2SStefan Roese */ 9259eefe2a2SStefan Roese struct ubifs_gced_idx_leb { 9269eefe2a2SStefan Roese struct list_head list; 9279eefe2a2SStefan Roese int lnum; 9289eefe2a2SStefan Roese int unmap; 9299eefe2a2SStefan Roese }; 9309eefe2a2SStefan Roese 9319eefe2a2SStefan Roese /** 9329eefe2a2SStefan Roese * struct ubifs_inode - UBIFS in-memory inode description. 9339eefe2a2SStefan Roese * @vfs_inode: VFS inode description object 9349eefe2a2SStefan Roese * @creat_sqnum: sequence number at time of creation 9359eefe2a2SStefan Roese * @del_cmtno: commit number corresponding to the time the inode was deleted, 9369eefe2a2SStefan Roese * protected by @c->commit_sem; 9379eefe2a2SStefan Roese * @xattr_size: summarized size of all extended attributes in bytes 9389eefe2a2SStefan Roese * @xattr_cnt: count of extended attributes this inode has 9399eefe2a2SStefan Roese * @xattr_names: sum of lengths of all extended attribute names belonging to 9409eefe2a2SStefan Roese * this inode 9419eefe2a2SStefan Roese * @dirty: non-zero if the inode is dirty 9429eefe2a2SStefan Roese * @xattr: non-zero if this is an extended attribute inode 9439eefe2a2SStefan Roese * @bulk_read: non-zero if bulk-read should be used 9449eefe2a2SStefan Roese * @ui_mutex: serializes inode write-back with the rest of VFS operations, 9459eefe2a2SStefan Roese * serializes "clean <-> dirty" state changes, serializes bulk-read, 9469eefe2a2SStefan Roese * protects @dirty, @bulk_read, @ui_size, and @xattr_size 9479eefe2a2SStefan Roese * @ui_lock: protects @synced_i_size 9489eefe2a2SStefan Roese * @synced_i_size: synchronized size of inode, i.e. the value of inode size 9499eefe2a2SStefan Roese * currently stored on the flash; used only for regular file 9509eefe2a2SStefan Roese * inodes 9519eefe2a2SStefan Roese * @ui_size: inode size used by UBIFS when writing to flash 9529eefe2a2SStefan Roese * @flags: inode flags (@UBIFS_COMPR_FL, etc) 9539eefe2a2SStefan Roese * @compr_type: default compression type used for this inode 9549eefe2a2SStefan Roese * @last_page_read: page number of last page read (for bulk read) 9559eefe2a2SStefan Roese * @read_in_a_row: number of consecutive pages read in a row (for bulk read) 9569eefe2a2SStefan Roese * @data_len: length of the data attached to the inode 9579eefe2a2SStefan Roese * @data: inode's data 9589eefe2a2SStefan Roese * 9599eefe2a2SStefan Roese * @ui_mutex exists for two main reasons. At first it prevents inodes from 9609eefe2a2SStefan Roese * being written back while UBIFS changing them, being in the middle of an VFS 9619eefe2a2SStefan Roese * operation. This way UBIFS makes sure the inode fields are consistent. For 9629eefe2a2SStefan Roese * example, in 'ubifs_rename()' we change 3 inodes simultaneously, and 9639eefe2a2SStefan Roese * write-back must not write any of them before we have finished. 9649eefe2a2SStefan Roese * 9659eefe2a2SStefan Roese * The second reason is budgeting - UBIFS has to budget all operations. If an 9669eefe2a2SStefan Roese * operation is going to mark an inode dirty, it has to allocate budget for 9679eefe2a2SStefan Roese * this. It cannot just mark it dirty because there is no guarantee there will 9689eefe2a2SStefan Roese * be enough flash space to write the inode back later. This means UBIFS has 9699eefe2a2SStefan Roese * to have full control over inode "clean <-> dirty" transitions (and pages 9709eefe2a2SStefan Roese * actually). But unfortunately, VFS marks inodes dirty in many places, and it 9719eefe2a2SStefan Roese * does not ask the file-system if it is allowed to do so (there is a notifier, 9729eefe2a2SStefan Roese * but it is not enough), i.e., there is no mechanism to synchronize with this. 9739eefe2a2SStefan Roese * So UBIFS has its own inode dirty flag and its own mutex to serialize 9749eefe2a2SStefan Roese * "clean <-> dirty" transitions. 9759eefe2a2SStefan Roese * 9769eefe2a2SStefan Roese * The @synced_i_size field is used to make sure we never write pages which are 9779eefe2a2SStefan Roese * beyond last synchronized inode size. See 'ubifs_writepage()' for more 9789eefe2a2SStefan Roese * information. 9799eefe2a2SStefan Roese * 9809eefe2a2SStefan Roese * The @ui_size is a "shadow" variable for @inode->i_size and UBIFS uses 9819eefe2a2SStefan Roese * @ui_size instead of @inode->i_size. The reason for this is that UBIFS cannot 9829eefe2a2SStefan Roese * make sure @inode->i_size is always changed under @ui_mutex, because it 983*ff94bc40SHeiko Schocher * cannot call 'truncate_setsize()' with @ui_mutex locked, because it would 984*ff94bc40SHeiko Schocher * deadlock with 'ubifs_writepage()' (see file.c). All the other inode fields 985*ff94bc40SHeiko Schocher * are changed under @ui_mutex, so they do not need "shadow" fields. Note, one 9869eefe2a2SStefan Roese * could consider to rework locking and base it on "shadow" fields. 9879eefe2a2SStefan Roese */ 9889eefe2a2SStefan Roese struct ubifs_inode { 9899eefe2a2SStefan Roese struct inode vfs_inode; 9909eefe2a2SStefan Roese unsigned long long creat_sqnum; 9919eefe2a2SStefan Roese unsigned long long del_cmtno; 9929eefe2a2SStefan Roese unsigned int xattr_size; 9939eefe2a2SStefan Roese unsigned int xattr_cnt; 9949eefe2a2SStefan Roese unsigned int xattr_names; 9959eefe2a2SStefan Roese unsigned int dirty:1; 9969eefe2a2SStefan Roese unsigned int xattr:1; 9979eefe2a2SStefan Roese unsigned int bulk_read:1; 9989eefe2a2SStefan Roese unsigned int compr_type:2; 9999eefe2a2SStefan Roese struct mutex ui_mutex; 10009eefe2a2SStefan Roese spinlock_t ui_lock; 10019eefe2a2SStefan Roese loff_t synced_i_size; 10029eefe2a2SStefan Roese loff_t ui_size; 10039eefe2a2SStefan Roese int flags; 10049eefe2a2SStefan Roese pgoff_t last_page_read; 10059eefe2a2SStefan Roese pgoff_t read_in_a_row; 10069eefe2a2SStefan Roese int data_len; 10079eefe2a2SStefan Roese void *data; 10089eefe2a2SStefan Roese }; 10099eefe2a2SStefan Roese 10109eefe2a2SStefan Roese /** 10119eefe2a2SStefan Roese * struct ubifs_unclean_leb - records a LEB recovered under read-only mode. 10129eefe2a2SStefan Roese * @list: list 10139eefe2a2SStefan Roese * @lnum: LEB number of recovered LEB 10149eefe2a2SStefan Roese * @endpt: offset where recovery ended 10159eefe2a2SStefan Roese * 10169eefe2a2SStefan Roese * This structure records a LEB identified during recovery that needs to be 10179eefe2a2SStefan Roese * cleaned but was not because UBIFS was mounted read-only. The information 10189eefe2a2SStefan Roese * is used to clean the LEB when remounting to read-write mode. 10199eefe2a2SStefan Roese */ 10209eefe2a2SStefan Roese struct ubifs_unclean_leb { 10219eefe2a2SStefan Roese struct list_head list; 10229eefe2a2SStefan Roese int lnum; 10239eefe2a2SStefan Roese int endpt; 10249eefe2a2SStefan Roese }; 10259eefe2a2SStefan Roese 10269eefe2a2SStefan Roese /* 10279eefe2a2SStefan Roese * LEB properties flags. 10289eefe2a2SStefan Roese * 10299eefe2a2SStefan Roese * LPROPS_UNCAT: not categorized 10309eefe2a2SStefan Roese * LPROPS_DIRTY: dirty > free, dirty >= @c->dead_wm, not index 10319eefe2a2SStefan Roese * LPROPS_DIRTY_IDX: dirty + free > @c->min_idx_node_sze and index 10329eefe2a2SStefan Roese * LPROPS_FREE: free > 0, dirty < @c->dead_wm, not empty, not index 10339eefe2a2SStefan Roese * LPROPS_HEAP_CNT: number of heaps used for storing categorized LEBs 10349eefe2a2SStefan Roese * LPROPS_EMPTY: LEB is empty, not taken 10359eefe2a2SStefan Roese * LPROPS_FREEABLE: free + dirty == leb_size, not index, not taken 10369eefe2a2SStefan Roese * LPROPS_FRDI_IDX: free + dirty == leb_size and index, may be taken 10379eefe2a2SStefan Roese * LPROPS_CAT_MASK: mask for the LEB categories above 10389eefe2a2SStefan Roese * LPROPS_TAKEN: LEB was taken (this flag is not saved on the media) 10399eefe2a2SStefan Roese * LPROPS_INDEX: LEB contains indexing nodes (this flag also exists on flash) 10409eefe2a2SStefan Roese */ 10419eefe2a2SStefan Roese enum { 10429eefe2a2SStefan Roese LPROPS_UNCAT = 0, 10439eefe2a2SStefan Roese LPROPS_DIRTY = 1, 10449eefe2a2SStefan Roese LPROPS_DIRTY_IDX = 2, 10459eefe2a2SStefan Roese LPROPS_FREE = 3, 10469eefe2a2SStefan Roese LPROPS_HEAP_CNT = 3, 10479eefe2a2SStefan Roese LPROPS_EMPTY = 4, 10489eefe2a2SStefan Roese LPROPS_FREEABLE = 5, 10499eefe2a2SStefan Roese LPROPS_FRDI_IDX = 6, 10509eefe2a2SStefan Roese LPROPS_CAT_MASK = 15, 10519eefe2a2SStefan Roese LPROPS_TAKEN = 16, 10529eefe2a2SStefan Roese LPROPS_INDEX = 32, 10539eefe2a2SStefan Roese }; 10549eefe2a2SStefan Roese 10559eefe2a2SStefan Roese /** 10569eefe2a2SStefan Roese * struct ubifs_lprops - logical eraseblock properties. 10579eefe2a2SStefan Roese * @free: amount of free space in bytes 10589eefe2a2SStefan Roese * @dirty: amount of dirty space in bytes 10599eefe2a2SStefan Roese * @flags: LEB properties flags (see above) 10609eefe2a2SStefan Roese * @lnum: LEB number 10619eefe2a2SStefan Roese * @list: list of same-category lprops (for LPROPS_EMPTY and LPROPS_FREEABLE) 10629eefe2a2SStefan Roese * @hpos: heap position in heap of same-category lprops (other categories) 10639eefe2a2SStefan Roese */ 10649eefe2a2SStefan Roese struct ubifs_lprops { 10659eefe2a2SStefan Roese int free; 10669eefe2a2SStefan Roese int dirty; 10679eefe2a2SStefan Roese int flags; 10689eefe2a2SStefan Roese int lnum; 10699eefe2a2SStefan Roese union { 10709eefe2a2SStefan Roese struct list_head list; 10719eefe2a2SStefan Roese int hpos; 10729eefe2a2SStefan Roese }; 10739eefe2a2SStefan Roese }; 10749eefe2a2SStefan Roese 10759eefe2a2SStefan Roese /** 10769eefe2a2SStefan Roese * struct ubifs_lpt_lprops - LPT logical eraseblock properties. 10779eefe2a2SStefan Roese * @free: amount of free space in bytes 10789eefe2a2SStefan Roese * @dirty: amount of dirty space in bytes 10799eefe2a2SStefan Roese * @tgc: trivial GC flag (1 => unmap after commit end) 10809eefe2a2SStefan Roese * @cmt: commit flag (1 => reserved for commit) 10819eefe2a2SStefan Roese */ 10829eefe2a2SStefan Roese struct ubifs_lpt_lprops { 10839eefe2a2SStefan Roese int free; 10849eefe2a2SStefan Roese int dirty; 10859eefe2a2SStefan Roese unsigned tgc:1; 10869eefe2a2SStefan Roese unsigned cmt:1; 10879eefe2a2SStefan Roese }; 10889eefe2a2SStefan Roese 10899eefe2a2SStefan Roese /** 10909eefe2a2SStefan Roese * struct ubifs_lp_stats - statistics of eraseblocks in the main area. 10919eefe2a2SStefan Roese * @empty_lebs: number of empty LEBs 10929eefe2a2SStefan Roese * @taken_empty_lebs: number of taken LEBs 10939eefe2a2SStefan Roese * @idx_lebs: number of indexing LEBs 10949eefe2a2SStefan Roese * @total_free: total free space in bytes (includes all LEBs) 10959eefe2a2SStefan Roese * @total_dirty: total dirty space in bytes (includes all LEBs) 10969eefe2a2SStefan Roese * @total_used: total used space in bytes (does not include index LEBs) 10979eefe2a2SStefan Roese * @total_dead: total dead space in bytes (does not include index LEBs) 10989eefe2a2SStefan Roese * @total_dark: total dark space in bytes (does not include index LEBs) 10999eefe2a2SStefan Roese * 11009eefe2a2SStefan Roese * The @taken_empty_lebs field counts the LEBs that are in the transient state 11019eefe2a2SStefan Roese * of having been "taken" for use but not yet written to. @taken_empty_lebs is 11029eefe2a2SStefan Roese * needed to account correctly for @gc_lnum, otherwise @empty_lebs could be 11039eefe2a2SStefan Roese * used by itself (in which case 'unused_lebs' would be a better name). In the 11049eefe2a2SStefan Roese * case of @gc_lnum, it is "taken" at mount time or whenever a LEB is retained 11059eefe2a2SStefan Roese * by GC, but unlike other empty LEBs that are "taken", it may not be written 11069eefe2a2SStefan Roese * straight away (i.e. before the next commit start or unmount), so either 11079eefe2a2SStefan Roese * @gc_lnum must be specially accounted for, or the current approach followed 11089eefe2a2SStefan Roese * i.e. count it under @taken_empty_lebs. 11099eefe2a2SStefan Roese * 11109eefe2a2SStefan Roese * @empty_lebs includes @taken_empty_lebs. 11119eefe2a2SStefan Roese * 11129eefe2a2SStefan Roese * @total_used, @total_dead and @total_dark fields do not account indexing 11139eefe2a2SStefan Roese * LEBs. 11149eefe2a2SStefan Roese */ 11159eefe2a2SStefan Roese struct ubifs_lp_stats { 11169eefe2a2SStefan Roese int empty_lebs; 11179eefe2a2SStefan Roese int taken_empty_lebs; 11189eefe2a2SStefan Roese int idx_lebs; 11199eefe2a2SStefan Roese long long total_free; 11209eefe2a2SStefan Roese long long total_dirty; 11219eefe2a2SStefan Roese long long total_used; 11229eefe2a2SStefan Roese long long total_dead; 11239eefe2a2SStefan Roese long long total_dark; 11249eefe2a2SStefan Roese }; 11259eefe2a2SStefan Roese 11269eefe2a2SStefan Roese struct ubifs_nnode; 11279eefe2a2SStefan Roese 11289eefe2a2SStefan Roese /** 11299eefe2a2SStefan Roese * struct ubifs_cnode - LEB Properties Tree common node. 11309eefe2a2SStefan Roese * @parent: parent nnode 11319eefe2a2SStefan Roese * @cnext: next cnode to commit 11329eefe2a2SStefan Roese * @flags: flags (%DIRTY_LPT_NODE or %OBSOLETE_LPT_NODE) 11339eefe2a2SStefan Roese * @iip: index in parent 11349eefe2a2SStefan Roese * @level: level in the tree (zero for pnodes, greater than zero for nnodes) 11359eefe2a2SStefan Roese * @num: node number 11369eefe2a2SStefan Roese */ 11379eefe2a2SStefan Roese struct ubifs_cnode { 11389eefe2a2SStefan Roese struct ubifs_nnode *parent; 11399eefe2a2SStefan Roese struct ubifs_cnode *cnext; 11409eefe2a2SStefan Roese unsigned long flags; 11419eefe2a2SStefan Roese int iip; 11429eefe2a2SStefan Roese int level; 11439eefe2a2SStefan Roese int num; 11449eefe2a2SStefan Roese }; 11459eefe2a2SStefan Roese 11469eefe2a2SStefan Roese /** 11479eefe2a2SStefan Roese * struct ubifs_pnode - LEB Properties Tree leaf node. 11489eefe2a2SStefan Roese * @parent: parent nnode 11499eefe2a2SStefan Roese * @cnext: next cnode to commit 11509eefe2a2SStefan Roese * @flags: flags (%DIRTY_LPT_NODE or %OBSOLETE_LPT_NODE) 11519eefe2a2SStefan Roese * @iip: index in parent 11529eefe2a2SStefan Roese * @level: level in the tree (always zero for pnodes) 11539eefe2a2SStefan Roese * @num: node number 11549eefe2a2SStefan Roese * @lprops: LEB properties array 11559eefe2a2SStefan Roese */ 11569eefe2a2SStefan Roese struct ubifs_pnode { 11579eefe2a2SStefan Roese struct ubifs_nnode *parent; 11589eefe2a2SStefan Roese struct ubifs_cnode *cnext; 11599eefe2a2SStefan Roese unsigned long flags; 11609eefe2a2SStefan Roese int iip; 11619eefe2a2SStefan Roese int level; 11629eefe2a2SStefan Roese int num; 11639eefe2a2SStefan Roese struct ubifs_lprops lprops[UBIFS_LPT_FANOUT]; 11649eefe2a2SStefan Roese }; 11659eefe2a2SStefan Roese 11669eefe2a2SStefan Roese /** 11679eefe2a2SStefan Roese * struct ubifs_nbranch - LEB Properties Tree internal node branch. 11689eefe2a2SStefan Roese * @lnum: LEB number of child 11699eefe2a2SStefan Roese * @offs: offset of child 11709eefe2a2SStefan Roese * @nnode: nnode child 11719eefe2a2SStefan Roese * @pnode: pnode child 11729eefe2a2SStefan Roese * @cnode: cnode child 11739eefe2a2SStefan Roese */ 11749eefe2a2SStefan Roese struct ubifs_nbranch { 11759eefe2a2SStefan Roese int lnum; 11769eefe2a2SStefan Roese int offs; 11779eefe2a2SStefan Roese union { 11789eefe2a2SStefan Roese struct ubifs_nnode *nnode; 11799eefe2a2SStefan Roese struct ubifs_pnode *pnode; 11809eefe2a2SStefan Roese struct ubifs_cnode *cnode; 11819eefe2a2SStefan Roese }; 11829eefe2a2SStefan Roese }; 11839eefe2a2SStefan Roese 11849eefe2a2SStefan Roese /** 11859eefe2a2SStefan Roese * struct ubifs_nnode - LEB Properties Tree internal node. 11869eefe2a2SStefan Roese * @parent: parent nnode 11879eefe2a2SStefan Roese * @cnext: next cnode to commit 11889eefe2a2SStefan Roese * @flags: flags (%DIRTY_LPT_NODE or %OBSOLETE_LPT_NODE) 11899eefe2a2SStefan Roese * @iip: index in parent 11909eefe2a2SStefan Roese * @level: level in the tree (always greater than zero for nnodes) 11919eefe2a2SStefan Roese * @num: node number 11929eefe2a2SStefan Roese * @nbranch: branches to child nodes 11939eefe2a2SStefan Roese */ 11949eefe2a2SStefan Roese struct ubifs_nnode { 11959eefe2a2SStefan Roese struct ubifs_nnode *parent; 11969eefe2a2SStefan Roese struct ubifs_cnode *cnext; 11979eefe2a2SStefan Roese unsigned long flags; 11989eefe2a2SStefan Roese int iip; 11999eefe2a2SStefan Roese int level; 12009eefe2a2SStefan Roese int num; 12019eefe2a2SStefan Roese struct ubifs_nbranch nbranch[UBIFS_LPT_FANOUT]; 12029eefe2a2SStefan Roese }; 12039eefe2a2SStefan Roese 12049eefe2a2SStefan Roese /** 12059eefe2a2SStefan Roese * struct ubifs_lpt_heap - heap of categorized lprops. 12069eefe2a2SStefan Roese * @arr: heap array 12079eefe2a2SStefan Roese * @cnt: number in heap 12089eefe2a2SStefan Roese * @max_cnt: maximum number allowed in heap 12099eefe2a2SStefan Roese * 12109eefe2a2SStefan Roese * There are %LPROPS_HEAP_CNT heaps. 12119eefe2a2SStefan Roese */ 12129eefe2a2SStefan Roese struct ubifs_lpt_heap { 12139eefe2a2SStefan Roese struct ubifs_lprops **arr; 12149eefe2a2SStefan Roese int cnt; 12159eefe2a2SStefan Roese int max_cnt; 12169eefe2a2SStefan Roese }; 12179eefe2a2SStefan Roese 12189eefe2a2SStefan Roese /* 12199eefe2a2SStefan Roese * Return codes for LPT scan callback function. 12209eefe2a2SStefan Roese * 12219eefe2a2SStefan Roese * LPT_SCAN_CONTINUE: continue scanning 12229eefe2a2SStefan Roese * LPT_SCAN_ADD: add the LEB properties scanned to the tree in memory 12239eefe2a2SStefan Roese * LPT_SCAN_STOP: stop scanning 12249eefe2a2SStefan Roese */ 12259eefe2a2SStefan Roese enum { 12269eefe2a2SStefan Roese LPT_SCAN_CONTINUE = 0, 12279eefe2a2SStefan Roese LPT_SCAN_ADD = 1, 12289eefe2a2SStefan Roese LPT_SCAN_STOP = 2, 12299eefe2a2SStefan Roese }; 12309eefe2a2SStefan Roese 12319eefe2a2SStefan Roese struct ubifs_info; 12329eefe2a2SStefan Roese 12339eefe2a2SStefan Roese /* Callback used by the 'ubifs_lpt_scan_nolock()' function */ 12349eefe2a2SStefan Roese typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, 12359eefe2a2SStefan Roese const struct ubifs_lprops *lprops, 12369eefe2a2SStefan Roese int in_tree, void *data); 12379eefe2a2SStefan Roese 12389eefe2a2SStefan Roese /** 12399eefe2a2SStefan Roese * struct ubifs_wbuf - UBIFS write-buffer. 12409eefe2a2SStefan Roese * @c: UBIFS file-system description object 12419eefe2a2SStefan Roese * @buf: write-buffer (of min. flash I/O unit size) 12429eefe2a2SStefan Roese * @lnum: logical eraseblock number the write-buffer points to 12439eefe2a2SStefan Roese * @offs: write-buffer offset in this logical eraseblock 12449eefe2a2SStefan Roese * @avail: number of bytes available in the write-buffer 12459eefe2a2SStefan Roese * @used: number of used bytes in the write-buffer 1246*ff94bc40SHeiko Schocher * @size: write-buffer size (in [@c->min_io_size, @c->max_write_size] range) 12479eefe2a2SStefan Roese * @jhead: journal head the mutex belongs to (note, needed only to shut lockdep 12489eefe2a2SStefan Roese * up by 'mutex_lock_nested()). 12499eefe2a2SStefan Roese * @sync_callback: write-buffer synchronization callback 12509eefe2a2SStefan Roese * @io_mutex: serializes write-buffer I/O 12519eefe2a2SStefan Roese * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes 12529eefe2a2SStefan Roese * fields 1253*ff94bc40SHeiko Schocher * @softlimit: soft write-buffer timeout interval 1254*ff94bc40SHeiko Schocher * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit 1255*ff94bc40SHeiko Schocher * and @softlimit + @delta) 12569eefe2a2SStefan Roese * @timer: write-buffer timer 1257*ff94bc40SHeiko Schocher * @no_timer: non-zero if this write-buffer does not have a timer 1258*ff94bc40SHeiko Schocher * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing 12599eefe2a2SStefan Roese * @next_ino: points to the next position of the following inode number 12609eefe2a2SStefan Roese * @inodes: stores the inode numbers of the nodes which are in wbuf 12619eefe2a2SStefan Roese * 12629eefe2a2SStefan Roese * The write-buffer synchronization callback is called when the write-buffer is 12639eefe2a2SStefan Roese * synchronized in order to notify how much space was wasted due to 12649eefe2a2SStefan Roese * write-buffer padding and how much free space is left in the LEB. 12659eefe2a2SStefan Roese * 12669eefe2a2SStefan Roese * Note: the fields @buf, @lnum, @offs, @avail and @used can be read under 12679eefe2a2SStefan Roese * spin-lock or mutex because they are written under both mutex and spin-lock. 12689eefe2a2SStefan Roese * @buf is appended to under mutex but overwritten under both mutex and 12699eefe2a2SStefan Roese * spin-lock. Thus the data between @buf and @buf + @used can be read under 12709eefe2a2SStefan Roese * spinlock. 12719eefe2a2SStefan Roese */ 12729eefe2a2SStefan Roese struct ubifs_wbuf { 12739eefe2a2SStefan Roese struct ubifs_info *c; 12749eefe2a2SStefan Roese void *buf; 12759eefe2a2SStefan Roese int lnum; 12769eefe2a2SStefan Roese int offs; 12779eefe2a2SStefan Roese int avail; 12789eefe2a2SStefan Roese int used; 1279*ff94bc40SHeiko Schocher int size; 12809eefe2a2SStefan Roese int jhead; 12819eefe2a2SStefan Roese int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); 12829eefe2a2SStefan Roese struct mutex io_mutex; 12839eefe2a2SStefan Roese spinlock_t lock; 1284*ff94bc40SHeiko Schocher // ktime_t softlimit; 1285*ff94bc40SHeiko Schocher // unsigned long long delta; 1286*ff94bc40SHeiko Schocher // struct hrtimer timer; 1287*ff94bc40SHeiko Schocher unsigned int no_timer:1; 1288*ff94bc40SHeiko Schocher unsigned int need_sync:1; 12899eefe2a2SStefan Roese int next_ino; 12909eefe2a2SStefan Roese ino_t *inodes; 12919eefe2a2SStefan Roese }; 12929eefe2a2SStefan Roese 12939eefe2a2SStefan Roese /** 12949eefe2a2SStefan Roese * struct ubifs_bud - bud logical eraseblock. 12959eefe2a2SStefan Roese * @lnum: logical eraseblock number 12969eefe2a2SStefan Roese * @start: where the (uncommitted) bud data starts 12979eefe2a2SStefan Roese * @jhead: journal head number this bud belongs to 12989eefe2a2SStefan Roese * @list: link in the list buds belonging to the same journal head 12999eefe2a2SStefan Roese * @rb: link in the tree of all buds 13009eefe2a2SStefan Roese */ 13019eefe2a2SStefan Roese struct ubifs_bud { 13029eefe2a2SStefan Roese int lnum; 13039eefe2a2SStefan Roese int start; 13049eefe2a2SStefan Roese int jhead; 13059eefe2a2SStefan Roese struct list_head list; 13069eefe2a2SStefan Roese struct rb_node rb; 13079eefe2a2SStefan Roese }; 13089eefe2a2SStefan Roese 13099eefe2a2SStefan Roese /** 13109eefe2a2SStefan Roese * struct ubifs_jhead - journal head. 13119eefe2a2SStefan Roese * @wbuf: head's write-buffer 13129eefe2a2SStefan Roese * @buds_list: list of bud LEBs belonging to this journal head 1313*ff94bc40SHeiko Schocher * @grouped: non-zero if UBIFS groups nodes when writing to this journal head 13149eefe2a2SStefan Roese * 13159eefe2a2SStefan Roese * Note, the @buds list is protected by the @c->buds_lock. 13169eefe2a2SStefan Roese */ 13179eefe2a2SStefan Roese struct ubifs_jhead { 13189eefe2a2SStefan Roese struct ubifs_wbuf wbuf; 13199eefe2a2SStefan Roese struct list_head buds_list; 1320*ff94bc40SHeiko Schocher unsigned int grouped:1; 13219eefe2a2SStefan Roese }; 13229eefe2a2SStefan Roese 13239eefe2a2SStefan Roese /** 13249eefe2a2SStefan Roese * struct ubifs_zbranch - key/coordinate/length branch stored in znodes. 13259eefe2a2SStefan Roese * @key: key 13269eefe2a2SStefan Roese * @znode: znode address in memory 13279eefe2a2SStefan Roese * @lnum: LEB number of the target node (indexing node or data node) 13289eefe2a2SStefan Roese * @offs: target node offset within @lnum 13299eefe2a2SStefan Roese * @len: target node length 13309eefe2a2SStefan Roese */ 13319eefe2a2SStefan Roese struct ubifs_zbranch { 13329eefe2a2SStefan Roese union ubifs_key key; 13339eefe2a2SStefan Roese union { 13349eefe2a2SStefan Roese struct ubifs_znode *znode; 13359eefe2a2SStefan Roese void *leaf; 13369eefe2a2SStefan Roese }; 13379eefe2a2SStefan Roese int lnum; 13389eefe2a2SStefan Roese int offs; 13399eefe2a2SStefan Roese int len; 13409eefe2a2SStefan Roese }; 13419eefe2a2SStefan Roese 13429eefe2a2SStefan Roese /** 13439eefe2a2SStefan Roese * struct ubifs_znode - in-memory representation of an indexing node. 13449eefe2a2SStefan Roese * @parent: parent znode or NULL if it is the root 13459eefe2a2SStefan Roese * @cnext: next znode to commit 13469eefe2a2SStefan Roese * @flags: znode flags (%DIRTY_ZNODE, %COW_ZNODE or %OBSOLETE_ZNODE) 13479eefe2a2SStefan Roese * @time: last access time (seconds) 13489eefe2a2SStefan Roese * @level: level of the entry in the TNC tree 13499eefe2a2SStefan Roese * @child_cnt: count of child znodes 13509eefe2a2SStefan Roese * @iip: index in parent's zbranch array 13519eefe2a2SStefan Roese * @alt: lower bound of key range has altered i.e. child inserted at slot 0 13529eefe2a2SStefan Roese * @lnum: LEB number of the corresponding indexing node 13539eefe2a2SStefan Roese * @offs: offset of the corresponding indexing node 13549eefe2a2SStefan Roese * @len: length of the corresponding indexing node 13559eefe2a2SStefan Roese * @zbranch: array of znode branches (@c->fanout elements) 1356*ff94bc40SHeiko Schocher * 1357*ff94bc40SHeiko Schocher * Note! The @lnum, @offs, and @len fields are not really needed - we have them 1358*ff94bc40SHeiko Schocher * only for internal consistency check. They could be removed to save some RAM. 13599eefe2a2SStefan Roese */ 13609eefe2a2SStefan Roese struct ubifs_znode { 13619eefe2a2SStefan Roese struct ubifs_znode *parent; 13629eefe2a2SStefan Roese struct ubifs_znode *cnext; 13639eefe2a2SStefan Roese unsigned long flags; 13649eefe2a2SStefan Roese unsigned long time; 13659eefe2a2SStefan Roese int level; 13669eefe2a2SStefan Roese int child_cnt; 13679eefe2a2SStefan Roese int iip; 13689eefe2a2SStefan Roese int alt; 1369*ff94bc40SHeiko Schocher int lnum; 1370*ff94bc40SHeiko Schocher int offs; 1371*ff94bc40SHeiko Schocher int len; 13729eefe2a2SStefan Roese struct ubifs_zbranch zbranch[]; 13739eefe2a2SStefan Roese }; 13749eefe2a2SStefan Roese 13759eefe2a2SStefan Roese /** 13769eefe2a2SStefan Roese * struct bu_info - bulk-read information. 13779eefe2a2SStefan Roese * @key: first data node key 13789eefe2a2SStefan Roese * @zbranch: zbranches of data nodes to bulk read 13799eefe2a2SStefan Roese * @buf: buffer to read into 13809eefe2a2SStefan Roese * @buf_len: buffer length 13819eefe2a2SStefan Roese * @gc_seq: GC sequence number to detect races with GC 13829eefe2a2SStefan Roese * @cnt: number of data nodes for bulk read 13839eefe2a2SStefan Roese * @blk_cnt: number of data blocks including holes 13849eefe2a2SStefan Roese * @oef: end of file reached 13859eefe2a2SStefan Roese */ 13869eefe2a2SStefan Roese struct bu_info { 13879eefe2a2SStefan Roese union ubifs_key key; 13889eefe2a2SStefan Roese struct ubifs_zbranch zbranch[UBIFS_MAX_BULK_READ]; 13899eefe2a2SStefan Roese void *buf; 13909eefe2a2SStefan Roese int buf_len; 13919eefe2a2SStefan Roese int gc_seq; 13929eefe2a2SStefan Roese int cnt; 13939eefe2a2SStefan Roese int blk_cnt; 13949eefe2a2SStefan Roese int eof; 13959eefe2a2SStefan Roese }; 13969eefe2a2SStefan Roese 13979eefe2a2SStefan Roese /** 13989eefe2a2SStefan Roese * struct ubifs_node_range - node length range description data structure. 13999eefe2a2SStefan Roese * @len: fixed node length 14009eefe2a2SStefan Roese * @min_len: minimum possible node length 14019eefe2a2SStefan Roese * @max_len: maximum possible node length 14029eefe2a2SStefan Roese * 14039eefe2a2SStefan Roese * If @max_len is %0, the node has fixed length @len. 14049eefe2a2SStefan Roese */ 14059eefe2a2SStefan Roese struct ubifs_node_range { 14069eefe2a2SStefan Roese union { 14079eefe2a2SStefan Roese int len; 14089eefe2a2SStefan Roese int min_len; 14099eefe2a2SStefan Roese }; 14109eefe2a2SStefan Roese int max_len; 14119eefe2a2SStefan Roese }; 14129eefe2a2SStefan Roese 14139eefe2a2SStefan Roese /** 14149eefe2a2SStefan Roese * struct ubifs_compressor - UBIFS compressor description structure. 14159eefe2a2SStefan Roese * @compr_type: compressor type (%UBIFS_COMPR_LZO, etc) 14169eefe2a2SStefan Roese * @cc: cryptoapi compressor handle 14179eefe2a2SStefan Roese * @comp_mutex: mutex used during compression 14189eefe2a2SStefan Roese * @decomp_mutex: mutex used during decompression 14199eefe2a2SStefan Roese * @name: compressor name 14209eefe2a2SStefan Roese * @capi_name: cryptoapi compressor name 14219eefe2a2SStefan Roese */ 14229eefe2a2SStefan Roese struct ubifs_compressor { 14239eefe2a2SStefan Roese int compr_type; 1424*ff94bc40SHeiko Schocher struct crypto_comp *cc; 1425*ff94bc40SHeiko Schocher struct mutex *comp_mutex; 1426*ff94bc40SHeiko Schocher struct mutex *decomp_mutex; 1427*ff94bc40SHeiko Schocher const char *name; 1428*ff94bc40SHeiko Schocher const char *capi_name; 1429*ff94bc40SHeiko Schocher #ifdef __UBOOT__ 14309eefe2a2SStefan Roese int (*decompress)(const unsigned char *in, size_t in_len, 14319eefe2a2SStefan Roese unsigned char *out, size_t *out_len); 1432*ff94bc40SHeiko Schocher #endif 14339eefe2a2SStefan Roese }; 14349eefe2a2SStefan Roese 14359eefe2a2SStefan Roese /** 14369eefe2a2SStefan Roese * struct ubifs_budget_req - budget requirements of an operation. 14379eefe2a2SStefan Roese * 14389eefe2a2SStefan Roese * @fast: non-zero if the budgeting should try to acquire budget quickly and 14399eefe2a2SStefan Roese * should not try to call write-back 14409eefe2a2SStefan Roese * @recalculate: non-zero if @idx_growth, @data_growth, and @dd_growth fields 14419eefe2a2SStefan Roese * have to be re-calculated 14429eefe2a2SStefan Roese * @new_page: non-zero if the operation adds a new page 14439eefe2a2SStefan Roese * @dirtied_page: non-zero if the operation makes a page dirty 14449eefe2a2SStefan Roese * @new_dent: non-zero if the operation adds a new directory entry 14459eefe2a2SStefan Roese * @mod_dent: non-zero if the operation removes or modifies an existing 14469eefe2a2SStefan Roese * directory entry 14479eefe2a2SStefan Roese * @new_ino: non-zero if the operation adds a new inode 14489eefe2a2SStefan Roese * @new_ino_d: now much data newly created inode contains 14499eefe2a2SStefan Roese * @dirtied_ino: how many inodes the operation makes dirty 14509eefe2a2SStefan Roese * @dirtied_ino_d: now much data dirtied inode contains 14519eefe2a2SStefan Roese * @idx_growth: how much the index will supposedly grow 14529eefe2a2SStefan Roese * @data_growth: how much new data the operation will supposedly add 14539eefe2a2SStefan Roese * @dd_growth: how much data that makes other data dirty the operation will 14549eefe2a2SStefan Roese * supposedly add 14559eefe2a2SStefan Roese * 14569eefe2a2SStefan Roese * @idx_growth, @data_growth and @dd_growth are not used in budget request. The 14579eefe2a2SStefan Roese * budgeting subsystem caches index and data growth values there to avoid 14589eefe2a2SStefan Roese * re-calculating them when the budget is released. However, if @idx_growth is 14599eefe2a2SStefan Roese * %-1, it is calculated by the release function using other fields. 14609eefe2a2SStefan Roese * 14619eefe2a2SStefan Roese * An inode may contain 4KiB of data at max., thus the widths of @new_ino_d 14629eefe2a2SStefan Roese * is 13 bits, and @dirtied_ino_d - 15, because up to 4 inodes may be made 14639eefe2a2SStefan Roese * dirty by the re-name operation. 14649eefe2a2SStefan Roese * 14659eefe2a2SStefan Roese * Note, UBIFS aligns node lengths to 8-bytes boundary, so the requester has to 14669eefe2a2SStefan Roese * make sure the amount of inode data which contribute to @new_ino_d and 14679eefe2a2SStefan Roese * @dirtied_ino_d fields are aligned. 14689eefe2a2SStefan Roese */ 14699eefe2a2SStefan Roese struct ubifs_budget_req { 14709eefe2a2SStefan Roese unsigned int fast:1; 14719eefe2a2SStefan Roese unsigned int recalculate:1; 14729eefe2a2SStefan Roese #ifndef UBIFS_DEBUG 14739eefe2a2SStefan Roese unsigned int new_page:1; 14749eefe2a2SStefan Roese unsigned int dirtied_page:1; 14759eefe2a2SStefan Roese unsigned int new_dent:1; 14769eefe2a2SStefan Roese unsigned int mod_dent:1; 14779eefe2a2SStefan Roese unsigned int new_ino:1; 14789eefe2a2SStefan Roese unsigned int new_ino_d:13; 14799eefe2a2SStefan Roese unsigned int dirtied_ino:4; 14809eefe2a2SStefan Roese unsigned int dirtied_ino_d:15; 14819eefe2a2SStefan Roese #else 14829eefe2a2SStefan Roese /* Not bit-fields to check for overflows */ 14839eefe2a2SStefan Roese unsigned int new_page; 14849eefe2a2SStefan Roese unsigned int dirtied_page; 14859eefe2a2SStefan Roese unsigned int new_dent; 14869eefe2a2SStefan Roese unsigned int mod_dent; 14879eefe2a2SStefan Roese unsigned int new_ino; 14889eefe2a2SStefan Roese unsigned int new_ino_d; 14899eefe2a2SStefan Roese unsigned int dirtied_ino; 14909eefe2a2SStefan Roese unsigned int dirtied_ino_d; 14919eefe2a2SStefan Roese #endif 14929eefe2a2SStefan Roese int idx_growth; 14939eefe2a2SStefan Roese int data_growth; 14949eefe2a2SStefan Roese int dd_growth; 14959eefe2a2SStefan Roese }; 14969eefe2a2SStefan Roese 14979eefe2a2SStefan Roese /** 14989eefe2a2SStefan Roese * struct ubifs_orphan - stores the inode number of an orphan. 14999eefe2a2SStefan Roese * @rb: rb-tree node of rb-tree of orphans sorted by inode number 15009eefe2a2SStefan Roese * @list: list head of list of orphans in order added 15019eefe2a2SStefan Roese * @new_list: list head of list of orphans added since the last commit 15029eefe2a2SStefan Roese * @cnext: next orphan to commit 15039eefe2a2SStefan Roese * @dnext: next orphan to delete 15049eefe2a2SStefan Roese * @inum: inode number 15059eefe2a2SStefan Roese * @new: %1 => added since the last commit, otherwise %0 1506*ff94bc40SHeiko Schocher * @cmt: %1 => commit pending, otherwise %0 1507*ff94bc40SHeiko Schocher * @del: %1 => delete pending, otherwise %0 15089eefe2a2SStefan Roese */ 15099eefe2a2SStefan Roese struct ubifs_orphan { 15109eefe2a2SStefan Roese struct rb_node rb; 15119eefe2a2SStefan Roese struct list_head list; 15129eefe2a2SStefan Roese struct list_head new_list; 15139eefe2a2SStefan Roese struct ubifs_orphan *cnext; 15149eefe2a2SStefan Roese struct ubifs_orphan *dnext; 15159eefe2a2SStefan Roese ino_t inum; 1516*ff94bc40SHeiko Schocher unsigned new:1; 1517*ff94bc40SHeiko Schocher unsigned cmt:1; 1518*ff94bc40SHeiko Schocher unsigned del:1; 15199eefe2a2SStefan Roese }; 15209eefe2a2SStefan Roese 15219eefe2a2SStefan Roese /** 15229eefe2a2SStefan Roese * struct ubifs_mount_opts - UBIFS-specific mount options information. 15239eefe2a2SStefan Roese * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) 15249eefe2a2SStefan Roese * @bulk_read: enable/disable bulk-reads (%0 default, %1 disabe, %2 enable) 15259eefe2a2SStefan Roese * @chk_data_crc: enable/disable CRC data checking when reading data nodes 15269eefe2a2SStefan Roese * (%0 default, %1 disabe, %2 enable) 15279eefe2a2SStefan Roese * @override_compr: override default compressor (%0 - do not override and use 15289eefe2a2SStefan Roese * superblock compressor, %1 - override and use compressor 15299eefe2a2SStefan Roese * specified in @compr_type) 15309eefe2a2SStefan Roese * @compr_type: compressor type to override the superblock compressor with 15319eefe2a2SStefan Roese * (%UBIFS_COMPR_NONE, etc) 15329eefe2a2SStefan Roese */ 15339eefe2a2SStefan Roese struct ubifs_mount_opts { 15349eefe2a2SStefan Roese unsigned int unmount_mode:2; 15359eefe2a2SStefan Roese unsigned int bulk_read:2; 15369eefe2a2SStefan Roese unsigned int chk_data_crc:2; 15379eefe2a2SStefan Roese unsigned int override_compr:1; 15389eefe2a2SStefan Roese unsigned int compr_type:2; 15399eefe2a2SStefan Roese }; 15409eefe2a2SStefan Roese 1541*ff94bc40SHeiko Schocher /** 1542*ff94bc40SHeiko Schocher * struct ubifs_budg_info - UBIFS budgeting information. 1543*ff94bc40SHeiko Schocher * @idx_growth: amount of bytes budgeted for index growth 1544*ff94bc40SHeiko Schocher * @data_growth: amount of bytes budgeted for cached data 1545*ff94bc40SHeiko Schocher * @dd_growth: amount of bytes budgeted for cached data that will make 1546*ff94bc40SHeiko Schocher * other data dirty 1547*ff94bc40SHeiko Schocher * @uncommitted_idx: amount of bytes were budgeted for growth of the index, but 1548*ff94bc40SHeiko Schocher * which still have to be taken into account because the index 1549*ff94bc40SHeiko Schocher * has not been committed so far 1550*ff94bc40SHeiko Schocher * @old_idx_sz: size of index on flash 1551*ff94bc40SHeiko Schocher * @min_idx_lebs: minimum number of LEBs required for the index 1552*ff94bc40SHeiko Schocher * @nospace: non-zero if the file-system does not have flash space (used as 1553*ff94bc40SHeiko Schocher * optimization) 1554*ff94bc40SHeiko Schocher * @nospace_rp: the same as @nospace, but additionally means that even reserved 1555*ff94bc40SHeiko Schocher * pool is full 1556*ff94bc40SHeiko Schocher * @page_budget: budget for a page (constant, nenver changed after mount) 1557*ff94bc40SHeiko Schocher * @inode_budget: budget for an inode (constant, nenver changed after mount) 1558*ff94bc40SHeiko Schocher * @dent_budget: budget for a directory entry (constant, nenver changed after 1559*ff94bc40SHeiko Schocher * mount) 1560*ff94bc40SHeiko Schocher */ 1561*ff94bc40SHeiko Schocher struct ubifs_budg_info { 1562*ff94bc40SHeiko Schocher long long idx_growth; 1563*ff94bc40SHeiko Schocher long long data_growth; 1564*ff94bc40SHeiko Schocher long long dd_growth; 1565*ff94bc40SHeiko Schocher long long uncommitted_idx; 1566*ff94bc40SHeiko Schocher unsigned long long old_idx_sz; 1567*ff94bc40SHeiko Schocher int min_idx_lebs; 1568*ff94bc40SHeiko Schocher unsigned int nospace:1; 1569*ff94bc40SHeiko Schocher unsigned int nospace_rp:1; 1570*ff94bc40SHeiko Schocher int page_budget; 1571*ff94bc40SHeiko Schocher int inode_budget; 1572*ff94bc40SHeiko Schocher int dent_budget; 1573*ff94bc40SHeiko Schocher }; 1574*ff94bc40SHeiko Schocher 15759eefe2a2SStefan Roese struct ubifs_debug_info; 15769eefe2a2SStefan Roese 15779eefe2a2SStefan Roese /** 15789eefe2a2SStefan Roese * struct ubifs_info - UBIFS file-system description data structure 15799eefe2a2SStefan Roese * (per-superblock). 15809eefe2a2SStefan Roese * @vfs_sb: VFS @struct super_block object 15819eefe2a2SStefan Roese * @bdi: backing device info object to make VFS happy and disable read-ahead 15829eefe2a2SStefan Roese * 15839eefe2a2SStefan Roese * @highest_inum: highest used inode number 15849eefe2a2SStefan Roese * @max_sqnum: current global sequence number 15859eefe2a2SStefan Roese * @cmt_no: commit number of the last successfully completed commit, protected 15869eefe2a2SStefan Roese * by @commit_sem 15879eefe2a2SStefan Roese * @cnt_lock: protects @highest_inum and @max_sqnum counters 15889eefe2a2SStefan Roese * @fmt_version: UBIFS on-flash format version 1589febd7e41SArtem Bityutskiy * @ro_compat_version: R/O compatibility version 15909eefe2a2SStefan Roese * @uuid: UUID from super block 15919eefe2a2SStefan Roese * 15929eefe2a2SStefan Roese * @lhead_lnum: log head logical eraseblock number 15939eefe2a2SStefan Roese * @lhead_offs: log head offset 15949eefe2a2SStefan Roese * @ltail_lnum: log tail logical eraseblock number (offset is always 0) 15959eefe2a2SStefan Roese * @log_mutex: protects the log, @lhead_lnum, @lhead_offs, @ltail_lnum, and 15969eefe2a2SStefan Roese * @bud_bytes 15979eefe2a2SStefan Roese * @min_log_bytes: minimum required number of bytes in the log 15989eefe2a2SStefan Roese * @cmt_bud_bytes: used during commit to temporarily amount of bytes in 15999eefe2a2SStefan Roese * committed buds 16009eefe2a2SStefan Roese * 16019eefe2a2SStefan Roese * @buds: tree of all buds indexed by bud LEB number 16029eefe2a2SStefan Roese * @bud_bytes: how many bytes of flash is used by buds 16039eefe2a2SStefan Roese * @buds_lock: protects the @buds tree, @bud_bytes, and per-journal head bud 16049eefe2a2SStefan Roese * lists 16059eefe2a2SStefan Roese * @jhead_cnt: count of journal heads 16069eefe2a2SStefan Roese * @jheads: journal heads (head zero is base head) 16079eefe2a2SStefan Roese * @max_bud_bytes: maximum number of bytes allowed in buds 16089eefe2a2SStefan Roese * @bg_bud_bytes: number of bud bytes when background commit is initiated 16099eefe2a2SStefan Roese * @old_buds: buds to be released after commit ends 16109eefe2a2SStefan Roese * @max_bud_cnt: maximum number of buds 16119eefe2a2SStefan Roese * 16129eefe2a2SStefan Roese * @commit_sem: synchronizes committer with other processes 16139eefe2a2SStefan Roese * @cmt_state: commit state 16149eefe2a2SStefan Roese * @cs_lock: commit state lock 16159eefe2a2SStefan Roese * @cmt_wq: wait queue to sleep on if the log is full and a commit is running 16169eefe2a2SStefan Roese * 16179eefe2a2SStefan Roese * @big_lpt: flag that LPT is too big to write whole during commit 1618*ff94bc40SHeiko Schocher * @space_fixup: flag indicating that free space in LEBs needs to be cleaned up 16199eefe2a2SStefan Roese * @no_chk_data_crc: do not check CRCs when reading data nodes (except during 16209eefe2a2SStefan Roese * recovery) 16219eefe2a2SStefan Roese * @bulk_read: enable bulk-reads 16229eefe2a2SStefan Roese * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc) 1623febd7e41SArtem Bityutskiy * @rw_incompat: the media is not R/W compatible 16249eefe2a2SStefan Roese * 16259eefe2a2SStefan Roese * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and 16269eefe2a2SStefan Roese * @calc_idx_sz 16279eefe2a2SStefan Roese * @zroot: zbranch which points to the root index node and znode 16289eefe2a2SStefan Roese * @cnext: next znode to commit 16299eefe2a2SStefan Roese * @enext: next znode to commit to empty space 16309eefe2a2SStefan Roese * @gap_lebs: array of LEBs used by the in-gaps commit method 16319eefe2a2SStefan Roese * @cbuf: commit buffer 16329eefe2a2SStefan Roese * @ileb_buf: buffer for commit in-the-gaps method 16339eefe2a2SStefan Roese * @ileb_len: length of data in ileb_buf 16349eefe2a2SStefan Roese * @ihead_lnum: LEB number of index head 16359eefe2a2SStefan Roese * @ihead_offs: offset of index head 16369eefe2a2SStefan Roese * @ilebs: pre-allocated index LEBs 16379eefe2a2SStefan Roese * @ileb_cnt: number of pre-allocated index LEBs 16389eefe2a2SStefan Roese * @ileb_nxt: next pre-allocated index LEBs 16399eefe2a2SStefan Roese * @old_idx: tree of index nodes obsoleted since the last commit start 16409eefe2a2SStefan Roese * @bottom_up_buf: a buffer which is used by 'dirty_cow_bottom_up()' in tnc.c 16419eefe2a2SStefan Roese * 16429eefe2a2SStefan Roese * @mst_node: master node 16439eefe2a2SStefan Roese * @mst_offs: offset of valid master node 16449eefe2a2SStefan Roese * @mst_mutex: protects the master node area, @mst_node, and @mst_offs 16459eefe2a2SStefan Roese * 16469eefe2a2SStefan Roese * @max_bu_buf_len: maximum bulk-read buffer length 16479eefe2a2SStefan Roese * @bu_mutex: protects the pre-allocated bulk-read buffer and @c->bu 16489eefe2a2SStefan Roese * @bu: pre-allocated bulk-read information 16499eefe2a2SStefan Roese * 1650*ff94bc40SHeiko Schocher * @write_reserve_mutex: protects @write_reserve_buf 1651*ff94bc40SHeiko Schocher * @write_reserve_buf: on the write path we allocate memory, which might 1652*ff94bc40SHeiko Schocher * sometimes be unavailable, in which case we use this 1653*ff94bc40SHeiko Schocher * write reserve buffer 1654*ff94bc40SHeiko Schocher * 16559eefe2a2SStefan Roese * @log_lebs: number of logical eraseblocks in the log 16569eefe2a2SStefan Roese * @log_bytes: log size in bytes 16579eefe2a2SStefan Roese * @log_last: last LEB of the log 16589eefe2a2SStefan Roese * @lpt_lebs: number of LEBs used for lprops table 16599eefe2a2SStefan Roese * @lpt_first: first LEB of the lprops table area 16609eefe2a2SStefan Roese * @lpt_last: last LEB of the lprops table area 16619eefe2a2SStefan Roese * @orph_lebs: number of LEBs used for the orphan area 16629eefe2a2SStefan Roese * @orph_first: first LEB of the orphan area 16639eefe2a2SStefan Roese * @orph_last: last LEB of the orphan area 16649eefe2a2SStefan Roese * @main_lebs: count of LEBs in the main area 16659eefe2a2SStefan Roese * @main_first: first LEB of the main area 16669eefe2a2SStefan Roese * @main_bytes: main area size in bytes 16679eefe2a2SStefan Roese * 16689eefe2a2SStefan Roese * @key_hash_type: type of the key hash 16699eefe2a2SStefan Roese * @key_hash: direntry key hash function 16709eefe2a2SStefan Roese * @key_fmt: key format 16719eefe2a2SStefan Roese * @key_len: key length 16729eefe2a2SStefan Roese * @fanout: fanout of the index tree (number of links per indexing node) 16739eefe2a2SStefan Roese * 16749eefe2a2SStefan Roese * @min_io_size: minimal input/output unit size 16759eefe2a2SStefan Roese * @min_io_shift: number of bits in @min_io_size minus one 1676*ff94bc40SHeiko Schocher * @max_write_size: maximum amount of bytes the underlying flash can write at a 1677*ff94bc40SHeiko Schocher * time (MTD write buffer size) 1678*ff94bc40SHeiko Schocher * @max_write_shift: number of bits in @max_write_size minus one 16799eefe2a2SStefan Roese * @leb_size: logical eraseblock size in bytes 1680*ff94bc40SHeiko Schocher * @leb_start: starting offset of logical eraseblocks within physical 1681*ff94bc40SHeiko Schocher * eraseblocks 16829eefe2a2SStefan Roese * @half_leb_size: half LEB size 1683*ff94bc40SHeiko Schocher * @idx_leb_size: how many bytes of an LEB are effectively available when it is 1684*ff94bc40SHeiko Schocher * used to store indexing nodes (@leb_size - @max_idx_node_sz) 16859eefe2a2SStefan Roese * @leb_cnt: count of logical eraseblocks 16869eefe2a2SStefan Roese * @max_leb_cnt: maximum count of logical eraseblocks 16879eefe2a2SStefan Roese * @old_leb_cnt: count of logical eraseblocks before re-size 16889eefe2a2SStefan Roese * @ro_media: the underlying UBI volume is read-only 1689*ff94bc40SHeiko Schocher * @ro_mount: the file-system was mounted as read-only 1690*ff94bc40SHeiko Schocher * @ro_error: UBIFS switched to R/O mode because an error happened 16919eefe2a2SStefan Roese * 16929eefe2a2SStefan Roese * @dirty_pg_cnt: number of dirty pages (not used) 16939eefe2a2SStefan Roese * @dirty_zn_cnt: number of dirty znodes 16949eefe2a2SStefan Roese * @clean_zn_cnt: number of clean znodes 16959eefe2a2SStefan Roese * 1696*ff94bc40SHeiko Schocher * @space_lock: protects @bi and @lst 1697*ff94bc40SHeiko Schocher * @lst: lprops statistics 1698*ff94bc40SHeiko Schocher * @bi: budgeting information 16999eefe2a2SStefan Roese * @calc_idx_sz: temporary variable which is used to calculate new index size 17009eefe2a2SStefan Roese * (contains accurate new index size at end of TNC commit start) 17019eefe2a2SStefan Roese * 17029eefe2a2SStefan Roese * @ref_node_alsz: size of the LEB reference node aligned to the min. flash 17039eefe2a2SStefan Roese * I/O unit 17049eefe2a2SStefan Roese * @mst_node_alsz: master node aligned size 17059eefe2a2SStefan Roese * @min_idx_node_sz: minimum indexing node aligned on 8-bytes boundary 17069eefe2a2SStefan Roese * @max_idx_node_sz: maximum indexing node aligned on 8-bytes boundary 17079eefe2a2SStefan Roese * @max_inode_sz: maximum possible inode size in bytes 17089eefe2a2SStefan Roese * @max_znode_sz: size of znode in bytes 17099eefe2a2SStefan Roese * 17109eefe2a2SStefan Roese * @leb_overhead: how many bytes are wasted in an LEB when it is filled with 17119eefe2a2SStefan Roese * data nodes of maximum size - used in free space reporting 17129eefe2a2SStefan Roese * @dead_wm: LEB dead space watermark 17139eefe2a2SStefan Roese * @dark_wm: LEB dark space watermark 17149eefe2a2SStefan Roese * @block_cnt: count of 4KiB blocks on the FS 17159eefe2a2SStefan Roese * 17169eefe2a2SStefan Roese * @ranges: UBIFS node length ranges 17179eefe2a2SStefan Roese * @ubi: UBI volume descriptor 17189eefe2a2SStefan Roese * @di: UBI device information 17199eefe2a2SStefan Roese * @vi: UBI volume information 17209eefe2a2SStefan Roese * 17219eefe2a2SStefan Roese * @orph_tree: rb-tree of orphan inode numbers 17229eefe2a2SStefan Roese * @orph_list: list of orphan inode numbers in order added 17239eefe2a2SStefan Roese * @orph_new: list of orphan inode numbers added since last commit 17249eefe2a2SStefan Roese * @orph_cnext: next orphan to commit 17259eefe2a2SStefan Roese * @orph_dnext: next orphan to delete 17269eefe2a2SStefan Roese * @orphan_lock: lock for orph_tree and orph_new 17279eefe2a2SStefan Roese * @orph_buf: buffer for orphan nodes 17289eefe2a2SStefan Roese * @new_orphans: number of orphans since last commit 17299eefe2a2SStefan Roese * @cmt_orphans: number of orphans being committed 17309eefe2a2SStefan Roese * @tot_orphans: number of orphans in the rb_tree 17319eefe2a2SStefan Roese * @max_orphans: maximum number of orphans allowed 17329eefe2a2SStefan Roese * @ohead_lnum: orphan head LEB number 17339eefe2a2SStefan Roese * @ohead_offs: orphan head offset 17349eefe2a2SStefan Roese * @no_orphs: non-zero if there are no orphans 17359eefe2a2SStefan Roese * 17369eefe2a2SStefan Roese * @bgt: UBIFS background thread 17379eefe2a2SStefan Roese * @bgt_name: background thread name 17389eefe2a2SStefan Roese * @need_bgt: if background thread should run 17399eefe2a2SStefan Roese * @need_wbuf_sync: if write-buffers have to be synchronized 17409eefe2a2SStefan Roese * 17419eefe2a2SStefan Roese * @gc_lnum: LEB number used for garbage collection 17429eefe2a2SStefan Roese * @sbuf: a buffer of LEB size used by GC and replay for scanning 17439eefe2a2SStefan Roese * @idx_gc: list of index LEBs that have been garbage collected 17449eefe2a2SStefan Roese * @idx_gc_cnt: number of elements on the idx_gc list 17459eefe2a2SStefan Roese * @gc_seq: incremented for every non-index LEB garbage collected 17469eefe2a2SStefan Roese * @gced_lnum: last non-index LEB that was garbage collected 17479eefe2a2SStefan Roese * 17489eefe2a2SStefan Roese * @infos_list: links all 'ubifs_info' objects 17499eefe2a2SStefan Roese * @umount_mutex: serializes shrinker and un-mount 17509eefe2a2SStefan Roese * @shrinker_run_no: shrinker run number 17519eefe2a2SStefan Roese * 17529eefe2a2SStefan Roese * @space_bits: number of bits needed to record free or dirty space 17539eefe2a2SStefan Roese * @lpt_lnum_bits: number of bits needed to record a LEB number in the LPT 17549eefe2a2SStefan Roese * @lpt_offs_bits: number of bits needed to record an offset in the LPT 17559eefe2a2SStefan Roese * @lpt_spc_bits: number of bits needed to space in the LPT 17569eefe2a2SStefan Roese * @pcnt_bits: number of bits needed to record pnode or nnode number 17579eefe2a2SStefan Roese * @lnum_bits: number of bits needed to record LEB number 17589eefe2a2SStefan Roese * @nnode_sz: size of on-flash nnode 17599eefe2a2SStefan Roese * @pnode_sz: size of on-flash pnode 17609eefe2a2SStefan Roese * @ltab_sz: size of on-flash LPT lprops table 17619eefe2a2SStefan Roese * @lsave_sz: size of on-flash LPT save table 17629eefe2a2SStefan Roese * @pnode_cnt: number of pnodes 17639eefe2a2SStefan Roese * @nnode_cnt: number of nnodes 17649eefe2a2SStefan Roese * @lpt_hght: height of the LPT 17659eefe2a2SStefan Roese * @pnodes_have: number of pnodes in memory 17669eefe2a2SStefan Roese * 17679eefe2a2SStefan Roese * @lp_mutex: protects lprops table and all the other lprops-related fields 17689eefe2a2SStefan Roese * @lpt_lnum: LEB number of the root nnode of the LPT 17699eefe2a2SStefan Roese * @lpt_offs: offset of the root nnode of the LPT 17709eefe2a2SStefan Roese * @nhead_lnum: LEB number of LPT head 17719eefe2a2SStefan Roese * @nhead_offs: offset of LPT head 17729eefe2a2SStefan Roese * @lpt_drty_flgs: dirty flags for LPT special nodes e.g. ltab 17739eefe2a2SStefan Roese * @dirty_nn_cnt: number of dirty nnodes 17749eefe2a2SStefan Roese * @dirty_pn_cnt: number of dirty pnodes 17759eefe2a2SStefan Roese * @check_lpt_free: flag that indicates LPT GC may be needed 17769eefe2a2SStefan Roese * @lpt_sz: LPT size 17779eefe2a2SStefan Roese * @lpt_nod_buf: buffer for an on-flash nnode or pnode 17789eefe2a2SStefan Roese * @lpt_buf: buffer of LEB size used by LPT 17799eefe2a2SStefan Roese * @nroot: address in memory of the root nnode of the LPT 17809eefe2a2SStefan Roese * @lpt_cnext: next LPT node to commit 17819eefe2a2SStefan Roese * @lpt_heap: array of heaps of categorized lprops 17829eefe2a2SStefan Roese * @dirty_idx: a (reverse sorted) copy of the LPROPS_DIRTY_IDX heap as at 17839eefe2a2SStefan Roese * previous commit start 17849eefe2a2SStefan Roese * @uncat_list: list of un-categorized LEBs 17859eefe2a2SStefan Roese * @empty_list: list of empty LEBs 1786*ff94bc40SHeiko Schocher * @freeable_list: list of freeable non-index LEBs (free + dirty == @leb_size) 1787*ff94bc40SHeiko Schocher * @frdi_idx_list: list of freeable index LEBs (free + dirty == @leb_size) 17889eefe2a2SStefan Roese * @freeable_cnt: number of freeable LEBs in @freeable_list 1789*ff94bc40SHeiko Schocher * @in_a_category_cnt: count of lprops which are in a certain category, which 1790*ff94bc40SHeiko Schocher * basically meants that they were loaded from the flash 17919eefe2a2SStefan Roese * 17929eefe2a2SStefan Roese * @ltab_lnum: LEB number of LPT's own lprops table 17939eefe2a2SStefan Roese * @ltab_offs: offset of LPT's own lprops table 17949eefe2a2SStefan Roese * @ltab: LPT's own lprops table 17959eefe2a2SStefan Roese * @ltab_cmt: LPT's own lprops table (commit copy) 17969eefe2a2SStefan Roese * @lsave_cnt: number of LEB numbers in LPT's save table 17979eefe2a2SStefan Roese * @lsave_lnum: LEB number of LPT's save table 17989eefe2a2SStefan Roese * @lsave_offs: offset of LPT's save table 17999eefe2a2SStefan Roese * @lsave: LPT's save table 18009eefe2a2SStefan Roese * @lscan_lnum: LEB number of last LPT scan 18019eefe2a2SStefan Roese * 18029eefe2a2SStefan Roese * @rp_size: size of the reserved pool in bytes 18039eefe2a2SStefan Roese * @report_rp_size: size of the reserved pool reported to user-space 18049eefe2a2SStefan Roese * @rp_uid: reserved pool user ID 18059eefe2a2SStefan Roese * @rp_gid: reserved pool group ID 18069eefe2a2SStefan Roese * 1807*ff94bc40SHeiko Schocher * @empty: %1 if the UBI device is empty 1808*ff94bc40SHeiko Schocher * @need_recovery: %1 if the file-system needs recovery 1809*ff94bc40SHeiko Schocher * @replaying: %1 during journal replay 1810*ff94bc40SHeiko Schocher * @mounting: %1 while mounting 1811*ff94bc40SHeiko Schocher * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode 18129eefe2a2SStefan Roese * @replay_list: temporary list used during journal replay 18139eefe2a2SStefan Roese * @replay_buds: list of buds to replay 18149eefe2a2SStefan Roese * @cs_sqnum: sequence number of first node in the log (commit start node) 18159eefe2a2SStefan Roese * @replay_sqnum: sequence number of node currently being replayed 1816*ff94bc40SHeiko Schocher * @unclean_leb_list: LEBs to recover when re-mounting R/O mounted FS to R/W 1817*ff94bc40SHeiko Schocher * mode 1818*ff94bc40SHeiko Schocher * @rcvrd_mst_node: recovered master node to write when re-mounting R/O mounted 1819*ff94bc40SHeiko Schocher * FS to R/W mode 18209eefe2a2SStefan Roese * @size_tree: inode size information for recovery 18219eefe2a2SStefan Roese * @mount_opts: UBIFS-specific mount options 18229eefe2a2SStefan Roese * 18239eefe2a2SStefan Roese * @dbg: debugging-related information 18249eefe2a2SStefan Roese */ 18259eefe2a2SStefan Roese struct ubifs_info { 18269eefe2a2SStefan Roese struct super_block *vfs_sb; 1827*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 1828*ff94bc40SHeiko Schocher struct backing_dev_info bdi; 1829*ff94bc40SHeiko Schocher #endif 18309eefe2a2SStefan Roese 18319eefe2a2SStefan Roese ino_t highest_inum; 18329eefe2a2SStefan Roese unsigned long long max_sqnum; 18339eefe2a2SStefan Roese unsigned long long cmt_no; 18349eefe2a2SStefan Roese spinlock_t cnt_lock; 18359eefe2a2SStefan Roese int fmt_version; 1836febd7e41SArtem Bityutskiy int ro_compat_version; 18379eefe2a2SStefan Roese unsigned char uuid[16]; 18389eefe2a2SStefan Roese 18399eefe2a2SStefan Roese int lhead_lnum; 18409eefe2a2SStefan Roese int lhead_offs; 18419eefe2a2SStefan Roese int ltail_lnum; 18429eefe2a2SStefan Roese struct mutex log_mutex; 18439eefe2a2SStefan Roese int min_log_bytes; 18449eefe2a2SStefan Roese long long cmt_bud_bytes; 18459eefe2a2SStefan Roese 18469eefe2a2SStefan Roese struct rb_root buds; 18479eefe2a2SStefan Roese long long bud_bytes; 18489eefe2a2SStefan Roese spinlock_t buds_lock; 18499eefe2a2SStefan Roese int jhead_cnt; 18509eefe2a2SStefan Roese struct ubifs_jhead *jheads; 18519eefe2a2SStefan Roese long long max_bud_bytes; 18529eefe2a2SStefan Roese long long bg_bud_bytes; 18539eefe2a2SStefan Roese struct list_head old_buds; 18549eefe2a2SStefan Roese int max_bud_cnt; 18559eefe2a2SStefan Roese 18569eefe2a2SStefan Roese struct rw_semaphore commit_sem; 18579eefe2a2SStefan Roese int cmt_state; 18589eefe2a2SStefan Roese spinlock_t cs_lock; 18599eefe2a2SStefan Roese wait_queue_head_t cmt_wq; 18609eefe2a2SStefan Roese 18619eefe2a2SStefan Roese unsigned int big_lpt:1; 1862*ff94bc40SHeiko Schocher unsigned int space_fixup:1; 18639eefe2a2SStefan Roese unsigned int no_chk_data_crc:1; 18649eefe2a2SStefan Roese unsigned int bulk_read:1; 18659eefe2a2SStefan Roese unsigned int default_compr:2; 1866febd7e41SArtem Bityutskiy unsigned int rw_incompat:1; 18679eefe2a2SStefan Roese 18689eefe2a2SStefan Roese struct mutex tnc_mutex; 18699eefe2a2SStefan Roese struct ubifs_zbranch zroot; 18709eefe2a2SStefan Roese struct ubifs_znode *cnext; 18719eefe2a2SStefan Roese struct ubifs_znode *enext; 18729eefe2a2SStefan Roese int *gap_lebs; 18739eefe2a2SStefan Roese void *cbuf; 18749eefe2a2SStefan Roese void *ileb_buf; 18759eefe2a2SStefan Roese int ileb_len; 18769eefe2a2SStefan Roese int ihead_lnum; 18779eefe2a2SStefan Roese int ihead_offs; 18789eefe2a2SStefan Roese int *ilebs; 18799eefe2a2SStefan Roese int ileb_cnt; 18809eefe2a2SStefan Roese int ileb_nxt; 18819eefe2a2SStefan Roese struct rb_root old_idx; 18829eefe2a2SStefan Roese int *bottom_up_buf; 18839eefe2a2SStefan Roese 18849eefe2a2SStefan Roese struct ubifs_mst_node *mst_node; 18859eefe2a2SStefan Roese int mst_offs; 18869eefe2a2SStefan Roese struct mutex mst_mutex; 18879eefe2a2SStefan Roese 18889eefe2a2SStefan Roese int max_bu_buf_len; 18899eefe2a2SStefan Roese struct mutex bu_mutex; 18909eefe2a2SStefan Roese struct bu_info bu; 18919eefe2a2SStefan Roese 1892*ff94bc40SHeiko Schocher struct mutex write_reserve_mutex; 1893*ff94bc40SHeiko Schocher void *write_reserve_buf; 1894*ff94bc40SHeiko Schocher 18959eefe2a2SStefan Roese int log_lebs; 18969eefe2a2SStefan Roese long long log_bytes; 18979eefe2a2SStefan Roese int log_last; 18989eefe2a2SStefan Roese int lpt_lebs; 18999eefe2a2SStefan Roese int lpt_first; 19009eefe2a2SStefan Roese int lpt_last; 19019eefe2a2SStefan Roese int orph_lebs; 19029eefe2a2SStefan Roese int orph_first; 19039eefe2a2SStefan Roese int orph_last; 19049eefe2a2SStefan Roese int main_lebs; 19059eefe2a2SStefan Roese int main_first; 19069eefe2a2SStefan Roese long long main_bytes; 19079eefe2a2SStefan Roese 19089eefe2a2SStefan Roese uint8_t key_hash_type; 19099eefe2a2SStefan Roese uint32_t (*key_hash)(const char *str, int len); 19109eefe2a2SStefan Roese int key_fmt; 19119eefe2a2SStefan Roese int key_len; 19129eefe2a2SStefan Roese int fanout; 19139eefe2a2SStefan Roese 19149eefe2a2SStefan Roese int min_io_size; 19159eefe2a2SStefan Roese int min_io_shift; 1916*ff94bc40SHeiko Schocher int max_write_size; 1917*ff94bc40SHeiko Schocher int max_write_shift; 19189eefe2a2SStefan Roese int leb_size; 1919*ff94bc40SHeiko Schocher int leb_start; 19209eefe2a2SStefan Roese int half_leb_size; 1921*ff94bc40SHeiko Schocher int idx_leb_size; 19229eefe2a2SStefan Roese int leb_cnt; 19239eefe2a2SStefan Roese int max_leb_cnt; 19249eefe2a2SStefan Roese int old_leb_cnt; 1925*ff94bc40SHeiko Schocher unsigned int ro_media:1; 1926*ff94bc40SHeiko Schocher unsigned int ro_mount:1; 1927*ff94bc40SHeiko Schocher unsigned int ro_error:1; 19289eefe2a2SStefan Roese 1929*ff94bc40SHeiko Schocher atomic_long_t dirty_pg_cnt; 1930*ff94bc40SHeiko Schocher atomic_long_t dirty_zn_cnt; 1931*ff94bc40SHeiko Schocher atomic_long_t clean_zn_cnt; 1932*ff94bc40SHeiko Schocher 19339eefe2a2SStefan Roese spinlock_t space_lock; 19349eefe2a2SStefan Roese struct ubifs_lp_stats lst; 1935*ff94bc40SHeiko Schocher struct ubifs_budg_info bi; 1936*ff94bc40SHeiko Schocher unsigned long long calc_idx_sz; 19379eefe2a2SStefan Roese 19389eefe2a2SStefan Roese int ref_node_alsz; 19399eefe2a2SStefan Roese int mst_node_alsz; 19409eefe2a2SStefan Roese int min_idx_node_sz; 19419eefe2a2SStefan Roese int max_idx_node_sz; 19429eefe2a2SStefan Roese long long max_inode_sz; 19439eefe2a2SStefan Roese int max_znode_sz; 19449eefe2a2SStefan Roese 19459eefe2a2SStefan Roese int leb_overhead; 19469eefe2a2SStefan Roese int dead_wm; 19479eefe2a2SStefan Roese int dark_wm; 19489eefe2a2SStefan Roese int block_cnt; 19499eefe2a2SStefan Roese 19509eefe2a2SStefan Roese struct ubifs_node_range ranges[UBIFS_NODE_TYPES_CNT]; 19519eefe2a2SStefan Roese struct ubi_volume_desc *ubi; 19529eefe2a2SStefan Roese struct ubi_device_info di; 19539eefe2a2SStefan Roese struct ubi_volume_info vi; 19549eefe2a2SStefan Roese 19559eefe2a2SStefan Roese struct rb_root orph_tree; 19569eefe2a2SStefan Roese struct list_head orph_list; 19579eefe2a2SStefan Roese struct list_head orph_new; 19589eefe2a2SStefan Roese struct ubifs_orphan *orph_cnext; 19599eefe2a2SStefan Roese struct ubifs_orphan *orph_dnext; 19609eefe2a2SStefan Roese spinlock_t orphan_lock; 19619eefe2a2SStefan Roese void *orph_buf; 19629eefe2a2SStefan Roese int new_orphans; 19639eefe2a2SStefan Roese int cmt_orphans; 19649eefe2a2SStefan Roese int tot_orphans; 19659eefe2a2SStefan Roese int max_orphans; 19669eefe2a2SStefan Roese int ohead_lnum; 19679eefe2a2SStefan Roese int ohead_offs; 19689eefe2a2SStefan Roese int no_orphs; 19699eefe2a2SStefan Roese 19709eefe2a2SStefan Roese struct task_struct *bgt; 19719eefe2a2SStefan Roese char bgt_name[sizeof(BGT_NAME_PATTERN) + 9]; 19729eefe2a2SStefan Roese int need_bgt; 19739eefe2a2SStefan Roese int need_wbuf_sync; 19749eefe2a2SStefan Roese 19759eefe2a2SStefan Roese int gc_lnum; 19769eefe2a2SStefan Roese void *sbuf; 19779eefe2a2SStefan Roese struct list_head idx_gc; 19789eefe2a2SStefan Roese int idx_gc_cnt; 19799eefe2a2SStefan Roese int gc_seq; 19809eefe2a2SStefan Roese int gced_lnum; 19819eefe2a2SStefan Roese 19829eefe2a2SStefan Roese struct list_head infos_list; 19839eefe2a2SStefan Roese struct mutex umount_mutex; 19849eefe2a2SStefan Roese unsigned int shrinker_run_no; 19859eefe2a2SStefan Roese 19869eefe2a2SStefan Roese int space_bits; 19879eefe2a2SStefan Roese int lpt_lnum_bits; 19889eefe2a2SStefan Roese int lpt_offs_bits; 19899eefe2a2SStefan Roese int lpt_spc_bits; 19909eefe2a2SStefan Roese int pcnt_bits; 19919eefe2a2SStefan Roese int lnum_bits; 19929eefe2a2SStefan Roese int nnode_sz; 19939eefe2a2SStefan Roese int pnode_sz; 19949eefe2a2SStefan Roese int ltab_sz; 19959eefe2a2SStefan Roese int lsave_sz; 19969eefe2a2SStefan Roese int pnode_cnt; 19979eefe2a2SStefan Roese int nnode_cnt; 19989eefe2a2SStefan Roese int lpt_hght; 19999eefe2a2SStefan Roese int pnodes_have; 20009eefe2a2SStefan Roese 20019eefe2a2SStefan Roese struct mutex lp_mutex; 20029eefe2a2SStefan Roese int lpt_lnum; 20039eefe2a2SStefan Roese int lpt_offs; 20049eefe2a2SStefan Roese int nhead_lnum; 20059eefe2a2SStefan Roese int nhead_offs; 20069eefe2a2SStefan Roese int lpt_drty_flgs; 20079eefe2a2SStefan Roese int dirty_nn_cnt; 20089eefe2a2SStefan Roese int dirty_pn_cnt; 20099eefe2a2SStefan Roese int check_lpt_free; 20109eefe2a2SStefan Roese long long lpt_sz; 20119eefe2a2SStefan Roese void *lpt_nod_buf; 20129eefe2a2SStefan Roese void *lpt_buf; 20139eefe2a2SStefan Roese struct ubifs_nnode *nroot; 20149eefe2a2SStefan Roese struct ubifs_cnode *lpt_cnext; 20159eefe2a2SStefan Roese struct ubifs_lpt_heap lpt_heap[LPROPS_HEAP_CNT]; 20169eefe2a2SStefan Roese struct ubifs_lpt_heap dirty_idx; 20179eefe2a2SStefan Roese struct list_head uncat_list; 20189eefe2a2SStefan Roese struct list_head empty_list; 20199eefe2a2SStefan Roese struct list_head freeable_list; 20209eefe2a2SStefan Roese struct list_head frdi_idx_list; 20219eefe2a2SStefan Roese int freeable_cnt; 2022*ff94bc40SHeiko Schocher int in_a_category_cnt; 20239eefe2a2SStefan Roese 20249eefe2a2SStefan Roese int ltab_lnum; 20259eefe2a2SStefan Roese int ltab_offs; 20269eefe2a2SStefan Roese struct ubifs_lpt_lprops *ltab; 20279eefe2a2SStefan Roese struct ubifs_lpt_lprops *ltab_cmt; 20289eefe2a2SStefan Roese int lsave_cnt; 20299eefe2a2SStefan Roese int lsave_lnum; 20309eefe2a2SStefan Roese int lsave_offs; 20319eefe2a2SStefan Roese int *lsave; 20329eefe2a2SStefan Roese int lscan_lnum; 20339eefe2a2SStefan Roese 20349eefe2a2SStefan Roese long long rp_size; 20359eefe2a2SStefan Roese long long report_rp_size; 2036*ff94bc40SHeiko Schocher kuid_t rp_uid; 2037*ff94bc40SHeiko Schocher kgid_t rp_gid; 20389eefe2a2SStefan Roese 20399eefe2a2SStefan Roese /* The below fields are used only during mounting and re-mounting */ 2040*ff94bc40SHeiko Schocher unsigned int empty:1; 2041*ff94bc40SHeiko Schocher unsigned int need_recovery:1; 2042*ff94bc40SHeiko Schocher unsigned int replaying:1; 2043*ff94bc40SHeiko Schocher unsigned int mounting:1; 2044*ff94bc40SHeiko Schocher unsigned int remounting_rw:1; 20459eefe2a2SStefan Roese struct list_head replay_list; 20469eefe2a2SStefan Roese struct list_head replay_buds; 20479eefe2a2SStefan Roese unsigned long long cs_sqnum; 20489eefe2a2SStefan Roese unsigned long long replay_sqnum; 20499eefe2a2SStefan Roese struct list_head unclean_leb_list; 20509eefe2a2SStefan Roese struct ubifs_mst_node *rcvrd_mst_node; 20519eefe2a2SStefan Roese struct rb_root size_tree; 20529eefe2a2SStefan Roese struct ubifs_mount_opts mount_opts; 20539eefe2a2SStefan Roese 2054*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 20559eefe2a2SStefan Roese struct ubifs_debug_info *dbg; 20569eefe2a2SStefan Roese #endif 20579eefe2a2SStefan Roese }; 20589eefe2a2SStefan Roese 2059*ff94bc40SHeiko Schocher extern struct list_head ubifs_infos; 20609eefe2a2SStefan Roese extern spinlock_t ubifs_infos_lock; 2061*ff94bc40SHeiko Schocher extern atomic_long_t ubifs_clean_zn_cnt; 20629eefe2a2SStefan Roese extern struct kmem_cache *ubifs_inode_slab; 20639eefe2a2SStefan Roese extern const struct super_operations ubifs_super_operations; 20649eefe2a2SStefan Roese extern const struct address_space_operations ubifs_file_address_operations; 20659eefe2a2SStefan Roese extern const struct file_operations ubifs_file_operations; 20669eefe2a2SStefan Roese extern const struct inode_operations ubifs_file_inode_operations; 20679eefe2a2SStefan Roese extern const struct file_operations ubifs_dir_operations; 20689eefe2a2SStefan Roese extern const struct inode_operations ubifs_dir_inode_operations; 20699eefe2a2SStefan Roese extern const struct inode_operations ubifs_symlink_inode_operations; 20709eefe2a2SStefan Roese extern struct backing_dev_info ubifs_backing_dev_info; 20719eefe2a2SStefan Roese extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; 20729eefe2a2SStefan Roese 20739eefe2a2SStefan Roese /* io.c */ 20749eefe2a2SStefan Roese void ubifs_ro_mode(struct ubifs_info *c, int err); 2075*ff94bc40SHeiko Schocher int ubifs_leb_read(const struct ubifs_info *c, int lnum, void *buf, int offs, 2076*ff94bc40SHeiko Schocher int len, int even_ebadmsg); 2077*ff94bc40SHeiko Schocher int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs, 2078*ff94bc40SHeiko Schocher int len); 2079*ff94bc40SHeiko Schocher int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len); 2080*ff94bc40SHeiko Schocher int ubifs_leb_unmap(struct ubifs_info *c, int lnum); 2081*ff94bc40SHeiko Schocher int ubifs_leb_map(struct ubifs_info *c, int lnum); 2082*ff94bc40SHeiko Schocher int ubifs_is_mapped(const struct ubifs_info *c, int lnum); 20839eefe2a2SStefan Roese int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len); 2084*ff94bc40SHeiko Schocher int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs); 20859eefe2a2SStefan Roese int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf); 20869eefe2a2SStefan Roese int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, 20879eefe2a2SStefan Roese int lnum, int offs); 20889eefe2a2SStefan Roese int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len, 20899eefe2a2SStefan Roese int lnum, int offs); 20909eefe2a2SStefan Roese int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum, 2091*ff94bc40SHeiko Schocher int offs); 20929eefe2a2SStefan Roese int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, 20939eefe2a2SStefan Roese int offs, int quiet, int must_chk_crc); 20949eefe2a2SStefan Roese void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad); 20959eefe2a2SStefan Roese void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last); 20969eefe2a2SStefan Roese int ubifs_io_init(struct ubifs_info *c); 20979eefe2a2SStefan Roese void ubifs_pad(const struct ubifs_info *c, void *buf, int pad); 20989eefe2a2SStefan Roese int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf); 20999eefe2a2SStefan Roese int ubifs_bg_wbufs_sync(struct ubifs_info *c); 21009eefe2a2SStefan Roese void ubifs_wbuf_add_ino_nolock(struct ubifs_wbuf *wbuf, ino_t inum); 21019eefe2a2SStefan Roese int ubifs_sync_wbufs_by_inode(struct ubifs_info *c, struct inode *inode); 21029eefe2a2SStefan Roese 21039eefe2a2SStefan Roese /* scan.c */ 21049eefe2a2SStefan Roese struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, 2105*ff94bc40SHeiko Schocher int offs, void *sbuf, int quiet); 21069eefe2a2SStefan Roese void ubifs_scan_destroy(struct ubifs_scan_leb *sleb); 21079eefe2a2SStefan Roese int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, 21089eefe2a2SStefan Roese int offs, int quiet); 21099eefe2a2SStefan Roese struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum, 21109eefe2a2SStefan Roese int offs, void *sbuf); 21119eefe2a2SStefan Roese void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, 21129eefe2a2SStefan Roese int lnum, int offs); 21139eefe2a2SStefan Roese int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, 21149eefe2a2SStefan Roese void *buf, int offs); 21159eefe2a2SStefan Roese void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, 21169eefe2a2SStefan Roese void *buf); 21179eefe2a2SStefan Roese 21189eefe2a2SStefan Roese /* log.c */ 21199eefe2a2SStefan Roese void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud); 21209eefe2a2SStefan Roese void ubifs_create_buds_lists(struct ubifs_info *c); 21219eefe2a2SStefan Roese int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs); 21229eefe2a2SStefan Roese struct ubifs_bud *ubifs_search_bud(struct ubifs_info *c, int lnum); 21239eefe2a2SStefan Roese struct ubifs_wbuf *ubifs_get_wbuf(struct ubifs_info *c, int lnum); 21249eefe2a2SStefan Roese int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum); 21259eefe2a2SStefan Roese int ubifs_log_end_commit(struct ubifs_info *c, int new_ltail_lnum); 21269eefe2a2SStefan Roese int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum); 21279eefe2a2SStefan Roese int ubifs_consolidate_log(struct ubifs_info *c); 21289eefe2a2SStefan Roese 21299eefe2a2SStefan Roese /* journal.c */ 21309eefe2a2SStefan Roese int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, 21319eefe2a2SStefan Roese const struct qstr *nm, const struct inode *inode, 21329eefe2a2SStefan Roese int deletion, int xent); 21339eefe2a2SStefan Roese int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, 21349eefe2a2SStefan Roese const union ubifs_key *key, const void *buf, int len); 21359eefe2a2SStefan Roese int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode); 21369eefe2a2SStefan Roese int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode); 21379eefe2a2SStefan Roese int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, 21389eefe2a2SStefan Roese const struct dentry *old_dentry, 21399eefe2a2SStefan Roese const struct inode *new_dir, 21409eefe2a2SStefan Roese const struct dentry *new_dentry, int sync); 21419eefe2a2SStefan Roese int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode, 21429eefe2a2SStefan Roese loff_t old_size, loff_t new_size); 21439eefe2a2SStefan Roese int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host, 21449eefe2a2SStefan Roese const struct inode *inode, const struct qstr *nm); 21459eefe2a2SStefan Roese int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode1, 21469eefe2a2SStefan Roese const struct inode *inode2); 21479eefe2a2SStefan Roese 21489eefe2a2SStefan Roese /* budget.c */ 21499eefe2a2SStefan Roese int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req); 21509eefe2a2SStefan Roese void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req); 21519eefe2a2SStefan Roese void ubifs_release_dirty_inode_budget(struct ubifs_info *c, 21529eefe2a2SStefan Roese struct ubifs_inode *ui); 21539eefe2a2SStefan Roese int ubifs_budget_inode_op(struct ubifs_info *c, struct inode *inode, 21549eefe2a2SStefan Roese struct ubifs_budget_req *req); 21559eefe2a2SStefan Roese void ubifs_release_ino_dirty(struct ubifs_info *c, struct inode *inode, 21569eefe2a2SStefan Roese struct ubifs_budget_req *req); 21579eefe2a2SStefan Roese void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode, 21589eefe2a2SStefan Roese struct ubifs_budget_req *req); 21599eefe2a2SStefan Roese long long ubifs_get_free_space(struct ubifs_info *c); 21609eefe2a2SStefan Roese long long ubifs_get_free_space_nolock(struct ubifs_info *c); 21619eefe2a2SStefan Roese int ubifs_calc_min_idx_lebs(struct ubifs_info *c); 21629eefe2a2SStefan Roese void ubifs_convert_page_budget(struct ubifs_info *c); 21639eefe2a2SStefan Roese long long ubifs_reported_space(const struct ubifs_info *c, long long free); 21649eefe2a2SStefan Roese long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs); 21659eefe2a2SStefan Roese 21669eefe2a2SStefan Roese /* find.c */ 2167*ff94bc40SHeiko Schocher int ubifs_find_free_space(struct ubifs_info *c, int min_space, int *offs, 21689eefe2a2SStefan Roese int squeeze); 21699eefe2a2SStefan Roese int ubifs_find_free_leb_for_idx(struct ubifs_info *c); 21709eefe2a2SStefan Roese int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp, 21719eefe2a2SStefan Roese int min_space, int pick_free); 21729eefe2a2SStefan Roese int ubifs_find_dirty_idx_leb(struct ubifs_info *c); 21739eefe2a2SStefan Roese int ubifs_save_dirty_idx_lnums(struct ubifs_info *c); 21749eefe2a2SStefan Roese 21759eefe2a2SStefan Roese /* tnc.c */ 21769eefe2a2SStefan Roese int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, 21779eefe2a2SStefan Roese struct ubifs_znode **zn, int *n); 21789eefe2a2SStefan Roese int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, 21799eefe2a2SStefan Roese void *node, const struct qstr *nm); 21809eefe2a2SStefan Roese int ubifs_tnc_locate(struct ubifs_info *c, const union ubifs_key *key, 21819eefe2a2SStefan Roese void *node, int *lnum, int *offs); 21829eefe2a2SStefan Roese int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum, 21839eefe2a2SStefan Roese int offs, int len); 21849eefe2a2SStefan Roese int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key, 21859eefe2a2SStefan Roese int old_lnum, int old_offs, int lnum, int offs, int len); 21869eefe2a2SStefan Roese int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key, 21879eefe2a2SStefan Roese int lnum, int offs, int len, const struct qstr *nm); 21889eefe2a2SStefan Roese int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key); 21899eefe2a2SStefan Roese int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key, 21909eefe2a2SStefan Roese const struct qstr *nm); 21919eefe2a2SStefan Roese int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key, 21929eefe2a2SStefan Roese union ubifs_key *to_key); 21939eefe2a2SStefan Roese int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum); 21949eefe2a2SStefan Roese struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c, 21959eefe2a2SStefan Roese union ubifs_key *key, 21969eefe2a2SStefan Roese const struct qstr *nm); 21979eefe2a2SStefan Roese void ubifs_tnc_close(struct ubifs_info *c); 21989eefe2a2SStefan Roese int ubifs_tnc_has_node(struct ubifs_info *c, union ubifs_key *key, int level, 21999eefe2a2SStefan Roese int lnum, int offs, int is_idx); 22009eefe2a2SStefan Roese int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level, 22019eefe2a2SStefan Roese int lnum, int offs); 22029eefe2a2SStefan Roese /* Shared by tnc.c for tnc_commit.c */ 22039eefe2a2SStefan Roese void destroy_old_idx(struct ubifs_info *c); 22049eefe2a2SStefan Roese int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, 22059eefe2a2SStefan Roese int lnum, int offs); 22069eefe2a2SStefan Roese int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode); 22079eefe2a2SStefan Roese int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu); 22089eefe2a2SStefan Roese int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu); 22099eefe2a2SStefan Roese 22109eefe2a2SStefan Roese /* tnc_misc.c */ 22119eefe2a2SStefan Roese struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, 22129eefe2a2SStefan Roese struct ubifs_znode *znode); 22139eefe2a2SStefan Roese int ubifs_search_zbranch(const struct ubifs_info *c, 22149eefe2a2SStefan Roese const struct ubifs_znode *znode, 22159eefe2a2SStefan Roese const union ubifs_key *key, int *n); 22169eefe2a2SStefan Roese struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode); 22179eefe2a2SStefan Roese struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode); 22189eefe2a2SStefan Roese long ubifs_destroy_tnc_subtree(struct ubifs_znode *zr); 22199eefe2a2SStefan Roese struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, 22209eefe2a2SStefan Roese struct ubifs_zbranch *zbr, 22219eefe2a2SStefan Roese struct ubifs_znode *parent, int iip); 22229eefe2a2SStefan Roese int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, 22239eefe2a2SStefan Roese void *node); 22249eefe2a2SStefan Roese 22259eefe2a2SStefan Roese /* tnc_commit.c */ 22269eefe2a2SStefan Roese int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot); 22279eefe2a2SStefan Roese int ubifs_tnc_end_commit(struct ubifs_info *c); 22289eefe2a2SStefan Roese 2229*ff94bc40SHeiko Schocher #ifndef __UBOOT__ 22309eefe2a2SStefan Roese /* shrinker.c */ 2231*ff94bc40SHeiko Schocher unsigned long ubifs_shrink_scan(struct shrinker *shrink, 2232*ff94bc40SHeiko Schocher struct shrink_control *sc); 2233*ff94bc40SHeiko Schocher unsigned long ubifs_shrink_count(struct shrinker *shrink, 2234*ff94bc40SHeiko Schocher struct shrink_control *sc); 2235*ff94bc40SHeiko Schocher #endif 22369eefe2a2SStefan Roese 22379eefe2a2SStefan Roese /* commit.c */ 22389eefe2a2SStefan Roese int ubifs_bg_thread(void *info); 22399eefe2a2SStefan Roese void ubifs_commit_required(struct ubifs_info *c); 22409eefe2a2SStefan Roese void ubifs_request_bg_commit(struct ubifs_info *c); 22419eefe2a2SStefan Roese int ubifs_run_commit(struct ubifs_info *c); 22429eefe2a2SStefan Roese void ubifs_recovery_commit(struct ubifs_info *c); 22439eefe2a2SStefan Roese int ubifs_gc_should_commit(struct ubifs_info *c); 22449eefe2a2SStefan Roese void ubifs_wait_for_commit(struct ubifs_info *c); 22459eefe2a2SStefan Roese 22469eefe2a2SStefan Roese /* master.c */ 22479eefe2a2SStefan Roese int ubifs_read_master(struct ubifs_info *c); 22489eefe2a2SStefan Roese int ubifs_write_master(struct ubifs_info *c); 22499eefe2a2SStefan Roese 22509eefe2a2SStefan Roese /* sb.c */ 22519eefe2a2SStefan Roese int ubifs_read_superblock(struct ubifs_info *c); 22529eefe2a2SStefan Roese struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c); 22539eefe2a2SStefan Roese int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup); 2254*ff94bc40SHeiko Schocher int ubifs_fixup_free_space(struct ubifs_info *c); 22559eefe2a2SStefan Roese 22569eefe2a2SStefan Roese /* replay.c */ 22579eefe2a2SStefan Roese int ubifs_validate_entry(struct ubifs_info *c, 22589eefe2a2SStefan Roese const struct ubifs_dent_node *dent); 22599eefe2a2SStefan Roese int ubifs_replay_journal(struct ubifs_info *c); 22609eefe2a2SStefan Roese 22619eefe2a2SStefan Roese /* gc.c */ 22629eefe2a2SStefan Roese int ubifs_garbage_collect(struct ubifs_info *c, int anyway); 22639eefe2a2SStefan Roese int ubifs_gc_start_commit(struct ubifs_info *c); 22649eefe2a2SStefan Roese int ubifs_gc_end_commit(struct ubifs_info *c); 22659eefe2a2SStefan Roese void ubifs_destroy_idx_gc(struct ubifs_info *c); 22669eefe2a2SStefan Roese int ubifs_get_idx_gc_leb(struct ubifs_info *c); 22679eefe2a2SStefan Roese int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp); 22689eefe2a2SStefan Roese 22699eefe2a2SStefan Roese /* orphan.c */ 22709eefe2a2SStefan Roese int ubifs_add_orphan(struct ubifs_info *c, ino_t inum); 22719eefe2a2SStefan Roese void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum); 22729eefe2a2SStefan Roese int ubifs_orphan_start_commit(struct ubifs_info *c); 22739eefe2a2SStefan Roese int ubifs_orphan_end_commit(struct ubifs_info *c); 22749eefe2a2SStefan Roese int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only); 22759eefe2a2SStefan Roese int ubifs_clear_orphans(struct ubifs_info *c); 22769eefe2a2SStefan Roese 22779eefe2a2SStefan Roese /* lpt.c */ 22789eefe2a2SStefan Roese int ubifs_calc_lpt_geom(struct ubifs_info *c); 22799eefe2a2SStefan Roese int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, 22809eefe2a2SStefan Roese int *lpt_lebs, int *big_lpt); 22819eefe2a2SStefan Roese int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr); 22829eefe2a2SStefan Roese struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum); 22839eefe2a2SStefan Roese struct ubifs_lprops *ubifs_lpt_lookup_dirty(struct ubifs_info *c, int lnum); 22849eefe2a2SStefan Roese int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum, 22859eefe2a2SStefan Roese ubifs_lpt_scan_callback scan_cb, void *data); 22869eefe2a2SStefan Roese 22879eefe2a2SStefan Roese /* Shared by lpt.c for lpt_commit.c */ 22889eefe2a2SStefan Roese void ubifs_pack_lsave(struct ubifs_info *c, void *buf, int *lsave); 22899eefe2a2SStefan Roese void ubifs_pack_ltab(struct ubifs_info *c, void *buf, 22909eefe2a2SStefan Roese struct ubifs_lpt_lprops *ltab); 22919eefe2a2SStefan Roese void ubifs_pack_pnode(struct ubifs_info *c, void *buf, 22929eefe2a2SStefan Roese struct ubifs_pnode *pnode); 22939eefe2a2SStefan Roese void ubifs_pack_nnode(struct ubifs_info *c, void *buf, 22949eefe2a2SStefan Roese struct ubifs_nnode *nnode); 22959eefe2a2SStefan Roese struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c, 22969eefe2a2SStefan Roese struct ubifs_nnode *parent, int iip); 22979eefe2a2SStefan Roese struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c, 22989eefe2a2SStefan Roese struct ubifs_nnode *parent, int iip); 22999eefe2a2SStefan Roese int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip); 23009eefe2a2SStefan Roese void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty); 23019eefe2a2SStefan Roese void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); 23029eefe2a2SStefan Roese uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits); 23039eefe2a2SStefan Roese struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght); 23049eefe2a2SStefan Roese /* Needed only in debugging code in lpt_commit.c */ 23059eefe2a2SStefan Roese int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf, 23069eefe2a2SStefan Roese struct ubifs_nnode *nnode); 23079eefe2a2SStefan Roese 23089eefe2a2SStefan Roese /* lpt_commit.c */ 23099eefe2a2SStefan Roese int ubifs_lpt_start_commit(struct ubifs_info *c); 23109eefe2a2SStefan Roese int ubifs_lpt_end_commit(struct ubifs_info *c); 23119eefe2a2SStefan Roese int ubifs_lpt_post_commit(struct ubifs_info *c); 23129eefe2a2SStefan Roese void ubifs_lpt_free(struct ubifs_info *c, int wr_only); 23139eefe2a2SStefan Roese 23149eefe2a2SStefan Roese /* lprops.c */ 23159eefe2a2SStefan Roese const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, 23169eefe2a2SStefan Roese const struct ubifs_lprops *lp, 23179eefe2a2SStefan Roese int free, int dirty, int flags, 23189eefe2a2SStefan Roese int idx_gc_cnt); 23199eefe2a2SStefan Roese void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst); 23209eefe2a2SStefan Roese void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, 23219eefe2a2SStefan Roese int cat); 23229eefe2a2SStefan Roese void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, 23239eefe2a2SStefan Roese struct ubifs_lprops *new_lprops); 23249eefe2a2SStefan Roese void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops); 23259eefe2a2SStefan Roese int ubifs_categorize_lprops(const struct ubifs_info *c, 23269eefe2a2SStefan Roese const struct ubifs_lprops *lprops); 23279eefe2a2SStefan Roese int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, 23289eefe2a2SStefan Roese int flags_set, int flags_clean, int idx_gc_cnt); 23299eefe2a2SStefan Roese int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, 23309eefe2a2SStefan Roese int flags_set, int flags_clean); 23319eefe2a2SStefan Roese int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp); 23329eefe2a2SStefan Roese const struct ubifs_lprops *ubifs_fast_find_free(struct ubifs_info *c); 23339eefe2a2SStefan Roese const struct ubifs_lprops *ubifs_fast_find_empty(struct ubifs_info *c); 23349eefe2a2SStefan Roese const struct ubifs_lprops *ubifs_fast_find_freeable(struct ubifs_info *c); 23359eefe2a2SStefan Roese const struct ubifs_lprops *ubifs_fast_find_frdi_idx(struct ubifs_info *c); 2336*ff94bc40SHeiko Schocher int ubifs_calc_dark(const struct ubifs_info *c, int spc); 23379eefe2a2SStefan Roese 23389eefe2a2SStefan Roese /* file.c */ 2339*ff94bc40SHeiko Schocher int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync); 23409eefe2a2SStefan Roese int ubifs_setattr(struct dentry *dentry, struct iattr *attr); 23419eefe2a2SStefan Roese 23429eefe2a2SStefan Roese /* dir.c */ 23439eefe2a2SStefan Roese struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, 2344*ff94bc40SHeiko Schocher umode_t mode); 23459eefe2a2SStefan Roese int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry, 23469eefe2a2SStefan Roese struct kstat *stat); 23479eefe2a2SStefan Roese 23489eefe2a2SStefan Roese /* xattr.c */ 23499eefe2a2SStefan Roese int ubifs_setxattr(struct dentry *dentry, const char *name, 23509eefe2a2SStefan Roese const void *value, size_t size, int flags); 23519eefe2a2SStefan Roese ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf, 23529eefe2a2SStefan Roese size_t size); 23539eefe2a2SStefan Roese ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); 23549eefe2a2SStefan Roese int ubifs_removexattr(struct dentry *dentry, const char *name); 23559eefe2a2SStefan Roese 23569eefe2a2SStefan Roese /* super.c */ 23579eefe2a2SStefan Roese struct inode *ubifs_iget(struct super_block *sb, unsigned long inum); 23589eefe2a2SStefan Roese int ubifs_iput(struct inode *inode); 23599eefe2a2SStefan Roese 23609eefe2a2SStefan Roese /* recovery.c */ 23619eefe2a2SStefan Roese int ubifs_recover_master_node(struct ubifs_info *c); 23629eefe2a2SStefan Roese int ubifs_write_rcvrd_mst_node(struct ubifs_info *c); 23639eefe2a2SStefan Roese struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, 2364*ff94bc40SHeiko Schocher int offs, void *sbuf, int jhead); 23659eefe2a2SStefan Roese struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, 23669eefe2a2SStefan Roese int offs, void *sbuf); 2367*ff94bc40SHeiko Schocher int ubifs_recover_inl_heads(struct ubifs_info *c, void *sbuf); 2368*ff94bc40SHeiko Schocher int ubifs_clean_lebs(struct ubifs_info *c, void *sbuf); 23699eefe2a2SStefan Roese int ubifs_rcvry_gc_commit(struct ubifs_info *c); 23709eefe2a2SStefan Roese int ubifs_recover_size_accum(struct ubifs_info *c, union ubifs_key *key, 23719eefe2a2SStefan Roese int deletion, loff_t new_size); 23729eefe2a2SStefan Roese int ubifs_recover_size(struct ubifs_info *c); 23739eefe2a2SStefan Roese void ubifs_destroy_size_tree(struct ubifs_info *c); 23749eefe2a2SStefan Roese 23759eefe2a2SStefan Roese /* ioctl.c */ 23769eefe2a2SStefan Roese long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 23779eefe2a2SStefan Roese void ubifs_set_inode_flags(struct inode *inode); 23789eefe2a2SStefan Roese #ifdef CONFIG_COMPAT 23799eefe2a2SStefan Roese long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 23809eefe2a2SStefan Roese #endif 23819eefe2a2SStefan Roese 23829eefe2a2SStefan Roese /* compressor.c */ 23839eefe2a2SStefan Roese int __init ubifs_compressors_init(void); 2384*ff94bc40SHeiko Schocher void ubifs_compressors_exit(void); 23859eefe2a2SStefan Roese void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, 23869eefe2a2SStefan Roese int *compr_type); 23879eefe2a2SStefan Roese int ubifs_decompress(const void *buf, int len, void *out, int *out_len, 23889eefe2a2SStefan Roese int compr_type); 23899eefe2a2SStefan Roese 23909eefe2a2SStefan Roese #include "debug.h" 23919eefe2a2SStefan Roese #include "misc.h" 23929eefe2a2SStefan Roese #include "key.h" 23939eefe2a2SStefan Roese 2394*ff94bc40SHeiko Schocher #ifdef __UBOOT__ 2395*ff94bc40SHeiko Schocher /* these are used in cmd_ubifs.c */ 2396*ff94bc40SHeiko Schocher int ubifs_init(void); 2397*ff94bc40SHeiko Schocher int uboot_ubifs_mount(char *vol_name); 2398*ff94bc40SHeiko Schocher void ubifs_umount(struct ubifs_info *c); 2399*ff94bc40SHeiko Schocher int ubifs_ls(char *dir_name); 2400*ff94bc40SHeiko Schocher int ubifs_load(char *filename, u32 addr, u32 size); 2401*ff94bc40SHeiko Schocher #endif 24029eefe2a2SStefan Roese #endif /* !__UBIFS_H__ */ 2403