Skip to content

Commit d6a846c

Browse files
author
CKI KWF Bot
committed
Merge: dm: sync with upstream v6.17
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7535 JIRA: https://issues.redhat.com/browse/RHEL-119009 Upstream Status: kernel/git/torvalds/linux.git Pull in various dm changes from upstream. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Approved-by: Matthew Sakai <msakai@redhat.com> Approved-by: Mikuláš Patočka <mpatocka@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 9530971 + 03ae34e commit d6a846c

33 files changed

+553
-611
lines changed

Documentation/admin-guide/device-mapper/dm-integrity.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ Target arguments:
9292
allowed. This mode is useful for data recovery if the
9393
device cannot be activated in any of the other standard
9494
modes.
95+
I - inline mode - in this mode, dm-integrity will store integrity
96+
data directly in the underlying device sectors.
97+
The underlying device must have an integrity profile that
98+
allows storing user integrity data and provides enough
99+
space for the selected integrity tag.
95100

96101
5. the number of additional arguments
97102

Documentation/admin-guide/device-mapper/thin-provisioning.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ less sharing than average you'll need a larger-than-average metadata device.
8080

8181
As a guide, we suggest you calculate the number of bytes to use in the
8282
metadata device as 48 * $data_dev_size / $data_block_size but round it up
83-
to 2MB if the answer is smaller. If you're creating large numbers of
83+
to 2MiB if the answer is smaller. If you're creating large numbers of
8484
snapshots which are recording large amounts of change, you may find you
8585
need to increase this.
8686

87-
The largest size supported is 16GB: If the device is larger,
87+
The largest size supported is 16GiB: If the device is larger,
8888
a warning will be issued and the excess space will not be used.
8989

9090
Reloading a pool table
@@ -107,13 +107,13 @@ Using an existing pool device
107107

108108
$data_block_size gives the smallest unit of disk space that can be
109109
allocated at a time expressed in units of 512-byte sectors.
110-
$data_block_size must be between 128 (64KB) and 2097152 (1GB) and a
111-
multiple of 128 (64KB). $data_block_size cannot be changed after the
110+
$data_block_size must be between 128 (64KiB) and 2097152 (1GiB) and a
111+
multiple of 128 (64KiB). $data_block_size cannot be changed after the
112112
thin-pool is created. People primarily interested in thin provisioning
113-
may want to use a value such as 1024 (512KB). People doing lots of
114-
snapshotting may want a smaller value such as 128 (64KB). If you are
113+
may want to use a value such as 1024 (512KiB). People doing lots of
114+
snapshotting may want a smaller value such as 128 (64KiB). If you are
115115
not zeroing newly-allocated data, a larger $data_block_size in the
116-
region of 256000 (128MB) is suggested.
116+
region of 262144 (128MiB) is suggested.
117117

118118
$low_water_mark is expressed in blocks of size $data_block_size. If
119119
free space on the data device drops below this level then a dm event
@@ -291,7 +291,7 @@ i) Constructor
291291
error_if_no_space:
292292
Error IOs, instead of queueing, if no space.
293293

294-
Data block size must be between 64KB (128 sectors) and 1GB
294+
Data block size must be between 64KiB (128 sectors) and 1GiB
295295
(2097152 sectors) inclusive.
296296

297297

Documentation/admin-guide/device-mapper/verity.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ panic_on_corruption
8787
Panic the device when a corrupted block is discovered. This option is
8888
not compatible with ignore_corruption and restart_on_corruption.
8989

90+
restart_on_error
91+
Restart the system when an I/O error is detected.
92+
This option can be combined with the restart_on_corruption option.
93+
94+
panic_on_error
95+
Panic the device when an I/O error is detected. This option is
96+
not compatible with the restart_on_error option but can be combined
97+
with the panic_on_corruption option.
98+
9099
ignore_zero_blocks
91100
Do not verify blocks that are expected to contain zeroes and always return
92101
zeroes instead. This may be useful if the partition contains unused blocks
@@ -142,8 +151,15 @@ root_hash_sig_key_desc <key_description>
142151
already in the secondary trusted keyring.
143152

144153
try_verify_in_tasklet
145-
If verity hashes are in cache, verify data blocks in kernel tasklet instead
146-
of workqueue. This option can reduce IO latency.
154+
If verity hashes are in cache and the IO size does not exceed the limit,
155+
verify data blocks in bottom half instead of workqueue. This option can
156+
reduce IO latency. The size limits can be configured via
157+
/sys/module/dm_verity/parameters/use_bh_bytes. The four parameters
158+
correspond to limits for IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT,
159+
IOPRIO_CLASS_BE and IOPRIO_CLASS_IDLE in turn.
160+
For example:
161+
<none>,<rt>,<be>,<idle>
162+
4096,4096,4096,4096
147163

148164
Theory of operation
149165
===================

drivers/md/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ config DM_CRYPT
284284
depends on BLK_DEV_DM
285285
depends on (ENCRYPTED_KEYS || ENCRYPTED_KEYS=n)
286286
depends on (TRUSTED_KEYS || TRUSTED_KEYS=n)
287+
select CRC32
287288
select CRYPTO
288289
select CRYPTO_CBC
289290
select CRYPTO_ESSIV

drivers/md/dm-bufio.c

Lines changed: 41 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@
4040
#define DM_BUFIO_WRITEBACK_RATIO 3
4141
#define DM_BUFIO_LOW_WATERMARK_RATIO 16
4242

43-
/*
44-
* Check buffer ages in this interval (seconds)
45-
*/
46-
#define DM_BUFIO_WORK_TIMER_SECS 30
47-
48-
/*
49-
* Free buffers when they are older than this (seconds)
50-
*/
51-
#define DM_BUFIO_DEFAULT_AGE_SECS 300
52-
5343
/*
5444
* The nr of bytes of cached data to keep around.
5545
*/
@@ -1057,10 +1047,8 @@ static unsigned long dm_bufio_cache_size_latch;
10571047

10581048
static DEFINE_SPINLOCK(global_spinlock);
10591049

1060-
/*
1061-
* Buffers are freed after this timeout
1062-
*/
1063-
static unsigned int dm_bufio_max_age = DM_BUFIO_DEFAULT_AGE_SECS;
1050+
static unsigned int dm_bufio_max_age; /* No longer does anything */
1051+
10641052
static unsigned long dm_bufio_retain_bytes = DM_BUFIO_DEFAULT_RETAIN_BYTES;
10651053

10661054
static unsigned long dm_bufio_peak_allocated;
@@ -1088,7 +1076,6 @@ static LIST_HEAD(dm_bufio_all_clients);
10881076
static DEFINE_MUTEX(dm_bufio_clients_lock);
10891077

10901078
static struct workqueue_struct *dm_bufio_wq;
1091-
static struct delayed_work dm_bufio_cleanup_old_work;
10921079
static struct work_struct dm_bufio_replacement_work;
10931080

10941081

@@ -2236,7 +2223,7 @@ int dm_bufio_issue_discard(struct dm_bufio_client *c, sector_t block, sector_t c
22362223
}
22372224
EXPORT_SYMBOL_GPL(dm_bufio_issue_discard);
22382225

2239-
static bool forget_buffer(struct dm_bufio_client *c, sector_t block)
2226+
static void forget_buffer(struct dm_bufio_client *c, sector_t block)
22402227
{
22412228
struct dm_buffer *b;
22422229

@@ -2251,8 +2238,6 @@ static bool forget_buffer(struct dm_bufio_client *c, sector_t block)
22512238
cache_put_and_wake(c, b);
22522239
}
22532240
}
2254-
2255-
return b ? true : false;
22562241
}
22572242

22582243
/*
@@ -2682,130 +2667,6 @@ EXPORT_SYMBOL_GPL(dm_bufio_set_sector_offset);
26822667

26832668
/*--------------------------------------------------------------*/
26842669

2685-
static unsigned int get_max_age_hz(void)
2686-
{
2687-
unsigned int max_age = READ_ONCE(dm_bufio_max_age);
2688-
2689-
if (max_age > UINT_MAX / HZ)
2690-
max_age = UINT_MAX / HZ;
2691-
2692-
return max_age * HZ;
2693-
}
2694-
2695-
static bool older_than(struct dm_buffer *b, unsigned long age_hz)
2696-
{
2697-
return time_after_eq(jiffies, READ_ONCE(b->last_accessed) + age_hz);
2698-
}
2699-
2700-
struct evict_params {
2701-
gfp_t gfp;
2702-
unsigned long age_hz;
2703-
2704-
/*
2705-
* This gets updated with the largest last_accessed (ie. most
2706-
* recently used) of the evicted buffers. It will not be reinitialised
2707-
* by __evict_many(), so you can use it across multiple invocations.
2708-
*/
2709-
unsigned long last_accessed;
2710-
};
2711-
2712-
/*
2713-
* We may not be able to evict this buffer if IO pending or the client
2714-
* is still using it.
2715-
*
2716-
* And if GFP_NOFS is used, we must not do any I/O because we hold
2717-
* dm_bufio_clients_lock and we would risk deadlock if the I/O gets
2718-
* rerouted to different bufio client.
2719-
*/
2720-
static enum evict_result select_for_evict(struct dm_buffer *b, void *context)
2721-
{
2722-
struct evict_params *params = context;
2723-
2724-
if (!(params->gfp & __GFP_FS) ||
2725-
(static_branch_unlikely(&no_sleep_enabled) && b->c->no_sleep)) {
2726-
if (test_bit_acquire(B_READING, &b->state) ||
2727-
test_bit(B_WRITING, &b->state) ||
2728-
test_bit(B_DIRTY, &b->state))
2729-
return ER_DONT_EVICT;
2730-
}
2731-
2732-
return older_than(b, params->age_hz) ? ER_EVICT : ER_STOP;
2733-
}
2734-
2735-
static unsigned long __evict_many(struct dm_bufio_client *c,
2736-
struct evict_params *params,
2737-
int list_mode, unsigned long max_count)
2738-
{
2739-
unsigned long count;
2740-
unsigned long last_accessed;
2741-
struct dm_buffer *b;
2742-
2743-
for (count = 0; count < max_count; count++) {
2744-
b = cache_evict(&c->cache, list_mode, select_for_evict, params);
2745-
if (!b)
2746-
break;
2747-
2748-
last_accessed = READ_ONCE(b->last_accessed);
2749-
if (time_after_eq(params->last_accessed, last_accessed))
2750-
params->last_accessed = last_accessed;
2751-
2752-
__make_buffer_clean(b);
2753-
__free_buffer_wake(b);
2754-
2755-
cond_resched();
2756-
}
2757-
2758-
return count;
2759-
}
2760-
2761-
static void evict_old_buffers(struct dm_bufio_client *c, unsigned long age_hz)
2762-
{
2763-
struct evict_params params = {.gfp = 0, .age_hz = age_hz, .last_accessed = 0};
2764-
unsigned long retain = get_retain_buffers(c);
2765-
unsigned long count;
2766-
LIST_HEAD(write_list);
2767-
2768-
dm_bufio_lock(c);
2769-
2770-
__check_watermark(c, &write_list);
2771-
if (unlikely(!list_empty(&write_list))) {
2772-
dm_bufio_unlock(c);
2773-
__flush_write_list(&write_list);
2774-
dm_bufio_lock(c);
2775-
}
2776-
2777-
count = cache_total(&c->cache);
2778-
if (count > retain)
2779-
__evict_many(c, &params, LIST_CLEAN, count - retain);
2780-
2781-
dm_bufio_unlock(c);
2782-
}
2783-
2784-
static void cleanup_old_buffers(void)
2785-
{
2786-
unsigned long max_age_hz = get_max_age_hz();
2787-
struct dm_bufio_client *c;
2788-
2789-
mutex_lock(&dm_bufio_clients_lock);
2790-
2791-
__cache_size_refresh();
2792-
2793-
list_for_each_entry(c, &dm_bufio_all_clients, client_list)
2794-
evict_old_buffers(c, max_age_hz);
2795-
2796-
mutex_unlock(&dm_bufio_clients_lock);
2797-
}
2798-
2799-
static void work_fn(struct work_struct *w)
2800-
{
2801-
cleanup_old_buffers();
2802-
2803-
queue_delayed_work(dm_bufio_wq, &dm_bufio_cleanup_old_work,
2804-
DM_BUFIO_WORK_TIMER_SECS * HZ);
2805-
}
2806-
2807-
/*--------------------------------------------------------------*/
2808-
28092670
/*
28102671
* Global cleanup tries to evict the oldest buffers from across _all_
28112672
* the clients. It does this by repeatedly evicting a few buffers from
@@ -2843,27 +2704,55 @@ static void __insert_client(struct dm_bufio_client *new_client)
28432704
list_add_tail(&new_client->client_list, h);
28442705
}
28452706

2707+
static enum evict_result select_for_evict(struct dm_buffer *b, void *context)
2708+
{
2709+
/* In no-sleep mode, we cannot wait on IO. */
2710+
if (static_branch_unlikely(&no_sleep_enabled) && b->c->no_sleep) {
2711+
if (test_bit_acquire(B_READING, &b->state) ||
2712+
test_bit(B_WRITING, &b->state) ||
2713+
test_bit(B_DIRTY, &b->state))
2714+
return ER_DONT_EVICT;
2715+
}
2716+
return ER_EVICT;
2717+
}
2718+
28462719
static unsigned long __evict_a_few(unsigned long nr_buffers)
28472720
{
2848-
unsigned long count;
28492721
struct dm_bufio_client *c;
2850-
struct evict_params params = {
2851-
.gfp = GFP_KERNEL,
2852-
.age_hz = 0,
2853-
/* set to jiffies in case there are no buffers in this client */
2854-
.last_accessed = jiffies
2855-
};
2722+
unsigned long oldest_buffer = jiffies;
2723+
unsigned long last_accessed;
2724+
unsigned long count;
2725+
struct dm_buffer *b;
28562726

28572727
c = __pop_client();
28582728
if (!c)
28592729
return 0;
28602730

28612731
dm_bufio_lock(c);
2862-
count = __evict_many(c, &params, LIST_CLEAN, nr_buffers);
2732+
2733+
for (count = 0; count < nr_buffers; count++) {
2734+
b = cache_evict(&c->cache, LIST_CLEAN, select_for_evict, NULL);
2735+
if (!b)
2736+
break;
2737+
2738+
last_accessed = READ_ONCE(b->last_accessed);
2739+
if (time_after_eq(oldest_buffer, last_accessed))
2740+
oldest_buffer = last_accessed;
2741+
2742+
__make_buffer_clean(b);
2743+
__free_buffer_wake(b);
2744+
2745+
if (need_resched()) {
2746+
dm_bufio_unlock(c);
2747+
cond_resched();
2748+
dm_bufio_lock(c);
2749+
}
2750+
}
2751+
28632752
dm_bufio_unlock(c);
28642753

28652754
if (count)
2866-
c->oldest_buffer = params.last_accessed;
2755+
c->oldest_buffer = oldest_buffer;
28672756
__insert_client(c);
28682757

28692758
return count;
@@ -2946,10 +2835,7 @@ static int __init dm_bufio_init(void)
29462835
if (!dm_bufio_wq)
29472836
return -ENOMEM;
29482837

2949-
INIT_DELAYED_WORK(&dm_bufio_cleanup_old_work, work_fn);
29502838
INIT_WORK(&dm_bufio_replacement_work, do_global_cleanup);
2951-
queue_delayed_work(dm_bufio_wq, &dm_bufio_cleanup_old_work,
2952-
DM_BUFIO_WORK_TIMER_SECS * HZ);
29532839

29542840
return 0;
29552841
}
@@ -2961,7 +2847,6 @@ static void __exit dm_bufio_exit(void)
29612847
{
29622848
int bug = 0;
29632849

2964-
cancel_delayed_work_sync(&dm_bufio_cleanup_old_work);
29652850
destroy_workqueue(dm_bufio_wq);
29662851

29672852
if (dm_bufio_client_count) {
@@ -2998,7 +2883,7 @@ module_param_named(max_cache_size_bytes, dm_bufio_cache_size, ulong, 0644);
29982883
MODULE_PARM_DESC(max_cache_size_bytes, "Size of metadata cache");
29992884

30002885
module_param_named(max_age_seconds, dm_bufio_max_age, uint, 0644);
3001-
MODULE_PARM_DESC(max_age_seconds, "Max age of a buffer in seconds");
2886+
MODULE_PARM_DESC(max_age_seconds, "No longer does anything");
30022887

30032888
module_param_named(retain_bytes, dm_bufio_retain_bytes, ulong, 0644);
30042889
MODULE_PARM_DESC(retain_bytes, "Try to keep at least this many bytes cached in memory");

drivers/md/dm-core.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ struct mapped_device {
141141
#ifdef CONFIG_BLK_DEV_ZONED
142142
unsigned int nr_zones;
143143
void *zone_revalidate_map;
144+
struct task_struct *revalidate_map_task;
144145
#endif
145146

146147
#ifdef CONFIG_IMA
@@ -161,9 +162,7 @@ struct mapped_device {
161162
#define DMF_SUSPENDED_INTERNALLY 7
162163
#define DMF_POST_SUSPENDING 8
163164
#define DMF_EMULATE_ZONE_APPEND 9
164-
165-
void disable_discard(struct mapped_device *md);
166-
void disable_write_zeroes(struct mapped_device *md);
165+
#define DMF_QUEUE_STOPPED 10
167166

168167
static inline sector_t dm_get_size(struct mapped_device *md)
169168
{

0 commit comments

Comments
 (0)