24 Oct, 2020

2 commits


02 Sep, 2020

2 commits

  • revalidate_disk is a relative awkward helper for driver use, as it first
    calls an optional driver method and then updates the block device size,
    while most callers either don't need the method call at all, or want to
    keep state between the caller and the called method.

    Add a revalidate_disk_size helper that just performs the update of the
    block device size from the gendisk one, and switch all drivers that do
    not implement ->revalidate_disk to use the new helper instead of
    revalidate_disk()

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Josef Bacik
    Reviewed-by: Johannes Thumshirn
    Acked-by: Song Liu
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Use kobj_to_dev() instead of container_of()

    Signed-off-by: Tian Tao
    Reviewed-by: Bart Van Assche
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Stefano Garzarella
    Signed-off-by: Jens Axboe

    Tian Tao
     

01 Sep, 2020

1 commit


17 Aug, 2020

1 commit

  • 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support") starts
    to support multi-range discard for virtio-blk. However, the virtio-blk
    disk may report max discard segment as 1, at least that is exactly what
    qemu is doing.

    So far, block layer switches to normal request merge if max discard segment
    limit is 1, and multiple bios can be merged to single segment. This way may
    cause memory corruption in virtblk_setup_discard_write_zeroes().

    Fix the issue by handling single max discard segment in straightforward
    way.

    Fixes: 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support")
    Signed-off-by: Ming Lei
    Reviewed-by: Christoph Hellwig
    Cc: Changpeng Liu
    Cc: Daniel Verkamp
    Cc: Michael S. Tsirkin
    Cc: Stefan Hajnoczi
    Cc: Stefano Garzarella
    Signed-off-by: Jens Axboe

    Ming Lei
     

07 Aug, 2020

1 commit


04 Aug, 2020

1 commit

  • Pull core block updates from Jens Axboe:
    "Good amount of cleanups and tech debt removals in here, and as a
    result, the diffstat shows a nice net reduction in code.

    - Softirq completion cleanups (Christoph)

    - Stop using ->queuedata (Christoph)

    - Cleanup bd claiming (Christoph)

    - Use check_events, moving away from the legacy media change
    (Christoph)

    - Use inode i_blkbits consistently (Christoph)

    - Remove old unused writeback congestion bits (Christoph)

    - Cleanup/unify submission path (Christoph)

    - Use bio_uninit consistently, instead of bio_disassociate_blkg
    (Christoph)

    - sbitmap cleared bits handling (John)

    - Request merging blktrace event addition (Jan)

    - sysfs add/remove race fixes (Luis)

    - blk-mq tag fixes/optimizations (Ming)

    - Duplicate words in comments (Randy)

    - Flush deferral cleanup (Yufen)

    - IO context locking/retry fixes (John)

    - struct_size() usage (Gustavo)

    - blk-iocost fixes (Chengming)

    - blk-cgroup IO stats fixes (Boris)

    - Various little fixes"

    * tag 'for-5.9/block-20200802' of git://git.kernel.dk/linux-block: (135 commits)
    block: blk-timeout: delete duplicated word
    block: blk-mq-sched: delete duplicated word
    block: blk-mq: delete duplicated word
    block: genhd: delete duplicated words
    block: elevator: delete duplicated word and fix typos
    block: bio: delete duplicated words
    block: bfq-iosched: fix duplicated word
    iocost_monitor: start from the oldest usage index
    iocost: Fix check condition of iocg abs_vdebt
    block: Remove callback typedefs for blk_mq_ops
    block: Use non _rcu version of list functions for tag_set_list
    blk-cgroup: show global disk stats in root cgroup io.stat
    blk-cgroup: make iostat functions visible to stat printing
    block: improve discard bio alignment in __blkdev_issue_discard()
    block: change REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL to be odd numbers
    block: defer flush request no matter whether we have elevator
    block: make blk_timeout_init() static
    block: remove retry loop in ioc_release_fn()
    block: remove unnecessary ioc nested locking
    block: integrate bd_start_claiming into __blkdev_get
    ...

    Linus Torvalds
     

06 Jul, 2020

1 commit


01 Jul, 2020

1 commit


24 Jun, 2020

1 commit

  • Move the call to blk_should_fake_timeout out of blk_mq_complete_request
    and into the drivers, skipping call sites that are obvious error
    handlers, and remove the now superflous blk_mq_force_complete_rq helper.
    This ensures we don't keep injecting errors into completions that just
    terminate the Linux request after the hardware has been reset or the
    command has been aborted.

    Reviewed-by: Daniel Wagner
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

11 May, 2020

1 commit


02 May, 2020

1 commit

  • A userspace process holding a file descriptor to a virtio_blk device can
    still invoke block_device_operations after hot unplug. This leads to a
    use-after-free accessing vblk->vdev in virtblk_getgeo() when
    ioctl(HDIO_GETGEO) is invoked:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000090
    IP: [] virtio_check_driver_offered_feature+0x10/0x90 [virtio]
    PGD 800000003a92f067 PUD 3a930067 PMD 0
    Oops: 0000 [#1] SMP
    CPU: 0 PID: 1310 Comm: hdio-getgeo Tainted: G OE ------------ 3.10.0-1062.el7.x86_64 #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
    task: ffff9be5fbfb8000 ti: ffff9be5fa890000 task.ti: ffff9be5fa890000
    RIP: 0010:[] [] virtio_check_driver_offered_feature+0x10/0x90 [virtio]
    RSP: 0018:ffff9be5fa893dc8 EFLAGS: 00010246
    RAX: ffff9be5fc3f3400 RBX: ffff9be5fa893e30 RCX: 0000000000000000
    RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffff9be5fbc10b40
    RBP: ffff9be5fa893dc8 R08: 0000000000000301 R09: 0000000000000301
    R10: 0000000000000000 R11: 0000000000000000 R12: ffff9be5fdc24680
    R13: ffff9be5fbc10b40 R14: ffff9be5fbc10480 R15: 0000000000000000
    FS: 00007f1bfb968740(0000) GS:ffff9be5ffc00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000090 CR3: 000000003a894000 CR4: 0000000000360ff0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    [] virtblk_getgeo+0x47/0x110 [virtio_blk]
    [] ? handle_mm_fault+0x39d/0x9b0
    [] blkdev_ioctl+0x1f5/0xa20
    [] block_ioctl+0x41/0x50
    [] do_vfs_ioctl+0x3a0/0x5a0
    [] SyS_ioctl+0xa1/0xc0

    A related problem is that virtblk_remove() leaks the vd_index_ida index
    when something still holds a reference to vblk->disk during hot unplug.
    This causes virtio-blk device names to be lost (vda, vdb, etc).

    Fix these issues by protecting vblk->vdev with a mutex and reference
    counting vblk so the vd_index_ida index can be removed in all cases.

    Fixes: 48e4043d4529 ("virtio: add virtio disk geometry feature")
    Reported-by: Lance Digby
    Signed-off-by: Stefan Hajnoczi
    Link: https://lore.kernel.org/r/20200430140442.171016-1-stefanha@redhat.com
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Stefano Garzarella

    Stefan Hajnoczi
     

27 Apr, 2020

1 commit


17 Apr, 2020

1 commit


31 Mar, 2020

2 commits

  • …/scm/linux/kernel/git/tip/tip into android-mainline

    In a quest to make the huge -rc1 merge easier to handle and bisect,
    merge the first chunk of 5.7-rc1 patches into android-mainline.

    Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
    Change-Id: Ib54436e9515660a4c0c25c49c21bfb399eb57921

    Greg Kroah-Hartman
     
  • Pull block updates from Jens Axboe:

    - Online capacity resizing (Balbir)

    - Number of hardware queue change fixes (Bart)

    - null_blk fault injection addition (Bart)

    - Cleanup of queue allocation, unifying the node/no-node API
    (Christoph)

    - Cleanup of genhd, moving code to where it makes sense (Christoph)

    - Cleanup of the partition handling code (Christoph)

    - disk stat fixes/improvements (Konstantin)

    - BFQ improvements (Paolo)

    - Various fixes and improvements

    * tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block: (72 commits)
    block: return NULL in blk_alloc_queue() on error
    block: move bio_map_* to blk-map.c
    Revert "blkdev: check for valid request queue before issuing flush"
    block: simplify queue allocation
    bcache: pass the make_request methods to blk_queue_make_request
    null_blk: use blk_mq_init_queue_data
    block: add a blk_mq_init_queue_data helper
    block: move the ->devnode callback to struct block_device_operations
    block: move the part_stat* helpers from genhd.h to a new header
    block: move block layer internals out of include/linux/genhd.h
    block: move guard_bio_eod to bio.c
    block: unexport get_gendisk
    block: unexport disk_map_sector_rcu
    block: unexport disk_get_part
    block: mark part_in_flight and part_in_flight_rw static
    block: mark block_depr static
    block: factor out requeue handling from dispatch code
    block/diskstats: replace time_in_queue with sum of request times
    block/diskstats: accumulate all per-cpu counters in one pass
    block/diskstats: more accurate approximation of io_ticks for slow disks
    ...

    Linus Torvalds
     

19 Mar, 2020

1 commit


16 Mar, 2020

1 commit


08 Mar, 2020

2 commits

  • Let's change the mapping between virtqueue_add errors to BLK_STS
    statuses, so that -ENOSPC, which indicates virtqueue full is still
    mapped to BLK_STS_DEV_RESOURCE, but -ENOMEM which indicates non-device
    specific resource outage is mapped to BLK_STS_RESOURCE.

    Signed-off-by: Halil Pasic
    Link: https://lore.kernel.org/r/20200213123728.61216-3-pasic@linux.ibm.com
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Stefan Hajnoczi

    Halil Pasic
     
  • Since nobody else is going to restart our hw_queue for us, the
    blk_mq_start_stopped_hw_queues() is in virtblk_done() is not sufficient
    necessarily sufficient to ensure that the queue will get started again.
    In case of global resource outage (-ENOMEM because mapping failure,
    because of swiotlb full) our virtqueue may be empty and we can get
    stuck with a stopped hw_queue.

    Let us not stop the queue on arbitrary errors, but only on -EONSPC which
    indicates a full virtqueue, where the hw_queue is guaranteed to get
    started by virtblk_done() before when it makes sense to carry on
    submitting requests. Let us also remove a stale comment.

    Signed-off-by: Halil Pasic
    Cc: Jens Axboe
    Fixes: f7728002c1c7 ("virtio_ring: fix return code on DMA mapping fails")
    Link: https://lore.kernel.org/r/20200213123728.61216-2-pasic@linux.ibm.com
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Stefan Hajnoczi

    Halil Pasic
     

10 Feb, 2020

1 commit


06 Feb, 2020

1 commit

  • Since the need for a special flag to support SCSI passthrough on a
    block device was added in May 2017 the SCSI passthrough support in
    virtio-blk has been disabled. It has always been a bad idea
    (just ask the original author..) and we have virtio-scsi for proper
    passthrough. The feature also never made it into the virtio 1.0
    or later specifications.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Stefan Hajnoczi

    Christoph Hellwig
     

03 Feb, 2020

1 commit


03 Jan, 2020

1 commit

  • Each driver calling scsi_ioctl() gets an equivalent compat_ioctl()
    handler that implements the same commands by calling scsi_compat_ioctl().

    The scsi_cmd_ioctl() and scsi_cmd_blk_ioctl() functions are compatible
    at this point, so any driver that calls those can do so for both native
    and compat mode, with the argument passed through compat_ptr().

    With this, we can remove the entries from fs/compat_ioctl.c. The new
    code is larger, but should be easier to maintain and keep updated with
    newly added commands.

    Reviewed-by: Ben Hutchings
    Acked-by: Stefan Hajnoczi
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

19 Nov, 2019

1 commit

  • The virtio_blk driver used by cuttlefish can crash if discard/zero ops,
    added in 4.20, pass through virtio_queue_rq(). Our theory is that this
    happens because multiple discards are merged, causing nr_phys_segments
    to be increased beyond the sg_elem size. This makes sense as a
    discard/zero is a form of I/O not backed by specific data.

    This patch should be submitted upstream once the true root cause has
    been tracked down and full analysis of the issue has been done.

    Originally-by: Satya Tangirala
    Bug: 144592287
    Test: boot cuttlefish with f2fs userdata and wait 1 minute
    Change-Id: Ic73e08035c91ec9c718e6496930b326d084062a4
    Signed-off-by: Alistair Delva

    Alistair Delva
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

22 Apr, 2019

1 commit

  • Pull in v5.1-rc6 to resolve two conflicts. One is in BFQ, in just a
    comment, and is trivial. The other one is a conflict due to a later fix
    in the bio multi-page work, and needs a bit more care.

    * tag 'v5.1-rc6': (770 commits)
    Linux 5.1-rc6
    block: make sure that bvec length can't be overflow
    block: kill all_q_node in request_queue
    x86/cpu/intel: Lower the "ENERGY_PERF_BIAS: Set to normal" message's log priority
    coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping
    mm/kmemleak.c: fix unused-function warning
    init: initialize jump labels before command line option parsing
    kernel/watchdog_hld.c: hard lockup message should end with a newline
    kcov: improve CONFIG_ARCH_HAS_KCOV help text
    mm: fix inactive list balancing between NUMA nodes and cgroups
    mm/hotplug: treat CMA pages as unmovable
    proc: fixup proc-pid-vm test
    proc: fix map_files test on F29
    mm/vmstat.c: fix /proc/vmstat format for CONFIG_DEBUG_TLBFLUSH=y CONFIG_SMP=n
    mm/memory_hotplug: do not unlock after failing to take the device_hotplug_lock
    mm: swapoff: shmem_unuse() stop eviction without igrab()
    mm: swapoff: take notice of completion sooner
    mm: swapoff: remove too limiting SWAP_UNUSE_MAX_TRIES
    mm: swapoff: shmem_find_swap_entries() filter out other types
    slab: store tagged freelist for off-slab slabmgmt
    ...

    Signed-off-by: Jens Axboe

    Jens Axboe
     

10 Apr, 2019

1 commit

  • When tag_set->nr_maps is 1, the block layer limits the number of hw queues
    by nr_cpu_ids. No matter how many hw queues are used by virtio-blk, as it
    has (tag_set->nr_maps == 1), it can use at most nr_cpu_ids hw queues.

    In addition, specifically for pci scenario, when the 'num-queues' specified
    by qemu is more than maxcpus, virtio-blk would not be able to allocate more
    than maxcpus vectors in order to have a vector for each queue. As a result,
    it falls back into MSI-X with one vector for config and one shared for
    queues.

    Considering above reasons, this patch limits the number of hw queues used
    by virtio-blk by nr_cpu_ids.

    Reviewed-by: Stefan Hajnoczi
    Signed-off-by: Dongli Zhang
    Signed-off-by: Jens Axboe

    Dongli Zhang
     

08 Apr, 2019

1 commit


07 Mar, 2019

1 commit


03 Jan, 2019

1 commit

  • Pull virtio/vhost updates from Michael Tsirkin:
    "Features, fixes, cleanups:

    - discard in virtio blk

    - misc fixes and cleanups"

    * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
    vhost: correct the related warning message
    vhost: split structs into a separate header file
    virtio: remove deprecated VIRTIO_PCI_CONFIG()
    vhost/vsock: switch to a mutex for vhost_vsock_hash
    virtio_blk: add discard and write zeroes support

    Linus Torvalds
     

20 Dec, 2018

1 commit

  • In commit 88c85538, "virtio-blk: add discard and write zeroes features
    to specification" (https://github.com/oasis-tcs/virtio-spec), the virtio
    block specification has been extended to add VIRTIO_BLK_T_DISCARD and
    VIRTIO_BLK_T_WRITE_ZEROES commands. This patch enables support for
    discard and write zeroes in the virtio-blk driver when the device
    advertises the corresponding features, VIRTIO_BLK_F_DISCARD and
    VIRTIO_BLK_F_WRITE_ZEROES.

    Signed-off-by: Changpeng Liu
    Signed-off-by: Daniel Verkamp
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Stefan Hajnoczi

    Changpeng Liu
     

30 Nov, 2018

1 commit

  • We need this for blk-mq to kick things into gear, if we told it that
    we had more IO coming, but then failed to deliver on that promise.

    Reviewed-by: Omar Sandoval
    Acked-by: Michael S. Tsirkin
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Ming Lei
    Signed-off-by: Jens Axboe

    Jens Axboe
     

08 Nov, 2018

1 commit


28 Sep, 2018

2 commits

  • Use new-style DEVICE_ATTR_RO/DEVICE_ATTR_RW to create the sysfs attributes
    and register the disk with default sysfs attribute groups.

    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Acked-by: Michael S. Tsirkin
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jens Axboe

    Hannes Reinecke
     
  • Update device_add_disk() to take an 'groups' argument so that
    individual drivers can register a device with additional sysfs
    attributes.
    This avoids race condition the driver would otherwise have if these
    groups were to be created with sysfs_add_groups().

    Signed-off-by: Martin Wilck
    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jens Axboe

    Hannes Reinecke
     

25 May, 2018

1 commit

  • Convert the S_ symbolic permissions to their octal equivalents as
    using octal and not symbolic permissions is preferred by many as more
    readable.

    see: https://lkml.org/lkml/2016/8/2/1945

    Done with automated conversion via:
    $ ./scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace

    Miscellanea:

    o Wrapped modified multi-line calls to a single line where appropriate
    o Realign modified multi-line calls to open parenthesis

    Signed-off-by: Joe Perches
    Signed-off-by: Jens Axboe

    Joe Perches
     

14 May, 2018

1 commit


09 Feb, 2018

1 commit

  • Pull virtio/vhost updates from Michael Tsirkin:
    "virtio, vhost: fixes, cleanups, features

    This includes the disk/cache memory stats for for the virtio balloon,
    as well as multiple fixes and cleanups"

    * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
    vhost: don't hold onto file pointer for VHOST_SET_LOG_FD
    vhost: don't hold onto file pointer for VHOST_SET_VRING_ERR
    vhost: don't hold onto file pointer for VHOST_SET_VRING_CALL
    ringtest: ring.c malloc & memset to calloc
    virtio_vop: don't kfree device on register failure
    virtio_pci: don't kfree device on register failure
    virtio: split device_register into device_initialize and device_add
    vhost: remove unused lock check flag in vhost_dev_cleanup()
    vhost: Remove the unused variable.
    virtio_blk: print capacity at probe time
    virtio: make VIRTIO a menuconfig to ease disabling it all
    virtio/ringtest: virtio_ring: fix up need_event math
    virtio/ringtest: fix up need_event math
    virtio: virtio_mmio: make of_device_ids const.
    firmware: Use PTR_ERR_OR_ZERO()
    virtio-mmio: Use PTR_ERR_OR_ZERO()
    vhost/scsi: Improve a size determination in four functions
    virtio_balloon: include disk/file caches memory statistics

    Linus Torvalds