Skip to content

Commit e43fe68

Browse files
committed
Merge git://git.infradead.org/~dedekind/ubi-2.6
2 parents 986ee01 + 434b825 commit e43fe68

11 files changed

Lines changed: 260 additions & 64 deletions

File tree

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
What: /sys/class/ubi/
2+
Date: July 2006
3+
KernelVersion: 2.6.22
4+
Contact: Artem Bityutskiy <dedekind@infradead.org>
5+
Description:
6+
The ubi/ class sub-directory belongs to the UBI subsystem and
7+
provides general UBI information, per-UBI device information
8+
and per-UBI volume information.
9+
10+
What: /sys/class/ubi/version
11+
Date: July 2006
12+
KernelVersion: 2.6.22
13+
Contact: Artem Bityutskiy <dedekind@infradead.org>
14+
Description:
15+
This file contains version of the latest supported UBI on-media
16+
format. Currently it is 1, and there is no plan to change this.
17+
However, if in the future UBI needs on-flash format changes
18+
which cannot be done in a compatible manner, a new format
19+
version will be added. So this is a mechanism for possible
20+
future backward-compatible (but forward-incompatible)
21+
improvements.
22+
23+
What: /sys/class/ubiX/
24+
Date: July 2006
25+
KernelVersion: 2.6.22
26+
Contact: Artem Bityutskiy <dedekind@infradead.org>
27+
Description:
28+
The /sys/class/ubi0, /sys/class/ubi1, etc directories describe
29+
UBI devices (UBI device 0, 1, etc). They contain general UBI
30+
device information and per UBI volume information (each UBI
31+
device may have many UBI volumes)
32+
33+
What: /sys/class/ubi/ubiX/avail_eraseblocks
34+
Date: July 2006
35+
KernelVersion: 2.6.22
36+
Contact: Artem Bityutskiy <dedekind@infradead.org>
37+
Description:
38+
Amount of available logical eraseblock. For example, one may
39+
create a new UBI volume which has this amount of logical
40+
eraseblocks.
41+
42+
What: /sys/class/ubi/ubiX/bad_peb_count
43+
Date: July 2006
44+
KernelVersion: 2.6.22
45+
Contact: Artem Bityutskiy <dedekind@infradead.org>
46+
Description:
47+
Count of bad physical eraseblocks on the underlying MTD device.
48+
49+
What: /sys/class/ubi/ubiX/bgt_enabled
50+
Date: July 2006
51+
KernelVersion: 2.6.22
52+
Contact: Artem Bityutskiy <dedekind@infradead.org>
53+
Description:
54+
Contains ASCII "0\n" if the UBI background thread is disabled,
55+
and ASCII "1\n" if it is enabled.
56+
57+
What: /sys/class/ubi/ubiX/dev
58+
Date: July 2006
59+
KernelVersion: 2.6.22
60+
Contact: Artem Bityutskiy <dedekind@infradead.org>
61+
Description:
62+
Major and minor numbers of the character device corresponding
63+
to this UBI device (in <major>:<minor> format).
64+
65+
What: /sys/class/ubi/ubiX/eraseblock_size
66+
Date: July 2006
67+
KernelVersion: 2.6.22
68+
Contact: Artem Bityutskiy <dedekind@infradead.org>
69+
Description:
70+
Maximum logical eraseblock size this UBI device may provide. UBI
71+
volumes may have smaller logical eraseblock size because of their
72+
alignment.
73+
74+
What: /sys/class/ubi/ubiX/max_ec
75+
Date: July 2006
76+
KernelVersion: 2.6.22
77+
Contact: Artem Bityutskiy <dedekind@infradead.org>
78+
Description:
79+
Maximum physical eraseblock erase counter value.
80+
81+
What: /sys/class/ubi/ubiX/max_vol_count
82+
Date: July 2006
83+
KernelVersion: 2.6.22
84+
Contact: Artem Bityutskiy <dedekind@infradead.org>
85+
Description:
86+
Maximum number of volumes which this UBI device may have.
87+
88+
What: /sys/class/ubi/ubiX/min_io_size
89+
Date: July 2006
90+
KernelVersion: 2.6.22
91+
Contact: Artem Bityutskiy <dedekind@infradead.org>
92+
Description:
93+
Minimum input/output unit size. All the I/O may only be done
94+
in fractions of the contained number.
95+
96+
What: /sys/class/ubi/ubiX/mtd_num
97+
Date: January 2008
98+
KernelVersion: 2.6.25
99+
Contact: Artem Bityutskiy <dedekind@infradead.org>
100+
Description:
101+
Number of the underlying MTD device.
102+
103+
What: /sys/class/ubi/ubiX/reserved_for_bad
104+
Date: July 2006
105+
KernelVersion: 2.6.22
106+
Contact: Artem Bityutskiy <dedekind@infradead.org>
107+
Description:
108+
Number of physical eraseblocks reserved for bad block handling.
109+
110+
What: /sys/class/ubi/ubiX/total_eraseblocks
111+
Date: July 2006
112+
KernelVersion: 2.6.22
113+
Contact: Artem Bityutskiy <dedekind@infradead.org>
114+
Description:
115+
Total number of good (not marked as bad) physical eraseblocks on
116+
the underlying MTD device.
117+
118+
What: /sys/class/ubi/ubiX/volumes_count
119+
Date: July 2006
120+
KernelVersion: 2.6.22
121+
Contact: Artem Bityutskiy <dedekind@infradead.org>
122+
Description:
123+
Count of volumes on this UBI device.
124+
125+
What: /sys/class/ubi/ubiX/ubiX_Y/
126+
Date: July 2006
127+
KernelVersion: 2.6.22
128+
Contact: Artem Bityutskiy <dedekind@infradead.org>
129+
Description:
130+
The /sys/class/ubi/ubiX/ubiX_0/, /sys/class/ubi/ubiX/ubiX_1/,
131+
etc directories describe UBI volumes on UBI device X (volumes
132+
0, 1, etc).
133+
134+
What: /sys/class/ubi/ubiX/ubiX_Y/alignment
135+
Date: July 2006
136+
KernelVersion: 2.6.22
137+
Contact: Artem Bityutskiy <dedekind@infradead.org>
138+
Description:
139+
Volume alignment - the value the logical eraseblock size of
140+
this volume has to be aligned on. For example, 2048 means that
141+
logical eraseblock size is multiple of 2048. In other words,
142+
volume logical eraseblock size is UBI device logical eraseblock
143+
size aligned to the alignment value.
144+
145+
What: /sys/class/ubi/ubiX/ubiX_Y/corrupted
146+
Date: July 2006
147+
KernelVersion: 2.6.22
148+
Contact: Artem Bityutskiy <dedekind@infradead.org>
149+
Description:
150+
Contains ASCII "0\n" if the UBI volume is OK, and ASCII "1\n"
151+
if it is corrupted (e.g., due to an interrupted volume update).
152+
153+
What: /sys/class/ubi/ubiX/ubiX_Y/data_bytes
154+
Date: July 2006
155+
KernelVersion: 2.6.22
156+
Contact: Artem Bityutskiy <dedekind@infradead.org>
157+
Description:
158+
The amount of data this volume contains. This value makes sense
159+
only for static volumes, and for dynamic volume it equivalent
160+
to the total volume size in bytes.
161+
162+
What: /sys/class/ubi/ubiX/ubiX_Y/dev
163+
Date: July 2006
164+
KernelVersion: 2.6.22
165+
Contact: Artem Bityutskiy <dedekind@infradead.org>
166+
Description:
167+
Major and minor numbers of the character device corresponding
168+
to this UBI volume (in <major>:<minor> format).
169+
170+
What: /sys/class/ubi/ubiX/ubiX_Y/name
171+
Date: July 2006
172+
KernelVersion: 2.6.22
173+
Contact: Artem Bityutskiy <dedekind@infradead.org>
174+
Description:
175+
Volume name.
176+
177+
What: /sys/class/ubi/ubiX/ubiX_Y/reserved_ebs
178+
Date: July 2006
179+
KernelVersion: 2.6.22
180+
Contact: Artem Bityutskiy <dedekind@infradead.org>
181+
Description:
182+
Count of physical eraseblock reserved for this volume.
183+
Equivalent to the volume size in logical eraseblocks.
184+
185+
What: /sys/class/ubi/ubiX/ubiX_Y/type
186+
Date: July 2006
187+
KernelVersion: 2.6.22
188+
Contact: Artem Bityutskiy <dedekind@infradead.org>
189+
Description:
190+
Volume type. Contains ASCII "dynamic\n" for dynamic volumes and
191+
"static\n" for static volumes.
192+
193+
What: /sys/class/ubi/ubiX/ubiX_Y/upd_marker
194+
Date: July 2006
195+
KernelVersion: 2.6.22
196+
Contact: Artem Bityutskiy <dedekind@infradead.org>
197+
Description:
198+
Contains ASCII "0\n" if the update marker is not set for this
199+
volume, and "1\n" if it is set. The update marker is set when
200+
volume update starts, and cleaned when it ends. So the presence
201+
of the update marker indicates that the volume is being updated
202+
at the moment of the update was interrupted. The later may be
203+
checked using the "corrupted" sysfs file.
204+
205+
What: /sys/class/ubi/ubiX/ubiX_Y/usable_eb_size
206+
Date: July 2006
207+
KernelVersion: 2.6.22
208+
Contact: Artem Bityutskiy <dedekind@infradead.org>
209+
Description:
210+
Logical eraseblock size of this volume. Equivalent to logical
211+
eraseblock size of the device aligned on the volume alignment
212+
value.

‎drivers/mtd/ubi/Kconfig‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ config MTD_UBI_WL_THRESHOLD
2424
erase counter value and the lowest erase counter value of eraseblocks
2525
of UBI devices. When this threshold is exceeded, UBI starts performing
2626
wear leveling by means of moving data from eraseblock with low erase
27-
counter to eraseblocks with high erase counter. Leave the default
28-
value if unsure.
27+
counter to eraseblocks with high erase counter.
28+
29+
The default value should be OK for SLC NAND flashes, NOR flashes and
30+
other flashes which have eraseblock life-cycle 100000 or more.
31+
However, in case of MLC NAND flashes which typically have eraseblock
32+
life-cycle less then 10000, the threshold should be lessened (e.g.,
33+
to 128 or 256, although it does not have to be power of 2).
2934

3035
config MTD_UBI_BEB_RESERVE
3136
int "Percentage of reserved eraseblocks for bad eraseblocks handling"

‎drivers/mtd/ubi/build.c‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,16 @@ static int io_init(struct ubi_device *ubi)
606606
ubi->ro_mode = 1;
607607
}
608608

609-
dbg_msg("leb_size %d", ubi->leb_size);
610-
dbg_msg("ro_mode %d", ubi->ro_mode);
609+
ubi_msg("physical eraseblock size: %d bytes (%d KiB)",
610+
ubi->peb_size, ubi->peb_size >> 10);
611+
ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size);
612+
ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size);
613+
if (ubi->hdrs_min_io_size != ubi->min_io_size)
614+
ubi_msg("sub-page size: %d",
615+
ubi->hdrs_min_io_size);
616+
ubi_msg("VID header offset: %d (aligned %d)",
617+
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset);
618+
ubi_msg("data offset: %d", ubi->leb_start);
611619

612620
/*
613621
* Note, ideally, we have to initialize ubi->bad_peb_count here. But
@@ -804,15 +812,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
804812
ubi_msg("attached mtd%d to ubi%d", mtd->index, ubi_num);
805813
ubi_msg("MTD device name: \"%s\"", mtd->name);
806814
ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20);
807-
ubi_msg("physical eraseblock size: %d bytes (%d KiB)",
808-
ubi->peb_size, ubi->peb_size >> 10);
809-
ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size);
810815
ubi_msg("number of good PEBs: %d", ubi->good_peb_count);
811816
ubi_msg("number of bad PEBs: %d", ubi->bad_peb_count);
812-
ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size);
813-
ubi_msg("VID header offset: %d (aligned %d)",
814-
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset);
815-
ubi_msg("data offset: %d", ubi->leb_start);
816817
ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots);
817818
ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD);
818819
ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT);
@@ -950,34 +951,33 @@ static int __init ubi_init(void)
950951
BUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);
951952

952953
if (mtd_devs > UBI_MAX_DEVICES) {
953-
printk(KERN_ERR "UBI error: too many MTD devices, "
954-
"maximum is %d\n", UBI_MAX_DEVICES);
954+
ubi_err("too many MTD devices, maximum is %d", UBI_MAX_DEVICES);
955955
return -EINVAL;
956956
}
957957

958958
/* Create base sysfs directory and sysfs files */
959959
ubi_class = class_create(THIS_MODULE, UBI_NAME_STR);
960960
if (IS_ERR(ubi_class)) {
961961
err = PTR_ERR(ubi_class);
962-
printk(KERN_ERR "UBI error: cannot create UBI class\n");
962+
ubi_err("cannot create UBI class");
963963
goto out;
964964
}
965965

966966
err = class_create_file(ubi_class, &ubi_version);
967967
if (err) {
968-
printk(KERN_ERR "UBI error: cannot create sysfs file\n");
968+
ubi_err("cannot create sysfs file");
969969
goto out_class;
970970
}
971971

972972
err = misc_register(&ubi_ctrl_cdev);
973973
if (err) {
974-
printk(KERN_ERR "UBI error: cannot register device\n");
974+
ubi_err("cannot register device");
975975
goto out_version;
976976
}
977977

978978
ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab",
979-
sizeof(struct ubi_wl_entry),
980-
0, 0, NULL);
979+
sizeof(struct ubi_wl_entry),
980+
0, 0, NULL);
981981
if (!ubi_wl_entry_slab)
982982
goto out_dev_unreg;
983983

@@ -1000,8 +1000,7 @@ static int __init ubi_init(void)
10001000
mutex_unlock(&ubi_devices_mutex);
10011001
if (err < 0) {
10021002
put_mtd_device(mtd);
1003-
printk(KERN_ERR "UBI error: cannot attach mtd%d\n",
1004-
mtd->index);
1003+
ubi_err("cannot attach mtd%d", mtd->index);
10051004
goto out_detach;
10061005
}
10071006
}
@@ -1023,7 +1022,7 @@ static int __init ubi_init(void)
10231022
out_class:
10241023
class_destroy(ubi_class);
10251024
out:
1026-
printk(KERN_ERR "UBI error: cannot initialize UBI, error %d\n", err);
1025+
ubi_err("UBI error: cannot initialize UBI, error %d", err);
10271026
return err;
10281027
}
10291028
module_init(ubi_init);

‎drivers/mtd/ubi/debug.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
9999
#ifdef CONFIG_MTD_UBI_DEBUG_MSG_BLD
100100
/* Initialization and build messages */
101101
#define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
102+
#define UBI_IO_DEBUG 1
102103
#else
103104
#define dbg_bld(fmt, ...) ({})
105+
#define UBI_IO_DEBUG 0
104106
#endif
105107

106108
#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS

‎drivers/mtd/ubi/gluebi.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,12 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
291291
/*
292292
* In case of dynamic volume, MTD device size is just volume size. In
293293
* case of a static volume the size is equivalent to the amount of data
294-
* bytes, which is zero at this moment and will be changed after volume
295-
* update.
294+
* bytes.
296295
*/
297296
if (vol->vol_type == UBI_DYNAMIC_VOLUME)
298297
mtd->size = vol->usable_leb_size * vol->reserved_pebs;
298+
else
299+
mtd->size = vol->used_bytes;
299300

300301
if (add_mtd_device(mtd)) {
301302
ubi_err("cannot not add MTD device\n");

‎drivers/mtd/ubi/io.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
631631

632632
dbg_io("read EC header from PEB %d", pnum);
633633
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
634+
if (UBI_IO_DEBUG)
635+
verbose = 1;
634636

635637
err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
636638
if (err) {
@@ -904,6 +906,8 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
904906

905907
dbg_io("read VID header from PEB %d", pnum);
906908
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
909+
if (UBI_IO_DEBUG)
910+
verbose = 1;
907911

908912
p = (char *)vid_hdr - ubi->vid_hdr_shift;
909913
err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,

0 commit comments

Comments
 (0)