Commit bea82c80 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull block fixes from Jens Axboe:

 - Scan partition tables asynchronously for ublk, similarly to how nvme
   does it. This avoids potential deadlocks, which is why nvme does it
   that way too. Includes a set of selftests as well.

 - MD pull request via Yu:
     - Fix null-pointer dereference in raid5 sysfs group_thread_cnt
       store (Tuo Li)
     - Fix possible mempool corruption during raid1 raid_disks update
       via sysfs (FengWei Shih)
     - Fix logical_block_size configuration being overwritten during
       super_1_validate() (Li Nan)
     - Fix forward incompatibility with configurable logical block size:
       arrays assembled on new kernels could not be assembled on older
       kernels (v6.18 and before) due to non-zero reserved pad rejection
       (Li Nan)
     - Fix static checker warning about iterator not incremented (Li Nan)

 - Skip CPU offlining notifications on unmapped hardware queues

 - bfq-iosched block stats fix

 - Fix outdated comment in bfq-iosched

* tag 'block-6.19-20260102' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux:
  block, bfq: update outdated comment
  blk-mq: skip CPU offline notify on unmapped hctx
  selftests/ublk: fix Makefile to rebuild on header changes
  selftests/ublk: add test for async partition scan
  ublk: scan partition in async way
  block,bfq: fix aux stat accumulation destination
  md: Fix forward incompatibility from configurable logical block size
  md: Fix logical_block_size configuration being overwritten
  md: suspend array while updating raid_disks via sysfs
  md/raid5: fix possible null-pointer dereferences in raid5_store_group_thread_cnt()
  md: Fix static checker warning in analyze_sbs
parents 509b5b11 69153e8b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ static void bfqg_stats_add_aux(struct bfqg_stats *to, struct bfqg_stats *from)
	blkg_rwstat_add_aux(&to->merged, &from->merged);
	blkg_rwstat_add_aux(&to->service_time, &from->service_time);
	blkg_rwstat_add_aux(&to->wait_time, &from->wait_time);
	bfq_stat_add_aux(&from->time, &from->time);
	bfq_stat_add_aux(&to->time, &from->time);
	bfq_stat_add_aux(&to->avg_queue_size_sum, &from->avg_queue_size_sum);
	bfq_stat_add_aux(&to->avg_queue_size_samples,
			  &from->avg_queue_size_samples);
+1 −1
Original line number Diff line number Diff line
@@ -984,7 +984,7 @@ struct bfq_group_data {
 *                   unused for the root group. Used to know whether there
 *                   are groups with more than one active @bfq_entity
 *                   (see the comments to the function
 *                   bfq_bfqq_may_idle()).
 *                   bfq_better_to_idle()).
 * @rq_pos_tree: rbtree sorted by next_request position, used when
 *               determining if two or more queues have interleaving
 *               requests (see bfq_find_close_cooperator()).
+1 −1
Original line number Diff line number Diff line
@@ -3721,7 +3721,7 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node)
			struct blk_mq_hw_ctx, cpuhp_online);
	int ret = 0;

	if (blk_mq_hctx_has_online_cpu(hctx, cpu))
	if (!hctx->nr_ctx || blk_mq_hctx_has_online_cpu(hctx, cpu))
		return 0;

	/*
+32 −3
Original line number Diff line number Diff line
@@ -237,6 +237,7 @@ struct ublk_device {
	bool canceling;
	pid_t 	ublksrv_tgid;
	struct delayed_work	exit_work;
	struct work_struct	partition_scan_work;

	struct ublk_queue       *queues[];
};
@@ -254,6 +255,20 @@ static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
		u16 q_id, u16 tag, struct ublk_io *io, size_t offset);
static inline unsigned int ublk_req_build_flags(struct request *req);

static void ublk_partition_scan_work(struct work_struct *work)
{
	struct ublk_device *ub =
		container_of(work, struct ublk_device, partition_scan_work);

	if (WARN_ON_ONCE(!test_and_clear_bit(GD_SUPPRESS_PART_SCAN,
					     &ub->ub_disk->state)))
		return;

	mutex_lock(&ub->ub_disk->open_mutex);
	bdev_disk_changed(ub->ub_disk, false);
	mutex_unlock(&ub->ub_disk->open_mutex);
}

static inline struct ublksrv_io_desc *
ublk_get_iod(const struct ublk_queue *ubq, unsigned tag)
{
@@ -2026,6 +2041,7 @@ static void ublk_stop_dev(struct ublk_device *ub)
	mutex_lock(&ub->mutex);
	ublk_stop_dev_unlocked(ub);
	mutex_unlock(&ub->mutex);
	flush_work(&ub->partition_scan_work);
	ublk_cancel_dev(ub);
}

@@ -2954,8 +2970,16 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,

	ublk_apply_params(ub);

	/* don't probe partitions if any daemon task is un-trusted */
	if (ub->unprivileged_daemons)
	/*
	 * Suppress partition scan to avoid potential IO hang.
	 *
	 * If ublk server error occurs during partition scan, the IO may
	 * wait while holding ub->mutex, which can deadlock with other
	 * operations that need the mutex. Defer partition scan to async
	 * work.
	 * For unprivileged daemons, keep GD_SUPPRESS_PART_SCAN set
	 * permanently.
	 */
	set_bit(GD_SUPPRESS_PART_SCAN, &disk->state);

	ublk_get_device(ub);
@@ -2973,6 +2997,10 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,

	set_bit(UB_STATE_USED, &ub->state);

	/* Schedule async partition scan for trusted daemons */
	if (!ub->unprivileged_daemons)
		schedule_work(&ub->partition_scan_work);

out_put_cdev:
	if (ret) {
		ublk_detach_disk(ub);
@@ -3138,6 +3166,7 @@ static int ublk_ctrl_add_dev(const struct ublksrv_ctrl_cmd *header)
	mutex_init(&ub->mutex);
	spin_lock_init(&ub->lock);
	mutex_init(&ub->cancel_mutex);
	INIT_WORK(&ub->partition_scan_work, ublk_partition_scan_work);

	ret = ublk_alloc_dev_number(ub, header->dev_id);
	if (ret < 0)
+50 −11
Original line number Diff line number Diff line
@@ -1999,7 +1999,6 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
		mddev->layout = le32_to_cpu(sb->layout);
		mddev->raid_disks = le32_to_cpu(sb->raid_disks);
		mddev->dev_sectors = le64_to_cpu(sb->size);
		mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);
		mddev->events = ev1;
		mddev->bitmap_info.offset = 0;
		mddev->bitmap_info.space = 0;
@@ -2015,6 +2014,9 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc

		mddev->max_disks =  (4096-256)/2;

		if (!mddev->logical_block_size)
			mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);

		if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) &&
		    mddev->bitmap_info.file == NULL) {
			mddev->bitmap_info.offset =
@@ -3882,7 +3884,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe

static int analyze_sbs(struct mddev *mddev)
{
	int i;
	struct md_rdev *rdev, *freshest, *tmp;

	freshest = NULL;
@@ -3909,11 +3910,9 @@ static int analyze_sbs(struct mddev *mddev)
	super_types[mddev->major_version].
		validate_super(mddev, NULL/*freshest*/, freshest);

	i = 0;
	rdev_for_each_safe(rdev, tmp, mddev) {
		if (mddev->max_disks &&
		    (rdev->desc_nr >= mddev->max_disks ||
		     i > mddev->max_disks)) {
		    rdev->desc_nr >= mddev->max_disks) {
			pr_warn("md: %s: %pg: only %d devices permitted\n",
				mdname(mddev), rdev->bdev,
				mddev->max_disks);
@@ -4407,7 +4406,7 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
	if (err < 0)
		return err;

	err = mddev_lock(mddev);
	err = mddev_suspend_and_lock(mddev);
	if (err)
		return err;
	if (mddev->pers)
@@ -4432,7 +4431,7 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
	} else
		mddev->raid_disks = n;
out_unlock:
	mddev_unlock(mddev);
	mddev_unlock_and_resume(mddev);
	return err ? err : len;
}
static struct md_sysfs_entry md_raid_disks =
@@ -5981,13 +5980,33 @@ lbs_store(struct mddev *mddev, const char *buf, size_t len)
	if (mddev->major_version == 0)
		return -EINVAL;

	if (mddev->pers)
		return -EBUSY;

	err = kstrtouint(buf, 10, &lbs);
	if (err < 0)
		return -EINVAL;

	if (mddev->pers) {
		unsigned int curr_lbs;

		if (mddev->logical_block_size)
			return -EBUSY;
		/*
		 * To fix forward compatibility issues, LBS is not
		 * configured for arrays from old kernels (<=6.18) by default.
		 * If the user confirms no rollback to old kernels,
		 * enable LBS by writing current LBS — to prevent data
		 * loss from LBS changes.
		 */
		curr_lbs = queue_logical_block_size(mddev->gendisk->queue);
		if (lbs != curr_lbs)
			return -EINVAL;

		mddev->logical_block_size = curr_lbs;
		set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
		pr_info("%s: logical block size configured successfully, array will not be assembled in old kernels (<= 6.18)\n",
			mdname(mddev));
		return len;
	}

	err = mddev_lock(mddev);
	if (err)
		goto unlock;
@@ -6163,7 +6182,27 @@ int mddev_stack_rdev_limits(struct mddev *mddev, struct queue_limits *lim,
			mdname(mddev));
		return -EINVAL;
	}

	/* Only 1.x meta needs to set logical block size */
	if (mddev->major_version == 0)
		return 0;

	/*
	 * Fix forward compatibility issue. Only set LBS by default for
	 * new arrays, mddev->events == 0 indicates the array was just
	 * created. When assembling an array, read LBS from the superblock
	 * instead — LBS is 0 in superblocks created by old kernels.
	 */
	if (!mddev->events) {
		pr_info("%s: array will not be assembled in old kernels that lack configurable LBS support (<= 6.18)\n",
			mdname(mddev));
		mddev->logical_block_size = lim->logical_block_size;
	}

	if (!mddev->logical_block_size)
		pr_warn("%s: echo current LBS to md/logical_block_size to prevent data loss issues from LBS changes.\n"
			"\tNote: After setting, array will not be assembled in old kernels (<= 6.18)\n",
			mdname(mddev));

	return 0;
}
Loading