Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6
* 'linux-next' of git://git.infradead.org/ubi-2.6: UBI: misc comment fixes UBI: fix s/then/than/ typos UBI: init even if MTD device cannot be attached, if built into kernel UBI: remove reboot notifier
This commit is contained in:
commit
c316ba3b51
8 changed files with 35 additions and 51 deletions
|
@ -27,7 +27,7 @@ config MTD_UBI_WL_THRESHOLD
|
|||
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.,
|
||||
life-cycle less than 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
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <linux/miscdevice.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include "ubi.h"
|
||||
|
@ -50,6 +49,12 @@
|
|||
/* Maximum length of the 'mtd=' parameter */
|
||||
#define MTD_PARAM_LEN_MAX 64
|
||||
|
||||
#ifdef CONFIG_MTD_UBI_MODULE
|
||||
#define ubi_is_module() 1
|
||||
#else
|
||||
#define ubi_is_module() 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct mtd_dev_param - MTD device parameter description data structure.
|
||||
* @name: MTD character device node path, MTD device name, or MTD device number
|
||||
|
@ -831,34 +836,6 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ubi_reboot_notifier - halt UBI transactions immediately prior to a reboot.
|
||||
* @n: reboot notifier object
|
||||
* @state: SYS_RESTART, SYS_HALT, or SYS_POWER_OFF
|
||||
* @cmd: pointer to command string for RESTART2
|
||||
*
|
||||
* This function stops the UBI background thread so that the flash device
|
||||
* remains quiescent when Linux restarts the system. Any queued work will be
|
||||
* discarded, but this function will block until do_work() finishes if an
|
||||
* operation is already in progress.
|
||||
*
|
||||
* This function solves a real-life problem observed on NOR flashes when an
|
||||
* PEB erase operation starts, then the system is rebooted before the erase is
|
||||
* finishes, and the boot loader gets confused and dies. So we prefer to finish
|
||||
* the ongoing operation before rebooting.
|
||||
*/
|
||||
static int ubi_reboot_notifier(struct notifier_block *n, unsigned long state,
|
||||
void *cmd)
|
||||
{
|
||||
struct ubi_device *ubi;
|
||||
|
||||
ubi = container_of(n, struct ubi_device, reboot_notifier);
|
||||
if (ubi->bgt_thread)
|
||||
kthread_stop(ubi->bgt_thread);
|
||||
ubi_sync(ubi->ubi_num);
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ubi_attach_mtd_dev - attach an MTD device.
|
||||
* @mtd: MTD device description object
|
||||
|
@ -1016,11 +993,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
|
|||
wake_up_process(ubi->bgt_thread);
|
||||
spin_unlock(&ubi->wl_lock);
|
||||
|
||||
/* Flash device priority is 0 - UBI needs to shut down first */
|
||||
ubi->reboot_notifier.priority = 1;
|
||||
ubi->reboot_notifier.notifier_call = ubi_reboot_notifier;
|
||||
register_reboot_notifier(&ubi->reboot_notifier);
|
||||
|
||||
ubi_devices[ubi_num] = ubi;
|
||||
ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
|
||||
return ubi_num;
|
||||
|
@ -1091,7 +1063,6 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
|
|||
* Before freeing anything, we have to stop the background thread to
|
||||
* prevent it from doing anything on this device while we are freeing.
|
||||
*/
|
||||
unregister_reboot_notifier(&ubi->reboot_notifier);
|
||||
if (ubi->bgt_thread)
|
||||
kthread_stop(ubi->bgt_thread);
|
||||
|
||||
|
@ -1241,9 +1212,24 @@ static int __init ubi_init(void)
|
|||
p->vid_hdr_offs);
|
||||
mutex_unlock(&ubi_devices_mutex);
|
||||
if (err < 0) {
|
||||
put_mtd_device(mtd);
|
||||
ubi_err("cannot attach mtd%d", mtd->index);
|
||||
goto out_detach;
|
||||
put_mtd_device(mtd);
|
||||
|
||||
/*
|
||||
* Originally UBI stopped initializing on any error.
|
||||
* However, later on it was found out that this
|
||||
* behavior is not very good when UBI is compiled into
|
||||
* the kernel and the MTD devices to attach are passed
|
||||
* through the command line. Indeed, UBI failure
|
||||
* stopped whole boot sequence.
|
||||
*
|
||||
* To fix this, we changed the behavior for the
|
||||
* non-module case, but preserved the old behavior for
|
||||
* the module case, just for compatibility. This is a
|
||||
* little inconsistent, though.
|
||||
*/
|
||||
if (ubi_is_module())
|
||||
goto out_detach;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@
|
|||
* device, e.g., make @ubi->min_io_size = 512 in the example above?
|
||||
*
|
||||
* A: because when writing a sub-page, MTD still writes a full 2K page but the
|
||||
* bytes which are no relevant to the sub-page are 0xFF. So, basically, writing
|
||||
* 4x512 sub-pages is 4 times slower then writing one 2KiB NAND page. Thus, we
|
||||
* prefer to use sub-pages only for EV and VID headers.
|
||||
* bytes which are not relevant to the sub-page are 0xFF. So, basically,
|
||||
* writing 4x512 sub-pages is 4 times slower than writing one 2KiB NAND page.
|
||||
* Thus, we prefer to use sub-pages only for EC and VID headers.
|
||||
*
|
||||
* As it was noted above, the VID header may start at a non-aligned offset.
|
||||
* For example, in case of a 2KiB page NAND flash with a 512 bytes sub-page,
|
||||
|
|
|
@ -488,7 +488,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_write);
|
|||
*
|
||||
* This function changes the contents of a logical eraseblock atomically. @buf
|
||||
* has to contain new logical eraseblock data, and @len - the length of the
|
||||
* data, which has to be aligned. The length may be shorter then the logical
|
||||
* data, which has to be aligned. The length may be shorter than the logical
|
||||
* eraseblock size, ant the logical eraseblock may be appended to more times
|
||||
* later on. This function guarantees that in case of an unclean reboot the old
|
||||
* contents is preserved. Returns zero in case of success and a negative error
|
||||
|
@ -571,7 +571,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_erase);
|
|||
*
|
||||
* This function un-maps logical eraseblock @lnum and schedules the
|
||||
* corresponding physical eraseblock for erasure, so that it will eventually be
|
||||
* physically erased in background. This operation is much faster then the
|
||||
* physically erased in background. This operation is much faster than the
|
||||
* erase operation.
|
||||
*
|
||||
* Unlike erase, the un-map operation does not guarantee that the logical
|
||||
|
@ -590,7 +590,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_erase);
|
|||
*
|
||||
* The main and obvious use-case of this function is when the contents of a
|
||||
* logical eraseblock has to be re-written. Then it is much more efficient to
|
||||
* first un-map it, then write new data, rather then first erase it, then write
|
||||
* first un-map it, then write new data, rather than first erase it, then write
|
||||
* new data. Note, once new data has been written to the logical eraseblock,
|
||||
* UBI guarantees that the old contents has gone forever. In other words, if an
|
||||
* unclean reboot happens after the logical eraseblock has been un-mapped and
|
||||
|
|
|
@ -231,7 +231,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id,
|
|||
* case of success this function returns a positive value, in case of failure, a
|
||||
* negative error code is returned. The success return codes use the following
|
||||
* bits:
|
||||
* o bit 0 is cleared: the first PEB (described by @seb) is newer then the
|
||||
* o bit 0 is cleared: the first PEB (described by @seb) is newer than the
|
||||
* second PEB (described by @pnum and @vid_hdr);
|
||||
* o bit 0 is set: the second PEB is newer;
|
||||
* o bit 1 is cleared: no bit-flips were detected in the newer LEB;
|
||||
|
@ -452,7 +452,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
|
|||
|
||||
if (cmp_res & 1) {
|
||||
/*
|
||||
* This logical eraseblock is newer then the one
|
||||
* This logical eraseblock is newer than the one
|
||||
* found earlier.
|
||||
*/
|
||||
err = validate_vid_hdr(vid_hdr, sv, pnum);
|
||||
|
|
|
@ -350,7 +350,6 @@ struct ubi_wl_entry;
|
|||
* @bgt_thread: background thread description object
|
||||
* @thread_enabled: if the background thread is enabled
|
||||
* @bgt_name: background thread name
|
||||
* @reboot_notifier: notifier to terminate background thread before rebooting
|
||||
*
|
||||
* @flash_size: underlying MTD device size (in bytes)
|
||||
* @peb_count: count of physical eraseblocks on the MTD device
|
||||
|
@ -436,7 +435,6 @@ struct ubi_device {
|
|||
struct task_struct *bgt_thread;
|
||||
int thread_enabled;
|
||||
char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2];
|
||||
struct notifier_block reboot_notifier;
|
||||
|
||||
/* I/O sub-system's stuff */
|
||||
long long flash_size;
|
||||
|
|
|
@ -414,7 +414,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
|
|||
* 0 contains more recent information.
|
||||
*
|
||||
* So the plan is to first check LEB 0. Then
|
||||
* a. if LEB 0 is OK, it must be containing the most resent data; then
|
||||
* a. if LEB 0 is OK, it must be containing the most recent data; then
|
||||
* we compare it with LEB 1, and if they are different, we copy LEB
|
||||
* 0 to LEB 1;
|
||||
* b. if LEB 0 is corrupted, but LEB 1 has to be OK, and we copy LEB 1
|
||||
|
@ -848,7 +848,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
|
|||
goto out_free;
|
||||
|
||||
/*
|
||||
* Get sure that the scanning information is consistent to the
|
||||
* Make sure that the scanning information is consistent to the
|
||||
* information stored in the volume table.
|
||||
*/
|
||||
err = check_scanning_info(ubi, si);
|
||||
|
|
|
@ -350,7 +350,7 @@ static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e)
|
|||
* @max: highest possible erase counter
|
||||
*
|
||||
* This function looks for a wear leveling entry with erase counter closest to
|
||||
* @max and less then @max.
|
||||
* @max and less than @max.
|
||||
*/
|
||||
static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue