1. 16 3月, 2011 7 次提交
  2. 15 3月, 2011 1 次提交
  3. 11 3月, 2011 4 次提交
    • A
      UBIFS: do not check data crc by default · 2bcf0021
      Artem Bityutskiy 提交于
      Change the default UBIFS behavior WRT data CRC checking. Currently,
      UBIFS checks data CRC when reading, which slows it down quite a bit,
      and this is the default option. However, it looks like in average
      user does not need this feature and would prefer faster read speed
      over extra reliability. And this seems to be de-facto standard that
      file-systems do not check data CRC every time they read from the
      media.
      
      Thus, make UBIFS default behavior so that it does not check data
      CRC. This corresponds to the no_chk_data_crc mount option. Those users
      who need extra protection can always enable it using the chk_data_crc
      option.
      
      Please, read more information about this feature here:
      http://www.linux-mtd.infradead.org/doc/ubifs.html#L_checksummingSigned-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2bcf0021
    • A
      UBIFS: simplify UBIFS Kconfig menu · cce3f612
      Artem Bityutskiy 提交于
      Remove debug message level and debug checks Kconfig options as they
      proved to be useless anyway. We have sysfs interface which we can
      use for fine-grained debugging messages and checks selection, see
      Documentation/filesystems/ubifs.txt for mode details.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      cce3f612
    • A
      UBIFS: print max. index node size · 6342aaeb
      Artem Bityutskiy 提交于
      Improve debugging messages by printing the maximum index node size
      on mount.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      6342aaeb
    • M
      UBIFS: handle allocation failures in UBIFS write path · d882962f
      Matthew L. Creech 提交于
      Running kernel 2.6.37, my PPC-based device occasionally gets an
      order-2 allocation failure in UBIFS, which causes the root FS to
      become unwritable:
      
      kswapd0: page allocation failure. order:2, mode:0x4050
      Call Trace:
      [c787dc30] [c00085b8] show_stack+0x7c/0x194 (unreliable)
      [c787dc70] [c0061aec] __alloc_pages_nodemask+0x4f0/0x57c
      [c787dd00] [c0061b98] __get_free_pages+0x20/0x50
      [c787dd10] [c00e4f88] ubifs_jnl_write_data+0x54/0x200
      [c787dd50] [c00e82d4] do_writepage+0x94/0x198
      [c787dd90] [c00675e4] shrink_page_list+0x40c/0x77c
      [c787de40] [c0067de0] shrink_inactive_list+0x1e0/0x370
      [c787de90] [c0068224] shrink_zone+0x2b4/0x2b8
      [c787df00] [c0068854] kswapd+0x408/0x5d4
      [c787dfb0] [c0037bcc] kthread+0x80/0x84
      [c787dff0] [c000ef44] kernel_thread+0x4c/0x68
      
      Similar problems were encountered last April by Tomasz Stanislawski:
      
      http://patchwork.ozlabs.org/patch/50965/
      
      This patch implements Artem's suggested fix: fall back to a
      mutex-protected static buffer, allocated at mount time.  I tested it
      by forcing execution down the failure path, and didn't see any ill
      effects.
      
      Artem: massaged the patch a little, improved it so that we'd not
      allocate the write reserve buffer when we are in R/O mode.
      Signed-off-by: NMatthew L. Creech <mlcreech@gmail.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      d882962f
  4. 08 3月, 2011 5 次提交
  5. 08 2月, 2011 1 次提交
  6. 07 2月, 2011 2 次提交
  7. 06 2月, 2011 1 次提交
  8. 25 1月, 2011 1 次提交
  9. 18 1月, 2011 2 次提交
    • A
      UBIFS: introduce mounting flag · 18d1d7fb
      Artem Bityutskiy 提交于
      This is a preparational patch which removes the 'c->always_chk_crc' which was
      set during mounting and remounting to R/W mode and introduces 'c->mounting'
      flag which is set when mounting. Now the 'c->always_chk_crc' flag is the
      same as 'c->remounting_rw && c->mounting'.
      
      This patch is a preparation for the next one which will need to know when we
      are mounting and remounting to R/W mode, which is exactly what
      'c->always_chk_crc' effectively is, but its name does not suite the
      next patch. The other possibility would be to just re-name it, but then
      we'd end up with less logical flags coverage.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      18d1d7fb
    • A
      UBIFS: re-arrange variables in ubifs_info · d8cdda3e
      Artem Bityutskiy 提交于
      This is a cosmetic patch which re-arranges variables in 'struct ubifs_info'
      so that all boolean-like variables which are only changed during mounting or
      re-mounting to R/W mode are places together. Then they are turned into
      bit-fields, which makes the structure a little bit smaller.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      d8cdda3e
  10. 07 1月, 2011 1 次提交
    • N
      fs: icache RCU free inodes · fa0d7e3d
      Nick Piggin 提交于
      RCU free the struct inode. This will allow:
      
      - Subsequent store-free path walking patch. The inode must be consulted for
        permissions when walking, so an RCU inode reference is a must.
      - sb_inode_list_lock to be moved inside i_lock because sb list walkers who want
        to take i_lock no longer need to take sb_inode_list_lock to walk the list in
        the first place. This will simplify and optimize locking.
      - Could remove some nested trylock loops in dcache code
      - Could potentially simplify things a bit in VM land. Do not need to take the
        page lock to follow page->mapping.
      
      The downsides of this is the performance cost of using RCU. In a simple
      creat/unlink microbenchmark, performance drops by about 10% due to inability to
      reuse cache-hot slab objects. As iterations increase and RCU freeing starts
      kicking over, this increases to about 20%.
      
      In cases where inode lifetimes are longer (ie. many inodes may be allocated
      during the average life span of a single inode), a lot of this cache reuse is
      not applicable, so the regression caused by this patch is smaller.
      
      The cache-hot regression could largely be avoided by using SLAB_DESTROY_BY_RCU,
      however this adds some complexity to list walking and store-free path walking,
      so I prefer to implement this at a later date, if it is shown to be a win in
      real situations. I haven't found a regression in any non-micro benchmark so I
      doubt it will be a problem.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fa0d7e3d
  11. 29 10月, 2010 1 次提交
  12. 26 10月, 2010 1 次提交
  13. 21 10月, 2010 3 次提交
    • A
      UBIFS: do not allocate unneeded scan buffer · 6599fcbd
      Artem Bityutskiy 提交于
      In 'ubifs_replay_journal()' we allocate 'sbuf' for scanning the log.
      However, we already have 'c->sbuf' for these purposes, so do not
      allocate yet another one. This reduces UBIFS memory consumption while
      recovering.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      6599fcbd
    • A
      UBIFS: do not forget to cancel timers · 3601ba27
      Artem Bityutskiy 提交于
      This is a bug-fix: when we unmount, and we are currently in R/O
      mode because of an error - we do not sync write-buffers, which
      means we also do not cancel write-buffer timers we may possibly
      have armed. This patch fixes the issue.
      
      The issue can easily be reproduced by enabling UBIFS failure debug
      mode (echo 4 > /sys/module/ubifs/parameters/debug_tsts) and
      unmounting as soon as a failure happen. At some point the system
      oopses because we have an armed hrtimer but UBIFS is unmounted
      already.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3601ba27
    • A
      UBIFS: remove a bit of unneeded code · 39037559
      Artem Bityutskiy 提交于
      This is a clean-up patch which:
      
      1. Removes explicite 'hrtimer_cancel()' after 'ubifs_wbuf_sync()' in
         'ubifs_remount_ro()', because the timers will be canceled by
         'ubifs_wbuf_sync()', no need to cancel them for the second time.
      2. Remove "if (c->jheads)" check from 'ubifs_put_super()', because
         at journal heads must always be allocated there, since we checked
         earlier that we were mounted R/W, and the olny situation when
         journal heads are not allocated is when mounter or re-mounted R/O.
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      39037559
  14. 17 10月, 2010 1 次提交
  15. 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
  16. 28 9月, 2010 1 次提交
  17. 20 9月, 2010 1 次提交
    • A
      UBIFS: introduce new flags for RO mounts · 2ef13294
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2ef13294
  18. 17 9月, 2010 1 次提交
    • A
      UBIFS: introduce new flag for RO due to errors · 2680d722
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      2680d722
  19. 07 9月, 2010 2 次提交
  20. 30 8月, 2010 3 次提交
    • A
      UBIFS: improve error reporting when reading bad node · 3a8fa0ed
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3a8fa0ed
    • A
      UBIFS: introduce list sorting debugging checks · 3bb66b47
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      3bb66b47
    • A
      UBIFS: fix assertion warnings in comparison function · 1a9476a7
      Artem Bityutskiy 提交于
      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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
      1a9476a7