1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __UBIFS_H__
16#define __UBIFS_H__
17
18#ifndef __UBOOT__
19#include <asm/div64.h>
20#include <linux/statfs.h>
21#include <linux/fs.h>
22#include <linux/err.h>
23#include <linux/sched.h>
24#include <linux/slab.h>
25#include <linux/vmalloc.h>
26#include <linux/spinlock.h>
27#include <linux/mutex.h>
28#include <linux/rwsem.h>
29#include <linux/mtd/ubi.h>
30#include <linux/pagemap.h>
31#include <linux/backing-dev.h>
32#include <linux/security.h>
33#include "ubifs-media.h"
34#else
35#include <asm/atomic.h>
36#include <asm-generic/atomic-long.h>
37#include <ubi_uboot.h>
38#include <ubifs_uboot.h>
39
40#include <linux/ctype.h>
41#include <linux/time.h>
42#include <linux/math64.h>
43#include "ubifs-media.h"
44
45struct dentry;
46struct file;
47struct iattr;
48struct kstat;
49struct vfsmount;
50
51extern struct super_block *ubifs_sb;
52
53extern unsigned int ubifs_msg_flags;
54extern unsigned int ubifs_chk_flags;
55extern unsigned int ubifs_tst_flags;
56
57#define pgoff_t unsigned long
58
59
60
61
62struct page {
63 pgoff_t index;
64 void *addr;
65 struct inode *inode;
66};
67
68void iput(struct inode *inode);
69
70
71#define NSEC_PER_SEC 1000000000L
72#define get_seconds() 0
73#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
74
75struct timespec {
76 time_t tv_sec;
77 long tv_nsec;
78};
79
80static struct timespec current_fs_time(struct super_block *sb)
81{
82 struct timespec now;
83 now.tv_sec = 0;
84 now.tv_nsec = 0;
85 return now;
86};
87
88
89
90
91
92
93
94
95
96
97struct qstr {
98 unsigned int hash;
99 unsigned int len;
100#ifndef __UBOOT__
101 const char *name;
102#else
103 char *name;
104#endif
105};
106
107
108
109
110enum {
111 SB_UNFROZEN = 0,
112 SB_FREEZE_WRITE = 1,
113 SB_FREEZE_PAGEFAULT = 2,
114 SB_FREEZE_FS = 3,
115
116 SB_FREEZE_COMPLETE = 4,
117};
118
119#define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
120
121struct sb_writers {
122#ifndef __UBOOT__
123
124 struct percpu_counter counter[SB_FREEZE_LEVELS];
125#endif
126 wait_queue_head_t wait;
127
128 int frozen;
129 wait_queue_head_t wait_unfrozen;
130
131#ifdef CONFIG_DEBUG_LOCK_ALLOC
132 struct lockdep_map lock_map[SB_FREEZE_LEVELS];
133#endif
134};
135
136struct address_space {
137 struct inode *host;
138#ifndef __UBOOT__
139 struct radix_tree_root page_tree;
140#endif
141 spinlock_t tree_lock;
142 unsigned int i_mmap_writable;
143 struct rb_root i_mmap;
144 struct list_head i_mmap_nonlinear;
145 struct mutex i_mmap_mutex;
146
147 unsigned long nrpages;
148 pgoff_t writeback_index;
149 const struct address_space_operations *a_ops;
150 unsigned long flags;
151#ifndef __UBOOT__
152 struct backing_dev_info *backing_dev_info;
153#endif
154 spinlock_t private_lock;
155 struct list_head private_list;
156 void *private_data;
157} __attribute__((aligned(sizeof(long))));
158
159
160
161
162
163
164struct inode {
165 umode_t i_mode;
166 unsigned short i_opflags;
167 kuid_t i_uid;
168 kgid_t i_gid;
169 unsigned int i_flags;
170
171#ifdef CONFIG_FS_POSIX_ACL
172 struct posix_acl *i_acl;
173 struct posix_acl *i_default_acl;
174#endif
175
176 const struct inode_operations *i_op;
177 struct super_block *i_sb;
178 struct address_space *i_mapping;
179
180#ifdef CONFIG_SECURITY
181 void *i_security;
182#endif
183
184
185 unsigned long i_ino;
186
187
188
189
190
191
192
193 union {
194 const unsigned int i_nlink;
195 unsigned int __i_nlink;
196 };
197 dev_t i_rdev;
198 loff_t i_size;
199 struct timespec i_atime;
200 struct timespec i_mtime;
201 struct timespec i_ctime;
202 spinlock_t i_lock;
203 unsigned short i_bytes;
204 unsigned int i_blkbits;
205 blkcnt_t i_blocks;
206
207#ifdef __NEED_I_SIZE_ORDERED
208 seqcount_t i_size_seqcount;
209#endif
210
211
212 unsigned long i_state;
213 struct mutex i_mutex;
214
215 unsigned long dirtied_when;
216
217 struct hlist_node i_hash;
218 struct list_head i_wb_list;
219 struct list_head i_lru;
220 struct list_head i_sb_list;
221 union {
222 struct hlist_head i_dentry;
223 struct rcu_head i_rcu;
224 };
225 u64 i_version;
226 atomic_t i_count;
227 atomic_t i_dio_count;
228 atomic_t i_writecount;
229 const struct file_operations *i_fop;
230 struct file_lock *i_flock;
231 struct address_space i_data;
232#ifdef CONFIG_QUOTA
233 struct dquot *i_dquot[MAXQUOTAS];
234#endif
235 struct list_head i_devices;
236 union {
237 struct pipe_inode_info *i_pipe;
238 struct block_device *i_bdev;
239 struct cdev *i_cdev;
240 };
241
242 __u32 i_generation;
243
244#ifdef CONFIG_FSNOTIFY
245 __u32 i_fsnotify_mask;
246 struct hlist_head i_fsnotify_marks;
247#endif
248
249#ifdef CONFIG_IMA
250 atomic_t i_readcount;
251#endif
252 void *i_private;
253};
254
255struct super_operations {
256 struct inode *(*alloc_inode)(struct super_block *sb);
257 void (*destroy_inode)(struct inode *);
258
259 void (*dirty_inode) (struct inode *, int flags);
260 int (*write_inode) (struct inode *, struct writeback_control *wbc);
261 int (*drop_inode) (struct inode *);
262 void (*evict_inode) (struct inode *);
263 void (*put_super) (struct super_block *);
264 int (*sync_fs)(struct super_block *sb, int wait);
265 int (*freeze_fs) (struct super_block *);
266 int (*unfreeze_fs) (struct super_block *);
267#ifndef __UBOOT__
268 int (*statfs) (struct dentry *, struct kstatfs *);
269#endif
270 int (*remount_fs) (struct super_block *, int *, char *);
271 void (*umount_begin) (struct super_block *);
272
273#ifndef __UBOOT__
274 int (*show_options)(struct seq_file *, struct dentry *);
275 int (*show_devname)(struct seq_file *, struct dentry *);
276 int (*show_path)(struct seq_file *, struct dentry *);
277 int (*show_stats)(struct seq_file *, struct dentry *);
278#endif
279#ifdef CONFIG_QUOTA
280 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
281 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
282#endif
283 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
284 long (*nr_cached_objects)(struct super_block *, int);
285 long (*free_cached_objects)(struct super_block *, long, int);
286};
287
288struct super_block {
289 struct list_head s_list;
290 dev_t s_dev;
291 unsigned char s_blocksize_bits;
292 unsigned long s_blocksize;
293 loff_t s_maxbytes;
294 struct file_system_type *s_type;
295 const struct super_operations *s_op;
296 const struct dquot_operations *dq_op;
297 const struct quotactl_ops *s_qcop;
298 const struct export_operations *s_export_op;
299 unsigned long s_flags;
300 unsigned long s_magic;
301 struct dentry *s_root;
302 struct rw_semaphore s_umount;
303 int s_count;
304 atomic_t s_active;
305#ifdef CONFIG_SECURITY
306 void *s_security;
307#endif
308 const struct xattr_handler **s_xattr;
309
310 struct list_head s_inodes;
311#ifndef __UBOOT__
312 struct hlist_bl_head s_anon;
313#endif
314 struct list_head s_mounts;
315 struct block_device *s_bdev;
316#ifndef __UBOOT__
317 struct backing_dev_info *s_bdi;
318#endif
319 struct mtd_info *s_mtd;
320 struct hlist_node s_instances;
321#ifndef __UBOOT__
322 struct quota_info s_dquot;
323#endif
324
325 struct sb_writers s_writers;
326
327 char s_id[32];
328 u8 s_uuid[16];
329
330 void *s_fs_info;
331 unsigned int s_max_links;
332#ifndef __UBOOT__
333 fmode_t s_mode;
334#endif
335
336
337
338 u32 s_time_gran;
339
340
341
342
343
344 struct mutex s_vfs_rename_mutex;
345
346
347
348
349
350 char *s_subtype;
351
352#ifndef __UBOOT__
353
354
355
356
357 char __rcu *s_options;
358#endif
359 const struct dentry_operations *s_d_op;
360
361
362
363
364 int cleancache_poolid;
365
366#ifndef __UBOOT__
367 struct shrinker s_shrink;
368#endif
369
370
371 atomic_long_t s_remove_count;
372
373
374 int s_readonly_remount;
375
376
377 struct workqueue_struct *s_dio_done_wq;
378
379#ifndef __UBOOT__
380
381
382
383
384 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp;
385 struct list_lru s_inode_lru ____cacheline_aligned_in_smp;
386#endif
387 struct rcu_head rcu;
388};
389
390struct file_system_type {
391 const char *name;
392 int fs_flags;
393#define FS_REQUIRES_DEV 1
394#define FS_BINARY_MOUNTDATA 2
395#define FS_HAS_SUBTYPE 4
396#define FS_USERNS_MOUNT 8
397#define FS_USERNS_DEV_MOUNT 16
398#define FS_RENAME_DOES_D_MOVE 32768
399 struct dentry *(*mount) (struct file_system_type *, int,
400 const char *, void *);
401 void (*kill_sb) (struct super_block *);
402 struct module *owner;
403 struct file_system_type * next;
404 struct hlist_head fs_supers;
405
406#ifndef __UBOOT__
407 struct lock_class_key s_lock_key;
408 struct lock_class_key s_umount_key;
409 struct lock_class_key s_vfs_rename_key;
410 struct lock_class_key s_writers_key[SB_FREEZE_LEVELS];
411
412 struct lock_class_key i_lock_key;
413 struct lock_class_key i_mutex_key;
414 struct lock_class_key i_mutex_dir_key;
415#endif
416};
417
418
419struct vfsmount {
420 struct dentry *mnt_root;
421 struct super_block *mnt_sb;
422 int mnt_flags;
423};
424
425struct path {
426 struct vfsmount *mnt;
427 struct dentry *dentry;
428};
429
430struct file {
431 struct path f_path;
432#define f_dentry f_path.dentry
433#define f_vfsmnt f_path.mnt
434 const struct file_operations *f_op;
435 unsigned int f_flags;
436 loff_t f_pos;
437 unsigned int f_uid, f_gid;
438
439 u64 f_version;
440#ifdef CONFIG_SECURITY
441 void *f_security;
442#endif
443
444 void *private_data;
445
446#ifdef CONFIG_EPOLL
447
448 struct list_head f_ep_links;
449 spinlock_t f_ep_lock;
450#endif
451#ifdef CONFIG_DEBUG_WRITECOUNT
452 unsigned long f_mnt_write_state;
453#endif
454};
455
456
457
458
459#define get_seconds() 0
460
461
462#define PAGE_CACHE_SHIFT 12
463#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT)
464
465
466
467#if BITS_PER_LONG==32
468#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
469#elif BITS_PER_LONG==64
470#define MAX_LFS_FILESIZE 0x7fffffffffffffffUL
471#endif
472
473
474
475
476#define MS_RDONLY 1
477#define MS_NOSUID 2
478#define MS_NODEV 4
479#define MS_NOEXEC 8
480#define MS_SYNCHRONOUS 16
481#define MS_REMOUNT 32
482#define MS_MANDLOCK 64
483#define MS_DIRSYNC 128
484#define MS_NOATIME 1024
485#define MS_NODIRATIME 2048
486#define MS_BIND 4096
487#define MS_MOVE 8192
488#define MS_REC 16384
489#define MS_VERBOSE 32768
490
491#define MS_SILENT 32768
492#define MS_POSIXACL (1<<16)
493#define MS_UNBINDABLE (1<<17)
494#define MS_PRIVATE (1<<18)
495#define MS_SLAVE (1<<19)
496#define MS_SHARED (1<<20)
497#define MS_RELATIME (1<<21)
498#define MS_KERNMOUNT (1<<22)
499#define MS_I_VERSION (1<<23)
500#define MS_ACTIVE (1<<30)
501#define MS_NOUSER (1<<31)
502
503#define I_NEW 8
504
505
506
507#define S_SYNC 1
508#define S_NOATIME 2
509#define S_APPEND 4
510#define S_IMMUTABLE 8
511#define S_DEAD 16
512#define S_NOQUOTA 32
513#define S_DIRSYNC 64
514#define S_NOCMTIME 128
515#define S_SWAPFILE 256
516#define S_PRIVATE 512
517
518
519
520#define S_IFMT 00170000
521#define S_IFSOCK 0140000
522#define S_IFLNK 0120000
523#define S_IFREG 0100000
524#define S_IFBLK 0060000
525#define S_IFDIR 0040000
526#define S_IFCHR 0020000
527#define S_IFIFO 0010000
528#define S_ISUID 0004000
529#define S_ISGID 0002000
530#define S_ISVTX 0001000
531
532
533
534
535
536
537
538
539
540#define DT_UNKNOWN 0
541#define DT_FIFO 1
542#define DT_CHR 2
543#define DT_DIR 4
544#define DT_BLK 6
545#define DT_REG 8
546#define DT_LNK 10
547#define DT_SOCK 12
548#define DT_WHT 14
549
550#define I_DIRTY_SYNC 1
551#define I_DIRTY_DATASYNC 2
552#define I_DIRTY_PAGES 4
553#define I_NEW 8
554#define I_WILL_FREE 16
555#define I_FREEING 32
556#define I_CLEAR 64
557#define __I_LOCK 7
558#define I_LOCK (1 << __I_LOCK)
559#define __I_SYNC 8
560#define I_SYNC (1 << __I_SYNC)
561
562#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
563
564
565
566#define DNAME_INLINE_LEN_MIN 36
567
568struct dentry {
569 unsigned int d_flags;
570 spinlock_t d_lock;
571 struct inode *d_inode;
572
573
574
575
576
577 struct hlist_node d_hash;
578 struct dentry *d_parent;
579 struct qstr d_name;
580
581 struct list_head d_lru;
582
583
584
585 struct list_head d_subdirs;
586 struct list_head d_alias;
587 unsigned long d_time;
588 struct super_block *d_sb;
589 void *d_fsdata;
590#ifdef CONFIG_PROFILING
591 struct dcookie_struct *d_cookie;
592#endif
593 int d_mounted;
594 unsigned char d_iname[DNAME_INLINE_LEN_MIN];
595};
596
597static inline ino_t parent_ino(struct dentry *dentry)
598{
599 ino_t res;
600
601 spin_lock(&dentry->d_lock);
602 res = dentry->d_parent->d_inode->i_ino;
603 spin_unlock(&dentry->d_lock);
604 return res;
605}
606
607
608
609#define module_param_named(...)
610
611
612#define mutex_lock_nested(...)
613#define mutex_unlock_nested(...)
614#define mutex_is_locked(...) 0
615#endif
616
617
618#define UBIFS_VERSION 1
619
620
621#define ubifs_msg(c, fmt, ...) \
622 pr_notice("UBIFS (ubi%d:%d): " fmt "\n", \
623 (c)->vi.ubi_num, (c)->vi.vol_id, ##__VA_ARGS__)
624
625#ifndef __UBOOT__
626#define ubifs_err(c, fmt, ...) \
627 pr_err("UBIFS error (ubi%d:%d pid %d): %s: " fmt "\n", \
628 (c)->vi.ubi_num, (c)->vi.vol_id, current->pid, \
629 __func__, ##__VA_ARGS__)
630
631#define ubifs_warn(c, fmt, ...) \
632 pr_warn("UBIFS warning (ubi%d:%d pid %d): %s: " fmt "\n", \
633 (c)->vi.ubi_num, (c)->vi.vol_id, current->pid, \
634 __func__, ##__VA_ARGS__)
635#else
636#define ubifs_err(c, fmt, ...) \
637 pr_err("UBIFS error (ubi%d:%d pid %d): %s: " fmt "\n", \
638 (c)->vi.ubi_num, (c)->vi.vol_id, 0, \
639 __func__, ##__VA_ARGS__)
640
641#define ubifs_warn(c, fmt, ...) \
642 pr_warn("UBIFS warning (ubi%d:%d pid %d): %s: " fmt "\n", \
643 (c)->vi.ubi_num, (c)->vi.vol_id, 0, \
644 __func__, ##__VA_ARGS__)
645
646#endif
647
648
649
650
651
652#define ubifs_errc(c, fmt, ...) \
653 do { \
654 if (!(c)->probing) \
655 ubifs_err(c, fmt, ##__VA_ARGS__); \
656 } while (0)
657
658
659#define UBIFS_SUPER_MAGIC 0x24051905
660
661
662#define UBIFS_BLOCKS_PER_PAGE (PAGE_CACHE_SIZE / UBIFS_BLOCK_SIZE)
663#define UBIFS_BLOCKS_PER_PAGE_SHIFT (PAGE_CACHE_SHIFT - UBIFS_BLOCK_SHIFT)
664
665
666#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL
667#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL
668
669
670
671
672
673
674
675#define MIN_INDEX_LEBS 2
676
677
678#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8)
679
680
681
682
683
684
685
686#define INUM_WARN_WATERMARK 0xFFF00000
687#define INUM_WATERMARK 0xFFFFFF00
688
689
690#define LPT_HEAP_SZ 256
691
692
693
694
695
696#define BGT_NAME_PATTERN "ubifs_bgt%d_%d"
697
698
699#define WBUF_TIMEOUT_SOFTLIMIT 3
700#define WBUF_TIMEOUT_HARDLIMIT 5
701
702
703#define MAX_INUM 0xFFFFFFFF
704
705
706#define NONDATA_JHEADS_CNT 2
707
708
709#define GCHD UBIFS_GC_HEAD
710#define BASEHD UBIFS_BASE_HEAD
711#define DATAHD UBIFS_DATA_HEAD
712
713
714#define LPROPS_NC 0x80000001
715
716
717
718
719
720
721
722
723
724
725#define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT
726#define UBIFS_INVALID_KEY UBIFS_KEY_TYPES_CNT
727
728
729
730
731
732#define CALC_DENT_SIZE(name_len) ALIGN(UBIFS_DENT_NODE_SZ + (name_len) + 1, 8)
733
734
735#define CALC_XATTR_BYTES(data_len) ALIGN(UBIFS_INO_NODE_SZ + (data_len) + 1, 8)
736
737
738
739
740
741
742
743#define OLD_ZNODE_AGE 20
744#define YOUNG_ZNODE_AGE 5
745
746
747
748
749
750
751#define WORST_COMPR_FACTOR 2
752
753
754
755
756#define COMPRESSED_DATA_NODE_BUF_SZ \
757 (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR)
758
759
760#define BOTTOM_UP_HEIGHT 64
761
762
763#define UBIFS_MAX_BULK_READ 32
764
765
766
767
768enum {
769 WB_MUTEX_1 = 0,
770 WB_MUTEX_2 = 1,
771 WB_MUTEX_3 = 2,
772};
773
774
775
776
777
778
779
780
781
782
783
784enum {
785 DIRTY_ZNODE = 0,
786 COW_ZNODE = 1,
787 OBSOLETE_ZNODE = 2,
788};
789
790
791
792
793
794
795
796
797
798
799
800enum {
801 COMMIT_RESTING = 0,
802 COMMIT_BACKGROUND,
803 COMMIT_REQUIRED,
804 COMMIT_RUNNING_BACKGROUND,
805 COMMIT_RUNNING_REQUIRED,
806 COMMIT_BROKEN,
807};
808
809
810
811
812
813
814
815
816
817
818
819
820enum {
821 SCANNED_GARBAGE = 0,
822 SCANNED_EMPTY_SPACE = -1,
823 SCANNED_A_NODE = -2,
824 SCANNED_A_CORRUPT_NODE = -3,
825 SCANNED_A_BAD_PAD_NODE = -4,
826};
827
828
829
830
831
832
833
834
835
836enum {
837 DIRTY_CNODE = 0,
838 OBSOLETE_CNODE = 1,
839 COW_CNODE = 2,
840};
841
842
843
844
845
846
847
848enum {
849 LTAB_DIRTY = 1,
850 LSAVE_DIRTY = 2,
851};
852
853
854
855
856
857
858
859enum {
860 LEB_FREED,
861 LEB_FREED_IDX,
862 LEB_RETAINED,
863};
864
865
866
867
868
869
870
871struct ubifs_old_idx {
872 struct rb_node rb;
873 int lnum;
874 int offs;
875};
876
877
878union ubifs_key {
879 uint8_t u8[UBIFS_SK_LEN];
880 uint32_t u32[UBIFS_SK_LEN/4];
881 uint64_t u64[UBIFS_SK_LEN/8];
882 __le32 j32[UBIFS_SK_LEN/4];
883};
884
885
886
887
888
889
890
891
892
893
894
895struct ubifs_scan_node {
896 struct list_head list;
897 union ubifs_key key;
898 unsigned long long sqnum;
899 int type;
900 int offs;
901 int len;
902 void *node;
903};
904
905
906
907
908
909
910
911
912
913struct ubifs_scan_leb {
914 int lnum;
915 int nodes_cnt;
916 struct list_head nodes;
917 int endpt;
918 void *buf;
919};
920
921
922
923
924
925
926
927
928
929
930
931struct ubifs_gced_idx_leb {
932 struct list_head list;
933 int lnum;
934 int unmap;
935};
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994struct ubifs_inode {
995 struct inode vfs_inode;
996 unsigned long long creat_sqnum;
997 unsigned long long del_cmtno;
998 unsigned int xattr_size;
999 unsigned int xattr_cnt;
1000 unsigned int xattr_names;
1001 unsigned int dirty:1;
1002 unsigned int xattr:1;
1003 unsigned int bulk_read:1;
1004 unsigned int compr_type:2;
1005 struct mutex ui_mutex;
1006 spinlock_t ui_lock;
1007 loff_t synced_i_size;
1008 loff_t ui_size;
1009 int flags;
1010 pgoff_t last_page_read;
1011 pgoff_t read_in_a_row;
1012 int data_len;
1013 void *data;
1014};
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026struct ubifs_unclean_leb {
1027 struct list_head list;
1028 int lnum;
1029 int endpt;
1030};
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047enum {
1048 LPROPS_UNCAT = 0,
1049 LPROPS_DIRTY = 1,
1050 LPROPS_DIRTY_IDX = 2,
1051 LPROPS_FREE = 3,
1052 LPROPS_HEAP_CNT = 3,
1053 LPROPS_EMPTY = 4,
1054 LPROPS_FREEABLE = 5,
1055 LPROPS_FRDI_IDX = 6,
1056 LPROPS_CAT_MASK = 15,
1057 LPROPS_TAKEN = 16,
1058 LPROPS_INDEX = 32,
1059};
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070struct ubifs_lprops {
1071 int free;
1072 int dirty;
1073 int flags;
1074 int lnum;
1075 union {
1076 struct list_head list;
1077 int hpos;
1078 };
1079};
1080
1081
1082
1083
1084
1085
1086
1087
1088struct ubifs_lpt_lprops {
1089 int free;
1090 int dirty;
1091 unsigned tgc:1;
1092 unsigned cmt:1;
1093};
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121struct ubifs_lp_stats {
1122 int empty_lebs;
1123 int taken_empty_lebs;
1124 int idx_lebs;
1125 long long total_free;
1126 long long total_dirty;
1127 long long total_used;
1128 long long total_dead;
1129 long long total_dark;
1130};
1131
1132struct ubifs_nnode;
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143struct ubifs_cnode {
1144 struct ubifs_nnode *parent;
1145 struct ubifs_cnode *cnext;
1146 unsigned long flags;
1147 int iip;
1148 int level;
1149 int num;
1150};
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162struct ubifs_pnode {
1163 struct ubifs_nnode *parent;
1164 struct ubifs_cnode *cnext;
1165 unsigned long flags;
1166 int iip;
1167 int level;
1168 int num;
1169 struct ubifs_lprops lprops[UBIFS_LPT_FANOUT];
1170};
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180struct ubifs_nbranch {
1181 int lnum;
1182 int offs;
1183 union {
1184 struct ubifs_nnode *nnode;
1185 struct ubifs_pnode *pnode;
1186 struct ubifs_cnode *cnode;
1187 };
1188};
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200struct ubifs_nnode {
1201 struct ubifs_nnode *parent;
1202 struct ubifs_cnode *cnext;
1203 unsigned long flags;
1204 int iip;
1205 int level;
1206 int num;
1207 struct ubifs_nbranch nbranch[UBIFS_LPT_FANOUT];
1208};
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218struct ubifs_lpt_heap {
1219 struct ubifs_lprops **arr;
1220 int cnt;
1221 int max_cnt;
1222};
1223
1224
1225
1226
1227
1228
1229
1230
1231enum {
1232 LPT_SCAN_CONTINUE = 0,
1233 LPT_SCAN_ADD = 1,
1234 LPT_SCAN_STOP = 2,
1235};
1236
1237struct ubifs_info;
1238
1239
1240typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c,
1241 const struct ubifs_lprops *lprops,
1242 int in_tree, void *data);
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278struct ubifs_wbuf {
1279 struct ubifs_info *c;
1280 void *buf;
1281 int lnum;
1282 int offs;
1283 int avail;
1284 int used;
1285 int size;
1286 int jhead;
1287 int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad);
1288 struct mutex io_mutex;
1289 spinlock_t lock;
1290
1291
1292
1293 unsigned int no_timer:1;
1294 unsigned int need_sync:1;
1295 int next_ino;
1296 ino_t *inodes;
1297};
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307struct ubifs_bud {
1308 int lnum;
1309 int start;
1310 int jhead;
1311 struct list_head list;
1312 struct rb_node rb;
1313};
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323struct ubifs_jhead {
1324 struct ubifs_wbuf wbuf;
1325 struct list_head buds_list;
1326 unsigned int grouped:1;
1327};
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337struct ubifs_zbranch {
1338 union ubifs_key key;
1339 union {
1340 struct ubifs_znode *znode;
1341 void *leaf;
1342 };
1343 int lnum;
1344 int offs;
1345 int len;
1346};
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366struct ubifs_znode {
1367 struct ubifs_znode *parent;
1368 struct ubifs_znode *cnext;
1369 unsigned long flags;
1370 unsigned long time;
1371 int level;
1372 int child_cnt;
1373 int iip;
1374 int alt;
1375 int lnum;
1376 int offs;
1377 int len;
1378 struct ubifs_zbranch zbranch[];
1379};
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392struct bu_info {
1393 union ubifs_key key;
1394 struct ubifs_zbranch zbranch[UBIFS_MAX_BULK_READ];
1395 void *buf;
1396 int buf_len;
1397 int gc_seq;
1398 int cnt;
1399 int blk_cnt;
1400 int eof;
1401};
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411struct ubifs_node_range {
1412 union {
1413 int len;
1414 int min_len;
1415 };
1416 int max_len;
1417};
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428struct ubifs_compressor {
1429 int compr_type;
1430 struct crypto_comp *cc;
1431 struct mutex *comp_mutex;
1432 struct mutex *decomp_mutex;
1433 const char *name;
1434 const char *capi_name;
1435#ifdef __UBOOT__
1436 int (*decompress)(const unsigned char *in, size_t in_len,
1437 unsigned char *out, size_t *out_len);
1438#endif
1439};
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475struct ubifs_budget_req {
1476 unsigned int fast:1;
1477 unsigned int recalculate:1;
1478#ifndef UBIFS_DEBUG
1479 unsigned int new_page:1;
1480 unsigned int dirtied_page:1;
1481 unsigned int new_dent:1;
1482 unsigned int mod_dent:1;
1483 unsigned int new_ino:1;
1484 unsigned int new_ino_d:13;
1485 unsigned int dirtied_ino:4;
1486 unsigned int dirtied_ino_d:15;
1487#else
1488
1489 unsigned int new_page;
1490 unsigned int dirtied_page;
1491 unsigned int new_dent;
1492 unsigned int mod_dent;
1493 unsigned int new_ino;
1494 unsigned int new_ino_d;
1495 unsigned int dirtied_ino;
1496 unsigned int dirtied_ino_d;
1497#endif
1498 int idx_growth;
1499 int data_growth;
1500 int dd_growth;
1501};
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515struct ubifs_orphan {
1516 struct rb_node rb;
1517 struct list_head list;
1518 struct list_head new_list;
1519 struct ubifs_orphan *cnext;
1520 struct ubifs_orphan *dnext;
1521 ino_t inum;
1522 unsigned new:1;
1523 unsigned cmt:1;
1524 unsigned del:1;
1525};
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539struct ubifs_mount_opts {
1540 unsigned int unmount_mode:2;
1541 unsigned int bulk_read:2;
1542 unsigned int chk_data_crc:2;
1543 unsigned int override_compr:1;
1544 unsigned int compr_type:2;
1545};
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567struct ubifs_budg_info {
1568 long long idx_growth;
1569 long long data_growth;
1570 long long dd_growth;
1571 long long uncommitted_idx;
1572 unsigned long long old_idx_sz;
1573 int min_idx_lebs;
1574 unsigned int nospace:1;
1575 unsigned int nospace_rp:1;
1576 int page_budget;
1577 int inode_budget;
1578 int dent_budget;
1579};
1580
1581struct ubifs_debug_info;
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831struct ubifs_info {
1832 struct super_block *vfs_sb;
1833#ifndef __UBOOT__
1834 struct backing_dev_info bdi;
1835#endif
1836
1837 ino_t highest_inum;
1838 unsigned long long max_sqnum;
1839 unsigned long long cmt_no;
1840 spinlock_t cnt_lock;
1841 int fmt_version;
1842 int ro_compat_version;
1843 unsigned char uuid[16];
1844
1845 int lhead_lnum;
1846 int lhead_offs;
1847 int ltail_lnum;
1848 struct mutex log_mutex;
1849 int min_log_bytes;
1850 long long cmt_bud_bytes;
1851
1852 struct rb_root buds;
1853 long long bud_bytes;
1854 spinlock_t buds_lock;
1855 int jhead_cnt;
1856 struct ubifs_jhead *jheads;
1857 long long max_bud_bytes;
1858 long long bg_bud_bytes;
1859 struct list_head old_buds;
1860 int max_bud_cnt;
1861
1862 struct rw_semaphore commit_sem;
1863 int cmt_state;
1864 spinlock_t cs_lock;
1865 wait_queue_head_t cmt_wq;
1866
1867 unsigned int big_lpt:1;
1868 unsigned int space_fixup:1;
1869 unsigned int no_chk_data_crc:1;
1870 unsigned int bulk_read:1;
1871 unsigned int default_compr:2;
1872 unsigned int rw_incompat:1;
1873
1874 struct mutex tnc_mutex;
1875 struct ubifs_zbranch zroot;
1876 struct ubifs_znode *cnext;
1877 struct ubifs_znode *enext;
1878 int *gap_lebs;
1879 void *cbuf;
1880 void *ileb_buf;
1881 int ileb_len;
1882 int ihead_lnum;
1883 int ihead_offs;
1884 int *ilebs;
1885 int ileb_cnt;
1886 int ileb_nxt;
1887 struct rb_root old_idx;
1888 int *bottom_up_buf;
1889
1890 struct ubifs_mst_node *mst_node;
1891 int mst_offs;
1892
1893 int max_bu_buf_len;
1894 struct mutex bu_mutex;
1895 struct bu_info bu;
1896
1897 struct mutex write_reserve_mutex;
1898 void *write_reserve_buf;
1899
1900 int log_lebs;
1901 long long log_bytes;
1902 int log_last;
1903 int lpt_lebs;
1904 int lpt_first;
1905 int lpt_last;
1906 int orph_lebs;
1907 int orph_first;
1908 int orph_last;
1909 int main_lebs;
1910 int main_first;
1911 long long main_bytes;
1912
1913 uint8_t key_hash_type;
1914 uint32_t (*key_hash)(const char *str, int len);
1915 int key_fmt;
1916 int key_len;
1917 int fanout;
1918
1919 int min_io_size;
1920 int min_io_shift;
1921 int max_write_size;
1922 int max_write_shift;
1923 int leb_size;
1924 int leb_start;
1925 int half_leb_size;
1926 int idx_leb_size;
1927 int leb_cnt;
1928 int max_leb_cnt;
1929 int old_leb_cnt;
1930 unsigned int ro_media:1;
1931 unsigned int ro_mount:1;
1932 unsigned int ro_error:1;
1933
1934 atomic_long_t dirty_pg_cnt;
1935 atomic_long_t dirty_zn_cnt;
1936 atomic_long_t clean_zn_cnt;
1937
1938 spinlock_t space_lock;
1939 struct ubifs_lp_stats lst;
1940 struct ubifs_budg_info bi;
1941 unsigned long long calc_idx_sz;
1942
1943 int ref_node_alsz;
1944 int mst_node_alsz;
1945 int min_idx_node_sz;
1946 int max_idx_node_sz;
1947 long long max_inode_sz;
1948 int max_znode_sz;
1949
1950 int leb_overhead;
1951 int dead_wm;
1952 int dark_wm;
1953 int block_cnt;
1954
1955 struct ubifs_node_range ranges[UBIFS_NODE_TYPES_CNT];
1956 struct ubi_volume_desc *ubi;
1957 struct ubi_device_info di;
1958 struct ubi_volume_info vi;
1959
1960 struct rb_root orph_tree;
1961 struct list_head orph_list;
1962 struct list_head orph_new;
1963 struct ubifs_orphan *orph_cnext;
1964 struct ubifs_orphan *orph_dnext;
1965 spinlock_t orphan_lock;
1966 void *orph_buf;
1967 int new_orphans;
1968 int cmt_orphans;
1969 int tot_orphans;
1970 int max_orphans;
1971 int ohead_lnum;
1972 int ohead_offs;
1973 int no_orphs;
1974
1975 struct task_struct *bgt;
1976 char bgt_name[sizeof(BGT_NAME_PATTERN) + 9];
1977 int need_bgt;
1978 int need_wbuf_sync;
1979
1980 int gc_lnum;
1981 void *sbuf;
1982 struct list_head idx_gc;
1983 int idx_gc_cnt;
1984 int gc_seq;
1985 int gced_lnum;
1986
1987 struct list_head infos_list;
1988 struct mutex umount_mutex;
1989 unsigned int shrinker_run_no;
1990
1991 int space_bits;
1992 int lpt_lnum_bits;
1993 int lpt_offs_bits;
1994 int lpt_spc_bits;
1995 int pcnt_bits;
1996 int lnum_bits;
1997 int nnode_sz;
1998 int pnode_sz;
1999 int ltab_sz;
2000 int lsave_sz;
2001 int pnode_cnt;
2002 int nnode_cnt;
2003 int lpt_hght;
2004 int pnodes_have;
2005
2006 struct mutex lp_mutex;
2007 int lpt_lnum;
2008 int lpt_offs;
2009 int nhead_lnum;
2010 int nhead_offs;
2011 int lpt_drty_flgs;
2012 int dirty_nn_cnt;
2013 int dirty_pn_cnt;
2014 int check_lpt_free;
2015 long long lpt_sz;
2016 void *lpt_nod_buf;
2017 void *lpt_buf;
2018 struct ubifs_nnode *nroot;
2019 struct ubifs_cnode *lpt_cnext;
2020 struct ubifs_lpt_heap lpt_heap[LPROPS_HEAP_CNT];
2021 struct ubifs_lpt_heap dirty_idx;
2022 struct list_head uncat_list;
2023 struct list_head empty_list;
2024 struct list_head freeable_list;
2025 struct list_head frdi_idx_list;
2026 int freeable_cnt;
2027 int in_a_category_cnt;
2028
2029 int ltab_lnum;
2030 int ltab_offs;
2031 struct ubifs_lpt_lprops *ltab;
2032 struct ubifs_lpt_lprops *ltab_cmt;
2033 int lsave_cnt;
2034 int lsave_lnum;
2035 int lsave_offs;
2036 int *lsave;
2037 int lscan_lnum;
2038
2039 long long rp_size;
2040 long long report_rp_size;
2041 kuid_t rp_uid;
2042 kgid_t rp_gid;
2043
2044
2045 unsigned int empty:1;
2046 unsigned int need_recovery:1;
2047 unsigned int replaying:1;
2048 unsigned int mounting:1;
2049 unsigned int remounting_rw:1;
2050 unsigned int probing:1;
2051 struct list_head replay_list;
2052 struct list_head replay_buds;
2053 unsigned long long cs_sqnum;
2054 unsigned long long replay_sqnum;
2055 struct list_head unclean_leb_list;
2056 struct ubifs_mst_node *rcvrd_mst_node;
2057 struct rb_root size_tree;
2058 struct ubifs_mount_opts mount_opts;
2059
2060#ifndef __UBOOT__
2061 struct ubifs_debug_info *dbg;
2062#endif
2063};
2064
2065extern struct list_head ubifs_infos;
2066extern spinlock_t ubifs_infos_lock;
2067extern atomic_long_t ubifs_clean_zn_cnt;
2068extern struct kmem_cache *ubifs_inode_slab;
2069extern const struct super_operations ubifs_super_operations;
2070extern const struct xattr_handler *ubifs_xattr_handlers[];
2071extern const struct address_space_operations ubifs_file_address_operations;
2072extern const struct file_operations ubifs_file_operations;
2073extern const struct inode_operations ubifs_file_inode_operations;
2074extern const struct file_operations ubifs_dir_operations;
2075extern const struct inode_operations ubifs_dir_inode_operations;
2076extern const struct inode_operations ubifs_symlink_inode_operations;
2077extern struct backing_dev_info ubifs_backing_dev_info;
2078extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
2079
2080
2081void ubifs_ro_mode(struct ubifs_info *c, int err);
2082int ubifs_leb_read(const struct ubifs_info *c, int lnum, void *buf, int offs,
2083 int len, int even_ebadmsg);
2084int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
2085 int len);
2086int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len);
2087int ubifs_leb_unmap(struct ubifs_info *c, int lnum);
2088int ubifs_leb_map(struct ubifs_info *c, int lnum);
2089int ubifs_is_mapped(const struct ubifs_info *c, int lnum);
2090int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len);
2091int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs);
2092int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf);
2093int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
2094 int lnum, int offs);
2095int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
2096 int lnum, int offs);
2097int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,
2098 int offs);
2099int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,
2100 int offs, int quiet, int must_chk_crc);
2101void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
2102void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last);
2103int ubifs_io_init(struct ubifs_info *c);
2104void ubifs_pad(const struct ubifs_info *c, void *buf, int pad);
2105int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf);
2106int ubifs_bg_wbufs_sync(struct ubifs_info *c);
2107void ubifs_wbuf_add_ino_nolock(struct ubifs_wbuf *wbuf, ino_t inum);
2108int ubifs_sync_wbufs_by_inode(struct ubifs_info *c, struct inode *inode);
2109
2110
2111struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
2112 int offs, void *sbuf, int quiet);
2113void ubifs_scan_destroy(struct ubifs_scan_leb *sleb);
2114int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum,
2115 int offs, int quiet);
2116struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum,
2117 int offs, void *sbuf);
2118void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
2119 int lnum, int offs);
2120int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
2121 void *buf, int offs);
2122void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs,
2123 void *buf);
2124
2125
2126void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud);
2127void ubifs_create_buds_lists(struct ubifs_info *c);
2128int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs);
2129struct ubifs_bud *ubifs_search_bud(struct ubifs_info *c, int lnum);
2130struct ubifs_wbuf *ubifs_get_wbuf(struct ubifs_info *c, int lnum);
2131int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum);
2132int ubifs_log_end_commit(struct ubifs_info *c, int new_ltail_lnum);
2133int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum);
2134int ubifs_consolidate_log(struct ubifs_info *c);
2135
2136
2137int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
2138 const struct qstr *nm, const struct inode *inode,
2139 int deletion, int xent);
2140int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
2141 const union ubifs_key *key, const void *buf, int len);
2142int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode);
2143int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode);
2144int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
2145 const struct dentry *old_dentry,
2146 const struct inode *new_dir,
2147 const struct dentry *new_dentry, int sync);
2148int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
2149 loff_t old_size, loff_t new_size);
2150int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
2151 const struct inode *inode, const struct qstr *nm);
2152int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode1,
2153 const struct inode *inode2);
2154
2155
2156int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req);
2157void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req);
2158void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
2159 struct ubifs_inode *ui);
2160int ubifs_budget_inode_op(struct ubifs_info *c, struct inode *inode,
2161 struct ubifs_budget_req *req);
2162void ubifs_release_ino_dirty(struct ubifs_info *c, struct inode *inode,
2163 struct ubifs_budget_req *req);
2164void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode,
2165 struct ubifs_budget_req *req);
2166long long ubifs_get_free_space(struct ubifs_info *c);
2167long long ubifs_get_free_space_nolock(struct ubifs_info *c);
2168int ubifs_calc_min_idx_lebs(struct ubifs_info *c);
2169void ubifs_convert_page_budget(struct ubifs_info *c);
2170long long ubifs_reported_space(const struct ubifs_info *c, long long free);
2171long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs);
2172
2173
2174int ubifs_find_free_space(struct ubifs_info *c, int min_space, int *offs,
2175 int squeeze);
2176int ubifs_find_free_leb_for_idx(struct ubifs_info *c);
2177int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp,
2178 int min_space, int pick_free);
2179int ubifs_find_dirty_idx_leb(struct ubifs_info *c);
2180int ubifs_save_dirty_idx_lnums(struct ubifs_info *c);
2181
2182
2183int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
2184 struct ubifs_znode **zn, int *n);
2185int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key,
2186 void *node, const struct qstr *nm);
2187int ubifs_tnc_locate(struct ubifs_info *c, const union ubifs_key *key,
2188 void *node, int *lnum, int *offs);
2189int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum,
2190 int offs, int len);
2191int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key,
2192 int old_lnum, int old_offs, int lnum, int offs, int len);
2193int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key,
2194 int lnum, int offs, int len, const struct qstr *nm);
2195int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key);
2196int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key,
2197 const struct qstr *nm);
2198int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key,
2199 union ubifs_key *to_key);
2200int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum);
2201struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
2202 union ubifs_key *key,
2203 const struct qstr *nm);
2204void ubifs_tnc_close(struct ubifs_info *c);
2205int ubifs_tnc_has_node(struct ubifs_info *c, union ubifs_key *key, int level,
2206 int lnum, int offs, int is_idx);
2207int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level,
2208 int lnum, int offs);
2209
2210void destroy_old_idx(struct ubifs_info *c);
2211int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level,
2212 int lnum, int offs);
2213int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode);
2214int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu);
2215int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu);
2216
2217
2218struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr,
2219 struct ubifs_znode *znode);
2220int ubifs_search_zbranch(const struct ubifs_info *c,
2221 const struct ubifs_znode *znode,
2222 const union ubifs_key *key, int *n);
2223struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode);
2224struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode);
2225long ubifs_destroy_tnc_subtree(struct ubifs_znode *zr);
2226struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c,
2227 struct ubifs_zbranch *zbr,
2228 struct ubifs_znode *parent, int iip);
2229int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
2230 void *node);
2231
2232
2233int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot);
2234int ubifs_tnc_end_commit(struct ubifs_info *c);
2235
2236#ifndef __UBOOT__
2237
2238unsigned long ubifs_shrink_scan(struct shrinker *shrink,
2239 struct shrink_control *sc);
2240unsigned long ubifs_shrink_count(struct shrinker *shrink,
2241 struct shrink_control *sc);
2242#endif
2243
2244
2245int ubifs_bg_thread(void *info);
2246void ubifs_commit_required(struct ubifs_info *c);
2247void ubifs_request_bg_commit(struct ubifs_info *c);
2248int ubifs_run_commit(struct ubifs_info *c);
2249void ubifs_recovery_commit(struct ubifs_info *c);
2250int ubifs_gc_should_commit(struct ubifs_info *c);
2251void ubifs_wait_for_commit(struct ubifs_info *c);
2252
2253
2254int ubifs_read_master(struct ubifs_info *c);
2255int ubifs_write_master(struct ubifs_info *c);
2256
2257
2258int ubifs_read_superblock(struct ubifs_info *c);
2259struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c);
2260int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup);
2261int ubifs_fixup_free_space(struct ubifs_info *c);
2262
2263
2264int ubifs_validate_entry(struct ubifs_info *c,
2265 const struct ubifs_dent_node *dent);
2266int ubifs_replay_journal(struct ubifs_info *c);
2267
2268
2269int ubifs_garbage_collect(struct ubifs_info *c, int anyway);
2270int ubifs_gc_start_commit(struct ubifs_info *c);
2271int ubifs_gc_end_commit(struct ubifs_info *c);
2272void ubifs_destroy_idx_gc(struct ubifs_info *c);
2273int ubifs_get_idx_gc_leb(struct ubifs_info *c);
2274int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp);
2275
2276
2277int ubifs_add_orphan(struct ubifs_info *c, ino_t inum);
2278void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum);
2279int ubifs_orphan_start_commit(struct ubifs_info *c);
2280int ubifs_orphan_end_commit(struct ubifs_info *c);
2281int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only);
2282int ubifs_clear_orphans(struct ubifs_info *c);
2283
2284
2285int ubifs_calc_lpt_geom(struct ubifs_info *c);
2286int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
2287 int *lpt_lebs, int *big_lpt);
2288int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr);
2289struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum);
2290struct ubifs_lprops *ubifs_lpt_lookup_dirty(struct ubifs_info *c, int lnum);
2291int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
2292 ubifs_lpt_scan_callback scan_cb, void *data);
2293
2294
2295void ubifs_pack_lsave(struct ubifs_info *c, void *buf, int *lsave);
2296void ubifs_pack_ltab(struct ubifs_info *c, void *buf,
2297 struct ubifs_lpt_lprops *ltab);
2298void ubifs_pack_pnode(struct ubifs_info *c, void *buf,
2299 struct ubifs_pnode *pnode);
2300void ubifs_pack_nnode(struct ubifs_info *c, void *buf,
2301 struct ubifs_nnode *nnode);
2302struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c,
2303 struct ubifs_nnode *parent, int iip);
2304struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c,
2305 struct ubifs_nnode *parent, int iip);
2306int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip);
2307void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty);
2308void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode);
2309uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits);
2310struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght);
2311
2312int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf,
2313 struct ubifs_nnode *nnode);
2314
2315
2316int ubifs_lpt_start_commit(struct ubifs_info *c);
2317int ubifs_lpt_end_commit(struct ubifs_info *c);
2318int ubifs_lpt_post_commit(struct ubifs_info *c);
2319void ubifs_lpt_free(struct ubifs_info *c, int wr_only);
2320
2321
2322const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c,
2323 const struct ubifs_lprops *lp,
2324 int free, int dirty, int flags,
2325 int idx_gc_cnt);
2326void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst);
2327void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
2328 int cat);
2329void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops,
2330 struct ubifs_lprops *new_lprops);
2331void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops);
2332int ubifs_categorize_lprops(const struct ubifs_info *c,
2333 const struct ubifs_lprops *lprops);
2334int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
2335 int flags_set, int flags_clean, int idx_gc_cnt);
2336int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
2337 int flags_set, int flags_clean);
2338int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp);
2339const struct ubifs_lprops *ubifs_fast_find_free(struct ubifs_info *c);
2340const struct ubifs_lprops *ubifs_fast_find_empty(struct ubifs_info *c);
2341const struct ubifs_lprops *ubifs_fast_find_freeable(struct ubifs_info *c);
2342const struct ubifs_lprops *ubifs_fast_find_frdi_idx(struct ubifs_info *c);
2343int ubifs_calc_dark(const struct ubifs_info *c, int spc);
2344
2345
2346int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
2347int ubifs_setattr(struct dentry *dentry, struct iattr *attr);
2348
2349
2350struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
2351 umode_t mode);
2352int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
2353 struct kstat *stat);
2354
2355
2356int ubifs_setxattr(struct dentry *dentry, const char *name,
2357 const void *value, size_t size, int flags);
2358ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
2359 size_t size);
2360ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
2361int ubifs_removexattr(struct dentry *dentry, const char *name);
2362int ubifs_init_security(struct inode *dentry, struct inode *inode,
2363 const struct qstr *qstr);
2364
2365
2366struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
2367int ubifs_iput(struct inode *inode);
2368
2369
2370int ubifs_recover_master_node(struct ubifs_info *c);
2371int ubifs_write_rcvrd_mst_node(struct ubifs_info *c);
2372struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
2373 int offs, void *sbuf, int jhead);
2374struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum,
2375 int offs, void *sbuf);
2376int ubifs_recover_inl_heads(struct ubifs_info *c, void *sbuf);
2377int ubifs_clean_lebs(struct ubifs_info *c, void *sbuf);
2378int ubifs_rcvry_gc_commit(struct ubifs_info *c);
2379int ubifs_recover_size_accum(struct ubifs_info *c, union ubifs_key *key,
2380 int deletion, loff_t new_size);
2381int ubifs_recover_size(struct ubifs_info *c);
2382void ubifs_destroy_size_tree(struct ubifs_info *c);
2383
2384
2385long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2386void ubifs_set_inode_flags(struct inode *inode);
2387#ifdef CONFIG_COMPAT
2388long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2389#endif
2390
2391
2392int __init ubifs_compressors_init(void);
2393void ubifs_compressors_exit(void);
2394void ubifs_compress(const struct ubifs_info *c, const void *in_buf, int in_len,
2395 void *out_buf, int *out_len, int *compr_type);
2396int ubifs_decompress(const struct ubifs_info *c, const void *buf, int len,
2397 void *out, int *out_len, int compr_type);
2398
2399#include "debug.h"
2400#include "misc.h"
2401#include "key.h"
2402
2403#ifdef __UBOOT__
2404void ubifs_umount(struct ubifs_info *c);
2405#endif
2406#endif
2407