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