1. 21 5月, 2015 1 次提交
  2. 13 5月, 2015 1 次提交
    • B
      mtd: fix: avoid race condition when accessing mtd->usecount · 073db4a5
      Brian Norris 提交于
      On A MIPS 32-cores machine a BUG_ON was triggered because some acesses to
      mtd->usecount were done without taking mtd_table_mutex.
      kernel: Call Trace:
      kernel: [<ffffffff80401818>] __put_mtd_device+0x20/0x50
      kernel: [<ffffffff804086f4>] blktrans_release+0x8c/0xd8
      kernel: [<ffffffff802577e0>] __blkdev_put+0x1a8/0x200
      kernel: [<ffffffff802579a4>] blkdev_close+0x1c/0x30
      kernel: [<ffffffff8022006c>] __fput+0xac/0x250
      kernel: [<ffffffff80171208>] task_work_run+0xd8/0x120
      kernel: [<ffffffff8012c23c>] work_notifysig+0x10/0x18
      kernel:
      kernel:
              Code: 2442ffff  ac8202d8  000217fe <00020336> dc820128  10400003
                     00000000  0040f809  00000000
      kernel: ---[ end trace 080fbb4579b47a73 ]---
      
      Fixed by taking the mutex in blktrans_open and blktrans_release.
      
      Note that this locking is already suggested in
      include/linux/mtd/blktrans.h:
      
      struct mtd_blktrans_ops {
      ...
      	/* Called with mtd_table_mutex held; no race with add/remove */
      	int (*open)(struct mtd_blktrans_dev *dev);
      	void (*release)(struct mtd_blktrans_dev *dev);
      ...
      };
      
      But we weren't following it.
      
      Originally reported by (and patched by) Zhang and Giuseppe,
      independently. Improved and rewritten.
      
      Cc: stable@vger.kernel.org
      Reported-by: NZhang Xingcai <zhangxingcai@huawei.com>
      Reported-by: NGiuseppe Cantavenera <giuseppe.cantavenera.ext@nokia.com>
      Tested-by: NGiuseppe Cantavenera <giuseppe.cantavenera.ext@nokia.com>
      Acked-by: NAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      073db4a5
  3. 12 3月, 2015 1 次提交
  4. 05 10月, 2014 1 次提交
    • M
      block: disable entropy contributions for nonrot devices · b277da0a
      Mike Snitzer 提交于
      Clear QUEUE_FLAG_ADD_RANDOM in all block drivers that set
      QUEUE_FLAG_NONROT.
      
      Historically, all block devices have automatically made entropy
      contributions.  But as previously stated in commit e2e1a148 ("block: add
      sysfs knob for turning off disk entropy contributions"):
          - On SSD disks, the completion times aren't as random as they
            are for rotational drives. So it's questionable whether they
            should contribute to the random pool in the first place.
          - Calling add_disk_randomness() has a lot of overhead.
      
      There are more reliable sources for randomness than non-rotational block
      devices.  From a security perspective it is better to err on the side of
      caution than to allow entropy contributions from unreliable "random"
      sources.
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      b277da0a
  5. 16 4月, 2014 2 次提交
    • R
      mtd: mtd_blkdevs: handle REQ_FLUSH request and do explicit flush of writeback buffer · 566c0d6a
      Roman Peniaev 提交于
      mtd_blkdevs is device with volatile cache (writeback buffer), so it should support
      REQ_FLUSH to do explicit flush.
      
      Without this patch 'sync' does not guarantee that writeback buffer will be flushed
      on disk in case of power off, e.g.:
      
        $ cp some_file /mnt
        $ sync
      
        ### POWER OFF
      
      In case of this sequence writeback buffer will not be flushed on disk.
      
      This patch fixes this behaviour and explicitly reports to block layer that flush
      requests are being supported.
      Signed-off-by: NRoman Peniaev <r.peniaev@gmail.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: linux-mtd@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      566c0d6a
    • J
      block: remove struct request buffer member · b4f42e28
      Jens Axboe 提交于
      This was used in the olden days, back when onions were proper
      yellow. Basically it mapped to the current buffer to be
      transferred. With highmem being added more than a decade ago,
      most drivers map pages out of a bio, and rq->buffer isn't
      pointing at anything valid.
      
      Convert old style drivers to just use bio_data().
      
      For the discard payload use case, just reference the page
      in the bio.
      Signed-off-by: NJens Axboe <axboe@fb.com>
      b4f42e28
  6. 11 3月, 2014 1 次提交
  7. 07 5月, 2013 1 次提交
  8. 06 5月, 2013 1 次提交
  9. 21 11月, 2012 2 次提交
  10. 27 3月, 2012 1 次提交
  11. 10 1月, 2012 1 次提交
    • B
      mtd: mtd_blkdevs: don't increase 'open' count on error path · 342ff28f
      Brian Norris 提交于
      Some error paths in mtd_blkdevs were fixed in the following commit:
      
          commit 94735ec4
          mtd: mtd_blkdevs: fix error path in blktrans_open
      
      But on these error paths, the block device's `dev->open' count is
      already incremented before we check for errors. This meant that, while
      the error path was handled correctly on the first time through
      blktrans_open(), the device is erroneously considered already open on
      the second time through.
      
      This problem can be seen, for instance, when a UBI volume is
      simultaneously mounted as a UBIFS partition and read through its
      corresponding gluebi mtdblockX device. This results in blktrans_open()
      passing its error checks (with `dev->open > 0') without actually having
      a handle on the device. Here's a summarized log of the actions and
      results with nandsim:
      
          # modprobe nandsim
          # modprobe mtdblock
          # modprobe gluebi
          # modprobe ubifs
          # ubiattach /dev/ubi_ctrl -m 0
          ...
          # ubimkvol /dev/ubi0 -N test -s 16MiB
          ...
          # mount -t ubifs ubi0:test /mnt
          # ls /dev/mtdblock*
          /dev/mtdblock0  /dev/mtdblock1
          # cat /dev/mtdblock1 > /dev/null
          cat: can't open '/dev/mtdblock4': Device or resource busy
          # cat /dev/mtdblock1 > /dev/null
      
          CPU 0 Unable to handle kernel paging request at virtual address
          fffffff0, epc == 8031536c, ra == 8031f280
          Oops[#1]:
          ...
          Call Trace:
          [<8031536c>] ubi_leb_read+0x14/0x164
          [<8031f280>] gluebi_read+0xf0/0x148
          [<802edba8>] mtdblock_readsect+0x64/0x198
          [<802ecfe4>] mtd_blktrans_thread+0x330/0x3f4
          [<8005be98>] kthread+0x88/0x90
          [<8000bc04>] kernel_thread_helper+0x10/0x18
      
      Cc: stable@kernel.org [3.0+]
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      342ff28f
  12. 14 10月, 2011 1 次提交
  13. 25 5月, 2011 1 次提交
  14. 11 3月, 2011 4 次提交
  15. 30 10月, 2010 2 次提交
  16. 25 10月, 2010 3 次提交
  17. 05 10月, 2010 1 次提交
    • A
      block: autoconvert trivial BKL users to private mutex · 2a48fc0a
      Arnd Bergmann 提交于
      The block device drivers have all gained new lock_kernel
      calls from a recent pushdown, and some of the drivers
      were already using the BKL before.
      
      This turns the BKL into a set of per-driver mutexes.
      Still need to check whether this is safe to do.
      
      file=$1
      name=$2
      if grep -q lock_kernel ${file} ; then
          if grep -q 'include.*linux.mutex.h' ${file} ; then
                  sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
          else
                  sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
          fi
          sed -i ${file} \
              -e "/^#include.*linux.mutex.h/,$ {
                      1,/^\(static\|int\|long\)/ {
                           /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);
      
      } }"  \
          -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
          -e '/[      ]*cycle_kernel_lock();/d'
      else
          sed -i -e '/include.*\<smp_lock.h\>/d' ${file}  \
                      -e '/cycle_kernel_lock()/d'
      fi
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      2a48fc0a
  18. 09 8月, 2010 1 次提交
  19. 08 8月, 2010 3 次提交
  20. 06 8月, 2010 1 次提交
  21. 02 8月, 2010 1 次提交
  22. 09 3月, 2010 1 次提交
  23. 27 2月, 2010 4 次提交
  24. 25 2月, 2010 2 次提交
  25. 30 11月, 2009 1 次提交
  26. 26 11月, 2009 1 次提交
    • I
      block: add helpers to run flush_dcache_page() against a bio and a request's pages · 2d4dc890
      Ilya Loginov 提交于
      Mtdblock driver doesn't call flush_dcache_page for pages in request.  So,
      this causes problems on architectures where the icache doesn't fill from
      the dcache or with dcache aliases.  The patch fixes this.
      
      The ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE symbol was introduced to avoid
      pointless empty cache-thrashing loops on architectures for which
      flush_dcache_page() is a no-op.  Every architecture was provided with this
      flush pages on architectires where ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE is
      equal 1 or do nothing otherwise.
      
      See "fix mtd_blkdevs problem with caches on some architectures" discussion
      on LKML for more information.
      Signed-off-by: NIlya Loginov <isloginov@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Peter Horton <phorton@bitbox.co.uk>
      Cc: "Ed L. Cashin" <ecashin@coraid.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      2d4dc890