aboutsummaryrefslogtreecommitdiffstats
path: root/include/mtd/ubi-header.h
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-16 08:44:24 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-25 09:41:24 -0500
commit4ccf8cffa963c7b5bdc6d455ea9417084ee49aa8 (patch)
treea7281874dc9298b3d7eca2d1e4cb22c326625382 /include/mtd/ubi-header.h
parent896c0c06aa30147630e9a75949b6ae2014c841fc (diff)
UBI: add auto-resize feature
The problem: NAND flashes have different amount of initial bad physical eraseblocks (marked as bad by the manufacturer). For example, for 256MiB Samsung OneNAND flash there might be from 0 to 40 bad initial eraseblocks, which is about 2%. When UBI is used as the base system, one needs to know the exact amount of good physical eraseblocks, because this number is needed to create the UBI image which is put to the devices during production. But this number is not know, which forces us to use the minimum number of good physical eraseblocks. And UBI additionally reserves some percentage of physical eraseblocks for bad block handling (default is 1%), so we have 1-3% of PEBs reserved at the end, depending on the amount of initial bad PEBs. But it is desired to always have 1% (or more, depending on the configuration). Solution: this patch adds an "auto-resize" flag to the volume table. The volume which has the "auto-resize" flag will automatically be re-sized (enlarged) on the first UBI initialization. UBI clears the flag when the volume is re-sized. Only one volume may have the "auto-resize" flag. So, the production UBI image may have one volume with "auto-resize" flag set, and its size is automatically adjusted on the first boot of the device. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include/mtd/ubi-header.h')
-rw-r--r--include/mtd/ubi-header.h43
1 files changed, 41 insertions, 2 deletions
diff --git a/include/mtd/ubi-header.h b/include/mtd/ubi-header.h
index 74efa7763479..69d5d7e22899 100644
--- a/include/mtd/ubi-header.h
+++ b/include/mtd/ubi-header.h
@@ -58,6 +58,43 @@ enum {
58}; 58};
59 59
60/* 60/*
61 * Volume flags used in the volume table record.
62 *
63 * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
64 *
65 * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
66 * table. UBI automatically re-sizes the volume which has this flag and makes
67 * the volume to be of largest possible size. This means that if after the
68 * initialization UBI finds out that there are available physical eraseblocks
69 * present on the device, it automatically appends all of them to the volume
70 * (the physical eraseblocks reserved for bad eraseblocks handling and other
71 * reserved physical eraseblocks are not taken). So, if there is a volume with
72 * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical
73 * eraseblocks will be zero after UBI is loaded, because all of them will be
74 * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
75 * after the volume had been initialized.
76 *
77 * The auto-resize feature is useful for device production purposes. For
78 * example, different NAND flash chips may have different amount of initial bad
79 * eraseblocks, depending of particular chip instance. Manufacturers of NAND
80 * chips usually guarantee that the amount of initial bad eraseblocks does not
81 * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
82 * flashed to the end devices in production, he does not know the exact amount
83 * of good physical eraseblocks the NAND chip on the device will have, but this
84 * number is required to calculate the volume sized and put them to the volume
85 * table of the UBI image. In this case, one of the volumes (e.g., the one
86 * which will store the root file system) is marked as "auto-resizable", and
87 * UBI will adjust its size on the first boot if needed.
88 *
89 * Note, first UBI reserves some amount of physical eraseblocks for bad
90 * eraseblock handling, and then re-sizes the volume, not vice-versa. This
91 * means that the pool of reserved physical eraseblocks will always be present.
92 */
93enum {
94 UBI_VTBL_AUTORESIZE_FLG = 0x01,
95};
96
97/*
61 * Compatibility constants used by internal volumes. 98 * Compatibility constants used by internal volumes.
62 * 99 *
63 * @UBI_COMPAT_DELETE: delete this internal volume before anything is written 100 * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
@@ -289,7 +326,8 @@ struct ubi_vid_hdr {
289 * @upd_marker: if volume update was started but not finished 326 * @upd_marker: if volume update was started but not finished
290 * @name_len: volume name length 327 * @name_len: volume name length
291 * @name: the volume name 328 * @name: the volume name
292 * @padding2: reserved, zeroes 329 * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
330 * @padding: reserved, zeroes
293 * @crc: a CRC32 checksum of the record 331 * @crc: a CRC32 checksum of the record
294 * 332 *
295 * The volume table records are stored in the volume table, which is stored in 333 * The volume table records are stored in the volume table, which is stored in
@@ -324,7 +362,8 @@ struct ubi_vtbl_record {
324 __u8 upd_marker; 362 __u8 upd_marker;
325 __be16 name_len; 363 __be16 name_len;
326 __u8 name[UBI_VOL_NAME_MAX+1]; 364 __u8 name[UBI_VOL_NAME_MAX+1];
327 __u8 padding2[24]; 365 __u8 flags;
366 __u8 padding[23];
328 __be32 crc; 367 __be32 crc;
329} __attribute__ ((packed)); 368} __attribute__ ((packed));
330 369