05 Oct, 2014

1 commit

  • 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: Mike Snitzer
    Signed-off-by: Jens Axboe

    Mike Snitzer
     

11 Jun, 2014

1 commit

  • Pull MTD updates from Brian Norris:
    - refactor m25p80.c driver for use as a general SPI NOR framework for
    other drivers which may speak to SPI NOR flash without providing full
    SPI support (i.e., not part of drivers/spi/)
    - new Freescale QuadSPI driver (utilizing new SPI NOR framework)
    - updates for the STMicro "FSM" SPI NOR driver
    - fix sync/flush behavior on mtd_blkdevs
    - fixup subpage write support on a few NAND drivers
    - correct the MTD OOB test for odd-sized OOB areas
    - add BCH-16 support for OMAP NAND
    - fix warnings and trivial refactoring
    - utilize new ECC DT bindings in pxa3xx NAND driver
    - new LPDDR NVM driver
    - address a few assorted bugs caught by Coverity
    - add new imx6sx support for GPMI NAND
    - use a bounce buffer for NAND when non-DMA-able buffers are used

    * tag 'for-linus-20140610' of git://git.infradead.org/linux-mtd: (77 commits)
    mtd: gpmi: add gpmi support for imx6sx
    mtd: maps: remove check for CONFIG_MTD_SUPERH_RESERVE
    mtd: bf5xx_nand: use the managed version of kzalloc
    mtd: pxa3xx_nand: make the driver work on big-endian systems
    mtd: nand: omap: fix omap_calculate_ecc_bch() for-loop error
    mtd: nand: r852: correct write_buf loop bounds
    mtd: nand_bbt: handle error case for nand_create_badblock_pattern()
    mtd: nand_bbt: remove unused variable
    mtd: maps: sc520cdp: fix warnings
    mtd: slram: fix unused variable warning
    mtd: pfow: remove unused variable
    mtd: lpddr: fix Kconfig dependency, for I/O accessors
    mtd: nand: pxa3xx: Add supported ECC strength and step size to the DT binding
    mtd: nand: pxa3xx: Use ECC strength and step size devicetree binding
    mtd: nand: pxa3xx: Clean pxa_ecc_init() error handling
    mtd: nand: Warn the user if the selected ECC strength is too weak
    mtd: nand: omap: Documentation: How to select correct ECC scheme for your device ?
    mtd: nand: omap: add support for BCH16_ECC - NAND driver updates
    mtd: nand: omap: add support for BCH16_ECC - ELM driver updates
    mtd: nand: omap: add support for BCH16_ECC - GPMC driver updates
    ...

    Linus Torvalds
     

16 Apr, 2014

2 commits

  • 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: Roman Peniaev
    Cc: David Woodhouse
    Cc: linux-mtd@lists.infradead.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Brian Norris

    Roman Peniaev
     
  • 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: Jens Axboe

    Jens Axboe
     

11 Mar, 2014

1 commit

  • None of these files are actually using any __init type directives
    and hence don't need to include . Most are just a
    left over from __devinit and __cpuinit removal, or simply due to
    code getting copied from one driver to the next.

    Cc: David Woodhouse
    Cc: Brian Norris
    Cc: linux-mtd@lists.infradead.org
    Signed-off-by: Paul Gortmaker
    [Brian: dropped one incorrect hunk]
    Signed-off-by: Brian Norris

    Paul Gortmaker
     

07 May, 2013

1 commit


06 May, 2013

1 commit


21 Nov, 2012

2 commits

  • By replacing a kthread with a workqueue, the code is now a bit clearer.
    There's also a slight reduction of code size (numbers apply for x86):
    Before:
    text data bss dec hex filename
    3248 36 0 3284 cd4 drivers/mtd/mtd_blkdevs.o

    After:
    text data bss dec hex filename
    3150 36 0 3186 c72 drivers/mtd/mtd_blkdevs.o

    Due to lack of real hardware, tests have been performed on an emulated
    environment with mtdswap and mtdblock over nandsim devices.
    Some real testing should be done, before merging this patch.

    Signed-off-by: Ezequiel Garcia
    Signed-off-by: Artem Bityutskiy

    Ezequiel Garcia
     
  • struct mtd_blktrans_ops is a type, and mtd_blktrans_ops is a variable.
    To improve code clarity it's better to not use the same names,
    so we just change the latter.

    Signed-off-by: Ezequiel Garcia
    Signed-off-by: Artem Bityutskiy

    Ezequiel Garcia
     

27 Mar, 2012

1 commit

  • Because it is useless to call it if the device is opened in R/O mode, and also
    harmful: on CFI NOR flash it may block for long time waiting for erase
    operations to complete is another partition with a R/W file-system on this
    chip.

    Artem Bityutskiy: write commit message, amend the patch to match the latest
    tree (we use mtd_sync(), not mtd->sync() nowadays).

    Signed-off-by: Alexander Stein
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Alexander Stein
     

10 Jan, 2012

1 commit

  • Some error paths in mtd_blkdevs were fixed in the following commit:

    commit 94735ec4044a6d318b83ad3c5794e931ed168d10
    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:
    [] ubi_leb_read+0x14/0x164
    [] gluebi_read+0xf0/0x148
    [] mtdblock_readsect+0x64/0x198
    [] mtd_blktrans_thread+0x330/0x3f4
    [] kthread+0x88/0x90
    [] kernel_thread_helper+0x10/0x18

    Cc: stable@kernel.org [3.0+]
    Signed-off-by: Brian Norris
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Brian Norris
     

14 Oct, 2011

1 commit


25 May, 2011

1 commit

  • The 'blktrans_open()' does not handle possible '__get_mtd_device()' failures
    because it does not check the error code. Moreover, the 'dev->tr->open()'
    failures are not handled correctly because in this case the function just
    goes ahead and gets the mtd device, then returns an error. But Instead, it
    should _not_ try to get the mtd device, then it should put back the module
    and the kref.

    This patch fixes the issue. Note, I only compile-tested it. This patch was
    inspired by a bug report about a similar issue in 2.6.34 kernels
    sent by Mike Turner to the MTD mailing list:

    http://lists.infradead.org/pipermail/linux-mtd/2011-April/034980.html

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     

25 Mar, 2011

1 commit

  • …linux-2.6 into for-linus-1

    * 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6: (9356 commits)
    [media] rc: update for bitop name changes
    fs: simplify iget & friends
    fs: pull inode->i_lock up out of writeback_single_inode
    fs: rename inode_lock to inode_hash_lock
    fs: move i_wb_list out from under inode_lock
    fs: move i_sb_list out from under inode_lock
    fs: remove inode_lock from iput_final and prune_icache
    fs: Lock the inode LRU list separately
    fs: factor inode disposal
    fs: protect inode->i_state with inode->i_lock
    lib, arch: add filter argument to show_mem and fix private implementations
    SLUB: Write to per cpu data when allocating it
    slub: Fix debugobjects with lockless fastpath
    autofs4: Do not potentially dereference NULL pointer returned by fget() in autofs_dev_ioctl_setpipefd()
    autofs4 - remove autofs4_lock
    autofs4 - fix d_manage() return on rcu-walk
    autofs4 - fix autofs4_expire_indirect() traversal
    autofs4 - fix dentry leak in autofs4_expire_direct()
    autofs4 - reinstate last used update on access
    vfs - check non-mountpoint dentry might block in __follow_mount_rcu()
    ...

    NOTE!

    This merge commit was created to fix compilation error. The block
    tree was merged upstream and removed the 'elv_queue_empty()'
    function which the new 'mtdswap' driver is using. So a simple
    merge of the mtd tree with upstream does not compile. And the
    mtd tree has already be published, so re-basing it is not an option.

    To fix this unfortunate situation, I had to merge upstream into the
    mtd-2.6.git tree without committing, put the fixup patch on top of
    this, and then commit this. The result is that we do not have commits
    which do not compile.

    In other words, this merge commit "merges" 3 things: the MTD tree, the
    upstream tree, and the fixup patch.

    Artem Bityutskiy
     

11 Mar, 2011

4 commits

  • Set max_discard_sectors to UINT_MAX.

    Signed-off-by: Jarkko Lavinen
    Tested-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jarkko Lavinen
     
  • Add a new background method into mtd_blktrans_ops, add background support
    into mtd_blktrans_thread(), and add mtd_blktrans_cease_background().

    If the mtd blktrans dev has the background support, the thread will
    call background function when the request queue becomes empty. The background
    operation may run as long as needs to until
    mtd_blktrans_cease_background() tells to stop.

    Signed-off-by: Jarkko Lavinen
    Tested-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jarkko Lavinen
     
  • The function blktrans_dev_release and blktrans_dev_put are only used
    locally in this file and should be static.

    Signed-off-by: H Hartley Sweeten
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    H Hartley Sweeten
     
  • This one liner patch fixes double free that will occur if add_mtd_blktrans_dev
    fails. On failure it frees the input argument, but all its users also free it
    on error which is natural thing to do. Thus don't free it.

    All credit for finding that bug belongs to reporters of the bug in the android bugzilla
    http://code.google.com/p/android/issues/detail?id=13761

    Commit message tweaked by Artem.

    Signed-off-by: Maxim Levitsky
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse
    Cc: stable@kernel.org

    Maxim Levitsky
     

30 Oct, 2010

3 commits


25 Oct, 2010

3 commits

  • There is small race window that could make kthread_stop hang forever.
    I found that while hacking the IR subsystem.

    Signed-off-by: Maxim Levitsky
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     
  • It not needed, because I already added locking for all fops
    methods.

    Signed-off-by: Maxim Levitsky
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     
  • Now it once again possible to remove mtdtrans module.
    You still need to ensure that block devices of that module aren't mounted.
    This is due to the fact that as long as a block device is open, it still exists,
    therefore if we were to allow module removal, this block device might became used again.

    This time in addition to code review, I also made the code
    pass some torture tests like module reload in a loop + read in a loop +
    card insert/removal all at same time.

    The blktrans_open/blktrans_release don't take the mtd table lock because:

    While device is added (that includes execution of add_mtd_blktrans_dev)
    the lock is already taken

    Now suppose the device will never be removed. In this case even if we have changes
    in mtd table, the entry that we need will stay exactly the same. (Note that we don't
    look at table at all, just following private pointer of block device).

    Now suppose that someone tries to remove the mtd device.
    This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev
    which will take the per device lock, release the mtd device and set trans->mtd = NULL.
    >From this point on, following opens won't even be able to know anything about that mtd device
    (which at that point is likely not to exist)
    Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

    Signed-off-by: Maxim Levitsky
    Tested-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     

05 Oct, 2010

1 commit

  • 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.*/d' ${file}
    else
    sed -i 's/include.*.*$/include /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.*\/d' ${file} \
    -e '/cycle_kernel_lock()/d'
    fi

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

11 Aug, 2010

1 commit

  • * 'for-2.6.36' of git://git.kernel.dk/linux-2.6-block: (149 commits)
    block: make sure that REQ_* types are seen even with CONFIG_BLOCK=n
    xen-blkfront: fix missing out label
    blkdev: fix blkdev_issue_zeroout return value
    block: update request stacking methods to support discards
    block: fix missing export of blk_types.h
    writeback: fix bad _bh spinlock nesting
    drbd: revert "delay probes", feature is being re-implemented differently
    drbd: Initialize all members of sync_conf to their defaults [Bugz 315]
    drbd: Disable delay probes for the upcomming release
    writeback: cleanup bdi_register
    writeback: add new tracepoints
    writeback: remove unnecessary init_timer call
    writeback: optimize periodic bdi thread wakeups
    writeback: prevent unnecessary bdi threads wakeups
    writeback: move bdi threads exiting logic to the forker thread
    writeback: restructure bdi forker loop a little
    writeback: move last_active to bdi
    writeback: do not remove bdi from bdi_list
    writeback: simplify bdi code a little
    writeback: do not lose wake-ups in bdi threads
    ...

    Fixed up pretty trivial conflicts in drivers/block/virtio_blk.c and
    drivers/scsi/scsi_error.c as per Jens.

    Linus Torvalds
     

09 Aug, 2010

1 commit


08 Aug, 2010

3 commits

  • The open and release block_device_operations are currently
    called with the BKL held. In order to change that, we must
    first make sure that all drivers that currently rely
    on this have no regressions.

    This blindly pushes the BKL into all .open and .release
    operations for all block drivers to prepare for the
    next step. The drivers can subsequently replace the BKL
    with their own locks or remove it completely when it can
    be shown that it is not needed.

    The functions blkdev_get and blkdev_put are the only
    remaining users of the big kernel lock in the block
    layer, besides a few uses in the ioctl code, none
    of which need to serialize with blkdev_{get,put}.

    Most of these two functions is also under the protection
    of bdev->bd_mutex, including the actual calls to
    ->open and ->release, and the common code does not
    access any global data structures that need the BKL.

    Signed-off-by: Arnd Bergmann
    Acked-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     
  • As a preparation for the removal of the big kernel
    lock in the block layer, this removes the BKL
    from the common ioctl handling code, moving it
    into every single driver still using it.

    Signed-off-by: Arnd Bergmann
    Acked-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     
  • Remove all the trivial wrappers for the cmd_type and cmd_flags fields in
    struct requests. This allows much easier grepping for different request
    types instead of unwinding through macros.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

06 Aug, 2010

1 commit


02 Aug, 2010

1 commit

  • There was a break missing so we returned -ENOTTY on success instead of
    zero. This was introduced by 048d8719956: "mtd: blktrans: Hotplug fixes"

    Signed-off-by: Dan Carpenter
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Dan Carpenter
     

09 Mar, 2010

1 commit


27 Feb, 2010

4 commits

  • * Test results of few functions that were declared with __must_check
    * Fix bogus gcc warning about uinitialized variable 'ret'
    * Remove unused variable from mtdblock_remove_dev
    * Don't use deprecated DMA_32BIT_MASK

    Signed-off-by: Maxim Levitsky
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     
  • This patch adds an ability to export sysfs attributes below
    the block disk device.

    This can be used to pass the udev an information about the FTL
    and could include the vendor, serial, version, etc...

    Signed-off-by: Maxim Levitsky
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     
  • * Add locking where it was missing.

    * Don't do a get_mtd_device in blktrans_open because it would lead to a
    deadlock; instead do that in add_mtd_blktrans_dev.

    * Only free the mtd_blktrans_dev structure when the last user exits.

    * Flush request queue on device removal.

    * Track users, and call tr->release in del_mtd_blktrans_dev
    Due to that ->open and release aren't called more that once.

    Now it is safe to call del_mtd_blktrans_dev while the device is still in use.

    Signed-off-by: Maxim Levitsky
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     
  • This is the biggest change. To make hotplug possible, and this layer
    clean, the mtd_blktrans_dev now contains everything for a single mtd
    block translation device. Also removed some very old leftovers.

    Signed-off-by: Maxim Levitsky
    Signed-off-by: David Woodhouse

    Maxim Levitsky
     

25 Feb, 2010

2 commits


17 Dec, 2009

1 commit

  • * git://git.infradead.org/mtd-2.6: (90 commits)
    jffs2: Fix long-standing bug with symlink garbage collection.
    mtd: OneNAND: Fix test of unsigned in onenand_otp_walk()
    mtd: cfi_cmdset_0002, fix lock imbalance
    Revert "mtd: move mxcnd_remove to .exit.text"
    mtd: m25p80: add support for Macronix MX25L4005A
    kmsg_dump: fix build for CONFIG_PRINTK=n
    mtd: nandsim: add support for 4KiB pages
    mtd: mtdoops: refactor as a kmsg_dumper
    mtd: mtdoops: make record size configurable
    mtd: mtdoops: limit the maximum mtd partition size
    mtd: mtdoops: keep track of used/unused pages in an array
    mtd: mtdoops: several minor cleanups
    core: Add kernel message dumper to call on oopses and panics
    mtd: add ARM pismo support
    mtd: pxa3xx_nand: Fix PIO data transfer
    mtd: nand: fix multi-chip suspend problem
    mtd: add support for switching old SST chips into QRY mode
    mtd: fix M29W800D dev_id and uaddr
    mtd: don't use PF_MEMALLOC
    mtd: Add bad block table overrides to Davinci NAND driver
    ...

    Fixed up conflicts (mostly trivial) in
    drivers/mtd/devices/m25p80.c
    drivers/mtd/maps/pcmciamtd.c
    drivers/mtd/nand/pxa3xx_nand.c
    kernel/printk.c

    Linus Torvalds