1. 30 Aug, 2010 10 commits
    • Artem Bityutskiy's avatar
      UBIFS: introduce list sorting debugging checks · 3bb66b47
      Artem Bityutskiy authored
      The UBIFS bug in the GC list sorting comparison functions inspired
      me to write internal debugging check functions which verify that
      the list of nodes is sorted properly.
      
      So, this patch implements 2 new debugging functions:
       o 'dbg_check_data_nodes_order()' - check order of data nodes list
       o 'dbg_check_nondata_nodes_order()' - check order of non-data nodes list
      
      The debugging functions are executed only if general UBIFS debugging checks are
      enabled. And they are compiled out if UBIFS debugging is disabled.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3bb66b47
    • Artem Bityutskiy's avatar
      UBIFS: fix assertion warnings in comparison function · 1a9476a7
      Artem Bityutskiy authored
      When running the integrity test ('integck' from mtd-utils) on current
      UBIFS on 2.6.35, I see that assertions in UBIFS 'list_sort()' comparison
      functions trigger sometimes, e.g.:
      
      UBIFS assert failed in data_nodes_cmp at 132 (pid 28311)
      
      My investigation showed that this happens when 'list_sort()' calls the 'cmp()'
      function with equivalent arguments. In this case, the 'struct list_head'
      parameter, passed to 'cmp()' is bogus, and it does not belong to any element in
      the original list.
      
      And this issue seems to be introduced by commit:
      
      commit 835cc0c8
      Author: Don Mullis <don.mullis@gmail.com>
      Date:   Fri Mar 5 13:43:15 2010 -0800
      
      It is easy to work around the issue by doing:
      
      if (a == b)
      	return 0;
      
      in UBIFS. It works, but 'lib_sort()' should nevertheless be fixed. Although it
      is harmless to have this piece of code in UBIFS.
      
      This patch adds that code to both UBIFS 'cmp()' functions:
      'data_nodes_cmp()' and 'nondata_nodes_cmp()'.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      1a9476a7
    • Artem Bityutskiy's avatar
      UBIFS: mark unused key objects as invalid · ba2f48f7
      Artem Bityutskiy authored
      When scanning the flash, UBIFS builds a list of flash nodes of type
      'struct ubifs_scan_node'. Each scanned node has a 'snod->key' field. This field
      is valid for most of the nodes, but invalid for some node type, e.g., truncation
      nodes. It is safer to explicitly initialize such keys to something invalid,
      rather than leaving them initialized to all zeros, which has key type of
      UBIFS_INO_KEY.
      
      This patch introduces new "fake" key type UBIFS_INVALID_KEY and initializes
      unused 'snod->key' objects to this type. It also adds debugging assertions in
      the TNC code to make sure no one ever tries to look these nodes up in the TNC.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      ba2f48f7
    • Artem Bityutskiy's avatar
      UBIFS: do not write rubbish into truncation scanning node · 5b7a3a2e
      Artem Bityutskiy authored
      In the scanning code, in 'ubifs_add_snod()', we write rubbish into
      'snod->key', because we assume that on-flash truncation nodes have a key, but
      they do not. If the other parts of UBIFS then mistakenly try to look-up
      the truncation node key (they should not do this, but may do because of a bug),
      we can succeed and corrupt TNC. It looks like we did have such a situation in
      'sort_nodes()' in gc.c.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      5b7a3a2e
    • Artem Bityutskiy's avatar
      UBIFS: improve assertion in node comparison functions · 66576833
      Artem Bityutskiy authored
      Improve assertions in gc.c in the comparison functions for 'list_sort()': check
      key types _and_ node types.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      66576833
    • Artem Bityutskiy's avatar
      UBIFS: do not use key type in list_sort · ab87118d
      Artem Bityutskiy authored
      In comparison function for 'list_sort()' we use key type to distinguish between
      node types. However, we have a bit simper way to detect node type -
      'snod->type'. This more logical to use, comparing to decoding key types. Also
      allows to get rid of 2 local variables.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      ab87118d
    • Artem Bityutskiy's avatar
      UBIFS: do not look up truncation nodes · 44ec83b8
      Artem Bityutskiy authored
      When moving nodes in GC, do not try to look up truncation nodes in TNC,
      because they do not exist there. This would be harmless, because the TNC
      look-up would fail, if we did not have bug 'ubifs_add_snod()' which reads
      garbage into 'snod->key'. But in any case, it is less error prone to
      explicitly ignore everything but inode, data, dentry and xentry nodes.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      44ec83b8
    • Artem Bityutskiy's avatar
      UBIFS: fix assertion warning · e3408ad4
      Artem Bityutskiy authored
      This patch fixes the following false assertion warning:
      
      UBIFS assert failed in data_nodes_cmp at 130 (pid 15107)
      
      The assertion was wrong because it did not take into account that the
      node can be an xentry.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      e3408ad4
    • Artem Bityutskiy's avatar
      UBIFS: do not treat ENOSPC specially · efe1881f
      Artem Bityutskiy authored
      'ubifs_garbage_collect_leb()' should never return '-ENOSPC', and if it
      does, this is an error. Thus, do not treat this error code specially.
      '-EAGAIN' is a special error code, but not '-ENOSPC'.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      efe1881f
    • Artem Bityutskiy's avatar
      UBIFS: switch to RO mode after synchronizing · 5ffef88f
      Artem Bityutskiy authored
      In 'ubifs_garbage_collect()' on error path, we first switch to R/O mode, and
      then synchronize write-buffers (to make sure no data are lost). But the GC
      write-buffer synchronization will fail, because we are already in R/O mode.
      This patch re-orders this and makes sure we first synchronize the write-buffer,
      and then switch to R/O mode.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      5ffef88f
  2. 29 Aug, 2010 3 commits
  3. 28 Aug, 2010 27 commits