24 Jan, 2014

1 commit


31 Aug, 2012

1 commit


22 Aug, 2012

1 commit


21 May, 2012

1 commit

  • We do not need this feature and to our shame it even was not working
    and there was a bug found very recently.
    -- Artem Bityutskiy

    Without the data type hint UBI2 (fastmap) will be easier to implement.

    Signed-off-by: Richard Weinberger
    Signed-off-by: Artem Bityutskiy

    Richard Weinberger
     

17 May, 2012

2 commits

  • This patch removes the 'dbg_err()' macro and we now use 'ubifs_err()' instead.
    The idea of 'dbg_err()' was to compile out some error message to make the
    binary a bit smaller - but I think it was a bad idea.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This commit re-names all functions which dump something from "dbg_dump_*()" to
    "ubifs_dump_*()". This is done for consistency with UBI and because this way it
    will be more logical once we remove the debugging sompilation option.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

29 Feb, 2012

1 commit


26 Aug, 2011

1 commit


08 Jul, 2011

1 commit

  • When the 1st LEB was unmapped and written but 2nd LEB not,
    the master node recovery doesn't succeed after power cut.
    We see following error when mounting UBIFS partition on NOR
    flash:

    UBIFS error (pid 1137): ubifs_recover_master_node: failed to recover master node

    Correct 2nd master node offset check is needed to fix the
    problem. If the 2nd master node is at the end in the 2nd LEB,
    first master node is used for recovery. When checking for this
    condition we should check whether the master node is exactly at
    the end of the LEB (without remaining empty space) or whether
    it is followed by an empty space less than the master node size.

    Artem: when the error happened, offs2 = 261120, sz = 512, c->leb_size = 262016.

    Signed-off-by: Anatolij Gustschin
    Signed-off-by: Artem Bityutskiy

    Anatolij Gustschin
     

04 Jul, 2011

3 commits

  • Switch the rest of direct UBI calls to UBIFS helper functions.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Instead of using 'ubi_read()' function directly, used the 'ubifs_leb_read()'
    helper function instead. This allows to get rid of several redundant error
    messages and make sure that we always have a stack dump on read errors.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Introduce the following I/O helper functions: 'ubifs_leb_read()',
    'ubifs_leb_write()', 'ubifs_leb_change()', 'ubifs_leb_unmap()',
    'ubifs_leb_map()', 'ubifs_is_mapped().

    The idea is to wrap all UBI I/O functions in order to encapsulate various
    assertions and error path handling (error message, stack dump, switching to R/O
    mode). And there are some other benefits of this which will be used in the
    following patches.

    This patch does not switch whole UBIFS to use these functions yet.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

01 Jun, 2011

3 commits

  • Unfortunately, the recovery fix d1606a59b6be4ea392eabd40d1250aa1eeb19efb
    (UBIFS: fix extremely rare mount failure) broke recovery. This commit make
    UBIFS drop the last min. I/O unit in all journal heads, but this is needed only
    for the GC head. And this does not work for non-GC heads. For example, if
    suppose we have min. I/O units A and B, and A contains a valid node X, which
    was fsynced, and then a group of nodes Y which spans the rest of A and B. In
    this case we'll drop not only Y, but also X, which is obviously incorrect.

    This patch fixes the issue and additionally makes recovery to drop last min.
    I/O unit only for the GC head, and leave things as they have been for ages for
    the other heads - this is safer.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Instead of passing "grouped" parameter to 'ubifs_recover_leb()' which tells
    whether the nodes are grouped in the LEB to recover, pass the journal head
    number and let 'ubifs_recover_leb()' look at the journal head's 'grouped' flag.

    This patch is a preparation to a further fix where we'll need to know the
    journal head number for other purposes.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Commit ab51afe05273741f72383529ef488aa1ea598ec6 was a good clean-up, but
    it introduced a regression - now UBIFS prints scary error messages during
    recovery on all corrupted nodes, even though the corruptions are expected
    (due to a power cut). This patch fixes the issue.

    Additionally fix a typo in a commentary introduced by the same commit.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

16 May, 2011

5 commits

  • This patch fixes an extremely rare mount failure after a power cut, when mount
    fails with ENOSPC error because UBIFS could not find the GC LEB.

    In short, the reason for this failure is that after recovery the GC head LEB
    contains less free space than it had contained just before the power cut
    happened. As a result, if the FS is full, 'ubifs_rcvry_gc_commit()' is unable
    to find a dirty LEB to GC and a free LEB, so mount fails.

    This patch contains a huge comment with more detailed explanation, please refer
    that comment.

    Since this is really really rare and unlikely situation, I do not send this
    patch to the stable tree, also because it requires a lot of preparation
    patches which I did before. So sending this to -stable would be too risky.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Further simplify 'ubifs_recover_leb()' by noticing that we have to call
    'clean_buf()' in any case, and it is fine to call it if the offset is
    aligned to 'c->min_io_size'. Thus, we do not have to call it separately
    from every "if" - just call it once at the end.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Now when we call 'ubifs_recover_leb()' only for LEBs which are potentially
    corrupted (i.e., only for last buds, not for all of them), we can cleanup every
    LEB, not only those where we find corruption. The reason - unstable bits. Even
    though the LEB may look good now, it might contain unstable bits which may hit
    us a bit later.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch cleans up 'ubifs_recover_leb()' function and makes it more readable.
    Move things which are done only once out of the loop and kill unneeded 'switch'
    statement.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Print a bit more information is some recovery and replay paths.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

14 May, 2011

8 commits

  • This patch fixes a problem with the following symptoms:

    UBIFS: deferred recovery completed
    UBIFS error (pid 15676): dbg_check_synced_i_size: ui_size is 11481088, synced_i_size is 11459081, but inode is clean
    UBIFS error (pid 15676): dbg_check_synced_i_size: i_ino 128, i_mode 0x81a4, i_size 11481088

    It happens when additional debugging checks are enabled and we are recovering
    from a power cut. When we fixup corrupted inode size during recovery, we change
    them in-place and we change ui_size as well, but not synced_i_size, which
    causes this failure. This patch makes sure we change both fields and fixes the
    issue.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • In 'ubifs_recover_size()' we have an "if (!e->inode && c->ro_mount)" statement.
    But if 'c->ro_mount' is true, then '!e->inode' must always be true as well. So
    we can remove the unnecessary '!e->inode' test and put an
    'ubifs_assert(!e->inode)' instead.

    This patch also removes an extra trailing white-space in a debugging print,
    as well as adds few empty lines to 'ubifs_recover_size()' to make it a bit more
    readable.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • When recovering the inode size, one of the debugging messages was printed
    incorrecly, this patches fixes it.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This commits refactors and cleans up 'ubifs_rcvry_gc_commit()' which was quite
    untidy, also removes the commentary which was not 100% correct.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • Split the 'ubifs_rcvry_gc_commit()' function and introduce a 'grab_empty_leb()'
    heler. This cleans 'ubifs_rcvry_gc_commit()' a little and makes it a bit less
    of spagetti.

    Also, add a commentary which explains why it is crucial to first search for an
    empty LEB and then run commit.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • If we fail to recover the gc_lnum we just return an error and it then
    it is difficult to figure out why this happened. This patch adds useful
    debugging information which should make it easier to debug the failure.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • This patch removes a piece of code in 'ubifs_rcvry_gc_commit()' which is never
    executed. We call 'ubifs_find_dirty_leb()' function with min_space =
    wbuf->offs, so if it returns us an LEB, it is guaranteed to have at lease
    'wbuf->offs' bytes of free+dirty space. So we can remove the subsequent code
    which deals with "returned LEB has less than 'wbuf->offs' bytes of free+dirty
    space". This simplifies 'ubifs_rcvry_gc_commit()' a little.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     
  • We have duplicated code in 'ubifs_garbage_collect()' and
    'ubifs_rcvry_gc_commit()', which is about handling the special case of free
    LEB. In both cases we just want to garbage-collect the LEB using
    'ubifs_garbage_collect_leb()'.

    This patch teaches 'ubifs_garbage_collect_leb()' to handle free LEB's so that
    the caller does not have to do this and the duplicated code is removed.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

21 Apr, 2011

1 commit

  • This patch fixes the following symptoms:
    1. Unmount UBIFS cleanly.
    2. Start mounting UBIFS R/W and have a power cut immediately
    3. Start mounting UBIFS R/O, this succeeds
    4. Try to re-mount UBIFS R/W - this fails immediately or later on,
    because UBIFS will write the master node to the flash area
    which has been written before.

    The analysis of the problem:

    1. UBIFS is unmounted cleanly, both copies of the master node are clean.
    2. UBIFS is being mounter R/W, starts changing master node copy 1, and
    a power cut happens. The copy N1 becomes corrupted.
    3. UBIFS is being mounted R/O. It notices the copy N1 is corrupted and
    reads copy N2. Copy N2 is clean.
    4. Because of R/O mode, UBIFS cannot recover copy 1.
    5. The mount code (ubifs_mount()) sees that the master node is clean,
    so it decides that no recovery is needed.
    6. We are re-mounting R/W. UBIFS believes no recovery is needed and
    starts updating the master node, but copy N1 is still corrupted
    and was not recovered!

    Fix this problem by marking the master node as dirty every time we
    recover it and we are in R/O mode. This forces further recovery and
    the UBIFS cleans-up the corruptions and recovers the copy N1 when
    re-mounting R/W later.

    Signed-off-by: Artem Bityutskiy
    Cc: stable@kernel.org

    Artem Bityutskiy
     

08 Mar, 2011

1 commit

  • When recovering from unclean reboots UBIFS scans the journal and checks nodes.
    If a corrupted node is found, UBIFS tries to check if this is the last node
    in the LEB or not. This is is done by checking if there only 0xFF bytes
    starting from the next min. I/O unit. However, since now we write in
    c->max_write_size, we should actually check for 0xFFs starting from the
    next max. write unit.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

08 Feb, 2011

1 commit


07 Feb, 2011

1 commit


17 Oct, 2010

1 commit


20 Sep, 2010

1 commit

  • Commit 2fde99cb55fb9d9b88180512a5e8a5d939d27fec "UBIFS: mark VFS SB RO too"
    introduced regression. This commit made UBIFS set the 'MS_RDONLY' flag in the
    VFS superblock when it switches to R/O mode due to an error. This was done
    to make VFS show the R/O UBIFS flag in /proc/mounts.

    However, several places in UBIFS relied on the 'MS_RDONLY' flag and assume this
    flag can only change when we re-mount. For example, 'ubifs_put_super()'.

    This patch introduces new UBIFS flag - 'c->ro_mount' which changes only when
    we re-mount, and preserves the way UBIFS was originally mounted (R/W or R/O).
    This allows us to de-initialize UBIFS cleanly in 'ubifs_put_super()'.

    This patch also changes all 'ubifs_assert(!c->ro_media)' assertions to
    'ubifs_assert(!c->ro_media && !c->ro_mount)', because we never should write
    anything if the FS was mounter R/O.

    All the places where we test for 'MS_RDONLY' flag in the VFS SB were changed
    and now we test the 'c->ro_mount' flag instead, because it preserves the
    original UBIFS mount type, unlike the 'MS_RDONLY' flag.

    Signed-off-by: Artem Bityutskiy

    Artem Bityutskiy
     

13 Jul, 2010

1 commit

  • UBIFS tries to alway have an LEB reserved for GC, and stores it
    in c->gc_lnum. Besides, there is GC head which points to the current
    GC head LEB.

    In case of an unclean power cut, what may happen is that the GC head
    was switched to the reserved GC LEB (c->gc_lnum), but a new reserved
    GC LEB was not created yet. So, after an unclean reboot we may have
    no reserved GC LEB, and we need to find a new LEB for this.

    To do this, we find a dirty LEB which can fit the current GC head,
    move the data, unmap this dirty LEB, and it becomes our reserved GC
    LEB.

    However, if we cannot find a dirty enough LEB, we return failure,
    which is wrong, because we still can have free LEBs to use for
    the reserved GC LEB. This patch fixes the issue.

    This patch also fixes few typos in comments, which were spotted by
    aspell.

    Note, this patch fixes a real issue

    [ 14.328117] UBIFS: recovery needed
    [ 53.941378] UBIFS error (pid 462): ubifs_rcvry_gc_commit: could not find a dirty LEB
    [ 89.606399] UBIFS: recovery completed
    [ 89.609329] UBIFS assert failed in mount_ubifs at 1358 (pid 462)
    [ 89.616165] [] (unwind_backtrace+0x0/0xe4) from [] (ubifs_fill_super+0x11d0/0x1c4c)
    [ 89.625930] [] (ubifs_fill_super+0x11d0/0x1c4c) from [] (ubifs_get_sb+0x1b0/0x354)
    [ 89.635696] [] (ubifs_get_sb+0x1b0/0x354) from [] (vfs_kern_mount+0x50/0xe0)
    [ 89.644485] [] (vfs_kern_mount+0x50/0xe0) from [] (do_kern_mount+0x34/0xdc)
    [ 89.653274] [] (do_kern_mount+0x34/0xdc) from [] (do_mount+0x148/0x7cc)
    [ 89.662063] [] (do_mount+0x148/0x7cc) from [] (sys_mount+0x98/0xc8)
    [ 89.670852] [] (sys_mount+0x98/0xc8) from [] (ret_fast_syscall+0x0/0x28)

    which was reported here:
    http://article.gmane.org/gmane.linux.drivers.mtd/29923
    by Alexander Pazdnikov

    Reported-by: Alexander Pazdnikov
    Signed-off-by: Artem Bityutskiy
    Reviewed-by: Adrian Hunter

    Artem Bityutskiy
     

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
     

04 Dec, 2009

1 commit

  • That is "success", "unknown", "through", "performance", "[re|un]mapping"
    , "access", "default", "reasonable", "[con]currently", "temperature"
    , "channel", "[un]used", "application", "example","hierarchy", "therefore"
    , "[over|under]flow", "contiguous", "threshold", "enough" and others.

    Signed-off-by: André Goddard Rosa
    Signed-off-by: Jiri Kosina

    André Goddard Rosa
     

10 Sep, 2009

1 commit

  • At the moment UBIFS print large and scary error messages and
    flash dumps in case of nearly any corruption, even if it is
    a recoverable corruption. For example, if the master node is
    corrupted, ubifs_scan() prints error dumps, then UBIFS recovers
    just fine and goes on.

    This patch makes UBIFS print scary error messages only in
    real cases, which are not recoverable. It adds 'quiet' argument
    to the 'ubifs_scan()' function, so the caller may ask 'ubi_scan()'
    not to print error messages if the caller is able to do recovery.

    Signed-off-by: Artem Bityutskiy
    Reviewed-by: Adrian Hunter

    Artem Bityutskiy
     

09 Jul, 2009

2 commits

  • In the 'ubifs_recover_leb()' function, when we find corrupted
    empty space, we dump 8K starting from the offset where the last
    node ends. This is OK if the corrupted empty space is somewhere
    near that offset. But if the corruption is far at the end of the
    LEB, we will dump all 0xFF bytes and complitely ignore the
    interesting data. This is observed on a PPC ("kilauea") with
    NOR flash.

    This patch changes the behavior and teaches UBIFS to print only
    interesting data. I.e., now we find where corruption starts and
    start dumping from that offset.

    Signed-off-by: Artem Bityutskiy
    Reviewed-by: Adrian Hunter

    Artem Bityutskiy
     
  • recovery.c has 'is_empty()' helper and it is better to use
    this helper instead of re-implementing it in several places.
    This patch does this and removes some amount of unneeded code.

    Signed-off-by: Artem Bityutskiy
    Reviewed-by: Adrian Hunter

    Artem Bityutskiy