Skip to content
  1. May 23, 2011
    • Artem Bityutskiy's avatar
      UBIFS: switch to dynamic printks · 56e46742
      Artem Bityutskiy authored
      
      
      Switch to debugging using dynamic printk (pr_debug()). There is no good reason
      to carry custom debugging prints if there is so cool and powerful generic
      dynamic printk infrastructure, see Documentation/dynamic-debug-howto.txt. With
      dynamic printks we can switch on/of individual prints, per-file, per-function
      and per format messages. This means that instead of doing old-fashioned
      
      echo 1 > /sys/module/ubifs/parameters/debug_msgs
      
      to enable general messages, we can do:
      
      echo 'format "UBIFS DBG gen" +ptlf' > control
      
      to enable general messages and additionally ask the dynamic printk
      infrastructure to print process ID, line number and function name. So there is
      no reason to keep UBIFS-specific crud if there is more powerful generic thing.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      56e46742
  2. May 20, 2011
  3. May 16, 2011
  4. May 14, 2011
    • Artem Bityutskiy's avatar
      UBIFS: fix a rare memory leak in ro to rw remounting path · eaeee242
      Artem Bityutskiy authored
      
      
      When re-mounting from R/O mode to R/W mode and the LEB count in the superblock
      is not up-to date, because for the underlying UBI volume became larger, we
      re-write the superblock. We allocate RAM for these purposes, but never free it.
      So this is a memory leak, although very rare one.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Cc: stable@kernel.org
      eaeee242
    • Artem Bityutskiy's avatar
      UBIFS: fix inode size debugging check failure · c1f1f91d
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      c1f1f91d
    • Artem Bityutskiy's avatar
      UBIFS: fix debugging FS checking failure · 45cd5cdd
      Artem Bityutskiy authored
      
      
      When the debugging self-checks are enabled, we go trough whole file-system
      after mount and check/validate every single node referred to by the index.
      This is implemented by the 'dbg_check_filesystem()' function. However, this
      function fails if we mount "unclean" file-system, i.e., if we mount the
      file-system after a power cut. It fails with the following symptoms:
      
      UBIFS DBG (pid 8171): ubifs_recover_size: ino 937 size 3309925 -> 3317760
      UBIFS: recovery deferred
      UBIFS error (pid 8171): check_leaf: data node at LEB 1000:0 is not within inode size 3309925
      
      The reason of failure is that recovery fixed up the inode size in memory, but
      not on the flash so far. So the value on the flash is incorrect so far,
      and would be corrected when we re-mount R/W. But 'check_leaf()' ignores
      this fact and tries to validate the size of the on-flash inode, which is
      incorrect, so it fails.
      
      This patch teaches the checking code to look at the VFS inode cache first,
      and if there is the inode in question, use that inode instead of the inode
      on the flash media. This fixes the issue.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      45cd5cdd
    • Artem Bityutskiy's avatar
      UBIFS: remove an unneeded check · 69f8a75a
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      69f8a75a
    • Artem Bityutskiy's avatar
      UBIFS: fix debugging message · 4c954520
      Artem Bityutskiy authored
      
      
      When recovering the inode size, one of the debugging messages was printed
      incorrecly, this patches fixes it.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      4c954520
    • Artem Bityutskiy's avatar
      UBIFS: refactor ubifs_rcvry_gc_commit · fe79c05f
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      fe79c05f
    • Artem Bityutskiy's avatar
      UBIFS: split ubifs_rcvry_gc_commit · 44744213
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      44744213
    • Artem Bityutskiy's avatar
      UBIFS: dump the stack on errors in failure mode too · ec068142
      Artem Bityutskiy authored
      
      
      When UBIFS is in the failure mode (used for power cut emulation testing) we for
      some reasons do not dump the stack in many places, e.g., in assertions.
      Probably at early days we had too many of them and disabled this to make the
      development easier, but then never enabled. Nowadays I sometimes observe
      assertion failures during power cut testing, but the useful stackdump is not
      printed, which is bad. This patch makes UBIFS always print the stackdump when
      debugging is enabled.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      ec068142
    • Artem Bityutskiy's avatar
      UBIFS: print useful debugging messages when cannot recover gc_lnum · 6d5904e0
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      6d5904e0
    • Artem Bityutskiy's avatar
      UBIFS: remove dead GC LEB recovery piece of code · bcdca3e1
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      bcdca3e1
    • Artem Bityutskiy's avatar
      UBIFS: remove duplicated code · 2405f594
      Artem Bityutskiy authored
      
      
      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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2405f594
    • Artem Bityutskiy's avatar
      UBIFS: remove strange commentary · 2cd0a60c
      Artem Bityutskiy authored
      
      
      Remove the following commentary from 'ubifs_file_mmap()':
      
      /* 'generic_file_mmap()' takes care of NOMMU case */
      
      I do not understand what it means, and I could not find anything relater to
      NOMMU in 'generic_file_mmap()'.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2cd0a60c
    • Artem Bityutskiy's avatar
      UBIFS: do not change debugfs file position · 341e262f
      Artem Bityutskiy authored
      
      
      This patch is a tiny improvement which removes few bytes of code.
      UBIFS debugfs files are non-seekable and the file position is ignored,
      so do not increase it in the write handler.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      341e262f
    • Artem Bityutskiy's avatar
      UBIFS: fix oops in lprops dump function · 1321657d
      Artem Bityutskiy authored
      
      
      The 'dbg_dump_lprop()' is trying to detect journal head LEBs when printing,
      so it looks at the write-buffers. However, if we are in R/O mode, we
      de-allocate the write-buffers, so 'dbg_dump_lprop()' oopses. This patch fixes
      the issue.
      
      Note, this patch is not critical, it is only about the debugging code path, and
      it is unlikely that anyone but UBIFS developers would ever hit this issue.
      
      Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      1321657d