From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon, 13 May 2024 20:03:54 +0000 (-0700)
Subject: Merge tag 'for-6.10/block-20240511' of git://git.kernel.dk/linux
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=0c9f4ac808b017a0013cee92a30de980550145d5;p=linux.git

Merge tag 'for-6.10/block-20240511' of git://git.kernel.dk/linux

Pull block updates from Jens Axboe:

 - Add a partscan attribute in sysfs, fixing an issue with systemd
   relying on an internal interface that went away.

 - Attempt #2 at making long running discards interruptible. The
   previous attempt went into 6.9, but we ended up mostly reverting it
   as it had issues.

 - Remove old ida_simple API in bcache

 - Support for zoned write plugging, greatly improving the performance
   on zoned devices.

 - Remove the old throttle low interface, which has been experimental
   since 2017 and never made it beyond that and isn't being used.

 - Remove page->index debugging checks in brd, as it hasn't caught
   anything and prepares us for removing in struct page.

 - MD pull request from Song

 - Don't schedule block workers on isolated CPUs

* tag 'for-6.10/block-20240511' of git://git.kernel.dk/linux: (84 commits)
  blk-throttle: delay initialization until configuration
  blk-throttle: remove CONFIG_BLK_DEV_THROTTLING_LOW
  block: fix that util can be greater than 100%
  block: support to account io_ticks precisely
  block: add plug while submitting IO
  bcache: fix variable length array abuse in btree_iter
  bcache: Remove usage of the deprecated ida_simple_xx() API
  md: Revert "md: Fix overflow in is_mddev_idle"
  blk-lib: check for kill signal in ioctl BLKDISCARD
  block: add a bio_await_chain helper
  block: add a blk_alloc_discard_bio helper
  block: add a bio_chain_and_submit helper
  block: move discard checks into the ioctl handler
  block: remove the discard_granularity check in __blkdev_issue_discard
  block/ioctl: prefer different overflow check
  null_blk: Fix the WARNING: modpost: missing MODULE_DESCRIPTION()
  block: fix and simplify blkdevparts= cmdline parsing
  block: refine the EOF check in blkdev_iomap_begin
  block: add a partscan sysfs attribute for disks
  block: add a disk_has_partscan helper
  ...
---

0c9f4ac808b017a0013cee92a30de980550145d5
diff --cc block/ioctl.c
index f505f9c341eb0,d7a6c6931a1e7..c7db3bd2d653c
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@@ -95,9 -95,12 +95,12 @@@ static int compat_blkpg_ioctl(struct bl
  static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
  		unsigned long arg)
  {
- 	uint64_t range[2];
- 	uint64_t start, len, end;
+ 	unsigned int bs_mask = bdev_logical_block_size(bdev) - 1;
  	struct inode *inode = bdev->bd_inode;
 -	uint64_t range[2], start, len;
++	uint64_t range[2], start, len, end;
+ 	struct bio *prev = NULL, *bio;
+ 	sector_t sector, nr_sects;
+ 	struct blk_plug plug;
  	int err;
  
  	if (!(mode & BLK_OPEN_WRITE))
@@@ -112,13 -117,12 +117,13 @@@
  	start = range[0];
  	len = range[1];
  
- 	if (start & 511)
+ 	if (!len)
  		return -EINVAL;
- 	if (len & 511)
+ 	if ((start | len) & bs_mask)
  		return -EINVAL;
  
 -	if (start + len > bdev_nr_bytes(bdev))
 +	if (check_add_overflow(start, len, &end) ||
 +	    end > bdev_nr_bytes(bdev))
  		return -EINVAL;
  
  	filemap_invalidate_lock(inode->i_mapping);