1. 27 3月, 2015 2 次提交
    • R
      UBI: Fastmap: Fix race after ubi_wl_get_peb() · 8fb2a514
      Richard Weinberger 提交于
      ubi_wl_get_peb() returns a fresh PEB which can be used by
      user of UBI. Due to the pool logic fastmap will correctly
      map this PEB upon attach time because it will be scanned.
      
      If a new fastmap is written (due to heavy parallel io)
      while the before the fresh PEB is assigned to the EBA table
      it will not be scanned as it is no longer in the pool.
      So, the race window exists between ubi_wl_get_peb()
      and the EBA table assignment.
      We have to make sure that no new fastmap can be written
      while that.
      
      To ensure that ubi_wl_get_peb() will grab ubi->fm_sem in read mode
      and the user of ubi_wl_get_peb() has to release it after the PEB
      got assigned.
      Signed-off-by: NRichard Weinberger <richard@nod.at>
      8fb2a514
    • R
      UBI: Fastmap: Fix race in ubi_eba_atomic_leb_change() · 36a87e44
      Richard Weinberger 提交于
      This function a) requests a new PEB, b) writes data to it,
      c) returns the old PEB and d) registers the new PEB in the EBA table.
      
      For the non-fastmap case this works perfectly fine and is powercut safe.
      Is fastmap enabled this can lead to issues.
      If a new fastmap is written between a) and c) the freshly requested PEB
      is no longer in a pool and will not be scanned upon attaching.
      If now a powercut happens between c) and d) the freshly requested PEB
      will not be scanned and the old one got already scheduled for erase.
      After attaching the EBA table will point to a erased PEB.
      
      Fix this issue by swapping steps c) and d).
      Signed-off-by: NRichard Weinberger <richard@nod.at>
      36a87e44
  2. 26 3月, 2015 1 次提交
  3. 24 2月, 2015 1 次提交
  4. 28 1月, 2015 2 次提交
    • A
      UBI: do propagate positive error codes up · 0e707ae7
      Artem Bityutskiy 提交于
      UBI uses positive function return codes internally, and should not propagate
      them up, except in the place this path fixes. Here is the original bug report
      from Dan Carpenter:
      
      The problem is really in ubi_eba_read_leb().
      
      drivers/mtd/ubi/eba.c
         412                  err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1);
         413                  if (err && err != UBI_IO_BITFLIPS) {
         414                          if (err > 0) {
         415                                  /*
         416                                   * The header is either absent or corrupted.
         417                                   * The former case means there is a bug -
         418                                   * switch to read-only mode just in case.
         419                                   * The latter case means a real corruption - we
         420                                   * may try to recover data. FIXME: but this is
         421                                   * not implemented.
         422                                   */
         423                                  if (err == UBI_IO_BAD_HDR_EBADMSG ||
         424                                      err == UBI_IO_BAD_HDR) {
         425                                          ubi_warn("corrupted VID header at PEB %d, LEB %d:%d",
         426                                                   pnum, vol_id, lnum);
         427                                          err = -EBADMSG;
         428                                  } else
         429                                          ubi_ro_mode(ubi);
      
      On this path we return UBI_IO_FF and UBI_IO_FF_BITFLIPS and it
      eventually gets passed to ERR_PTR().  We probably dereference the bad
      pointer and oops.  At that point we've gone read only so it was already
      a bad situation...
      
         430                          }
         431                          goto out_free;
         432                  } else if (err == UBI_IO_BITFLIPS)
         433                          scrub = 1;
         434
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      0e707ae7
    • R
      UBI: Add initial support for scatter gather · 9ff08979
      Richard Weinberger 提交于
      Adds a new set of functions to deal with scatter gather.
      ubi_eba_read_leb_sg() will read from a LEB into a scatter gather list.
      The new data structure struct ubi_sgl will be used within UBI to
      hold the scatter gather list itself and metadata to have a cursor
      within the list.
      Signed-off-by: NRichard Weinberger <richard@nod.at>
      Tested-by: NEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
      Reviewed-by: NEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
      9ff08979
  5. 07 11月, 2014 1 次提交
  6. 26 9月, 2014 1 次提交
  7. 03 10月, 2012 3 次提交
  8. 04 9月, 2012 1 次提交
  9. 21 5月, 2012 11 次提交
  10. 09 3月, 2012 3 次提交
  11. 30 11月, 2011 1 次提交
  12. 21 9月, 2011 1 次提交
  13. 19 10月, 2010 2 次提交
    • A
      UBI: preserve corrupted PEBs · 5fc01ab6
      Artem Bityutskiy 提交于
      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 <mlcreech@gmail.com>) 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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      5fc01ab6
    • A
      UBI: rename IO error code · 756e1df1
      Artem Bityutskiy 提交于
      Rename UBI_IO_BAD_HDR_READ into UBI_IO_BAD_HDR_EBADMSG which is presumably more
      self-documenting and readable. Indeed, the '_READ' suffix does not tell much and
      even confuses, while '_EBADMSG' tells about uncorrectable ECC error, because we
      use -EBADMSG all over the place to represent ECC errors.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      756e1df1
  14. 02 8月, 2010 1 次提交
    • A
      UBI: do not warn unnecessarily · 64d4b4c9
      Artem Bityutskiy 提交于
      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 <mlcreech@gmail.com> 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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      64d4b4c9
  15. 04 6月, 2010 2 次提交
  16. 21 9月, 2009 1 次提交
  17. 25 7月, 2009 1 次提交
  18. 10 6月, 2009 2 次提交
    • A
      UBI: handle more error codes · 6b5c94c6
      Artem Bityutskiy 提交于
      The UBIFS WL worker may encounter read errors and there is logic
      which makes a decision whether we should do one of:
      
      1. cancel the operation and move the PEB with the read errors to
         the 'erroneous' list;
      2. switch to R/O mode.
      
      ATM, only -EIO errors trigger 1., other errors trigger 2. The idea
      is that if we know we encountered an I/O error, do 1. Otherwise,
      we do not know how to react, and do 2., just in case. E.g., if
      the underlying driver became crazy because of a bug, we do not
      want to harm any data, and switch to R/O mode.
      
      This patch does 2 things:
      1. Makes sure reads from the source PEB always cause 1. This is
         more consistent with other reads which come from the upper
         layers and never cause R/O.
      2. Teaches UBI to do 1. also on -EBADMSG, UBI_IO_BAD_VID_HDR,
         -ENOMEM, and -ETIMEOUT. But this is only when reading the
         target PEB.
      
      This preblems were hunted by Adrian Hunter.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      6b5c94c6
    • A
      UBI: fix multiple spelling typos · 815bc5f8
      Artem Bityutskiy 提交于
      Some of the typos were indicated by Adrian Hunter,
      some by 'aspell'.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      815bc5f8
  19. 02 6月, 2009 3 次提交
    • A
      UBI: do not switch to R/O mode on read errors · b86a2c56
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      b86a2c56
    • A
      UBI: fix and clean-up error paths in WL worker · 87960c0b
      Artem Bityutskiy 提交于
      This patch fixes the error path in the WL worker - in same cases
      UBI oopses when 'goto out_error' happens and e1 or e2 are NULL.
      This patch also cleans up the error paths a little. And I have
      tested nearly all error paths in the WL worker.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      87960c0b
    • A
      UBI: introduce new constants · 90bf0265
      Artem Bityutskiy 提交于
      This patch is a clean-up and a preparation for the following
      patches. It introduece constants for the return values of the
      'ubi_eba_copy_leb()' function.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      90bf0265