1. 03 12月, 2010 1 次提交
    • A
      UBI: fix corrupted PEB detection for NOR flash · 7ac760c2
      Artem Bityutskiy 提交于
      My new shiny code for corrupted PEB detection has NOR specific bug.
      We tread PEB as corrupted and preserve it, if
      
      1. EC header is OK.
      2. VID header is corrupted.
      3. data area is not "all 0xFFs"
      
      In case of NOR we have 'nor_erase_prepare()' quirk, which invalidates
      the headers before erasing the PEB. And we invalidate first the VID
      header, and then the EC header. So if a power cut happens after we have
      invalidated the VID header, but before we have invalidated the EC
      header, we end up with a PEB which satisfies the above 3 conditions,
      and the scanning code will treat it as corrupted, and will print
      scary warnings, wrongly.
      
      This patch fixes the issue by firt invalidating the EC header, then
      invalidating the VID header. In case of power cut inbetween, we still
      just lose the EC header, and UBI can deal with this situation gracefully.
      
      Thanks to Anatolij Gustschin <agust@denx.de> for tracking this down.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Reported-by: NAnatolij Gustschin <agust@denx.de>
      Tested-by: NAnatolij Gustschin <agust@denx.de>
      7ac760c2
  2. 19 11月, 2010 1 次提交
  3. 21 10月, 2010 3 次提交
  4. 19 10月, 2010 13 次提交
    • 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: add truly corrupted PEBs to corrupted list · feeba4b8
      Artem Bityutskiy 提交于
      Start using the 'corr' list and add there PEBs which look truly corrupted,
      which means they have corrupted VID header and the data which follows the
      corrupted header does not contain all 0xFF bytes.
      
      At the moment, this does not change UBI functionality much because these
      PEBs will be erase when scanning finishes. But the plan is to teach UBI
      preserving them.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      feeba4b8
    • A
      UBI: introduce debugging helper function · 31532494
      Artem Bityutskiy 提交于
      Introduce a helper function to print hexdump: 'ubi_dbg_print_hex_dump()'.
      It is compiled out if debugging is enabled. Will be used in the next patch.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      31532494
    • A
      UBI: make check_pattern function non-static · bb00e180
      Artem Bityutskiy 提交于
      This patch turns static function 'check_pattern()' into a non-static
      'ubi_check_pattern()'. This is just a preparation for the chages which
      are coming in the next patches.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      bb00e180
    • A
      UBI: do not put eraseblocks to the corrupted list unnecessarily · 0525dac9
      Artem Bityutskiy 提交于
      Currently UBI maintains 2 lists of PEBs during scanning:
      1. 'erase' list - PEBs which have no corruptions but should be erased
      2. 'corr' list - PEBs which have some corruptions and should be erased
      
      But we do not really need 2 lists for PEBs which should be erased after
      scanning is done - this is redundant. So this patch makes sure all PEBs
      which are corrupted are moved to the head of the 'erase' list. We add
      them to the head to make sure they are erased first and we get rid of
      corruption ASAP.
      
      However, we do not remove the 'corr' list and realted functions, because
      the plan is to use this list for other purposes. Namely, we plan to
      put eraseblocks with corruption which does not look like it was caused
      by unclean power cut. Then we'll preserve thes PEBs in order to avoid
      killing potentially valuable user data.
      
      This patch also amends PEBs accounting, because it was closely tight to
      the 'erase'/'corr' lists separation.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      0525dac9
    • A
      UBI: separate out corrupted list · 3fb34124
      Artem Bityutskiy 提交于
      This patch introduces 'add_corrupted()' function and separates out 'corr' list
      manipulation from the common 'add_to_list()' function. This is just a
      preparation for further changes - this patch does not change functionality.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3fb34124
    • A
      UBI: change cascade of ifs to switch statements · b3321508
      Artem Bityutskiy 提交于
      This patch improves readability and simplifies scanning code by changing a
      long cascade of 'if' statements to a switch statement. This should presumably
      be a little faster as well.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      b3321508
    • A
      UBI: rename a local variable · e0e718c2
      Artem Bityutskiy 提交于
      Rename local variable 'ec_corr' into 'ec_err' to make the code a little bit
      more readable. 'ec_err' is more appropriate because it sounds more like 'error
      when EC was read' and it looks more logical because we use it together with
      'err'. Just a minor nicification which should improve the rather complex
      scanning code.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      e0e718c2
    • A
      UBI: handle bit-flips when no header found · 92e1a7d9
      Artem Bityutskiy 提交于
      Currently UBI has one small flaw - when we read EC or VID header, but find only
      0xFF bytes, we return UBI_IO_FF and do not report whether we had bit-flips or
      not. In case of the VID header, the scanning code adds this PEB to the free list,
      even though there were bit-flips.
      
      Imagine the following situation: we start writing VID header to a PEB and have a
      power cut, so the PEB becomes unstable. When we scan and read the PEB, we get
      a bit-flip. Currently, UBI would just ignore this and treat the PEB as free. This
      patch changes UBI behavior and now UBI will schedule this PEB for erasure.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      92e1a7d9
    • A
      UBI: remove duplicate IO error codes · 74d82d26
      Artem Bityutskiy 提交于
      The 'UBI_IO_PEB_EMPTY' and 'UBI_IO_PEB_FREE' are essentially the same
      and mean that there are only 0xFF bytes instead of headers. Simplify
      UBI a little by turning them into a single 'UBI_IO_FF' error code.
      
      Also, stop maintaining commentaries in 'ubi_io_read_vid_hdr()' which are
      almost identical to commentaries in 'ubi_io_read_ec_hdr()'.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      74d82d26
    • 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
    • A
      UBI: fix small 80 characters limit style issue · c174a08c
      Artem Bityutskiy 提交于
      One line was longer than 80 lines, make it shorter.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      c174a08c
    • H
      UBI: cleanup and simplify Kconfig · 1dd78632
      H Hartley Sweeten 提交于
      Cleanup the Kconfig for UBI by using menuconfig to enable/disable the entire
      driver. Remove the dependency checks for MTD_UBI and MTD_UBI_DEBUG by
      wrapping the options in if/endif blocks and remove any redundant checks.
      Remove all default n since that is the Kconfig default. Change menu "Additional
      UBI debugging messages" into a comment to remove one menu level.
      Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      1dd78632
  5. 15 10月, 2010 1 次提交
    • A
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann 提交于
      All file_operations should get a .llseek operation so we can make
      nonseekable_open the default for future file operations without a
      .llseek pointer.
      
      The three cases that we can automatically detect are no_llseek, seq_lseek
      and default_llseek. For cases where we can we can automatically prove that
      the file offset is always ignored, we use noop_llseek, which maintains
      the current behavior of not returning an error from a seek.
      
      New drivers should normally not use noop_llseek but instead use no_llseek
      and call nonseekable_open at open time.  Existing drivers can be converted
      to do the same when the maintainer knows for certain that no user code
      relies on calling seek on the device file.
      
      The generated code is often incorrectly indented and right now contains
      comments that clarify for each added line why a specific variant was
      chosen. In the version that gets submitted upstream, the comments will
      be gone and I will manually fix the indentation, because there does not
      seem to be a way to do that using coccinelle.
      
      Some amount of new code is currently sitting in linux-next that should get
      the same modifications, which I will do at the end of the merge window.
      
      Many thanks to Julia Lawall for helping me learn to write a semantic
      patch that does all this.
      
      ===== begin semantic patch =====
      // This adds an llseek= method to all file operations,
      // as a preparation for making no_llseek the default.
      //
      // The rules are
      // - use no_llseek explicitly if we do nonseekable_open
      // - use seq_lseek for sequential files
      // - use default_llseek if we know we access f_pos
      // - use noop_llseek if we know we don't access f_pos,
      //   but we still want to allow users to call lseek
      //
      @ open1 exists @
      identifier nested_open;
      @@
      nested_open(...)
      {
      <+...
      nonseekable_open(...)
      ...+>
      }
      
      @ open exists@
      identifier open_f;
      identifier i, f;
      identifier open1.nested_open;
      @@
      int open_f(struct inode *i, struct file *f)
      {
      <+...
      (
      nonseekable_open(...)
      |
      nested_open(...)
      )
      ...+>
      }
      
      @ read disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      <+...
      (
         *off = E
      |
         *off += E
      |
         func(..., off, ...)
      |
         E = *off
      )
      ...+>
      }
      
      @ read_no_fpos disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ write @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      <+...
      (
        *off = E
      |
        *off += E
      |
        func(..., off, ...)
      |
        E = *off
      )
      ...+>
      }
      
      @ write_no_fpos @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ fops0 @
      identifier fops;
      @@
      struct file_operations fops = {
       ...
      };
      
      @ has_llseek depends on fops0 @
      identifier fops0.fops;
      identifier llseek_f;
      @@
      struct file_operations fops = {
      ...
       .llseek = llseek_f,
      ...
      };
      
      @ has_read depends on fops0 @
      identifier fops0.fops;
      identifier read_f;
      @@
      struct file_operations fops = {
      ...
       .read = read_f,
      ...
      };
      
      @ has_write depends on fops0 @
      identifier fops0.fops;
      identifier write_f;
      @@
      struct file_operations fops = {
      ...
       .write = write_f,
      ...
      };
      
      @ has_open depends on fops0 @
      identifier fops0.fops;
      identifier open_f;
      @@
      struct file_operations fops = {
      ...
       .open = open_f,
      ...
      };
      
      // use no_llseek if we call nonseekable_open
      ////////////////////////////////////////////
      @ nonseekable1 depends on !has_llseek && has_open @
      identifier fops0.fops;
      identifier nso ~= "nonseekable_open";
      @@
      struct file_operations fops = {
      ...  .open = nso, ...
      +.llseek = no_llseek, /* nonseekable */
      };
      
      @ nonseekable2 depends on !has_llseek @
      identifier fops0.fops;
      identifier open.open_f;
      @@
      struct file_operations fops = {
      ...  .open = open_f, ...
      +.llseek = no_llseek, /* open uses nonseekable */
      };
      
      // use seq_lseek for sequential files
      /////////////////////////////////////
      @ seq depends on !has_llseek @
      identifier fops0.fops;
      identifier sr ~= "seq_read";
      @@
      struct file_operations fops = {
      ...  .read = sr, ...
      +.llseek = seq_lseek, /* we have seq_read */
      };
      
      // use default_llseek if there is a readdir
      ///////////////////////////////////////////
      @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier readdir_e;
      @@
      // any other fop is used that changes pos
      struct file_operations fops = {
      ... .readdir = readdir_e, ...
      +.llseek = default_llseek, /* readdir is present */
      };
      
      // use default_llseek if at least one of read/write touches f_pos
      /////////////////////////////////////////////////////////////////
      @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read.read_f;
      @@
      // read fops use offset
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = default_llseek, /* read accesses f_pos */
      };
      
      @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ... .write = write_f, ...
      +	.llseek = default_llseek, /* write accesses f_pos */
      };
      
      // Use noop_llseek if neither read nor write accesses f_pos
      ///////////////////////////////////////////////////////////
      
      @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      identifier write_no_fpos.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ...
       .write = write_f,
       .read = read_f,
      ...
      +.llseek = noop_llseek, /* read and write both use no f_pos */
      };
      
      @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write_no_fpos.write_f;
      @@
      struct file_operations fops = {
      ... .write = write_f, ...
      +.llseek = noop_llseek, /* write uses no f_pos */
      };
      
      @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      @@
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = noop_llseek, /* read uses no f_pos */
      };
      
      @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      @@
      struct file_operations fops = {
      ...
      +.llseek = noop_llseek, /* no read or write fn */
      };
      ===== End semantic patch =====
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  6. 30 8月, 2010 4 次提交
    • A
      UBI: do not oops when erroneous PEB is scheduled for scrubbing · d3f6e6c6
      Artem Bityutskiy 提交于
      When an erroneous PEB is scheduling for scrubbing, we end up with the
      following oops:
      
      [<c0162404>] (prot_queue_del+0x0/0x50) from [<c01635b4>] (ubi_wl_scrub_peb+0xec/0x13c)
      [<c01634c8>] (ubi_wl_scrub_peb+0x0/0x13c) from [<c01603bc>] (ubi_eba_read_leb+0x200/0x428)
      [<c01601bc>] (ubi_eba_read_leb+0x0/0x428) from [<c015e3c0>] (ubi_leb_read+0xe8/0x138)
      [<c015e2d8>] (ubi_leb_read+0x0/0x138) from [<c00d6918>] (ubifs_start_scan+0x7c/0xf4)
      [<c00d689c>] (ubifs_start_scan+0x0/0xf4) from [<c00e3650>] (ubifs_recover_leb+0x3c/0x730)
      [<c00e3614>] (ubifs_recover_leb+0x0/0x730) from [<c00e444c>] (ubifs_recover_log_leb+0xc8/0x2dc)
      [<c00e4384>] (ubifs_recover_log_leb+0x0/0x2dc) from [<c00d7c20>] (ubifs_replay_journal+0xb90/0x13a4)
      [<c00d7090>] (ubifs_replay_journal+0x0/0x13a4) from [<c00cdd68>] (ubifs_fill_super+0xb84/0x1054)
      [<c00cd1e4>] (ubifs_fill_super+0x0/0x1054) from [<c00ced04>] (ubifs_get_sb+0xc4/0x2ac)
      [<c00cec40>] (ubifs_get_sb+0x0/0x2ac) from [<c007f04c>] (vfs_kern_mount+0x58/0x94)
      [<c007eff4>] (vfs_kern_mount+0x0/0x94) from [<c007f0e8>] (do_kern_mount+0x40/0xe8)
      [<c007f0a8>] (do_kern_mount+0x0/0xe8) from [<c0095628>] (do_new_mount+0x68/0x8c)
      [<c00955c0>] (do_new_mount+0x0/0x8c) from [<c00957a8>] (do_mount+0x15c/0x1b8)
      [<c009564c>] (do_mount+0x0/0x1b8) from [<c0095890>] (sys_mount+0x8c/0xd4)
      [<c0095804>] (sys_mount+0x0/0xd4) from [<c0023c00>] (ret_fast_syscall+0x0/0x2c)
      Kernel panic - not syncing: Fatal exception
      
      The problem is that 'ubi_wl_scrub_peb()' does not expect that PEBs may
      be in the erroneous tree, which is a bug. This patch fixes the bug
      and adds corresponding check to 'ubi_wl_scrub_peb()'. Now it will simply
      ignore erroneous PEBs, instead of causing an oops.
      Reported-by: NMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      d3f6e6c6
    • R
      UBI: fix kconfig unmet dependency · 1deacd7a
      Randy Dunlap 提交于
      warning: (OPTPROBES && KPROBES && HAVE_OPTPROBES && !PREEMPT && DEBUG_KERNEL ||
      MTD_UBI_DEBUG && MTD && SYSFS && MTD_UBI || UBIFS_FS_DEBUG && MISC_FILESYSTEMS &&
      UBIFS_FS || LOCKDEP && DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT &&
      STACKTRACE_SUPPORT && LOCKDEP_SUPPORT || LATENCYTOP && HAVE_LATENCYTOP_SUPPORT &&
      DEBUG_KERNEL && STACKTRACE_SUPPORT && PROC_FS) selects KALLSYMS_ALL
      which has unmet direct dependencies (DEBUG_KERNEL && KALLSYMS)
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      1deacd7a
    • A
      UBI: fix forward compatibility · 80c1c16f
      Artem Bityutskiy 提交于
      Commit 0798cea8 "UBI: improve corrupted flash handling"
      broke delet-compatible volumes handling - it introduced a limit of 8 eraseblocks which
      may be corrupted. And delete-compatible eraseblocks are added to the "corrupted" list,
      so if we'd have a large delete-compatible volume, UBI would refuse it.
      
      The fix is to add delete-compatible volumes to the erase list instead. Indeed, they are
      corrupted, we just have to erase them.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      80c1c16f
    • J
      UBI: eliminate update of list_for_each_entry loop cursor · 01ebc12f
      Julia Lawall 提交于
      list_for_each_entry uses its first argument to move from one element to the
      next, so modifying it can break the iteration.  The variable re1 is already
      used within the loop as a temporary variable, and is not live here.
      
      The semantic match that finds this problem is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @r@
      iterator name list_for_each_entry;
      expression x,E;
      position p1,p2;
      @@
      
      list_for_each_entry@p1(x,...) { <... x =@p2 E ...> }
      
      @@
      expression x,E;
      position r.p1,r.p2;
      statement S;
      @@
      
      *x =@p2 E
      ...
      list_for_each_entry@p1(x,...) S
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      01ebc12f
  7. 02 8月, 2010 2 次提交
  8. 16 6月, 2010 1 次提交
  9. 14 6月, 2010 1 次提交
    • A
      UBI: fix error message and compilation warnings · f5d5b1f8
      Artem Bityutskiy 提交于
      Fix the followong compilation warnings introduced by commit
      095751a6:
      
      drivers/mtd/ubi/scan.c: In function 'check_what_we_have':
      drivers/mtd/ubi/scan.c:960: warning: passing argument 1 of 'get_random_bytes' discards qualifiers from pointer target type
      
      Fix the following compilation warnings introduced by commit
      1a49af2c:
      
      drivers/mtd/ubi/io.c: In function 'ubi_io_read':
      drivers/mtd/ubi/io.c:153: warning: initialization makes integer from pointer without a cast
      drivers/mtd/ubi/io.c:170: warning: format '%s' expects type 'char *', but argument 5 has type 'int'
      drivers/mtd/ubi/io.c:177: warning: format '%zd' expects type 'signed size_t', but argument 7 has type 'int'
      drivers/mtd/ubi/io.c:177: warning: too many arguments for format
      
      Also, amend the ECC error code string and add brackets and whitespace
      there - this should make the message readable.
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      f5d5b1f8
  10. 11 6月, 2010 2 次提交
  11. 04 6月, 2010 4 次提交
  12. 28 5月, 2010 1 次提交
  13. 07 5月, 2010 2 次提交
  14. 06 5月, 2010 1 次提交
    • M
      UBI: init even if MTD device cannot be attached, if built into kernel · af7ad7a0
      Marc Kleine-Budde 提交于
      UBI can be built into the kernel or be compiled as a kernel module.
      Further on the command line one can specify MTD devices to be attach to
      UBI while loading. In the current implementation the UBI driver refuses
      to load if one of the MTD devices cannot be attached.
      
      Consider:
      1) UBI compiled into the kernel and
      2) a MTD device specified on the command line and
      3) this MTD device contains bogus data (for whatever reason).
      
      During init UBI tries to attach the MTD device is this fails the whole
      UBI subsystem isn't initialized. Later the userspace cannot attach any
      MTD to UBI because UBI isn't loaded.
      
      This patch keeps the current behaviour: if UBI is compiled as a module
      and a MTD device cannot be attached the UBI module cannot be loaded,
      but changes it for the UBI-is-built-into-the-kernel usecase.
      
      If UBI is builtin, a not attachable MTD device doen't stop UBI from
      initializing. This slightly modifies the behaviour if multiple MTD
      devices are specified on the command line. Now every MTD device is
      probed and, if possible, attached, i.e. a faulty MTD device doesn't
      stop the others from being attached.
      
      Artem: tweaked the patch
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      af7ad7a0
  15. 03 5月, 2010 1 次提交
  16. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit 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: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  17. 08 3月, 2010 1 次提交