From a5bde5d8fde8a8cb28e59a672d5ddc5b9c1e7656 Mon Sep 17 00:00:00 2001 From: Breno Leitao Date: Wed, 5 Aug 2026 07:52:36 -0700 Subject: workqueue: skip the node_nr_active update for non-unbound workqueues apply_wqattrs_commit() updates node_nr_active->max unconditionally. wq->node_nr_active[] is only allocated for unbound workqueues, so guard the call before per-cpu workqueues start using this path. No functional change: only unbound workqueues reach apply_wqattrs_*() today. Signed-off-by: Breno Leitao Signed-off-by: Tejun Heo --- drivers/md/dm-zero.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 drivers/md/dm-zero.c (limited to 'drivers/md/dm-zero.c') diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c new file mode 100644 index 000000000..9a0bb623e --- /dev/null +++ b/drivers/md/dm-zero.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2003 Jana Saout + * + * This file is released under the GPL. + */ + +#include + +#include +#include +#include + +#define DM_MSG_PREFIX "zero" + +/* + * Construct a dummy mapping that only returns zeros + */ +static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv) +{ + if (argc != 0) { + ti->error = "No arguments required"; + return -EINVAL; + } + + /* + * Silently drop discards, avoiding -EOPNOTSUPP. + */ + ti->num_discard_bios = 1; + ti->discards_supported = true; + + return 0; +} + +/* + * Return zeros only on reads + */ +static int zero_map(struct dm_target *ti, struct bio *bio) +{ + switch (bio_op(bio)) { + case REQ_OP_READ: + if (bio->bi_opf & REQ_RAHEAD) { + /* readahead of null bytes only wastes buffer cache */ + return DM_MAPIO_KILL; + } + zero_fill_bio(bio); + break; + case REQ_OP_WRITE: + case REQ_OP_DISCARD: + /* writes get silently dropped */ + break; + default: + return DM_MAPIO_KILL; + } + + bio_endio(bio); + + /* accepted bio, don't make new request */ + return DM_MAPIO_SUBMITTED; +} + +static void zero_io_hints(struct dm_target *ti, struct queue_limits *limits) +{ + limits->max_hw_discard_sectors = UINT_MAX; + limits->discard_granularity = 512; +} + +static struct target_type zero_target = { + .name = "zero", + .version = {1, 2, 0}, + .features = DM_TARGET_NOWAIT, + .module = THIS_MODULE, + .ctr = zero_ctr, + .map = zero_map, + .io_hints = zero_io_hints, +}; +module_dm(zero); + +MODULE_AUTHOR("Jana Saout "); +MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros"); +MODULE_LICENSE("GPL"); -- cgit v1.3.1