aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/debug.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-10-11treewide: use prandom_u32_max() when possible, part 1Jason A. Donenfeld1-1/+1
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done mechanically with this coccinelle script: @basic@ expression E; type T; identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32"; typedef u64; @@ ( - ((T)get_random_u32() % (E)) + prandom_u32_max(E) | - ((T)get_random_u32() & ((E) - 1)) + prandom_u32_max(E * XXX_MAKE_SURE_E_IS_POW2) | - ((u64)(E) * get_random_u32() >> 32) + prandom_u32_max(E) | - ((T)get_random_u32() & ~PAGE_MASK) + prandom_u32_max(PAGE_SIZE) ) @multi_line@ identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32"; identifier RAND; expression E; @@ - RAND = get_random_u32(); ... when != RAND - RAND %= (E); + RAND = prandom_u32_max(E); // Find a potential literal @literal_mask@ expression LITERAL; type T; identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32"; position p; @@ ((T)get_random_u32()@p & (LITERAL)) // Add one to the literal. @script:python add_one@ literal << literal_mask.LITERAL; RESULT; @@ value = None if literal.startswith('0x'): value = int(literal, 16) elif literal[0] in '123456789': value = int(literal, 10) if value is None: print("I don't know how to handle %s" % (literal)) cocci.include_match(False) elif value == 2**32 - 1 or value == 2**31 - 1 or value == 2**24 - 1 or value == 2**16 - 1 or value == 2**8 - 1: print("Skipping 0x%x for cleanup elsewhere" % (value)) cocci.include_match(False) elif value & (value + 1) != 0: print("Skipping 0x%x because it's not a power of two minus one" % (value)) cocci.include_match(False) elif literal.startswith('0x'): coccinelle.RESULT = cocci.make_expr("0x%x" % (value + 1)) else: coccinelle.RESULT = cocci.make_expr("%d" % (value + 1)) // Replace the literal mask with the calculated result. @plus_one@ expression literal_mask.LITERAL; position literal_mask.p; expression add_one.RESULT; identifier FUNC; @@ - (FUNC()@p & (LITERAL)) + prandom_u32_max(RESULT) @collapse_ret@ type T; identifier VAR; expression E; @@ { - T VAR; - VAR = (E); - return VAR; + return E; } @drop_var@ type T; identifier VAR; @@ { - T VAR; ... when != VAR } Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Yury Norov <yury.norov@gmail.com> Reviewed-by: KP Singh <kpsingh@kernel.org> Reviewed-by: Jan Kara <jack@suse.cz> # for ext4 and sbitmap Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> # for drbd Acked-by: Jakub Kicinski <kuba@kernel.org> Acked-by: Heiko Carstens <hca@linux.ibm.com> # for s390 Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # for mmc Acked-by: Darrick J. Wong <djwong@kernel.org> # for xfs Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-12-23ubi: Fix a mistake in commentKai Song1-1/+1
Fixes: 2a734bb8d502 ("UBI: use debugfs for the extra checks knobs") There is a mistake in docstrings, it should be ubi_debugfs_exit_dev instead of dbg_debug_exit_dev. Signed-off-by: Kai Song <songkai01@inspur.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2021-06-18ubifs: fix snprintf() checkingDan Carpenter1-1/+1
The snprintf() function returns the number of characters (not counting the NUL terminator) that it would have printed if we had space. This buffer has UBIFS_DFS_DIR_LEN characters plus one extra for the terminator. Printing UBIFS_DFS_DIR_LEN is okay but anything higher will result in truncation. Thus the comparison needs to be change from == to >. These strings are compile time constants so this patch doesn't affect runtime. Fixes: ae380ce04731 ("UBIFS: lessen the size of debugging info data structure") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Alexander Dahl <ada@thorsis.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2020-05-17ubi: Fix seq_file usage in detailed_erase_block_info debugfs fileRichard Weinberger1-10/+2
3bfa7e141b0b ("fs/seq_file.c: seq_read(): add info message about buggy .next functions") showed that we don't use seq_file correctly. So make sure that our ->next function always updates the position. Fixes: 7bccd12d27b7 ("ubi: Add debugfs file for tracking PEB state") Signed-off-by: Richard Weinberger <richard@nod.at>
2019-12-02Merge tag 'upstream-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifsLinus Torvalds1-0/+1
Pull UBI/UBIFS/JFFS2 updates from Richard Weinberger: "This pull request contains mostly fixes for UBI, UBIFS and JFFS2: UBI: - Fix a regression around producing a anchor PEB for fastmap. Due to a change in our locking fastmap was unable to produce fresh anchors an re-used the existing one a way to often. UBIFS: - Fixes for endianness. A few places blindly assumed little endian. - Fix for a memory leak in the orphan code. - Fix for a possible crash during a commit. - Revert a wrong bugfix. JFFS2: - Revert a bad bugfix (false positive from a code checking tool)" * tag 'upstream-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs: Revert "jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()" ubi: Fix producing anchor PEBs ubifs: ubifs_tnc_start_commit: Fix OOB in layout_in_gaps ubifs: do_kill_orphans: Fix a memory leak bug Revert "ubifs: Fix memory leak bug in alloc_ubifs_info() error path" ubifs: Fix type of sup->hash_algo ubifs: Fixed missed le64_to_cpu() in journal ubifs: Force prandom result to __le32 ubifs: Remove obsolete TODO from dfs_file_write() ubi: Fix warning static is not at beginning of declaration ubi: Print skip_check in ubi_dump_vol_info()
2019-11-17ubi: Print skip_check in ubi_dump_vol_info()Stefan Roese1-0/+1
It might be interesting, if "skip_check" is set or not, so lets print this flag in ubi_dump_vol_info() as well. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Richard Weinberger <richard@nod.at> Cc: Boris Brezillon <boris.brezillon@collabora.com> Cc: Heiko Schocher <hs@denx.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2019-11-14mtd: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-88/+43
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: David Woodhouse <dwmw2@infradead.org> Cc: Brian Norris <computersforpeace@gmail.com> Cc: Marek Vasut <marek.vasut@gmail.com> Cc: Miquel Raynal <miquel.raynal@bootlin.com> Cc: Richard Weinberger <richard@nod.at> Cc: Vignesh Raghavendra <vigneshr@ti.com> Cc: Artem Bityutskiy <dedekind1@gmail.com> Cc: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156Thomas Gleixner1-14/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 59 temple place suite 330 boston ma 02111 1307 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1334 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-08ubi: Add debugfs file for tracking PEB stateBen Shelton1-1/+125
Add a file under debugfs to allow easy access to the erase count for each physical erase block on an UBI device. This is useful when debugging data integrity issues with UBIFS on NAND flash devices. Signed-off-by: Ben Shelton <ben.shelton@ni.com> Signed-off-by: Zach Brown <zach.brown@ni.com> v2: * If ubi_io_is_bad eraseblk_count_seq_show just returns the err. * if ubi->lookuptbl returns null, its no longer treated as an error instead info for that block is not printeded * Removed check for UBI_MAX_ERASECOUNTER since it is impossible to hit * Removed block state from print, if a block is printed then it is good and if it is not printed, then it is bad. v3: * Remove errant ! symbol from if statement checking if erase count is valid. Signed-off-by: Richard Weinberger <richard@nod.at>
2016-05-24UBI: Silence an unintialized variable warningDan Carpenter1-1/+2
My static checker complains that "val" is uninitialized when kstrtoint() fails. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-12-16UBI: fix return error codeSudip Mukherjee1-1/+1
We are checking dfs_rootdir for error value or NULL. But in the conditional ternary operator we returned -ENODEV if dfs_rootdir contains an error value and returned PTR_ERR(dfs_rootdir) if dfs_rootdir is NULL. So in the case of dfs_rootdir being NULL we actually assigned 0 to err and returned it to the caller implying a success. Lets return -ENODEV when dfs_rootdir is NULL else return PTR_ERR(dfs_rootdir). Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-04-13UBI: power cut emulation for testingdavid.oberhollenzer@sigma-star.at1-2/+87
Emulate random power cuts by switching device to ro after a number of writes to allow simple power cut testing with nand-sim. Maximum and minimum number of successful writes before power cut and what kind of writes (EC header, VID header or none) to interrupt configurable via debugfs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-03-26UBI: Add initial support for fastmap self checksRichard Weinberger1-0/+11
Using this debugfs knob fastmap self checks can be controlled. Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>
2014-11-07UBI: Extend UBI layer debug/messaging capabilitiesTanya Brokhman1-5/+5
If there is more then one UBI device mounted, there is no way to distinguish between messages from different UBI devices. Add device number to all ubi layer message types. The R/O block driver messages were replaced by pr_* since ubi_device structure is not used by it. Amended a bit by Artem. Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-12-10UBI: embed ubi_debug_info field in ubi_device structEzequiel Garcia1-30/+4
ubi_debug_info struct was dynamically allocated which is always suboptimal, for it tends to fragment memory and make the code error-prone. Fix this by embedding it in ubi_device struct. Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-04UBI: use pr_ helper instead of printkArtem Bityutskiy1-78/+71
Use 'pr_err()' instead of 'printk(KERN_ERR', etc. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-04UBI: comply with coding styleArtem Bityutskiy1-2/+2
Join all the split printk lines in order to stop checkpatch complaining. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-06-27UBI: correct usage of IS_ENABLED()Brian Norris1-4/+4
Commit "e9b4cf2 UBI: fix debugfs-less systems support" fixed one regression but introduced a different regression - the debugfs is now always compiled out. Root cause: IS_ENABLED() arguments should be used with the CONFIG_* prefix. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-06-07UBI: fix debugfs-less systems supportArtem Bityutskiy1-2/+10
Commit "aa44d1d UBI: remove Kconfig debugging option" broke UBI and it refuses to initialize if debugfs (CONFIG_DEBUG_FS) is disabled. I incorrectly assumed that debugfs files creation function will return success if debugfs is disabled, but they actually return -ENODEV. This patch fixes the issue. Reported-by: Paul Parsons <lost.distance@yahoo.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Tested-by: Paul Parsons <lost.distance@yahoo.com>
2012-05-20UBI: rename sv to avArtem Bityutskiy1-11/+11
After re-naming the 'struct ubi_scan_volume' we should adjust all variables named 'sv' to something else, because 'sv' stands for "scanning volume". Let's rename it to 'av' which stands for "attaching volume" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-05-20UBI: rename si to aiArtem Bityutskiy1-2/+2
After re-naming the 'struct ubi_scan_info' we should adjust all variables named 'si' to something else, because 'si' stands for "scanning info". Let's rename it to 'ai' which stands for "attaching info" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-05-20UBI: rename seb to aebArtem Bityutskiy1-8/+8
After re-naming the 'struct ubi_scan_leb' we should adjust all variables named 'seb' to something else, because 'seb' stands for "scanning eraseblock". Let's rename it to 'aeb' which stands for "attaching eraseblock" which is a bit more consistend and has the same length. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-05-20UBI: rename struct ubi_scan_volumeArtem Bityutskiy1-2/+2
Rename 'struct ubi_scan_volume' to 'struct ubi_ainf_volume'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-05-20UBI: rename struct ubi_scan_lebArtem Bityutskiy1-2/+2
Rename 'struct ubi_scan_leb' to 'struct ubi_ainf_leb'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-05-20UBI: remove Kconfig debugging optionArtem Bityutskiy1-4/+0
This patch kills the UBI debugging Kconfig option completely and makes all the debugging stuff to be always compiled-in. It was pain in the neck to maintain this useless option because all users I am aware of have debugging enabled anyway - how else will you diagnose errors otherwise? Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: rename ubi_dbg_dump_mkvol_reqArtem Bityutskiy1-2/+2
I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_mkvol_req()' to 'ubi_dump_mkvol_req()'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: rename ubi_dbg_dump_sebArtem Bityutskiy1-2/+2
I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_seb()' to 'ubi_dump_seb()'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: rename ubi_dbg_dump_svArtem Bityutskiy1-2/+2
I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_sv()' to 'ubi_dump_sv()'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: rename ubi_dbg_dump_vtbl_recordArtem Bityutskiy1-2/+2
I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vtbl_record()' to 'ubi_dump_vtbl_record()'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: rename ubi_dbg_dump_vol_infoArtem Bityutskiy1-2/+2
I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vol_info()' to 'ubi_dump_vol_info()'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: always dump VID and EC headers in case of errorsArtem Bityutskiy1-6/+6
UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. Always dump the VID and EC headers' contents in case of errors when it is helpful. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-20UBI: always dump flash contents in case of errorsArtem Bityutskiy1-40/+35
UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. Always dump the flash contents in case of errors, not only when debugging is enabled. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2012-04-05simple_open: automatically convert to simple_open()Stephen Boyd1-9/+1
Many users of debugfs copy the implementation of default_open() when they want to support a custom read/write function op. This leads to a proliferation of the default_open() implementation across the entire tree. Now that the common implementation has been consolidated into libfs we can replace all the users of this function with simple_open(). This replacement was done with the following semantic patch: <smpl> @ open @ identifier open_f != simple_open; identifier i, f; @@ -int open_f(struct inode *i, struct file *f) -{ ( -if (i->i_private) -f->private_data = i->i_private; | -f->private_data = i->i_private; ) -return 0; -} @ has_open depends on open @ identifier fops; identifier open.open_f; @@ struct file_operations fops = { ... -.open = open_f, +.open = simple_open, ... }; </smpl> [akpm@linux-foundation.org: checkpatch fixes] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Julia Lawall <Julia.Lawall@lip6.fr> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-09mtd: introduce mtd_read interfaceArtem Bityutskiy1-1/+1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2011-06-01UBI: switch debugging tests knobs to debugfsArtem Bityutskiy1-7/+33
Kill the UBI 'debug_tsts' module parameter and switch to debugfs. Create per-test mode files there. E.g., to enable bit-flips emulation you may just do: echo 1 > /sys/kernel/debug/ubi/ubi0/tst_emulate_bitflips Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-01UBI: use debugfs for the extra checks knobsArtem Bityutskiy1-4/+227
This patch introduces debugfs support to UBI. All the UBI stuff is kept in the "ubi" debugfs directory, which contains per-UBI device "ubi/ubiX" sub-directories, containing debugging files. This file also creates "ubi/ubiX/chk_gen" and "ubi/ubiX/chk_io" knobs for switching general and I/O extra checks on and off. And it removes the 'debug_chks' UBI module parameters. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-05-20UBI: switch to dynamic printksArtem Bityutskiy1-3/+0
Remove custom dynamic prints and the module parameter to toggle them and use the generic kernel dynamic printk infrastructure. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-04-14UBI: fix minor stylistic issuesArtem Bityutskiy1-9/+9
Fix checkpatch.pl errors and warnings: * space before tab * line over 80 characters * include linux/ioctl.h instead of asm/ioctl.h Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-03-16UBI: make tests modes dynamicArtem Bityutskiy1-0/+3
Similarly to the debugging checks and message, make the test modes be dynamically selected via the "debug_tsts" module parameter or via the "/sys/module/ubi/parameters/debug_tsts" sysfs file. This is consistent with UBIFS as well. And now, since all the Kconfig knobs became dynamic, we can remove the Kconfig.debug file completely. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-03-16UBI: make self-checks dynamicArtem Bityutskiy1-0/+3
This patch adds a possibility to dynamically switch UBI self-checks on and off, instead of toggling them compile-time from the configuration menu. This is much more flexible, and consistent with UBIFS, and this also simplifies UBI Kconfig menu and the code. This patch introduces two levels of self-checks - general, which includes all self-checks which are relatively fast, and I/O, which includes write-verify checks and erase-verify checks, which are relatively slow and involve flash I/O. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-03-16UBI: make debugging messages dynamicArtem Bityutskiy1-0/+8
This patch adds a possibility to dynamically select UBI debugging messages, instead of selecting them compile-time from the configuration menu. This is much more flexible, and consistent with UBIFS, and this also simplifies UBI Kconfig menu and the code. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-08-14UBI: introduce flash dump helperArtem Bityutskiy1-0/+32
Useful for debugging problems, compiled in only if UBI debugging is enabled. This patch also makes the UBI writing function dump the flash if it fails to write. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-07-05UBI: add image sequence number to EC headerAdrian Hunter1-0/+2
An image sequence number is added to the UBI erase-counter header to be able determine if the root file system contains a mixture of old and new images (because the flashing failed to complete). A change to nolo is also needed for this to take effect. Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-07-24UBI: remove pre-sqnum images supportArtem Bityutskiy1-2/+0
Before UBI got into mainline, there was a slight flash format change - we did not have sequence number support, then added it. We have carried full support of those ancient images till this moment. Now the support is removed, well, not fully removed. Now UBI will support only _clean_ old images, which were cleanly detached last time (just before kernel upgrade). This is most likely the case. But we will not support unclean ancient images. Surprisingly, this allows us to remove a big chunk of legacy code. And the same should be true for downgrading: clean images should downgrade fine, but unclean ones will not. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-07-24UBI: fix and re-work debugging stuffArtem Bityutskiy1-76/+84
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-10-14UBI: use byte hexdumpArtem Bityutskiy1-2/+2
More handy since word hexdump prints in host endian. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-10-14UBI: use linux print_hex_dump(), not home-grown oneArtem Bityutskiy1-35/+2
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: bugfix in error pathArtem Bityutskiy1-3/+3
When volume creation fails, we have to set ubi->volumes[vol_id] back to NULL. This patch also tweaks some debugging stuff. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: kill homegrown endian macrosChristoph Hellwig1-19/+19
Kill UBI's homegrown endianess handling and replace it with the standard kernel endianess handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-04-27UBI: Unsorted Block ImagesArtem B. Bityutskiy1-0/+224
UBI (Latin: "where?") manages multiple logical volumes on a single flash device, specifically supporting NAND flash devices. UBI provides a flexible partitioning concept which still allows for wear-levelling across the whole flash device. In a sense, UBI may be compared to the Logical Volume Manager (LVM). Whereas LVM maps logical sector numbers to physical HDD sector numbers, UBI maps logical eraseblocks to physical eraseblocks. More information may be found at http://www.linux-mtd.infradead.org/doc/ubi.html Partitioning/Re-partitioning An UBI volume occupies a certain number of erase blocks. This is limited by a configured maximum volume size, which could also be viewed as the partition size. Each individual UBI volume's size can be changed independently of the other UBI volumes, provided that the sum of all volume sizes doesn't exceed a certain limit. UBI supports dynamic volumes and static volumes. Static volumes are read-only and their contents are protected by CRC check sums. Bad eraseblocks handling UBI transparently handles bad eraseblocks. When a physical eraseblock becomes bad, it is substituted by a good physical eraseblock, and the user does not even notice this. Scrubbing On a NAND flash bit flips can occur on any write operation, sometimes also on read. If bit flips persist on the device, at first they can still be corrected by ECC, but once they accumulate, correction will become impossible. Thus it is best to actively scrub the affected eraseblock, by first copying it to a free eraseblock and then erasing the original. The UBI layer performs this type of scrubbing under the covers, transparently to the UBI volume users. Erase Counts UBI maintains an erase count header per eraseblock. This frees higher-level layers (like file systems) from doing this and allows for centralized erase count management instead. The erase counts are used by the wear-levelling algorithm in the UBI layer. The algorithm itself is exchangeable. Booting from NAND For booting directly from NAND flash the hardware must at least be capable of fetching and executing a small portion of the NAND flash. Some NAND flash controllers have this kind of support. They usually limit the window to a few kilobytes in erase block 0. This "initial program loader" (IPL) must then contain sufficient logic to load and execute the next boot phase. Due to bad eraseblocks, which may be randomly scattered over the flash device, it is problematic to store the "secondary program loader" (SPL) statically. Also, due to bit-flips it may become corrupted over time. UBI allows to solve this problem gracefully by storing the SPL in a small static UBI volume. UBI volumes vs. static partitions UBI volumes are still very similar to static MTD partitions: * both consist of eraseblocks (logical eraseblocks in case of UBI volumes, and physical eraseblocks in case of static partitions; * both support three basic operations - read, write, erase. But UBI volumes have the following advantages over traditional static MTD partitions: * there are no eraseblock wear-leveling constraints in case of UBI volumes, so the user should not care about this; * there are no bit-flips and bad eraseblocks in case of UBI volumes. So, UBI volumes may be considered as flash devices with relaxed restrictions. Where can it be found? Documentation, kernel code and applications can be found in the MTD gits. What are the applications for? The applications help to create binary flash images for two purposes: pfi files (partial flash images) for in-system update of UBI volumes, and plain binary images, with or without OOB data in case of NAND, for a manufacturing step. Furthermore some tools are/and will be created that allow flash content analysis after a system has crashed.. Who did UBI? The original ideas, where UBI is based on, were developed by Andreas Arnez, Frank Haverkamp and Thomas Gleixner. Josh W. Boyer and some others were involved too. The implementation of the kernel layer was done by Artem B. Bityutskiy. The user-space applications and tools were written by Oliver Lohmann with contributions from Frank Haverkamp, Andreas Arnez, and Artem. Joern Engel contributed a patch which modifies JFFS2 so that it can be run on a UBI volume. Thomas Gleixner did modifications to the NAND layer. Alexander Schmidt made some testing work as well as core functionality improvements. Signed-off-by: Artem B. Bityutskiy <dedekind@linutronix.de> Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>