16 Mar, 2022

1 commit

  • commit b81e0c2372e65e5627864ba034433b64b2fc73f5 upstream.

    Drop various include not actually used in genhd.h itself, and
    move the remaning includes closer together.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Johannes Thumshirn
    Link: https://lore.kernel.org/r/20210920123328.1399408-15-hch@lst.de
    Signed-off-by: Jens Axboe
    Reported-by: Sudip Mukherjee a
    Reported-by: "H. Nikolaus Schaller"
    Reported-by: Guenter Roeck
    Cc: "Maciej W. Rozycki"
    [ resolves MIPS build failure by luck, root cause needs to be fixed in
    Linus's tree properly, but this is needed for now to fix the build - gregkh ]
    Signed-off-by: Greg Kroah-Hartman

    Christoph Hellwig
     

19 Oct, 2021

1 commit

  • When adding partitions to the disk, the reference count of the disk
    object is increased. then alloc partition device and called
    device_add(), if the device_add() return error, the reference
    count of the disk object will be reduced twice, at put_device(pdev)
    and put_disk(disk). this leads to the end of the object's life cycle
    prematurely, and trigger following calltrace.

    __init_work+0x2d/0x50 kernel/workqueue.c:519
    synchronize_rcu_expedited+0x3af/0x650 kernel/rcu/tree_exp.h:847
    bdi_remove_from_list mm/backing-dev.c:938 [inline]
    bdi_unregister+0x17f/0x5c0 mm/backing-dev.c:946
    release_bdi+0xa1/0xc0 mm/backing-dev.c:968
    kref_put include/linux/kref.h:65 [inline]
    bdi_put+0x72/0xa0 mm/backing-dev.c:976
    bdev_free_inode+0x11e/0x220 block/bdev.c:408
    i_callback+0x3f/0x70 fs/inode.c:226
    rcu_do_batch kernel/rcu/tree.c:2508 [inline]
    rcu_core+0x76d/0x16c0 kernel/rcu/tree.c:2743
    __do_softirq+0x1d7/0x93b kernel/softirq.c:558
    invoke_softirq kernel/softirq.c:432 [inline]
    __irq_exit_rcu kernel/softirq.c:636 [inline]
    irq_exit_rcu+0xf2/0x130 kernel/softirq.c:648
    sysvec_apic_timer_interrupt+0x93/0xc0

    making disk is NULL when calling put_disk().

    Reported-by: Hao Sun
    Signed-off-by: Zqiang
    Reviewed-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20211018103422.2043-1-qiang.zhang1211@gmail.com
    Signed-off-by: Jens Axboe

    Zqiang
     

31 Aug, 2021

1 commit

  • Pull block updates from Jens Axboe:
    "Nothing major in here - lots of good cleanups and tech debt handling,
    which is also evident in the diffstats. In particular:

    - Add disk sequence numbers (Matteo)

    - Discard merge fix (Ming)

    - Relax disk zoned reporting restrictions (Niklas)

    - Bio error handling zoned leak fix (Pavel)

    - Start of proper add_disk() error handling (Luis, Christoph)

    - blk crypto fix (Eric)

    - Non-standard GPT location support (Dmitry)

    - IO priority improvements and cleanups (Damien)o

    - blk-throtl improvements (Chunguang)

    - diskstats_show() stack reduction (Abd-Alrhman)

    - Loop scheduler selection (Bart)

    - Switch block layer to use kmap_local_page() (Christoph)

    - Remove obsolete disk_name helper (Christoph)

    - block_device refcounting improvements (Christoph)

    - Ensure gendisk always has a request queue reference (Christoph)

    - Misc fixes/cleanups (Shaokun, Oliver, Guoqing)"

    * tag 'for-5.15/block-2021-08-30' of git://git.kernel.dk/linux-block: (129 commits)
    sg: pass the device name to blk_trace_setup
    block, bfq: cleanup the repeated declaration
    blk-crypto: fix check for too-large dun_bytes
    blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN
    blk-zoned: allow zone management send operations without CAP_SYS_ADMIN
    block: mark blkdev_fsync static
    block: refine the disk_live check in del_gendisk
    mmc: sdhci-tegra: Enable MMC_CAP2_ALT_GPT_TEGRA
    mmc: block: Support alternative_gpt_sector() operation
    partitions/efi: Support non-standard GPT location
    block: Add alternative_gpt_sector() operation
    bio: fix page leak bio_add_hw_page failure
    block: remove CONFIG_DEBUG_BLOCK_EXT_DEVT
    block: remove a pointless call to MINOR() in device_add_disk
    null_blk: add error handling support for add_disk()
    virtio_blk: add error handling support for add_disk()
    block: add error handling for device_add_disk / add_disk
    block: return errors from disk_alloc_events
    block: return errors from blk_integrity_add
    block: call blk_register_queue earlier in device_add_disk
    ...

    Linus Torvalds
     

25 Aug, 2021

1 commit

  • Support looking up GPT at a non-standard location specified by a block
    device driver.

    Acked-by: Davidlohr Bueso
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Dmitry Osipenko
    Reviewed-by: Ulf Hansson
    Link: https://lore.kernel.org/r/20210820004536.15791-3-digetx@gmail.com
    Signed-off-by: Jens Axboe

    Dmitry Osipenko
     

17 Aug, 2021

1 commit

  • The dev_t is used as the inode hash, so we should only released it
    once then block device inode is gone from the inode cache. Move it
    to bdev_free_inode to ensure that.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210816122614.601358-2-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

13 Aug, 2021

5 commits

  • bdev_resize_partition can only operate on the whole device. Make that clear
    by passing a gendisk instead of a block_device.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210810154512.1809898-5-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • bdev_del_partition can only operate on the whole device. Make that clear
    by passing a gendisk instead of a block_device.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210810154512.1809898-4-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • bdev_add_partition can only operate on the whole device. Make that clear
    by passing a gendisk instead of a block_device.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210810154512.1809898-3-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Partition scanning only happens on the whole device, so pass a
    struct gendisk instead of the whole device block_device to the scanners.
    This allows to simplify printing the device name in various places as the
    disk name is available in disk->name.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Stefan Haberland
    Link: https://lore.kernel.org/r/20210810154512.1809898-2-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Just check inode_unhashed on the whole device bdev inode instead,
    and provide a helper to check for that information.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210809064028.1198327-9-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

08 Aug, 2021

1 commit

  • Pull block fixes from Jens Axboe:
    "A few minor fixes:

    - Fix ldm kernel-doc warning (Bart)

    - Fix adding offset twice for DMA address in n64cart (Christoph)

    - Fix use-after-free in dasd path handling (Stefan)

    - Order kyber insert trace correctly (Vincent)

    - raid1 errored write handling fix (Wei)

    - Fix blk-iolatency queue get failure handling (Yu)"

    * tag 'block-5.14-2021-08-07' of git://git.kernel.dk/linux-block:
    kyber: make trace_block_rq call consistent with documentation
    block/partitions/ldm.c: Fix a kernel-doc warning
    blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()
    n64cart: fix the dma address in n64cart_do_bvec
    s390/dasd: fix use after free in dasd path handling
    md/raid10: properly indicate failure when ending a failed write request

    Linus Torvalds
     

06 Aug, 2021

1 commit

  • Fix the following kernel-doc warning that appears when building with W=1:

    block/partitions/ldm.c:31: warning: expecting prototype for ldm().
    Prototype was for ldm_debug() instead

    Signed-off-by: Bart Van Assche
    Link: https://lore.kernel.org/r/20210805173447.3249906-1-bvanassche@acm.org
    Signed-off-by: Jens Axboe

    Bart Van Assche
     

03 Aug, 2021

6 commits

  • cmdline-parser.c is only used by the cmdline faux partition format,
    so merge the code into that and avoid an indirect call.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210728053756.409654-1-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • disk_name for partition 0 just copies out the disk_name field. Replace
    the call to disk_name with a %s format specifier.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Martin K. Petersen
    Link: https://lore.kernel.org/r/20210727062518.122108-6-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Now that we've stopped using inode references for anything meaninful
    in the block layer get rid of the helper to put it and just open code
    the call to iput on the block_device inode.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Josef Bacik
    Reviewed-by: Chaitanya Kulkarni
    Link: https://lore.kernel.org/r/20210722075402.983367-10-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Instead of acquiring an inode reference on open make sure partitions
    always hold device model references to the disk while alive, and switch
    open to grab only a device model reference to the opened block device.
    If that is a partition the disk reference is transitively held by the
    partition already.

    Link: https://lore.kernel.org/r/20210722075402.983367-6-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Move the allocation of bd_meta_info after initializing the struct device
    to avoid the special bdput error handling path.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ming Lei
    Link: https://lore.kernel.org/r/20210722075402.983367-5-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Add a lockdep assert instead of the outdated locking comment.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Josef Bacik
    Reviewed-by: Ming Lei
    Reviewed-by: Chaitanya Kulkarni
    Link: https://lore.kernel.org/r/20210722075402.983367-3-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

10 Jul, 2021

1 commit

  • Pull more block updates from Jens Axboe:
    "A combination of changes that ended up depending on both the driver
    and core branch (and/or the IDE removal), and a few late arriving
    fixes. In detail:

    - Fix io ticks wrap-around issue (Chunguang)

    - nvme-tcp sock locking fix (Maurizio)

    - s390-dasd fixes (Kees, Christoph)

    - blk_execute_rq polling support (Keith)

    - blk-cgroup RCU iteration fix (Yu)

    - nbd backend ID addition (Prasanna)

    - Partition deletion fix (Yufen)

    - Use blk_mq_alloc_disk for mmc, mtip32xx, ubd (Christoph)

    - Removal of now dead block request types due to IDE removal
    (Christoph)

    - Loop probing and control device cleanups (Christoph)

    - Device uevent fix (Christoph)

    - Misc cleanups/fixes (Tetsuo, Christoph)"

    * tag 'block-5.14-2021-07-08' of git://git.kernel.dk/linux-block: (34 commits)
    blk-cgroup: prevent rcu_sched detected stalls warnings while iterating blkgs
    block: fix the problem of io_ticks becoming smaller
    nvme-tcp: can't set sk_user_data without write_lock
    loop: remove unused variable in loop_set_status()
    block: remove the bdgrab in blk_drop_partitions
    block: grab a device refcount in disk_uevent
    s390/dasd: Avoid field over-reading memcpy()
    dasd: unexport dasd_set_target_state
    block: check disk exist before trying to add partition
    ubd: remove dead code in ubd_setup_common
    nvme: use return value from blk_execute_rq()
    block: return errors from blk_execute_rq()
    nvme: use blk_execute_rq() for passthrough commands
    block: support polling through blk_execute_rq
    block: remove REQ_OP_SCSI_{IN,OUT}
    block: mark blk_mq_init_queue_data static
    loop: rewrite loop_exit using idr_for_each_entry
    loop: split loop_lookup
    loop: don't allow deleting an unspecified loop device
    loop: move loop_ctl_mutex locking into loop_add
    ...

    Linus Torvalds
     

03 Jul, 2021

1 commit

  • …nel/git/arnd/asm-generic

    Pull asm/unaligned.h unification from Arnd Bergmann:
    "Unify asm/unaligned.h around struct helper

    The get_unaligned()/put_unaligned() helpers are traditionally
    architecture specific, with the two main variants being the
    "access-ok.h" version that assumes unaligned pointer accesses always
    work on a particular architecture, and the "le-struct.h" version that
    casts the data to a byte aligned type before dereferencing, for
    architectures that cannot always do unaligned accesses in hardware.

    Based on the discussion linked below, it appears that the access-ok
    version is not realiable on any architecture, but the struct version
    probably has no downsides. This series changes the code to use the
    same implementation on all architectures, addressing the few
    exceptions separately"

    Link: https://lore.kernel.org/lkml/75d07691-1e4f-741f-9852-38c0b4f520bc@synopsys.com/
    Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363
    Link: https://lore.kernel.org/lkml/20210507220813.365382-14-arnd@kernel.org/
    Link: git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git unaligned-rework-v2
    Link: https://lore.kernel.org/lkml/CAHk-=whGObOKruA_bU3aPGZfoDqZM1_9wBkwREp0H0FgR-90uQ@mail.gmail.com/

    * tag 'asm-generic-unaligned-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    asm-generic: simplify asm/unaligned.h
    asm-generic: uaccess: 1-byte access is always aligned
    netpoll: avoid put_unaligned() on single character
    mwifiex: re-fix for unaligned accesses
    apparmor: use get_unaligned() only for multi-byte words
    partitions: msdos: fix one-byte get_unaligned()
    asm-generic: unaligned always use struct helpers
    asm-generic: unaligned: remove byteshift helpers
    powerpc: use linux/unaligned/le_struct.h on LE power7
    m68k: select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
    sh: remove unaligned access for sh4a
    openrisc: always use unaligned-struct header
    asm-generic: use asm-generic/unaligned.h for most architectures

    Linus Torvalds
     

02 Jul, 2021

1 commit


01 Jul, 2021

1 commit

  • If disk have been deleted, we should return fail for ioctl
    BLKPG_DEL_PARTITION. Otherwise, the directory /sys/class/block
    may remain invalid symlinks file. The race as following:

    blkdev_open
    del_gendisk
    disk->flags &= ~GENHD_FL_UP;
    blk_drop_partitions
    blkpg_ioctl
    bdev_add_partition
    add_partition
    device_add
    device_add_class_symlinks

    ioctl may add_partition after del_gendisk() have tried to delete
    partitions. Then, symlinks file will be created.

    Reviewed-by: Jan Kara
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Yufen Yu
    Link: https://lore.kernel.org/r/20210610023241.3646241-1-yuyufen@huawei.com
    Signed-off-by: Jens Axboe

    Yufen Yu
     

25 Jun, 2021

2 commits


22 Jun, 2021

1 commit


01 Jun, 2021

4 commits

  • Just opencode the xa_load in the callers, as none of them actually
    needs a reference to the bdev.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Ming Lei
    Link: https://lore.kernel.org/r/20210525061301.2242282-9-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Replace the per-block device bd_mutex with a per-gendisk open_mutex,
    thus simplifying locking wherever we deal with partitions.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ming Lei
    Acked-by: Roger Pau Monné
    Link: https://lore.kernel.org/r/20210525061301.2242282-4-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Automatically set the GENHD_FL_EXT_DEVT flag for all disks allocated
    without an explicit number of minors. This is what all new block
    drivers should do, so make sure it is the default without boilerplate
    code.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Luis Chamberlain
    Reviewed-by: Ulf Hansson
    Link: https://lore.kernel.org/r/20210521055116.1053587-4-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Untangle the mess around blk_alloc_devt by moving the check for
    the used allocation scheme into the callers.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Luis Chamberlain
    Reviewed-by: Ulf Hansson
    Link: https://lore.kernel.org/r/20210521055116.1053587-2-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

17 May, 2021

1 commit

  • A simplification of get_unaligned() clashes with callers that pass
    in a character pointer, causing a harmless warning like:

    block/partitions/msdos.c: In function 'msdos_partition':
    include/asm-generic/unaligned.h:13:22: warning: 'packed' attribute ignored for field of type 'u8' {aka 'unsigned char'} [-Wattributes]

    Remove the SYS_IND() macro with the get_unaligned() call
    and just use the ->ind field directly.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

14 May, 2021

1 commit


29 Apr, 2021

1 commit

  • Pull block updates from Jens Axboe:
    "Pretty quiet round this time, which is nice. In detail:

    - Series revamping bounce buffer support (Christoph)

    - Dead code removal (Christoph, Bart)

    - Partition iteration revamp, now using xarray (Christoph)

    - Passthrough request scheduler improvements (Lin)

    - Series of BFQ improvements (Paolo)

    - Fix ioprio task iteration (Peter)

    - Various little tweaks and fixes (Tejun, Saravanan, Bhaskar, Max,
    Nikolay)"

    * tag 'for-5.13/block-2021-04-27' of git://git.kernel.dk/linux-block: (41 commits)
    blk-iocost: don't ignore vrate_min on QD contention
    blk-mq: Fix spurious debugfs directory creation during initialization
    bfq/mq-deadline: remove redundant check for passthrough request
    blk-mq: bypass IO scheduler's limit_depth for passthrough request
    block: Remove an obsolete comment from sg_io()
    block: move bio_list_copy_data to pktcdvd
    block: remove zero_fill_bio_iter
    block: add queue_to_disk() to get gendisk from request_queue
    block: remove an incorrect check from blk_rq_append_bio
    block: initialize ret in bdev_disk_changed
    block: Fix sys_ioprio_set(.which=IOPRIO_WHO_PGRP) task iteration
    block: remove disk_part_iter
    block: simplify diskstats_show
    block: simplify show_partition
    block: simplify printk_all_partitions
    block: simplify partition_overlaps
    block: simplify partition removal
    block: take bd_mutex around delete_partitions in del_gendisk
    block: refactor blk_drop_partitions
    block: move more syncing and invalidation to delete_partition
    ...

    Linus Torvalds
     

09 Apr, 2021

6 commits

  • Just use xa_for_each to iterate over the partitions as there is no need
    to grab a reference to each partition.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210406062303.811835-8-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Always look up the first available entry instead of the complicated
    stateful traversal.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210406062303.811835-7-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • There is nothing preventing an ioctl from trying do delete partition
    concurrenly with del_gendisk, so take open_mutex to serialize against
    that.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210406062303.811835-6-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Move the busy check and disk-wide sync into the only caller, so that
    the remainder can be shared with del_gendisk. Also pass the gendisk
    instead of the bdev as that is all that is needed.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210406062303.811835-5-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Move the calls to fsync_bdev and __invalidate_device from del_gendisk to
    delete_partition. For the other two callers that check that there are
    no openers for the delete partitions(s) the callouts are a no-op as no
    file system can be mounted, but this keeps all the cleanup in one
    place.

    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20210406062303.811835-4-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Use the more general interface - the behavior is the same except
    that now a change uevent is sent, which is the right thing to do
    when the device becomes unusable.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Haberland
    Link: https://lore.kernel.org/r/20210406062303.811835-2-hch@lst.de
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

27 Mar, 2021

1 commit

  • Commit a33df75c6328 ("block: use an xarray for disk->part_tbl") drops the
    check on max supported number of partitionsr, and allows partition with
    bigger partition numbers to be added. However, ->bd_partno is defined as
    u8, so partition index of xarray table may not match with ->bd_partno.
    Then delete_partition() may delete one unmatched partition, and caused
    use-after-free.

    Reviewed-by: Bart Van Assche
    Reported-by: syzbot+8fede7e30c7cee0de139@syzkaller.appspotmail.com
    Fixes: a33df75c6328 ("block: use an xarray for disk->part_tbl")
    Signed-off-by: Ming Lei
    Signed-off-by: Jens Axboe

    Ming Lei
     

01 Mar, 2021

1 commit

  • With the removal of the skd driver, using IRQ safe locking of a bdev
    bd_size_lock spinlock to protect the bdev inode size is not necessary
    anymore as there is no other known driver using this lock under an IRQ
    disabled context (e.g. calling set_capacity() with IRQ disabled).
    Revert commit 0fe37724f8e7 ("block: fix bd_size_lock use") which
    introduced the IRQ safe change.

    Signed-off-by: Damien Le Moal
    Signed-off-by: Jens Axboe

    Damien Le Moal