Lines Matching +full:ubi +full:- +full:volume +full:-

1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
10 * This file defines the layout of UBI headers and all the other UBI on-flash
19 /* The version of UBI images supported by this implementation */
28 /* Erase counter header magic number (ASCII "UBI#") */
30 /* Volume identifier header magic number (ASCII "UBI!") */
34 * Volume type constants used in the volume identifier header.
36 * @UBI_VID_DYNAMIC: dynamic volume
37 * @UBI_VID_STATIC: static volume
45 * Volume flags used in the volume table record.
47 * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
48 * @UBI_VTBL_SKIP_CRC_CHECK_FLG: skip the CRC check done on a static volume at
51 * check. Main use-case for this flag is
52 * boot-time reduction
54 * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
55 * table. UBI automatically re-sizes the volume which has this flag and makes
56 * the volume to be of largest possible size. This means that if after the
57 * initialization UBI finds out that there are available physical eraseblocks
58 * present on the device, it automatically appends all of them to the volume
60 * reserved physical eraseblocks are not taken). So, if there is a volume with
62 * eraseblocks will be zero after UBI is loaded, because all of them will be
63 * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
64 * after the volume had been initialized.
66 * The auto-resize feature is useful for device production purposes. For
70 * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
73 * number is required to calculate the volume sized and put them to the volume
74 * table of the UBI image. In this case, one of the volumes (e.g., the one
75 * which will store the root file system) is marked as "auto-resizable", and
76 * UBI will adjust its size on the first boot if needed.
78 * Note, first UBI reserves some amount of physical eraseblocks for bad
79 * eraseblock handling, and then re-sizes the volume, not vice-versa. This
90 * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
92 * @UBI_COMPAT_RO: attach this device in read-only mode
93 * @UBI_COMPAT_PRESERVE: preserve this internal volume - do not touch its
94 * physical eraseblocks, don't allow the wear-leveling
95 * sub-system to move them
96 * @UBI_COMPAT_REJECT: reject this UBI image
105 /* Sizes of UBI headers */
109 /* Sizes of UBI headers without the ending CRC */
110 #define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32))
111 #define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32))
114 * struct ubi_ec_hdr - UBI erase counter header.
116 * @version: version of UBI implementation which is supposed to accept this
117 * UBI image
128 * indicate the version of UBI implementation which is supposed to be able to
129 * work with this UBI image. If @version is greater than the current UBI
131 * is changed radically. This field is duplicated in the volume identifier
135 * volume identifier header and user data, relative to the beginning of the
139 * The @image_seq field is used to validate a UBI image that has been prepared
140 * for a UBI device. The @image_seq value can be any value, but it must be the
141 * same on all eraseblocks. UBI will ensure that all new erase counter headers
145 * complete, UBI will detect the error when attaching the media.
151 __be64 ec; /* Warning: the current limit is 31-bit anyway! */
160 * struct ubi_vid_hdr - on-flash UBI volume identifier header.
161 * @magic: volume identifier header magic number (%UBI_VID_HDR_MAGIC)
162 * @version: UBI implementation version which is supposed to accept this UBI
164 * @vol_type: volume type (%UBI_VID_DYNAMIC or %UBI_VID_STATIC)
166 * eraseblock (for wear-leveling reasons)
167 * @compat: compatibility of this volume (%0, %UBI_COMPAT_DELETE,
169 * @vol_id: ID of this volume
173 * @used_ebs: total number of used logical eraseblocks in this volume
180 * @hdr_crc: volume identifier header CRC checksum
184 * UBI writes a new VID header to the flash, i.e. when it maps a logical
186 * unsigned 64-bit integer and we assume it never overflows. The @sqnum
192 * and @lnum values in the volume identifier header. Suppose we have a logical
195 * 1. Because UBI may erase physical eraseblocks asynchronously, the following
198 * so P1 is written to, then an unclean reboot happens. Result - there are 2
200 * L. But P1 has greater sequence number, so UBI picks P1 when it attaches the
203 * 2. From time to time UBI moves logical eraseblocks to other physical
204 * eraseblocks for wear-leveling reasons. If, for example, UBI moves L from P
206 * are two physical eraseblocks P and P1 corresponding to L and UBI has to
218 * UBI uses the @copy_flag field to indicate that this logical eraseblock is a
219 * copy. UBI also calculates data CRC when the data is moved and stores it at
220 * the @data_crc field of the copy (P1). So when UBI needs to pick one physical
227 * There are 2 sorts of volumes in UBI: user volumes and internal volumes.
229 * UBI purposes. In this implementation there is only one internal volume - the
230 * layout volume. Internal volumes are the main mechanism of UBI extensions.
231 * For example, in future one may introduce a journal internal volume. Internal
236 * provides a mechanism to introduce UBI extensions and to be still compatible
237 * with older UBI binaries. For example, if someone introduced a journal in
239 * journal volume. And in this case, older UBI binaries, which know nothing
240 * about the journal volume, would just delete this volume and work perfectly
242 * - it just ignores the Ext3fs journal.
245 * eraseblock if this is a static volume. In case of dynamic volumes, it does
247 * data of the physical eraseblock was moved by the wear-leveling sub-system,
248 * then the wear-leveling sub-system calculates the data CRC and stores it in
251 * The @data_size field is used only for static volumes because UBI has to know
255 * wear-leveling reasons. In this case, UBI calculates CRC checksum of the
260 * eraseblocks the data of the volume takes. For dynamic volumes this field is
265 * eraseblocks of this volume. This is very handy when one uses block-oriented
266 * software (say, cramfs) on top of the UBI volume.
287 /* Internal UBI volumes count */
294 #define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
296 /* The layout volume contains the volume table */
302 #define UBI_LAYOUT_VOLUME_NAME "layout volume"
305 /* The maximum number of volumes per one UBI device */
308 /* The maximum volume name length */
311 /* Size of the volume table record */
314 /* Size of the volume table record without the ending CRC */
315 #define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
318 * struct ubi_vtbl_record - a record in the volume table.
319 * @reserved_pebs: how many physical eraseblocks are reserved for this volume
320 * @alignment: volume alignment
323 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
324 * @upd_marker: if volume update was started but not finished
325 * @name_len: volume name length
326 * @name: the volume name
327 * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
331 * The volume table records are stored in the volume table, which is stored in
332 * the layout volume. The layout volume consists of 2 logical eraseblock, each
333 * of which contains a copy of the volume table (i.e., the volume table is
334 * duplicated). The volume table is an array of &struct ubi_vtbl_record
335 * objects indexed by the volume ID.
338 * %UBI_MAX_VOLUMES records, the volume table contains %UBI_MAX_VOLUMES
342 * The @upd_marker flag is used to implement volume update. It is set to %1
344 * interrupted, UBI knows that the volume is corrupted.
346 * The @alignment field is specified when the volume is created and cannot be
347 * later changed. It may be useful, for example, when a block-oriented file
348 * system works on top of UBI. The @data_pad field is calculated using the
368 /* UBI fastmap on-flash data structures */
373 /* fastmap on-flash data structure format version */
397 * struct ubi_fm_sb - UBI fastmap super block
420 * struct ubi_fm_hdr - header of the fastmap data set
427 * @vol_count: number of UBI volumes known by this fastmap
443 * struct ubi_fm_scan_pool - Fastmap pool PEBs to be scanned while attaching
460 * struct ubi_fm_ec - stores the erase counter of a PEB
470 * struct ubi_fm_volhdr - Fastmap volume header
472 * @magic: Fastmap volume header magic number (%UBI_FM_VHDR_MAGIC)
473 * @vol_id: volume id of the fastmapped volume
474 * @vol_type: type of the fastmapped volume
475 * @data_pad: data_pad value of the fastmapped volume
476 * @used_ebs: number of used LEBs within this volume
493 * struct ubi_fm_eba - denotes an association between a PEB and LEB