Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e43fe686 authored by David Woodhouse's avatar David Woodhouse
Browse files
parents 986ee013 434b825e
Loading
Loading
Loading
Loading
+212 −0
Original line number Original line Diff line number Diff line
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.
+7 −2
Original line number Original line Diff line number Diff line
@@ -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"
+18 −19
Original line number Original line Diff line number Diff line
@@ -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,19 +959,19 @@ 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;
	}
	}


@@ -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);
+2 −0
Original line number Original line Diff line number Diff line
@@ -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
+3 −2
Original line number Original line Diff line number Diff line
@@ -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");
Loading