Skip to content

Commit

Permalink
Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6
Browse files Browse the repository at this point in the history
* 'linux-next' of git://git.infradead.org/ubi-2.6:
  UBI: tighten the corrupted PEB criteria
  UBI: fix check_data_ff return code
  UBI: remember copy_flag while scanning
  UBI: preserve corrupted PEBs
  UBI: add truly corrupted PEBs to corrupted list
  UBI: introduce debugging helper function
  UBI: make check_pattern function non-static
  UBI: do not put eraseblocks to the corrupted list unnecessarily
  UBI: separate out corrupted list
  UBI: change cascade of ifs to switch statements
  UBI: rename a local variable
  UBI: handle bit-flips when no header found
  UBI: remove duplicate IO error codes
  UBI: rename IO error code
  UBI: fix small 80 characters limit style issue
  UBI: cleanup and simplify Kconfig
  • Loading branch information
torvalds committed Oct 22, 2010
2 parents 06d3629 + 45aafd3 commit 4f3a29d
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 286 deletions.
17 changes: 6 additions & 11 deletions drivers/mtd/ubi/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
menu "UBI - Unsorted block images"
depends on MTD

config MTD_UBI
tristate "Enable UBI"
depends on MTD
menuconfig MTD_UBI
tristate "Enable UBI - Unsorted block images"
select CRC32
help
UBI is a software layer above MTD layer which admits of LVM-like
Expand All @@ -12,11 +8,12 @@ config MTD_UBI
capabilities. Please, consult the MTD web site for more details
(www.linux-mtd.infradead.org).

if MTD_UBI

config MTD_UBI_WL_THRESHOLD
int "UBI wear-leveling threshold"
default 4096
range 2 65536
depends on MTD_UBI
help
This parameter defines the maximum difference between the highest
erase counter value and the lowest erase counter value of eraseblocks
Expand All @@ -34,7 +31,6 @@ config MTD_UBI_BEB_RESERVE
int "Percentage of reserved eraseblocks for bad eraseblocks handling"
default 1
range 0 25
depends on MTD_UBI
help
If the MTD device admits of bad eraseblocks (e.g. NAND flash), UBI
reserves some amount of physical eraseblocks to handle new bad
Expand All @@ -48,8 +44,6 @@ config MTD_UBI_BEB_RESERVE

config MTD_UBI_GLUEBI
tristate "MTD devices emulation driver (gluebi)"
default n
depends on MTD_UBI
help
This option enables gluebi - an additional driver which emulates MTD
devices on top of UBI volumes: for each UBI volumes an MTD device is
Expand All @@ -59,4 +53,5 @@ config MTD_UBI_GLUEBI
software.

source "drivers/mtd/ubi/Kconfig.debug"
endmenu

endif # MTD_UBI
29 changes: 4 additions & 25 deletions drivers/mtd/ubi/Kconfig.debug
Original file line number Diff line number Diff line change
@@ -1,94 +1,73 @@
comment "UBI debugging options"
depends on MTD_UBI

config MTD_UBI_DEBUG
bool "UBI debugging"
depends on SYSFS
depends on MTD_UBI
select DEBUG_FS
select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL
help
This option enables UBI debugging.

if MTD_UBI_DEBUG

config MTD_UBI_DEBUG_MSG
bool "UBI debugging messages"
depends on MTD_UBI_DEBUG
default n
help
This option enables UBI debugging messages.

config MTD_UBI_DEBUG_PARANOID
bool "Extra self-checks"
default n
depends on MTD_UBI_DEBUG
help
This option enables extra checks in UBI code. Note this slows UBI down
significantly.

config MTD_UBI_DEBUG_DISABLE_BGT
bool "Do not enable the UBI background thread"
depends on MTD_UBI_DEBUG
default n
help
This option switches the background thread off by default. The thread
may be also be enabled/disabled via UBI sysfs.

config MTD_UBI_DEBUG_EMULATE_BITFLIPS
bool "Emulate flash bit-flips"
depends on MTD_UBI_DEBUG
default n
help
This option emulates bit-flips with probability 1/50, which in turn
causes scrubbing. Useful for debugging and stressing UBI.

config MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
bool "Emulate flash write failures"
depends on MTD_UBI_DEBUG
default n
help
This option emulates write failures with probability 1/100. Useful for
debugging and testing how UBI handlines errors.

config MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
bool "Emulate flash erase failures"
depends on MTD_UBI_DEBUG
default n
help
This option emulates erase failures with probability 1/100. Useful for
debugging and testing how UBI handlines errors.

menu "Additional UBI debugging messages"
depends on MTD_UBI_DEBUG
comment "Additional UBI debugging messages"

config MTD_UBI_DEBUG_MSG_BLD
bool "Additional UBI initialization and build messages"
default n
depends on MTD_UBI_DEBUG
help
This option enables detailed UBI initialization and device build
debugging messages.

config MTD_UBI_DEBUG_MSG_EBA
bool "Eraseblock association unit messages"
default n
depends on MTD_UBI_DEBUG
help
This option enables debugging messages from the UBI eraseblock
association unit.

config MTD_UBI_DEBUG_MSG_WL
bool "Wear-leveling unit messages"
default n
depends on MTD_UBI_DEBUG
help
This option enables debugging messages from the UBI wear-leveling
unit.

config MTD_UBI_DEBUG_MSG_IO
bool "Input/output unit messages"
default n
depends on MTD_UBI_DEBUG
help
This option enables debugging messages from the UBI input/output unit.

endmenu # UBI debugging messages
endif # MTD_UBI_DEBUG
6 changes: 4 additions & 2 deletions drivers/mtd/ubi/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ DEFINE_MUTEX(ubi_devices_mutex);
static DEFINE_SPINLOCK(ubi_devices_lock);

/* "Show" method for files in '/<sysfs>/class/ubi/' */
static ssize_t ubi_version_show(struct class *class, struct class_attribute *attr,
char *buf)
static ssize_t ubi_version_show(struct class *class,
struct class_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", UBI_VERSION);
}
Expand Down Expand Up @@ -591,6 +591,7 @@ static int attach_by_scanning(struct ubi_device *ubi)

ubi->bad_peb_count = si->bad_peb_count;
ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
ubi->corr_peb_count = si->corr_peb_count;
ubi->max_ec = si->max_ec;
ubi->mean_ec = si->mean_ec;
ubi_msg("max. sequence number: %llu", si->max_sqnum);
Expand Down Expand Up @@ -972,6 +973,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20);
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 corrupted PEBs: %d", ubi->corr_peb_count);
ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots);
ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD);
ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT);
Expand Down
4 changes: 4 additions & 0 deletions drivers/mtd/ubi/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type);
void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);

#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
print_hex_dump(l, ps, pt, r, g, b, len, a)

#ifdef CONFIG_MTD_UBI_DEBUG_MSG
/* General debugging messages */
#define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
Expand Down Expand Up @@ -172,6 +175,7 @@ static inline int ubi_dbg_is_erase_failure(void)
#define ubi_dbg_dump_seb(seb, type) ({})
#define ubi_dbg_dump_mkvol_req(req) ({})
#define ubi_dbg_dump_flash(ubi, pnum, offset, len) ({})
#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) ({})

#define UBI_IO_DEBUG 0
#define DBG_DISABLE_BGT 0
Expand Down
10 changes: 8 additions & 2 deletions drivers/mtd/ubi/eba.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
* may try to recover data. FIXME: but this is
* not implemented.
*/
if (err == UBI_IO_BAD_HDR_READ ||
if (err == UBI_IO_BAD_HDR_EBADMSG ||
err == UBI_IO_BAD_HDR) {
ubi_warn("corrupted VID header at PEB "
"%d, LEB %d:%d", pnum, vol_id,
Expand Down Expand Up @@ -963,7 +963,7 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
static int is_error_sane(int err)
{
if (err == -EIO || err == -ENOMEM || err == UBI_IO_BAD_HDR ||
err == UBI_IO_BAD_HDR_READ || err == -ETIMEDOUT)
err == UBI_IO_BAD_HDR_EBADMSG || err == -ETIMEDOUT)
return 0;
return 1;
}
Expand Down Expand Up @@ -1201,6 +1201,9 @@ static void print_rsvd_warning(struct ubi_device *ubi,

ubi_warn("cannot reserve enough PEBs for bad PEB handling, reserved %d,"
" need %d", ubi->beb_rsvd_pebs, ubi->beb_rsvd_level);
if (ubi->corr_peb_count)
ubi_warn("%d PEBs are corrupted and not used",
ubi->corr_peb_count);
}

/**
Expand Down Expand Up @@ -1263,6 +1266,9 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
if (ubi->avail_pebs < EBA_RESERVED_PEBS) {
ubi_err("no enough physical eraseblocks (%d, need %d)",
ubi->avail_pebs, EBA_RESERVED_PEBS);
if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used",
ubi->corr_peb_count);
err = -ENOSPC;
goto out_free;
}
Expand Down
Loading

0 comments on commit 4f3a29d

Please sign in to comment.