Merge git://git.infradead.org/~dedekind/ubi-2.6
This commit is contained in:
commit
e43fe686e4
11 changed files with 260 additions and 64 deletions
212
Documentation/ABI/stable/sysfs-class-ubi
Normal file
212
Documentation/ABI/stable/sysfs-class-ubi
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
What: /sys/class/ubi/
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
The ubi/ class sub-directory belongs to the UBI subsystem and
|
||||||
|
provides general UBI information, per-UBI device information
|
||||||
|
and per-UBI volume information.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/version
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
This file contains version of the latest supported UBI on-media
|
||||||
|
format. Currently it is 1, and there is no plan to change this.
|
||||||
|
However, if in the future UBI needs on-flash format changes
|
||||||
|
which cannot be done in a compatible manner, a new format
|
||||||
|
version will be added. So this is a mechanism for possible
|
||||||
|
future backward-compatible (but forward-incompatible)
|
||||||
|
improvements.
|
||||||
|
|
||||||
|
What: /sys/class/ubiX/
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
The /sys/class/ubi0, /sys/class/ubi1, etc directories describe
|
||||||
|
UBI devices (UBI device 0, 1, etc). They contain general UBI
|
||||||
|
device information and per UBI volume information (each UBI
|
||||||
|
device may have many UBI volumes)
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/avail_eraseblocks
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Amount of available logical eraseblock. For example, one may
|
||||||
|
create a new UBI volume which has this amount of logical
|
||||||
|
eraseblocks.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/bad_peb_count
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Count of bad physical eraseblocks on the underlying MTD device.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/bgt_enabled
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Contains ASCII "0\n" if the UBI background thread is disabled,
|
||||||
|
and ASCII "1\n" if it is enabled.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/dev
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Major and minor numbers of the character device corresponding
|
||||||
|
to this UBI device (in <major>:<minor> format).
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/eraseblock_size
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Maximum logical eraseblock size this UBI device may provide. UBI
|
||||||
|
volumes may have smaller logical eraseblock size because of their
|
||||||
|
alignment.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/max_ec
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Maximum physical eraseblock erase counter value.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/max_vol_count
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Maximum number of volumes which this UBI device may have.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/min_io_size
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Minimum input/output unit size. All the I/O may only be done
|
||||||
|
in fractions of the contained number.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/mtd_num
|
||||||
|
Date: January 2008
|
||||||
|
KernelVersion: 2.6.25
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Number of the underlying MTD device.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/reserved_for_bad
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Number of physical eraseblocks reserved for bad block handling.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/total_eraseblocks
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Total number of good (not marked as bad) physical eraseblocks on
|
||||||
|
the underlying MTD device.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/volumes_count
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Count of volumes on this UBI device.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
The /sys/class/ubi/ubiX/ubiX_0/, /sys/class/ubi/ubiX/ubiX_1/,
|
||||||
|
etc directories describe UBI volumes on UBI device X (volumes
|
||||||
|
0, 1, etc).
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/alignment
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Volume alignment - the value the logical eraseblock size of
|
||||||
|
this volume has to be aligned on. For example, 2048 means that
|
||||||
|
logical eraseblock size is multiple of 2048. In other words,
|
||||||
|
volume logical eraseblock size is UBI device logical eraseblock
|
||||||
|
size aligned to the alignment value.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/corrupted
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Contains ASCII "0\n" if the UBI volume is OK, and ASCII "1\n"
|
||||||
|
if it is corrupted (e.g., due to an interrupted volume update).
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/data_bytes
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
The amount of data this volume contains. This value makes sense
|
||||||
|
only for static volumes, and for dynamic volume it equivalent
|
||||||
|
to the total volume size in bytes.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/dev
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Major and minor numbers of the character device corresponding
|
||||||
|
to this UBI volume (in <major>:<minor> format).
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/name
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Volume name.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/reserved_ebs
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Count of physical eraseblock reserved for this volume.
|
||||||
|
Equivalent to the volume size in logical eraseblocks.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/type
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Volume type. Contains ASCII "dynamic\n" for dynamic volumes and
|
||||||
|
"static\n" for static volumes.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/upd_marker
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Contains ASCII "0\n" if the update marker is not set for this
|
||||||
|
volume, and "1\n" if it is set. The update marker is set when
|
||||||
|
volume update starts, and cleaned when it ends. So the presence
|
||||||
|
of the update marker indicates that the volume is being updated
|
||||||
|
at the moment of the update was interrupted. The later may be
|
||||||
|
checked using the "corrupted" sysfs file.
|
||||||
|
|
||||||
|
What: /sys/class/ubi/ubiX/ubiX_Y/usable_eb_size
|
||||||
|
Date: July 2006
|
||||||
|
KernelVersion: 2.6.22
|
||||||
|
Contact: Artem Bityutskiy <dedekind@infradead.org>
|
||||||
|
Description:
|
||||||
|
Logical eraseblock size of this volume. Equivalent to logical
|
||||||
|
eraseblock size of the device aligned on the volume alignment
|
||||||
|
value.
|
|
@ -24,8 +24,13 @@ config MTD_UBI_WL_THRESHOLD
|
||||||
erase counter value and the lowest erase counter value of eraseblocks
|
erase counter value and the lowest erase counter value of eraseblocks
|
||||||
of UBI devices. When this threshold is exceeded, UBI starts performing
|
of UBI devices. When this threshold is exceeded, UBI starts performing
|
||||||
wear leveling by means of moving data from eraseblock with low erase
|
wear leveling by means of moving data from eraseblock with low erase
|
||||||
counter to eraseblocks with high erase counter. Leave the default
|
counter to eraseblocks with high erase counter.
|
||||||
value if unsure.
|
|
||||||
|
The default value should be OK for SLC NAND flashes, NOR flashes and
|
||||||
|
other flashes which have eraseblock life-cycle 100000 or more.
|
||||||
|
However, in case of MLC NAND flashes which typically have eraseblock
|
||||||
|
life-cycle less then 10000, the threshold should be lessened (e.g.,
|
||||||
|
to 128 or 256, although it does not have to be power of 2).
|
||||||
|
|
||||||
config MTD_UBI_BEB_RESERVE
|
config MTD_UBI_BEB_RESERVE
|
||||||
int "Percentage of reserved eraseblocks for bad eraseblocks handling"
|
int "Percentage of reserved eraseblocks for bad eraseblocks handling"
|
||||||
|
|
|
@ -606,8 +606,16 @@ static int io_init(struct ubi_device *ubi)
|
||||||
ubi->ro_mode = 1;
|
ubi->ro_mode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_msg("leb_size %d", ubi->leb_size);
|
ubi_msg("physical eraseblock size: %d bytes (%d KiB)",
|
||||||
dbg_msg("ro_mode %d", ubi->ro_mode);
|
ubi->peb_size, ubi->peb_size >> 10);
|
||||||
|
ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size);
|
||||||
|
ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size);
|
||||||
|
if (ubi->hdrs_min_io_size != ubi->min_io_size)
|
||||||
|
ubi_msg("sub-page size: %d",
|
||||||
|
ubi->hdrs_min_io_size);
|
||||||
|
ubi_msg("VID header offset: %d (aligned %d)",
|
||||||
|
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset);
|
||||||
|
ubi_msg("data offset: %d", ubi->leb_start);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note, ideally, we have to initialize ubi->bad_peb_count here. But
|
* 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)
|
||||||
ubi_msg("attached mtd%d to ubi%d", mtd->index, ubi_num);
|
ubi_msg("attached mtd%d to ubi%d", mtd->index, ubi_num);
|
||||||
ubi_msg("MTD device name: \"%s\"", mtd->name);
|
ubi_msg("MTD device name: \"%s\"", mtd->name);
|
||||||
ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20);
|
ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20);
|
||||||
ubi_msg("physical eraseblock size: %d bytes (%d KiB)",
|
|
||||||
ubi->peb_size, ubi->peb_size >> 10);
|
|
||||||
ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size);
|
|
||||||
ubi_msg("number of good PEBs: %d", ubi->good_peb_count);
|
ubi_msg("number of good PEBs: %d", ubi->good_peb_count);
|
||||||
ubi_msg("number of bad PEBs: %d", ubi->bad_peb_count);
|
ubi_msg("number of bad PEBs: %d", ubi->bad_peb_count);
|
||||||
ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size);
|
|
||||||
ubi_msg("VID header offset: %d (aligned %d)",
|
|
||||||
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset);
|
|
||||||
ubi_msg("data offset: %d", ubi->leb_start);
|
|
||||||
ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots);
|
ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots);
|
||||||
ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD);
|
ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD);
|
||||||
ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT);
|
ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT);
|
||||||
|
@ -950,8 +951,7 @@ static int __init ubi_init(void)
|
||||||
BUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);
|
BUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);
|
||||||
|
|
||||||
if (mtd_devs > UBI_MAX_DEVICES) {
|
if (mtd_devs > UBI_MAX_DEVICES) {
|
||||||
printk(KERN_ERR "UBI error: too many MTD devices, "
|
ubi_err("too many MTD devices, maximum is %d", UBI_MAX_DEVICES);
|
||||||
"maximum is %d\n", UBI_MAX_DEVICES);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,25 +959,25 @@ static int __init ubi_init(void)
|
||||||
ubi_class = class_create(THIS_MODULE, UBI_NAME_STR);
|
ubi_class = class_create(THIS_MODULE, UBI_NAME_STR);
|
||||||
if (IS_ERR(ubi_class)) {
|
if (IS_ERR(ubi_class)) {
|
||||||
err = PTR_ERR(ubi_class);
|
err = PTR_ERR(ubi_class);
|
||||||
printk(KERN_ERR "UBI error: cannot create UBI class\n");
|
ubi_err("cannot create UBI class");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = class_create_file(ubi_class, &ubi_version);
|
err = class_create_file(ubi_class, &ubi_version);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "UBI error: cannot create sysfs file\n");
|
ubi_err("cannot create sysfs file");
|
||||||
goto out_class;
|
goto out_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = misc_register(&ubi_ctrl_cdev);
|
err = misc_register(&ubi_ctrl_cdev);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "UBI error: cannot register device\n");
|
ubi_err("cannot register device");
|
||||||
goto out_version;
|
goto out_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab",
|
ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab",
|
||||||
sizeof(struct ubi_wl_entry),
|
sizeof(struct ubi_wl_entry),
|
||||||
0, 0, NULL);
|
0, 0, NULL);
|
||||||
if (!ubi_wl_entry_slab)
|
if (!ubi_wl_entry_slab)
|
||||||
goto out_dev_unreg;
|
goto out_dev_unreg;
|
||||||
|
|
||||||
|
@ -1000,8 +1000,7 @@ static int __init ubi_init(void)
|
||||||
mutex_unlock(&ubi_devices_mutex);
|
mutex_unlock(&ubi_devices_mutex);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
put_mtd_device(mtd);
|
put_mtd_device(mtd);
|
||||||
printk(KERN_ERR "UBI error: cannot attach mtd%d\n",
|
ubi_err("cannot attach mtd%d", mtd->index);
|
||||||
mtd->index);
|
|
||||||
goto out_detach;
|
goto out_detach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1022,7 @@ static int __init ubi_init(void)
|
||||||
out_class:
|
out_class:
|
||||||
class_destroy(ubi_class);
|
class_destroy(ubi_class);
|
||||||
out:
|
out:
|
||||||
printk(KERN_ERR "UBI error: cannot initialize UBI, error %d\n", err);
|
ubi_err("UBI error: cannot initialize UBI, error %d", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
module_init(ubi_init);
|
module_init(ubi_init);
|
||||||
|
|
|
@ -99,8 +99,10 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
|
||||||
#ifdef CONFIG_MTD_UBI_DEBUG_MSG_BLD
|
#ifdef CONFIG_MTD_UBI_DEBUG_MSG_BLD
|
||||||
/* Initialization and build messages */
|
/* Initialization and build messages */
|
||||||
#define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
|
#define dbg_bld(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
|
||||||
|
#define UBI_IO_DEBUG 1
|
||||||
#else
|
#else
|
||||||
#define dbg_bld(fmt, ...) ({})
|
#define dbg_bld(fmt, ...) ({})
|
||||||
|
#define UBI_IO_DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
|
#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
|
||||||
|
|
|
@ -291,11 +291,12 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
|
||||||
/*
|
/*
|
||||||
* In case of dynamic volume, MTD device size is just volume size. In
|
* In case of dynamic volume, MTD device size is just volume size. In
|
||||||
* case of a static volume the size is equivalent to the amount of data
|
* case of a static volume the size is equivalent to the amount of data
|
||||||
* bytes, which is zero at this moment and will be changed after volume
|
* bytes.
|
||||||
* update.
|
|
||||||
*/
|
*/
|
||||||
if (vol->vol_type == UBI_DYNAMIC_VOLUME)
|
if (vol->vol_type == UBI_DYNAMIC_VOLUME)
|
||||||
mtd->size = vol->usable_leb_size * vol->reserved_pebs;
|
mtd->size = vol->usable_leb_size * vol->reserved_pebs;
|
||||||
|
else
|
||||||
|
mtd->size = vol->used_bytes;
|
||||||
|
|
||||||
if (add_mtd_device(mtd)) {
|
if (add_mtd_device(mtd)) {
|
||||||
ubi_err("cannot not add MTD device\n");
|
ubi_err("cannot not add MTD device\n");
|
||||||
|
|
|
@ -631,6 +631,8 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
|
||||||
|
|
||||||
dbg_io("read EC header from PEB %d", pnum);
|
dbg_io("read EC header from PEB %d", pnum);
|
||||||
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
|
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
|
||||||
|
if (UBI_IO_DEBUG)
|
||||||
|
verbose = 1;
|
||||||
|
|
||||||
err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
|
err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -904,6 +906,8 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
|
||||||
|
|
||||||
dbg_io("read VID header from PEB %d", pnum);
|
dbg_io("read VID header from PEB %d", pnum);
|
||||||
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
|
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
|
||||||
|
if (UBI_IO_DEBUG)
|
||||||
|
verbose = 1;
|
||||||
|
|
||||||
p = (char *)vid_hdr - ubi->vid_hdr_shift;
|
p = (char *)vid_hdr - ubi->vid_hdr_shift;
|
||||||
err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
|
err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
|
#include <asm/div64.h>
|
||||||
#include "ubi.h"
|
#include "ubi.h"
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
|
#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
|
||||||
|
@ -91,27 +92,6 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* commit_to_mean_value - commit intermediate results to the final mean erase
|
|
||||||
* counter value.
|
|
||||||
* @si: scanning information
|
|
||||||
*
|
|
||||||
* This is a helper function which calculates partial mean erase counter mean
|
|
||||||
* value and adds it to the resulting mean value. As we can work only in
|
|
||||||
* integer arithmetic and we want to calculate the mean value of erase counter
|
|
||||||
* accurately, we first sum erase counter values in @si->ec_sum variable and
|
|
||||||
* count these components in @si->ec_count. If this temporary @si->ec_sum is
|
|
||||||
* going to overflow, we calculate the partial mean value
|
|
||||||
* (@si->ec_sum/@si->ec_count) and add it to @si->mean_ec.
|
|
||||||
*/
|
|
||||||
static void commit_to_mean_value(struct ubi_scan_info *si)
|
|
||||||
{
|
|
||||||
si->ec_sum /= si->ec_count;
|
|
||||||
if (si->ec_sum % si->ec_count >= si->ec_count / 2)
|
|
||||||
si->mean_ec += 1;
|
|
||||||
si->mean_ec += si->ec_sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validate_vid_hdr - check that volume identifier header is correct and
|
* validate_vid_hdr - check that volume identifier header is correct and
|
||||||
* consistent.
|
* consistent.
|
||||||
|
@ -901,15 +881,8 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum
|
||||||
|
|
||||||
adjust_mean_ec:
|
adjust_mean_ec:
|
||||||
if (!ec_corr) {
|
if (!ec_corr) {
|
||||||
if (si->ec_sum + ec < ec) {
|
si->ec_sum += ec;
|
||||||
commit_to_mean_value(si);
|
si->ec_count += 1;
|
||||||
si->ec_sum = 0;
|
|
||||||
si->ec_count = 0;
|
|
||||||
} else {
|
|
||||||
si->ec_sum += ec;
|
|
||||||
si->ec_count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ec > si->max_ec)
|
if (ec > si->max_ec)
|
||||||
si->max_ec = ec;
|
si->max_ec = ec;
|
||||||
if (ec < si->min_ec)
|
if (ec < si->min_ec)
|
||||||
|
@ -965,9 +938,11 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
|
||||||
|
|
||||||
dbg_msg("scanning is finished");
|
dbg_msg("scanning is finished");
|
||||||
|
|
||||||
/* Finish mean erase counter calculations */
|
/* Calculate mean erase counter */
|
||||||
if (si->ec_count)
|
if (si->ec_count) {
|
||||||
commit_to_mean_value(si);
|
do_div(si->ec_sum, si->ec_count);
|
||||||
|
si->mean_ec = si->ec_sum;
|
||||||
|
}
|
||||||
|
|
||||||
if (si->is_empty)
|
if (si->is_empty)
|
||||||
ubi_msg("empty MTD device detected");
|
ubi_msg("empty MTD device detected");
|
||||||
|
|
|
@ -124,7 +124,7 @@ struct ubi_scan_info {
|
||||||
int max_ec;
|
int max_ec;
|
||||||
unsigned long long max_sqnum;
|
unsigned long long max_sqnum;
|
||||||
int mean_ec;
|
int mean_ec;
|
||||||
int ec_sum;
|
uint64_t ec_sum;
|
||||||
int ec_count;
|
int ec_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file defines the layout of UBI headers and all the other UBI on-flash
|
* This file defines the layout of UBI headers and all the other UBI on-flash
|
||||||
* data structures. May be included by user-space.
|
* data structures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UBI_HEADER_H__
|
#ifndef __UBI_MEDIA_H__
|
||||||
#define __UBI_HEADER_H__
|
#define __UBI_MEDIA_H__
|
||||||
|
|
||||||
#include <asm/byteorder.h>
|
#include <asm/byteorder.h>
|
||||||
|
|
||||||
|
@ -369,4 +369,4 @@ struct ubi_vtbl_record {
|
||||||
__be32 crc;
|
__be32 crc;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#endif /* !__UBI_HEADER_H__ */
|
#endif /* !__UBI_MEDIA_H__ */
|
|
@ -37,10 +37,9 @@
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/mtd/mtd.h>
|
#include <linux/mtd/mtd.h>
|
||||||
|
|
||||||
#include <mtd/ubi-header.h>
|
|
||||||
#include <linux/mtd/ubi.h>
|
#include <linux/mtd/ubi.h>
|
||||||
|
|
||||||
|
#include "ubi-media.h"
|
||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,4 @@ header-y += jffs2-user.h
|
||||||
header-y += mtd-abi.h
|
header-y += mtd-abi.h
|
||||||
header-y += mtd-user.h
|
header-y += mtd-user.h
|
||||||
header-y += nftl-user.h
|
header-y += nftl-user.h
|
||||||
header-y += ubi-header.h
|
|
||||||
header-y += ubi-user.h
|
header-y += ubi-user.h
|
||||||
|
|
Loading…
Reference in a new issue