summaryrefslogtreecommitdiff
path: root/drivers/mtd/ubi/build.c
AgeCommit message (Collapse)Author
2008-03-04UBI: fix error messageArtem Bityutskiy
Make it print "UBI error: cannot attach mtd4" instead of "UBI error: cannot attach 4" Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-01-25UBI: bugfix: calculate data offset properlyArtem Bityutskiy
Data offset is VID header offset + VID header size aligned to the min. I/O unit size up. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-01-25UBI: amend array sizeArtem Bityutskiy
Since the data offset parameter was removed, the size of the parameters array is now 2, not 3. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-01-25UBI: add auto-resize featureArtem Bityutskiy
The problem: NAND flashes have different amount of initial bad physical eraseblocks (marked as bad by the manufacturer). For example, for 256MiB Samsung OneNAND flash there might be from 0 to 40 bad initial eraseblocks, which is about 2%. When UBI is used as the base system, one needs to know the exact amount of good physical eraseblocks, because this number is needed to create the UBI image which is put to the devices during production. But this number is not know, which forces us to use the minimum number of good physical eraseblocks. And UBI additionally reserves some percentage of physical eraseblocks for bad block handling (default is 1%), so we have 1-3% of PEBs reserved at the end, depending on the amount of initial bad PEBs. But it is desired to always have 1% (or more, depending on the configuration). Solution: this patch adds an "auto-resize" flag to the volume table. The volume which has the "auto-resize" flag will automatically be re-sized (enlarged) on the first UBI initialization. UBI clears the flag when the volume is re-sized. Only one volume may have the "auto-resize" flag. So, the production UBI image may have one volume with "auto-resize" flag set, and its size is automatically adjusted on the first boot of the device. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-01-25UBI: get rid of ubi_ltree_slabArtem Bityutskiy
This slab cache is not really needed since the number of objects is low and the constructor does not make much sense because we allocate oblects when doint I/O, which is way slower then allocation. Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: bugfix: do not forget to increment vol_countArtem Bityutskiy
When creating a new volume, do not forget to increment the vol_count variable. Also, users are not interested in internal volumes, so do not show them in the volumes_count sysfs file. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: do not support kiBArtem Bityutskiy
Be strict and accept only KiB, MiB and GiB, not Kib, not kib, etc. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: add mtd_num sysfs attributeArtem Bityutskiy
Expose number or the underlying MTD device in sysfs. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: fix mtd device string parsingArtem Bityutskiy
UBI allows to specify MTD device name or number when the module is being loaded. When parsing MTD device identity string, it first tries to treat it as device NAME, and if that fails, it treats it as device number. Make it vice-versa as this is more logical and makes less troubles when you have an MTD device named "1" and try to load mtd1 which has different name. This is especially easy to hit when gluebi is enabled. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: use separate mutex for volumes checkingArtem Bityutskiy
Introduce a separate mutex which serializes volumes checking, because we cammot really use volumes_mutex - it cases reverse locking problems with mtd_tbl_mutex when gluebi is used - thanks to lockdep. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: handle attach ioctlArtem Bityutskiy
Actually implement the MTD device attach/detach handlers. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: remove data_offsetArtem Bityutskiy
'data_offset' parameter does not really make sense and it is not needed. Get rid of it. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: prepare attach and detach functionsArtem Bityutskiy
Prepare the attach and detach functions to by used outside of module initialization: * detach function checks reference count before detaching * it kills the background thread as well Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: add UBI devices reference countingArtem Bityutskiy
This is one more step on the way to "removable" UBI devices. It adds reference counting for UBI devices. Every time a volume on this device is opened - the device's refcount is increased. It is also increased if someone is reading any sysfs file of this UBI device or of one of its volumes. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: add UBI control deviceArtem Bityutskiy
This patch is a preparation to make UBI devices dynamic. It adds an UBI control device which has dynamically allocated major number and registers itself as "ubi_ctrl". It does not do anything so far. The idea is that this device will allow to attach/detach MTD devices from userspace. This is symilar to what the Linux device mapper has. The next things to do are: * Fix UBI, because it now assumes UBI devices cannot go away * Implement control device ioctls which will attach/detach MTD devices Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: fix printkArtem Bityutskiy
Add proper log level to printk's. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: simplify error handlingArtem Bityutskiy
If we fail halfway through sysfs file creation, we may just call sysfs remove function and it will delete all the files we created. For non-existing files it will also be OK - the remove functions just return -ENOENT. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: tweak volumes lockingArtem Bityutskiy
Transform vtbl_mutex to volumes_mutex - this just makes code easier to understand. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: improve internal interfacesArtem Bityutskiy
Pass volume description object to the EBA function which makes more sense, and EBA function do not have to find the volume description object by volume ID. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: bugfix: dont oops with NULL module parameterArtem Bityutskiy
E.g., it oopsed in case of: modprobe ubi mtd = 0 Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: remove ubi_devices_cntArtem Bityutskiy
This global variablea is not really needed, remove it Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: create ubi_wl_entry slab on initializationArtem Bityutskiy
Similarly to ltree_entry_slab, it makes more sense to create and destroy ubi_wl_entry slab on module initialization/exit. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: create ltree_entry slab on initializationArtem Bityutskiy
Since the ltree_entry slab cache is a global entity, which is used by all UBI devices, it is more logical to create it on module initialization time and destro on module exit time. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: improve error messagesArtem Bityutskiy
Always print error code with error messages, sometimes it is extremely helpful info. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-12-26UBI: remove redundant fieldArtem Bityutskiy
Remove redundant ubi->major field - we have it in ubi->cdev.dev already. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-10-14UBI: do not use vmalloc on I/O pathArtem Bityutskiy
Similar reason as in case of the previous patch: it causes deadlocks if a filesystem with writeback support works on top of UBI. So pre-allocate needed buffers when attaching MTD device. We also need mutexes to protect the buffers, but they do not cause much contantion because they are used in recovery, torture, and WL copy routines, which are called seldom. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: remove unneeded error checksArtem Bityutskiy
Pointed to by viro. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: fix messageVinit Agnihotri
Increase UBI devices couter after the message, not before. Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: use is_power_of_2()Vignesh Babu
Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2 Signed-off-by: Vignesh Babu <vignesh.babu@wipro.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: fix freeing ubi->vtbl while unloadingVinit Agnihotri
ubi->vtbl is allocated using vmalloc() in vtbl.c empty_create_lvol(), but it is freed in build.c with kfree() Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-07-18UBI: use vmalloc for large buffersArtem Bityutskiy
UBI allocates temporary buffers of PEB size, which may be 256KiB. Use vmalloc instead of kmalloc for such big temporary buffers. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-04-27UBI: Unsorted Block ImagesArtem B. Bityutskiy
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>