01 Jun, 2011

2 commits

  • This patch fixes an oops in the error path of 'ubi_attach_mtd_dev()'. If
    anything after 'uif_init()' fails, we get an oops in 'cancel_pending()'. The
    reason is that 'uif_close()' drops the last reference count for 'ubi->dev' and
    whole 'struct ubi_device' is freed. And then
    'ubi_wl_close()'->'cancel_pending()' tries to access the 'ubi' pointer and
    problems begin.

    Note, in 'ubi_detach_mtd_dev()' function we get a device reference to
    work-around this issue. Do the same in the error path of
    'ubi_attach_mtd_dev()'.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • 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
     

19 Mar, 2011

1 commit

  • * 'linux-next' of git://git.infradead.org/ubifs-2.6: (25 commits)
    UBIFS: clean-up commentaries
    UBIFS: save 128KiB or more RAM
    UBIFS: allocate orphans scan buffer on demand
    UBIFS: allocate lpt dump buffer on demand
    UBIFS: allocate ltab checking buffer on demand
    UBIFS: allocate scanning buffer on demand
    UBIFS: allocate dump buffer on demand
    UBIFS: do not check data crc by default
    UBIFS: simplify UBIFS Kconfig menu
    UBIFS: print max. index node size
    UBIFS: handle allocation failures in UBIFS write path
    UBIFS: use max_write_size during recovery
    UBIFS: use max_write_size for write-buffers
    UBIFS: introduce write-buffer size field
    UBI: incorporate LEB offset information
    UBIFS: incorporate maximum write size
    UBI: provide LEB offset information
    UBI: incorporate maximum write size
    UBIFS: fix LEB number in printk
    UBIFS: restrict world-writable debugfs files
    ...

    Linus Torvalds
     

16 Mar, 2011

2 commits

  • 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
     
  • This patch kills the 'ubi->dbg_peb_buf' debugging buffer and the
    associated mutex, because all users of this buffer are now gone.
    We are killing this buffer because we are going to switch to
    dynamic debugging control, just like in UBIFS, which means that
    CONFIG_MTD_UBI_DEBUG_PARANOID will be removed. In this case we'd
    end up always allocating 'ubi->dbg_peb_buf', which is rather large
    (128KiB or more), and this would be wasteful. Thus, we are just
    killing it.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

08 Mar, 2011

1 commit


07 Feb, 2011

1 commit

  • During scanning UBI allocates one struct ubi_scan_leb object for each PEB,
    so it can end up allocating thousands of them. Use slab cache to reduce
    memory consumption for these 48-byte objects, because currently used
    'kmalloc()' ends up allocating 64 bytes per object, instead of 48.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

26 Jan, 2011

1 commit

  • Wrong macro was used in calculating the data offset: UBI_EC_HDR_SIZE instead of
    UBI_VID_HDR_SIZE. The data offset should be VID header offset + VID header size
    (aligned to the minimum I/O unit).

    This was not a bug only because currently UBI_EC_HDR_SIZE and UBI_VID_HDR_SIZE
    have the same value of 64 bytes.

    Commit message was amended by Artem.

    Signed-off-by: John Ogness
    Signed-off-by: Artem Bityutskiy

    John Ogness
     

19 Oct, 2010

2 commits

  • Currently UBI erases all corrupted eraseblocks, irrespectively of the nature
    of corruption: corruption due to power cuts and non-power cut corruption.
    The former case is OK, but the latter is not, because UBI may destroy
    potentially important data.

    With this patch, during scanning, when UBI hits a PEB with corrupted VID
    header, it checks whether this PEB contains only 0xFF data. If yes, it is
    safe to erase this PEB and it is put to the 'erase' list. If not, this may
    be important data and it is better to avoid erasing this PEB. Instead,
    UBI puts it to the corr list and moves out of the pool of available PEB.
    IOW, UBI preserves this PEB.

    Such corrupted PEB lessen the amount of available PEBs. So the more of them
    we accumulate, the less PEBs are available. The maximum amount of non-power
    cut corrupted PEBs is 8.

    This patch is a response to UBIFS problem where reporter
    (Matthew L. Creech ) observes that UBIFS index points
    to an unmapped LEB. The theory is that corresponding PEB somehow got
    corrupted and UBI wiped it. This patch (actually a series of patches)
    tries to make sure such PEBs are preserved - this would make it is easier
    to analyze the corruption.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • One line was longer than 80 lines, make it shorter.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

02 Aug, 2010

1 commit

  • Currently, when UBI attaches an MTD device and cannot reserve all 1% (by
    default) of PEBs for bad eraseblocks handling, it prints a warning. However,
    Matthew L. Creech is not very happy to see this warning,
    because he did reserve enough of PEB at the beginning, but with time some
    PEBs became bad. The warning is not necessary in this case.

    This patch makes UBI print the warning
    o if this is a new image
    o of this is used image and the amount of reserved PEBs is only 10% (or less)
    of the size of the reserved PEB pool.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

06 May, 2010

1 commit

  • UBI can be built into the kernel or be compiled as a kernel module.
    Further on the command line one can specify MTD devices to be attach to
    UBI while loading. In the current implementation the UBI driver refuses
    to load if one of the MTD devices cannot be attached.

    Consider:
    1) UBI compiled into the kernel and
    2) a MTD device specified on the command line and
    3) this MTD device contains bogus data (for whatever reason).

    During init UBI tries to attach the MTD device is this fails the whole
    UBI subsystem isn't initialized. Later the userspace cannot attach any
    MTD to UBI because UBI isn't loaded.

    This patch keeps the current behaviour: if UBI is compiled as a module
    and a MTD device cannot be attached the UBI module cannot be loaded,
    but changes it for the UBI-is-built-into-the-kernel usecase.

    If UBI is builtin, a not attachable MTD device doen't stop UBI from
    initializing. This slightly modifies the behaviour if multiple MTD
    devices are specified on the command line. Now every MTD device is
    probed and, if possible, attached, i.e. a faulty MTD device doesn't
    stop the others from being attached.

    Artem: tweaked the patch

    Signed-off-by: Marc Kleine-Budde
    Signed-off-by: Artem Bityutskiy

    Marc Kleine-Budde
     

03 May, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

08 Mar, 2010

1 commit

  • Passing the attribute to the low level IO functions allows all kinds
    of cleanups, by sharing low level IO code without requiring
    an own function for every piece of data.

    Also drivers can extend the attributes with own data fields
    and use that in the low level function.

    This makes the class attributes the same as sysdev_class attributes
    and plain attributes.

    This will allow further cleanups in drivers.

    Full tree sweep converting all users.

    Signed-off-by: Andi Kleen
    Signed-off-by: Greg Kroah-Hartman

    Andi Kleen
     

01 Feb, 2010

3 commits

  • In the error path of 'ubi_attach_mtd_dev()' we have a tricky situation:
    we have to release things differently depending on at which point
    the failure happening. Namely, if @ubi->dev is not initialized, we have
    to free everything ourselves. But if it was, we should not free the @ubi
    object, because it will be freed in the 'dev_release()' function. And
    we did not get this situation right.

    This patch introduces additional argument to the 'uif_init()' function.
    On exit, this argument indicates whether the final 'free(ubi)' will
    happen in 'dev_release()' or not. So the caller always knows how to
    properly release the resources.

    Impact: all memory is now correctly released when UBI fails to attach
    an MTD device.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch adds a capability to attach MTD devices by their character
    device paths. For example, one can do:

    $ modprobe ubi mtd=/dev/mtd0

    to attach /dev/mtd0.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • The @mtd_devs and @mtd_dev_param variables are used only during the
    initialization, and all functions that use the variables have
    the __init prefix. This means we can safely mark the variables
    as __initdata, which is a tiny optimization.

    Impact: tiny RAM consumption optimization when UBI is used as a kernel
    module.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

20 Oct, 2009

1 commit


07 Jul, 2009

1 commit

  • This commit fixes NOR flash recovery issues observed with Spansion
    S29GL512N NOR.

    When NOR erases, it first fills PEBs with zeroes, then sets all bytes
    to 0xFF. Filling with zeroes starts from the end of the PEB. And when
    power is cut, this results in PEBs containing correct EC and VID headers
    but corrupted with zeros at the end. This confuses UBI and it mistakinly
    accepts these PEBs and associate them with LEBs.

    Fis this issue by zeroing EC and VID magics before erasing PEBs, to
    make UBI later refuse zem.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

05 Jul, 2009

1 commit

  • 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
    Signed-off-by: Artem Bityutskiy

    Adrian Hunter
     

10 Jun, 2009

1 commit

  • Terminate the UBI background thread prior to restarting the system.

    [Artem: amended comments a little]

    Signed-off-by: Kevin Cernekee
    Tested-by: Artem Bityutskiy
    Signed-off-by: Artem Bityutskiy

    Kevin Cernekee
     

02 Jun, 2009

2 commits

  • UBI volume notifications are intended to create the API to get clients
    notified about volume creation/deletion, renaming and re-sizing. A
    client can subscribe to these notifications using 'ubi_volume_register()'
    and cancel the subscription using 'ubi_volume_unregister()'. When UBI
    volumes change, a blocking notifier is called. Clients also can request
    "added" events on all volumes that existed before client subscribed
    to the notifications.

    If we use notifications instead of calling functions like 'ubi_gluebi_xxx()',
    we can make the MTD emulation layer to be more flexible: build it as a
    separate module and load/unload it on demand.

    [Artem: many cleanups, rework locking, add "updated" event, provide
    device/volume info in notifiers]

    Signed-off-by: Dmitry Pervushin
    Signed-off-by: Artem Bityutskiy

    Dmitry Pervushin
     
  • This patch improves UBI errors handling. ATM UBI switches to
    R/O mode when the WL worker fails to read the source PEB.
    This means that the upper layers (e.g., UBIFS) has no
    chances to unmap the erroneous PEB and fix the error.
    This patch changes this behaviour and makes UBI put PEBs
    like this into a separate RB-tree, thus preventing the
    WL worker from hitting the same read errors again and
    again.

    But there is a 10% limit on a maximum amount of PEBs like this.
    If there are too much of them, UBI switches to R/O mode.

    Additionally, this patch teaches UBI not to panic and
    switch to R/O mode if after a PEB has been copied, the
    target LEB cannot be read back. Instead, now UBI cancels
    the operation and schedules the target PEB for torturing.

    The error paths has been tested by ingecting errors
    into 'ubi_eba_copy_leb()'.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

26 May, 2009

1 commit

  • This patch fixes a minor problem where we may fail to wake
    upe the UBI background thread. This is not fatal at all,
    it may just result at sligtly worse performace for a short
    period of time, just because the thread will be woken up
    when real I/O on the UBI starts.

    Anywey, the issue is the race condition between
    'ubi_attach_mtd_dev()' and 'ubi_thread()'. If we do not
    serialize them, the 'wake_up_process()' call may be done
    before 'ubi_thread()' went seep, but after it checked
    'ubi->thread_enabled'.

    This issue was spotted by Shin Hong

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

18 May, 2009

3 commits


21 Jan, 2009

2 commits


05 Jan, 2009

1 commit


23 Dec, 2008

1 commit


10 Dec, 2008

2 commits

  • MTD internal API presently uses 32-bit values to represent
    device size. This patch updates them to 64-bits but leaves
    the external API unchanged. Extending the external API
    is a separate issue for several reasons. First, no one
    needs it at the moment. Secondly, whether the implementation
    is done with IOCTLs, sysfs or both is still debated. Thirdly
    external API changes require the internal API to be accepted
    first.

    Note that although the MTD API will be able to support 64-bit
    device sizes, existing drivers do not and are not required
    to do so, although NAND base has been updated.

    In general, changing from 32-bit to 64-bit values cause little
    or no changes to the majority of the code with the following
    exceptions:
    - printk message formats
    - division and modulus of 64-bit values
    - NAND base support
    - 32-bit local variables used by mtdpart and mtdconcat
    - naughtily assuming one structure maps to another
    in MEMERASE ioctl

    Signed-off-by: Adrian Hunter
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Adrian Hunter
     
  • Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon
    failing vmalloc().

    Signed-off-by: Stefan Roese
    Signed-off-by: Artem Bityutskiy

    Stefan Roese
     

25 Jul, 2008

1 commit

  • This fix only affects UBI debugging.

    If the the background thread is disabled for debugging purposes,
    start it anyway, because otherwise we see tonns of kernel debugging
    complaints like this:

    INFO: task ubi_bgt0d:26857 blocked for more than 120 seconds.
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    ubi_bgt0d D dd37bf94 0 26857 2
    dd37bfcc 00000086 f8e17cea dd37bf94 00000046 00000000 00000000 f5c62430
    f5c62430 f5c62590 c2a09c80 f6cbd498 dd8e9cbc 00000296 dd37bfb0 00000296
    dd8e9cb8 dd8e9cbc dd37bfcc c0119774 00000000 00000000 c0132e89 f6961560
    Call Trace:
    [] ? ubi_thread+0x0/0x127 [ubi]
    [] ? complete+0x43/0x4b
    [] ? kthread+0x0/0x5b
    [] ? ubi_thread+0x0/0x127 [ubi]
    [] kthread+0x25/0x5b
    [] ? kthread+0x0/0x5b
    [] kernel_thread_helper+0x7/0x14
    =======================

    So start it, and go sleep inside it, instead of creating it and never
    start.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

24 Jul, 2008

5 commits