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
     

30 Nov, 2009

1 commit

  • Non MM subsystem must not use PF_MEMALLOC. Memory reclaim need few
    memory, anyone must not prevent it. Otherwise the system cause
    mysterious hang-up and/or OOM Killer invokation.

    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: David Woodhouse

    KOSAKI Motohiro
     

26 Nov, 2009

1 commit

  • 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: Ilya Loginov
    Cc: Ingo Molnar
    Cc: David Woodhouse
    Cc: Peter Horton
    Cc: "Ed L. Cashin"
    Signed-off-by: Jens Axboe

    Ilya Loginov
     

20 Oct, 2009

1 commit

  • In register_mtd_blktrans(), the symbol 'ret' is already declared
    as an int at the start of the function. The inner loop declaration
    is unnecessary. Quiets the following sparse warning:

    warning: symbol 'ret' shadows an earlier one

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

    hartleys
     

02 Oct, 2009

1 commit

  • prepare_discard_fn() was being called in a place where memory allocation
    was effectively impossible. This makes it inappropriate for all but
    the most trivial translations of Linux's DISCARD operation to the block
    command set. Additionally adding a payload there makes the ownership
    of the bio backing unclear as it's now allocated by the device driver
    and not the submitter as usual.

    It is replaced with QUEUE_FLAG_DISCARD which is used to indicate whether
    the queue supports discard operations or not. blkdev_issue_discard now
    allocates a one-page, sector-length payload which is the right thing
    for the common ATA and SCSI implementations.

    The mtd implementation of prepare_discard_fn() is replaced with simply
    checking for the request being a discard.

    Largely based on a previous patch from Matthew Wilcox
    which did the prepare_discard_fn but not the different payload allocation
    yet.

    Signed-off-by: Christoph Hellwig

    Christoph Hellwig
     

22 Sep, 2009

1 commit


03 Aug, 2009

1 commit

  • Nowadays MTD devices have to be "get" before they can be
    used. This has to be done with 'get_mtd_device()'. The
    'blktrans_open()' function did not do this and instead
    used 'try_module_get()'. Fix this.

    Since 'get_mtd_device()' already gets the module, extra
    'try_module_get()' is not needed.

    This fixes oops when one tries to use mtdblock on top of
    gluebi.

    Reported-by: Holger Brunck
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     

23 Jun, 2009

1 commit

  • * git://git.infradead.org/mtd-2.6: (63 commits)
    mtd: OneNAND: Allow setting of boundary information when built as module
    jffs2: leaking jffs2_summary in function jffs2_scan_medium
    mtd: nand: Fix memory leak on txx9ndfmc probe failure.
    mtd: orion_nand: use burst reads with double word accesses
    mtd/nand: s3c6400 support for s3c2410 driver
    [MTD] [NAND] S3C2410: Use DIV_ROUND_UP
    [MTD] [NAND] S3C2410: Deal with unaligned lengths in S3C2440 buffer read/write
    [MTD] [NAND] S3C2410: Allow the machine code to get the BBT table from NAND
    [MTD] [NAND] S3C2410: Added a kerneldoc for s3c2410_nand_set
    mtd: physmap_of: Add multiple regions and concatenation support
    mtd: nand: max_retries off by one in mxc_nand
    mtd: nand: s3c2410_nand_setrate(): use correct macros for 2412/2440
    mtd: onenand: add bbt_wait & unlock_all as replaceable for some platform
    mtd: Flex-OneNAND support
    mtd: nand: add OMAP2/OMAP3 NAND driver
    mtd: maps: Blackfin async: fix memory leaks in probe/remove funcs
    mtd: uclinux: mark local stuff static
    mtd: uclinux: do not allow to be built as a module
    mtd: uclinux: allow systems to override map addr/size
    mtd: blackfin NFC: fix hang when using NAND on BF527-EZKITs
    ...

    Linus Torvalds
     

26 May, 2009

1 commit


23 May, 2009

1 commit

  • Until now we have had a 1:1 mapping between storage device physical
    block size and the logical block sized used when addressing the device.
    With SATA 4KB drives coming out that will no longer be the case. The
    sector size will be 4KB but the logical block size will remain
    512-bytes. Hence we need to distinguish between the physical block size
    and the logical ditto.

    This patch renames hardsect_size to logical_block_size.

    Signed-off-by: Martin K. Petersen
    Signed-off-by: Jens Axboe

    Martin K. Petersen
     

11 May, 2009

1 commit

  • Till now block layer allowed two separate modes of request execution.
    A request is always acquired from the request queue via
    elv_next_request(). After that, drivers are free to either dequeue it
    or process it without dequeueing. Dequeue allows elv_next_request()
    to return the next request so that multiple requests can be in flight.

    Executing requests without dequeueing has its merits mostly in
    allowing drivers for simpler devices which can't do sg to deal with
    segments only without considering request boundary. However, the
    benefit this brings is dubious and declining while the cost of the API
    ambiguity is increasing. Segment based drivers are usually for very
    old or limited devices and as converting to dequeueing model isn't
    difficult, it doesn't justify the API overhead it puts on block layer
    and its more modern users.

    Previous patches converted all block low level drivers to dequeueing
    model. This patch completes the API transition by...

    * renaming elv_next_request() to blk_peek_request()

    * renaming blkdev_dequeue_request() to blk_start_request()

    * adding blk_fetch_request() which is combination of peek and start

    * disallowing completion of queued (not started) requests

    * applying new API to all LLDs

    Renamings are for consistency and to break out of tree code so that
    it's apparent that out of tree drivers need updating.

    [ Impact: block request issue API cleanup, no functional change ]

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Cc: James Bottomley
    Cc: Mike Miller
    Cc: unsik Kim
    Cc: Paul Clements
    Cc: Tim Waugh
    Cc: Geert Uytterhoeven
    Cc: David S. Miller
    Cc: Laurent Vivier
    Cc: Jeff Garzik
    Cc: Jeremy Fitzhardinge
    Cc: Grant Likely
    Cc: Adrian McMenamin
    Cc: Stephen Rothwell
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Cc: Alex Dubov
    Cc: Pierre Ossman
    Cc: David Woodhouse
    Cc: Markus Lidel
    Cc: Stefan Weinhuber
    Cc: Martin Schwidefsky
    Cc: Pete Zaitcev
    Cc: FUJITA Tomonori
    Signed-off-by: Jens Axboe

    Tejun Heo