Lines Matching +full:nand +full:- +full:rb

1 /* SPDX-License-Identifier: GPL-2.0+ */
34 #include "ubi-media.h"
35 #include <mtd/ubi-user.h>
48 ubi->ubi_num, ##__VA_ARGS__)
53 ubi->ubi_num, __func__, ##__VA_ARGS__)
56 ubi->ubi_num, __func__, ##__VA_ARGS__)
62 * This marker in the EBA table means that the LEB is um-mapped.
65 #define UBI_LEB_UNMAPPED -1
69 * returning error. The below constant defines how many times UBI re-tries.
75 * number of (global) erase cycles PEBs are protected from the wear-leveling
81 #define UBI_UNKNOWN -1
91 * Error codes returned by the I/O sub-system.
96 * (uncorrectable ECC error in case of NAND)
100 * (uncorrectable ECC error in case of NAND)
101 * UBI_IO_BITFLIPS: bit-flips were detected and corrected
103 * Note, it is probably better to have bit-flip and ebadmsg as flags which can
126 * MOVE_TARGET_BITFLIPS: canceled because a bit-flip was detected in the
140 * Return codes of the fastmap sub-system
162 * struct ubi_wl_entry - wear-leveling entry.
163 * @u.rb: link in the corresponding (free/used) RB-tree
168 * This data structure is used in the WL sub-system. Each physical eraseblock
170 * RB-trees. See WL sub-system for details.
174 struct rb_node rb; member
182 * struct ubi_ltree_entry - an entry in the lock tree.
183 * @rb: links RB-tree nodes
190 * This data structure is used in the EBA sub-system to implement per-LEB
191 * locking. When a logical eraseblock is being locked - corresponding
192 * &struct ubi_ltree_entry object is inserted to the lock tree (@ubi->ltree).
193 * See EBA sub-system for details.
196 struct rb_node rb; member
204 * struct ubi_rename_entry - volume re-name description data structure.
207 * @remove: if not zero, this volume should be removed, not re-named
209 * @list: links re-name entries into a list
211 * This data structure is utilized in the multiple volume re-name code. Namely,
227 * struct ubi_fastmap_layout - in-memory fastmap data structure.
229 * @to_be_tortured: if non-zero tortured this PEB
232 * @max_wl_pool_size: maximal size of the pool used by the WL sub-system
243 * struct ubi_fm_pool - in-memory fastmap pool
262 * struct ubi_volume - UBI volume description data structure.
268 * @readers: number of users holding this volume in read-only mode
269 * @writers: number of users holding this volume in read-write mode
295 * @eba_tbl: EBA table of this volume (LEB->PEB mapping)
305 * dynamic volumes - it is user's responsibility to assure their data
353 * struct ubi_volume_desc - UBI volume descriptor returned when it is opened.
366 * struct ubi_debug_info - debugging information for an UBI device.
372 * @emulate_bitflips: emulate bit-flips for testing purposes
384 * @dfs_emulate_bitflips: debugfs knob to emulate bit-flips
415 * struct ubi_device - UBI device description structure
424 * @vol->readers, @vol->writers, @vol->exclusive,
425 * @vol->metaonly, @vol->ref_count, @vol->mapping and
426 * @vol->eba_tbl.
436 * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end
440 * @vtbl: in-RAM volume table copy
441 * @device_mutex: protects on-flash volume table and serializes volume
442 * creation, deletion, update, re-size, re-name and set
453 * @fm_disabled: non-zero if fastmap is disabled (default)
454 * @fm: in-memory data structure of the currently used fastmap
455 * @fm_pool: in-memory data structure of the fastmap pool
456 * @fm_wl_pool: in-memory data structure of the fastmap pool used by the WL
457 * sub-system
464 * @fm_work_scheduled: non-zero if fastmap work was scheduled
466 * @used: RB-tree of used physical eraseblocks
467 * @erroneous: RB-tree of erroneous used physical eraseblocks
468 * @free: RB-tree of free physical eraseblocks
470 * @scrub: RB-tree of physical eraseblocks which need scrubbing
472 * protected from the wear-leveling worker)
481 * @wl_scheduled: non-zero if the wear-leveling was scheduled
505 * @ro_mode: if the UBI device is in read-only mode
515 * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset
518 * @nor_flash: non-zero if working on top of NOR flash
553 /* Note, mean_ec is not updated run-time - should be fixed */
556 /* EBA sub-system's stuff */
576 /* Wear-leveling sub-system's stuff */
598 /* I/O sub-system's stuff */
630 * struct ubi_ainf_peb - attach information about a physical eraseblock.
638 * @u: unions RB-tree or @list links
639 * @u.rb: link in the per-volume RB-tree of &struct ubi_ainf_peb objects
655 struct rb_node rb; member
661 * struct ubi_ainf_volume - attaching information about a volume.
674 * @rb: link in the volume RB-tree
675 * @root: root of the RB-tree containing all the eraseblock belonging to this
690 struct rb_node rb; member
695 * struct ubi_attach_info - MTD device attaching information.
696 * @volumes: root of the volume RB-tree
701 * those belonging to "preserve"-compatible internal volumes)
721 * be used by other UBI sub-systems to build final UBI data structures, further
722 * error-recovery and so on.
748 * struct ubi_work - UBI work description data structure.
759 * WL sub-system is shutting down.
942 return -ENOSYS; in ubiblock_create()
946 return -ENOSYS; in ubiblock_remove()
951 * ubi_for_each_free_peb - walk the UBI free RB tree.
954 * @pos: a pointer to RB-tree entry type to use as a loop counter
957 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->free, u.rb)
960 * ubi_for_each_used_peb - walk the UBI used RB tree.
963 * @pos: a pointer to RB-tree entry type to use as a loop counter
966 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->used, u.rb)
969 * ubi_for_each_scub_peb - walk the UBI scub RB tree.
972 * @pos: a pointer to RB-tree entry type to use as a loop counter
975 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->scrub, u.rb)
978 * ubi_for_each_protected_peb - walk the UBI protection queue.
985 list_for_each_entry((e), &(ubi->pq[(i)]), u.list)
988 * ubi_rb_for_each_entry - walk an RB-tree.
989 * @rb: a pointer to type 'struct rb_node' to use as a loop counter
990 * @pos: a pointer to RB-tree entry type to use as a loop counter
991 * @root: RB-tree's root
992 * @member: the name of the 'struct rb_node' within the RB-tree entry
994 #define ubi_rb_for_each_entry(rb, pos, root, member) \ argument
995 for (rb = rb_first(root), \
996 pos = (rb ? container_of(rb, typeof(*pos), member) : NULL); \
997 rb; \
998 rb = rb_next(rb), \
999 pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))
1002 * ubi_move_aeb_to_list - move a PEB from the volume tree to a list.
1012 rb_erase(&aeb->u.rb, &av->root); in ubi_move_aeb_to_list()
1013 list_add_tail(&aeb->u.list, list); in ubi_move_aeb_to_list()
1017 * ubi_zalloc_vid_hdr - allocate a volume identifier header object.
1021 * This function returns a pointer to the newly allocated and zero-filled
1030 vid_hdr = kzalloc(ubi->vid_hdr_alsize, gfp_flags); in ubi_zalloc_vid_hdr()
1035 * VID headers may be stored at un-aligned flash offsets, so we shift in ubi_zalloc_vid_hdr()
1038 return vid_hdr + ubi->vid_hdr_shift; in ubi_zalloc_vid_hdr()
1042 * ubi_free_vid_hdr - free a volume identifier header object.
1054 kfree(p - ubi->vid_hdr_shift); in ubi_free_vid_hdr()
1066 return ubi_io_read(ubi, buf, pnum, offset + ubi->leb_start, len); in ubi_io_read_data()
1078 return ubi_io_write(ubi, buf, pnum, offset + ubi->leb_start, len); in ubi_io_write_data()
1082 * ubi_ro_mode - switch to read-only mode.
1087 if (!ubi->ro_mode) { in ubi_ro_mode()
1088 ubi->ro_mode = 1; in ubi_ro_mode()
1089 ubi_warn(ubi, "switch to read-only mode"); in ubi_ro_mode()
1095 * vol_id2idx - get table index by volume ID.
1102 return vol_id - UBI_INTERNAL_VOL_START + ubi->vtbl_slots; in vol_id2idx()
1108 * idx2vol_id - get volume ID by table index.
1114 if (idx >= ubi->vtbl_slots) in idx2vol_id()
1115 return idx - ubi->vtbl_slots + UBI_INTERNAL_VOL_START; in idx2vol_id()