aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/ubifs.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ubifs/ubifs.h')
-rw-r--r--fs/ubifs/ubifs.h85
1 files changed, 69 insertions, 16 deletions
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 17c620b93eec..a7bd32fa15b9 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -142,6 +142,9 @@
142/* Maximum expected tree height for use by bottom_up_buf */ 142/* Maximum expected tree height for use by bottom_up_buf */
143#define BOTTOM_UP_HEIGHT 64 143#define BOTTOM_UP_HEIGHT 64
144 144
145/* Maximum number of data nodes to bulk-read */
146#define UBIFS_MAX_BULK_READ 32
147
145/* 148/*
146 * Lockdep classes for UBIFS inode @ui_mutex. 149 * Lockdep classes for UBIFS inode @ui_mutex.
147 */ 150 */
@@ -328,9 +331,10 @@ struct ubifs_gced_idx_leb {
328 * this inode 331 * this inode
329 * @dirty: non-zero if the inode is dirty 332 * @dirty: non-zero if the inode is dirty
330 * @xattr: non-zero if this is an extended attribute inode 333 * @xattr: non-zero if this is an extended attribute inode
334 * @bulk_read: non-zero if bulk-read should be used
331 * @ui_mutex: serializes inode write-back with the rest of VFS operations, 335 * @ui_mutex: serializes inode write-back with the rest of VFS operations,
332 * serializes "clean <-> dirty" state changes, protects @dirty, 336 * serializes "clean <-> dirty" state changes, serializes bulk-read,
333 * @ui_size, and @xattr_size 337 * protects @dirty, @bulk_read, @ui_size, and @xattr_size
334 * @ui_lock: protects @synced_i_size 338 * @ui_lock: protects @synced_i_size
335 * @synced_i_size: synchronized size of inode, i.e. the value of inode size 339 * @synced_i_size: synchronized size of inode, i.e. the value of inode size
336 * currently stored on the flash; used only for regular file 340 * currently stored on the flash; used only for regular file
@@ -338,6 +342,8 @@ struct ubifs_gced_idx_leb {
338 * @ui_size: inode size used by UBIFS when writing to flash 342 * @ui_size: inode size used by UBIFS when writing to flash
339 * @flags: inode flags (@UBIFS_COMPR_FL, etc) 343 * @flags: inode flags (@UBIFS_COMPR_FL, etc)
340 * @compr_type: default compression type used for this inode 344 * @compr_type: default compression type used for this inode
345 * @last_page_read: page number of last page read (for bulk read)
346 * @read_in_a_row: number of consecutive pages read in a row (for bulk read)
341 * @data_len: length of the data attached to the inode 347 * @data_len: length of the data attached to the inode
342 * @data: inode's data 348 * @data: inode's data
343 * 349 *
@@ -379,12 +385,15 @@ struct ubifs_inode {
379 unsigned int xattr_names; 385 unsigned int xattr_names;
380 unsigned int dirty:1; 386 unsigned int dirty:1;
381 unsigned int xattr:1; 387 unsigned int xattr:1;
388 unsigned int bulk_read:1;
382 struct mutex ui_mutex; 389 struct mutex ui_mutex;
383 spinlock_t ui_lock; 390 spinlock_t ui_lock;
384 loff_t synced_i_size; 391 loff_t synced_i_size;
385 loff_t ui_size; 392 loff_t ui_size;
386 int flags; 393 int flags;
387 int compr_type; 394 int compr_type;
395 pgoff_t last_page_read;
396 pgoff_t read_in_a_row;
388 int data_len; 397 int data_len;
389 void *data; 398 void *data;
390}; 399};
@@ -698,8 +707,8 @@ struct ubifs_jhead {
698 * struct ubifs_zbranch - key/coordinate/length branch stored in znodes. 707 * struct ubifs_zbranch - key/coordinate/length branch stored in znodes.
699 * @key: key 708 * @key: key
700 * @znode: znode address in memory 709 * @znode: znode address in memory
701 * @lnum: LEB number of the indexing node 710 * @lnum: LEB number of the target node (indexing node or data node)
702 * @offs: offset of the indexing node within @lnum 711 * @offs: target node offset within @lnum
703 * @len: target node length 712 * @len: target node length
704 */ 713 */
705struct ubifs_zbranch { 714struct ubifs_zbranch {
@@ -744,6 +753,28 @@ struct ubifs_znode {
744}; 753};
745 754
746/** 755/**
756 * struct bu_info - bulk-read information
757 * @key: first data node key
758 * @zbranch: zbranches of data nodes to bulk read
759 * @buf: buffer to read into
760 * @buf_len: buffer length
761 * @gc_seq: GC sequence number to detect races with GC
762 * @cnt: number of data nodes for bulk read
763 * @blk_cnt: number of data blocks including holes
764 * @oef: end of file reached
765 */
766struct bu_info {
767 union ubifs_key key;
768 struct ubifs_zbranch zbranch[UBIFS_MAX_BULK_READ];
769 void *buf;
770 int buf_len;
771 int gc_seq;
772 int cnt;
773 int blk_cnt;
774 int eof;
775};
776
777/**
747 * struct ubifs_node_range - node length range description data structure. 778 * struct ubifs_node_range - node length range description data structure.
748 * @len: fixed node length 779 * @len: fixed node length
749 * @min_len: minimum possible node length 780 * @min_len: minimum possible node length
@@ -862,9 +893,13 @@ struct ubifs_orphan {
862/** 893/**
863 * struct ubifs_mount_opts - UBIFS-specific mount options information. 894 * struct ubifs_mount_opts - UBIFS-specific mount options information.
864 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) 895 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast)
896 * @bulk_read: enable bulk-reads
897 * @chk_data_crc: check CRCs when reading data nodes
865 */ 898 */
866struct ubifs_mount_opts { 899struct ubifs_mount_opts {
867 unsigned int unmount_mode:2; 900 unsigned int unmount_mode:2;
901 unsigned int bulk_read:2;
902 unsigned int chk_data_crc:2;
868}; 903};
869 904
870/** 905/**
@@ -905,13 +940,12 @@ struct ubifs_mount_opts {
905 * @cmt_state: commit state 940 * @cmt_state: commit state
906 * @cs_lock: commit state lock 941 * @cs_lock: commit state lock
907 * @cmt_wq: wait queue to sleep on if the log is full and a commit is running 942 * @cmt_wq: wait queue to sleep on if the log is full and a commit is running
943 *
908 * @fast_unmount: do not run journal commit before un-mounting 944 * @fast_unmount: do not run journal commit before un-mounting
909 * @big_lpt: flag that LPT is too big to write whole during commit 945 * @big_lpt: flag that LPT is too big to write whole during commit
910 * @check_lpt_free: flag that indicates LPT GC may be needed 946 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during
911 * @nospace: non-zero if the file-system does not have flash space (used as 947 * recovery)
912 * optimization) 948 * @bulk_read: enable bulk-reads
913 * @nospace_rp: the same as @nospace, but additionally means that even reserved
914 * pool is full
915 * 949 *
916 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and 950 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and
917 * @calc_idx_sz 951 * @calc_idx_sz
@@ -935,6 +969,7 @@ struct ubifs_mount_opts {
935 * @mst_node: master node 969 * @mst_node: master node
936 * @mst_offs: offset of valid master node 970 * @mst_offs: offset of valid master node
937 * @mst_mutex: protects the master node area, @mst_node, and @mst_offs 971 * @mst_mutex: protects the master node area, @mst_node, and @mst_offs
972 * @bulk_read_buf_size: buffer size for bulk-reads
938 * 973 *
939 * @log_lebs: number of logical eraseblocks in the log 974 * @log_lebs: number of logical eraseblocks in the log
940 * @log_bytes: log size in bytes 975 * @log_bytes: log size in bytes
@@ -977,12 +1012,17 @@ struct ubifs_mount_opts {
977 * but which still have to be taken into account because 1012 * but which still have to be taken into account because
978 * the index has not been committed so far 1013 * the index has not been committed so far
979 * @space_lock: protects @budg_idx_growth, @budg_data_growth, @budg_dd_growth, 1014 * @space_lock: protects @budg_idx_growth, @budg_data_growth, @budg_dd_growth,
980 * @budg_uncommited_idx, @min_idx_lebs, @old_idx_sz, and @lst; 1015 * @budg_uncommited_idx, @min_idx_lebs, @old_idx_sz, @lst,
1016 * @nospace, and @nospace_rp;
981 * @min_idx_lebs: minimum number of LEBs required for the index 1017 * @min_idx_lebs: minimum number of LEBs required for the index
982 * @old_idx_sz: size of index on flash 1018 * @old_idx_sz: size of index on flash
983 * @calc_idx_sz: temporary variable which is used to calculate new index size 1019 * @calc_idx_sz: temporary variable which is used to calculate new index size
984 * (contains accurate new index size at end of TNC commit start) 1020 * (contains accurate new index size at end of TNC commit start)
985 * @lst: lprops statistics 1021 * @lst: lprops statistics
1022 * @nospace: non-zero if the file-system does not have flash space (used as
1023 * optimization)
1024 * @nospace_rp: the same as @nospace, but additionally means that even reserved
1025 * pool is full
986 * 1026 *
987 * @page_budget: budget for a page 1027 * @page_budget: budget for a page
988 * @inode_budget: budget for an inode 1028 * @inode_budget: budget for an inode
@@ -1061,6 +1101,7 @@ struct ubifs_mount_opts {
1061 * @lpt_drty_flgs: dirty flags for LPT special nodes e.g. ltab 1101 * @lpt_drty_flgs: dirty flags for LPT special nodes e.g. ltab
1062 * @dirty_nn_cnt: number of dirty nnodes 1102 * @dirty_nn_cnt: number of dirty nnodes
1063 * @dirty_pn_cnt: number of dirty pnodes 1103 * @dirty_pn_cnt: number of dirty pnodes
1104 * @check_lpt_free: flag that indicates LPT GC may be needed
1064 * @lpt_sz: LPT size 1105 * @lpt_sz: LPT size
1065 * @lpt_nod_buf: buffer for an on-flash nnode or pnode 1106 * @lpt_nod_buf: buffer for an on-flash nnode or pnode
1066 * @lpt_buf: buffer of LEB size used by LPT 1107 * @lpt_buf: buffer of LEB size used by LPT
@@ -1102,6 +1143,7 @@ struct ubifs_mount_opts {
1102 * @rcvrd_mst_node: recovered master node to write when mounting ro to rw 1143 * @rcvrd_mst_node: recovered master node to write when mounting ro to rw
1103 * @size_tree: inode size information for recovery 1144 * @size_tree: inode size information for recovery
1104 * @remounting_rw: set while remounting from ro to rw (sb flags have MS_RDONLY) 1145 * @remounting_rw: set while remounting from ro to rw (sb flags have MS_RDONLY)
1146 * @always_chk_crc: always check CRCs (while mounting and remounting rw)
1105 * @mount_opts: UBIFS-specific mount options 1147 * @mount_opts: UBIFS-specific mount options
1106 * 1148 *
1107 * @dbg_buf: a buffer of LEB size used for debugging purposes 1149 * @dbg_buf: a buffer of LEB size used for debugging purposes
@@ -1146,11 +1188,11 @@ struct ubifs_info {
1146 int cmt_state; 1188 int cmt_state;
1147 spinlock_t cs_lock; 1189 spinlock_t cs_lock;
1148 wait_queue_head_t cmt_wq; 1190 wait_queue_head_t cmt_wq;
1191
1149 unsigned int fast_unmount:1; 1192 unsigned int fast_unmount:1;
1150 unsigned int big_lpt:1; 1193 unsigned int big_lpt:1;
1151 unsigned int check_lpt_free:1; 1194 unsigned int no_chk_data_crc:1;
1152 unsigned int nospace:1; 1195 unsigned int bulk_read:1;
1153 unsigned int nospace_rp:1;
1154 1196
1155 struct mutex tnc_mutex; 1197 struct mutex tnc_mutex;
1156 struct ubifs_zbranch zroot; 1198 struct ubifs_zbranch zroot;
@@ -1175,6 +1217,7 @@ struct ubifs_info {
1175 struct ubifs_mst_node *mst_node; 1217 struct ubifs_mst_node *mst_node;
1176 int mst_offs; 1218 int mst_offs;
1177 struct mutex mst_mutex; 1219 struct mutex mst_mutex;
1220 int bulk_read_buf_size;
1178 1221
1179 int log_lebs; 1222 int log_lebs;
1180 long long log_bytes; 1223 long long log_bytes;
@@ -1218,6 +1261,8 @@ struct ubifs_info {
1218 unsigned long long old_idx_sz; 1261 unsigned long long old_idx_sz;
1219 unsigned long long calc_idx_sz; 1262 unsigned long long calc_idx_sz;
1220 struct ubifs_lp_stats lst; 1263 struct ubifs_lp_stats lst;
1264 unsigned int nospace:1;
1265 unsigned int nospace_rp:1;
1221 1266
1222 int page_budget; 1267 int page_budget;
1223 int inode_budget; 1268 int inode_budget;
@@ -1294,6 +1339,7 @@ struct ubifs_info {
1294 int lpt_drty_flgs; 1339 int lpt_drty_flgs;
1295 int dirty_nn_cnt; 1340 int dirty_nn_cnt;
1296 int dirty_pn_cnt; 1341 int dirty_pn_cnt;
1342 int check_lpt_free;
1297 long long lpt_sz; 1343 long long lpt_sz;
1298 void *lpt_nod_buf; 1344 void *lpt_nod_buf;
1299 void *lpt_buf; 1345 void *lpt_buf;
@@ -1335,6 +1381,7 @@ struct ubifs_info {
1335 struct ubifs_mst_node *rcvrd_mst_node; 1381 struct ubifs_mst_node *rcvrd_mst_node;
1336 struct rb_root size_tree; 1382 struct rb_root size_tree;
1337 int remounting_rw; 1383 int remounting_rw;
1384 int always_chk_crc;
1338 struct ubifs_mount_opts mount_opts; 1385 struct ubifs_mount_opts mount_opts;
1339 1386
1340#ifdef CONFIG_UBIFS_FS_DEBUG 1387#ifdef CONFIG_UBIFS_FS_DEBUG
@@ -1347,6 +1394,12 @@ struct ubifs_info {
1347 unsigned long fail_timeout; 1394 unsigned long fail_timeout;
1348 unsigned int fail_cnt; 1395 unsigned int fail_cnt;
1349 unsigned int fail_cnt_max; 1396 unsigned int fail_cnt_max;
1397 long long chk_lpt_sz;
1398 long long chk_lpt_sz2;
1399 long long chk_lpt_wastage;
1400 int chk_lpt_lebs;
1401 int new_nhead_lnum;
1402 int new_nhead_offs;
1350#endif 1403#endif
1351}; 1404};
1352 1405
@@ -1377,7 +1430,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
1377int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum, 1430int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,
1378 int offs, int dtype); 1431 int offs, int dtype);
1379int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, 1432int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,
1380 int offs, int quiet); 1433 int offs, int quiet, int chk_crc);
1381void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad); 1434void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
1382void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last); 1435void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last);
1383int ubifs_io_init(struct ubifs_info *c); 1436int ubifs_io_init(struct ubifs_info *c);
@@ -1490,6 +1543,8 @@ void destroy_old_idx(struct ubifs_info *c);
1490int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, 1543int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level,
1491 int lnum, int offs); 1544 int lnum, int offs);
1492int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode); 1545int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode);
1546int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu);
1547int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu);
1493 1548
1494/* tnc_misc.c */ 1549/* tnc_misc.c */
1495struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, 1550struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr,
@@ -1586,12 +1641,10 @@ int ubifs_lpt_post_commit(struct ubifs_info *c);
1586void ubifs_lpt_free(struct ubifs_info *c, int wr_only); 1641void ubifs_lpt_free(struct ubifs_info *c, int wr_only);
1587 1642
1588/* lprops.c */ 1643/* lprops.c */
1589void ubifs_get_lprops(struct ubifs_info *c);
1590const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, 1644const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c,
1591 const struct ubifs_lprops *lp, 1645 const struct ubifs_lprops *lp,
1592 int free, int dirty, int flags, 1646 int free, int dirty, int flags,
1593 int idx_gc_cnt); 1647 int idx_gc_cnt);
1594void ubifs_release_lprops(struct ubifs_info *c);
1595void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats); 1648void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats);
1596void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, 1649void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
1597 int cat); 1650 int cat);