1. 19 Sep, 2010 1 commit
    • Artem Bityutskiy's avatar
      UBIFS: introduce new flags for RO mounts · 2ef13294
      Artem Bityutskiy authored
      Commit 2fde99cb "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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2ef13294
  2. 17 Sep, 2010 1 commit
    • Artem Bityutskiy's avatar
      UBIFS: introduce new flag for RO due to errors · 2680d722
      Artem Bityutskiy authored
      The R/O state may have various reasons:
      
      1. The UBI volume is R/O
      2. The FS is mounted R/O
      3. The FS switched to R/O mode because of an error
      
      However, in UBIFS we have only one variable which represents cases
      1 and 3 - 'c->ro_media'. Indeed, we set this to 1 if we switch to
      R/O mode due to an error, and then we test it in many places to
      make sure that we stop writing as soon as the error happens.
      
      But this is very unclean. One consequence of this, for example, is
      that in 'ubifs_remount_fs()' we use 'c->ro_media' to check whether
      we are in R/O mode because on an error, and we print a message
      in this case. However, if we are in R/O mode because the media
      is R/O, our message is bogus.
      
      This patch introduces new flag - 'c->ro_error' which is set when
      we switch to R/O mode because of an error. It also changes all
      "if (c->ro_media)" checks to "if (c->ro_error)" checks, because
      this is what the checks actually mean. We do not need to check
      for 'c->ro_media' because if the UBI volume is in R/O mode, we
      do not allow R/W mounting, and now writes can happen. This is
      guaranteed by VFS. But it is good to double-check this, so this
      patch also adds many "ubifs_assert(!c->ro_media)" checks.
      
      In the 'ubifs_remount_fs()' function this patch makes a bit more
      changes - it fixes the error messages as well.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2680d722
  3. 07 Sep, 2010 2 commits
  4. 30 Aug, 2010 11 commits
    • Artem Bityutskiy's avatar
      UBIFS: improve error reporting when reading bad node · 3a8fa0ed
      Artem Bityutskiy authored
      When an error happens during validation of read node, the typical situation is that
      the LEB we read is unmapped (due to some bug). It is handy to include the mapping
      status into the error message.
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3a8fa0ed
    • 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
  5. 29 Aug, 2010 3 commits
  6. 28 Aug, 2010 22 commits