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