Skip to content

Commit e477dba

Browse files
committed
Merge tag 'for-6.12/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mikulas Patocka: - Misc VDO fixes - Remove unused declarations dm_get_rq_mapinfo() and dm_zone_map_bio() - Dm-delay: Improve kernel documentation - Dm-crypt: Allow to specify the integrity key size as an option - Dm-bufio: Remove pointless NULL check - Small code cleanups: Use ERR_CAST; remove unlikely() around IS_ERR; use __assign_bit - Dm-integrity: Fix gcc 5 warning; convert comma to semicolon; fix smatch warning - Dm-integrity: Support recalculation in the 'I' mode - Revert "dm: requeue IO if mapping table not yet available" - Dm-crypt: Small refactoring to make the code more readable - Dm-cache: Remove pointless error check - Dm: Fix spelling errors - Dm-verity: Restart or panic on an I/O error if restart or panic was requested - Dm-verity: Fallback to platform keyring also if key in trusted keyring is rejected * tag 'for-6.12/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (26 commits) dm verity: fallback to platform keyring also if key in trusted keyring is rejected dm-verity: restart or panic on an I/O error dm: fix spelling errors dm-cache: remove pointless error check dm vdo: handle unaligned discards correctly dm vdo indexer: Convert comma to semicolon dm-crypt: Use common error handling code in crypt_set_keyring_key() dm-crypt: Use up_read() together with key_put() only once in crypt_set_keyring_key() Revert "dm: requeue IO if mapping table not yet available" dm-integrity: check mac_size against HASH_MAX_DIGESTSIZE in sb_mac() dm-integrity: support recalculation in the 'I' mode dm integrity: Convert comma to semicolon dm integrity: fix gcc 5 warning dm: Make use of __assign_bit() API dm integrity: Remove extra unlikely helper dm: Convert to use ERR_CAST() dm bufio: Remove NULL check of list_entry() dm-crypt: Allow to specify the integrity key size as option dm: Remove unused declaration and empty definition "dm_zone_map_bio" dm delay: enhance kernel documentation ...
2 parents b6c49fc + 579b2ba commit e477dba

26 files changed

+487
-146
lines changed

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,52 @@ dm-delay
33
========
44

55
Device-Mapper's "delay" target delays reads and/or writes
6-
and maps them to different devices.
6+
and/or flushs and optionally maps them to different devices.
77

8-
Parameters::
8+
Arguments::
99

1010
<device> <offset> <delay> [<write_device> <write_offset> <write_delay>
1111
[<flush_device> <flush_offset> <flush_delay>]]
1212

13-
With separate write parameters, the first set is only used for reads.
13+
Table line has to either have 3, 6 or 9 arguments:
14+
15+
3: apply offset and delay to read, write and flush operations on device
16+
17+
6: apply offset and delay to device, also apply write_offset and write_delay
18+
to write and flush operations on optionally different write_device with
19+
optionally different sector offset
20+
21+
9: same as 6 arguments plus define flush_offset and flush_delay explicitely
22+
on/with optionally different flush_device/flush_offset.
23+
1424
Offsets are specified in sectors.
25+
1526
Delays are specified in milliseconds.
1627

28+
1729
Example scripts
1830
===============
1931

2032
::
21-
2233
#!/bin/sh
23-
# Create device delaying rw operation for 500ms
24-
echo "0 `blockdev --getsz $1` delay $1 0 500" | dmsetup create delayed
34+
#
35+
# Create mapped device named "delayed" delaying read, write and flush operations for 500ms.
36+
#
37+
dmsetup create delayed --table "0 `blockdev --getsz $1` delay $1 0 500"
2538

2639
::
40+
#!/bin/sh
41+
#
42+
# Create mapped device delaying write and flush operations for 400ms and
43+
# splitting reads to device $1 but writes and flushs to different device $2
44+
# to different offsets of 2048 and 4096 sectors respectively.
45+
#
46+
dmsetup create delayed --table "0 `blockdev --getsz $1` delay $1 2048 0 $2 4096 400"
2747

48+
::
2849
#!/bin/sh
29-
# Create device delaying only write operation for 500ms and
30-
# splitting reads and writes to different devices $1 $2
31-
echo "0 `blockdev --getsz $1` delay $1 0 0 $2 0 500" | dmsetup create delayed
50+
#
51+
# Create mapped device delaying reads for 50ms, writes for 100ms and flushs for 333ms
52+
# onto the same backing device at offset 0 sectors.
53+
#
54+
dmsetup create delayed --table "0 `blockdev --getsz $1` delay $1 0 50 $2 0 100 $1 0 333"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ iv_large_sectors
160160
The <iv_offset> must be multiple of <sector_size> (in 512 bytes units)
161161
if this flag is specified.
162162

163+
integrity_key_size:<bytes>
164+
Use an integrity key of <bytes> size instead of using an integrity key size
165+
of the digest size of the used HMAC algorithm.
166+
163167

164168
Module parameters::
165169
max_read_size

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ The messages are:
251251
by the vdostats userspace program to interpret the output
252252
buffer.
253253

254-
dump:
254+
config:
255+
Outputs useful vdo configuration information. Mostly used
256+
by users who want to recreate a similar VDO volume and
257+
want to know the creation configuration used.
258+
259+
dump:
255260
Dumps many internal structures to the system log. This is
256261
not always safe to run, so it should only be used to debug
257262
a hung vdo. Optional parameters to specify structures to

drivers/md/dm-bufio.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,6 @@ static struct dm_buffer *list_to_buffer(struct list_head *l)
529529
{
530530
struct lru_entry *le = list_entry(l, struct lru_entry, list);
531531

532-
if (!le)
533-
return NULL;
534-
535532
return le_to_buffer(le);
536533
}
537534

drivers/md/dm-cache-target.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ static void mg_copy(struct work_struct *ws)
13681368
*/
13691369
bool rb = bio_detain_shared(mg->cache, mg->op->oblock, mg->overwrite_bio);
13701370

1371-
BUG_ON(rb); /* An exclussive lock must _not_ be held for this block */
1371+
BUG_ON(rb); /* An exclusive lock must _not_ be held for this block */
13721372
mg->overwrite_bio = NULL;
13731373
inc_io_migrations(mg->cache);
13741374
mg_full_copy(ws);
@@ -3200,8 +3200,6 @@ static int parse_cblock_range(struct cache *cache, const char *str,
32003200
* Try and parse form (ii) first.
32013201
*/
32023202
r = sscanf(str, "%llu-%llu%c", &b, &e, &dummy);
3203-
if (r < 0)
3204-
return r;
32053203

32063204
if (r == 2) {
32073205
result->begin = to_cblock(b);
@@ -3213,8 +3211,6 @@ static int parse_cblock_range(struct cache *cache, const char *str,
32133211
* That didn't work, try form (i).
32143212
*/
32153213
r = sscanf(str, "%llu%c", &b, &dummy);
3216-
if (r < 0)
3217-
return r;
32183214

32193215
if (r == 1) {
32203216
result->begin = to_cblock(b);

drivers/md/dm-clone-metadata.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,7 @@ static int __load_bitset_in_core(struct dm_clone_metadata *cmd)
530530
return r;
531531

532532
for (i = 0; ; i++) {
533-
if (dm_bitset_cursor_get_value(&c))
534-
__set_bit(i, cmd->region_map);
535-
else
536-
__clear_bit(i, cmd->region_map);
533+
__assign_bit(i, cmd->region_map, dm_bitset_cursor_get_value(&c));
537534

538535
if (i >= (cmd->nr_regions - 1))
539536
break;

drivers/md/dm-crypt.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ enum cipher_flags {
147147
CRYPT_MODE_INTEGRITY_AEAD, /* Use authenticated mode for cipher */
148148
CRYPT_IV_LARGE_SECTORS, /* Calculate IV from sector_size, not 512B sectors */
149149
CRYPT_ENCRYPT_PREPROCESS, /* Must preprocess data for encryption (elephant) */
150+
CRYPT_KEY_MAC_SIZE_SET, /* The integrity_key_size option was used */
150151
};
151152

152153
/*
@@ -2613,35 +2614,31 @@ static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string
26132614

26142615
key = request_key(type, key_desc + 1, NULL);
26152616
if (IS_ERR(key)) {
2616-
kfree_sensitive(new_key_string);
2617-
return PTR_ERR(key);
2617+
ret = PTR_ERR(key);
2618+
goto free_new_key_string;
26182619
}
26192620

26202621
down_read(&key->sem);
2621-
26222622
ret = set_key(cc, key);
2623-
if (ret < 0) {
2624-
up_read(&key->sem);
2625-
key_put(key);
2626-
kfree_sensitive(new_key_string);
2627-
return ret;
2628-
}
2629-
26302623
up_read(&key->sem);
26312624
key_put(key);
2625+
if (ret < 0)
2626+
goto free_new_key_string;
26322627

26332628
/* clear the flag since following operations may invalidate previously valid key */
26342629
clear_bit(DM_CRYPT_KEY_VALID, &cc->flags);
26352630

26362631
ret = crypt_setkey(cc);
2632+
if (ret)
2633+
goto free_new_key_string;
26372634

2638-
if (!ret) {
2639-
set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
2640-
kfree_sensitive(cc->key_string);
2641-
cc->key_string = new_key_string;
2642-
} else
2643-
kfree_sensitive(new_key_string);
2635+
set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
2636+
kfree_sensitive(cc->key_string);
2637+
cc->key_string = new_key_string;
2638+
return 0;
26442639

2640+
free_new_key_string:
2641+
kfree_sensitive(new_key_string);
26452642
return ret;
26462643
}
26472644

@@ -2937,7 +2934,8 @@ static int crypt_ctr_auth_cipher(struct crypt_config *cc, char *cipher_api)
29372934
if (IS_ERR(mac))
29382935
return PTR_ERR(mac);
29392936

2940-
cc->key_mac_size = crypto_ahash_digestsize(mac);
2937+
if (!test_bit(CRYPT_KEY_MAC_SIZE_SET, &cc->cipher_flags))
2938+
cc->key_mac_size = crypto_ahash_digestsize(mac);
29412939
crypto_free_ahash(mac);
29422940

29432941
cc->authenc_key = kmalloc(crypt_authenckey_size(cc), GFP_KERNEL);
@@ -3219,6 +3217,13 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
32193217
cc->cipher_auth = kstrdup(sval, GFP_KERNEL);
32203218
if (!cc->cipher_auth)
32213219
return -ENOMEM;
3220+
} else if (sscanf(opt_string, "integrity_key_size:%u%c", &val, &dummy) == 1) {
3221+
if (!val) {
3222+
ti->error = "Invalid integrity_key_size argument";
3223+
return -EINVAL;
3224+
}
3225+
cc->key_mac_size = val;
3226+
set_bit(CRYPT_KEY_MAC_SIZE_SET, &cc->cipher_flags);
32223227
} else if (sscanf(opt_string, "sector_size:%hu%c", &cc->sector_size, &dummy) == 1) {
32233228
if (cc->sector_size < (1 << SECTOR_SHIFT) ||
32243229
cc->sector_size > 4096 ||
@@ -3607,10 +3612,10 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
36073612
num_feature_args += test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags);
36083613
num_feature_args += test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags);
36093614
num_feature_args += test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags);
3615+
num_feature_args += !!cc->used_tag_size;
36103616
num_feature_args += cc->sector_size != (1 << SECTOR_SHIFT);
36113617
num_feature_args += test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags);
3612-
if (cc->used_tag_size)
3613-
num_feature_args++;
3618+
num_feature_args += test_bit(CRYPT_KEY_MAC_SIZE_SET, &cc->cipher_flags);
36143619
if (num_feature_args) {
36153620
DMEMIT(" %d", num_feature_args);
36163621
if (ti->num_discard_bios)
@@ -3631,6 +3636,8 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
36313636
DMEMIT(" sector_size:%d", cc->sector_size);
36323637
if (test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags))
36333638
DMEMIT(" iv_large_sectors");
3639+
if (test_bit(CRYPT_KEY_MAC_SIZE_SET, &cc->cipher_flags))
3640+
DMEMIT(" integrity_key_size:%u", cc->key_mac_size);
36343641
}
36353642
break;
36363643

@@ -3758,7 +3765,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
37583765

37593766
static struct target_type crypt_target = {
37603767
.name = "crypt",
3761-
.version = {1, 27, 0},
3768+
.version = {1, 28, 0},
37623769
.module = THIS_MODULE,
37633770
.ctr = crypt_ctr,
37643771
.dtr = crypt_dtr,

0 commit comments

Comments
 (0)