Skip to content

Commit 661fb4e

Browse files
committed
Merge tag 'for-6.11/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mikulas Patocka: - Optimize processing of flush bios in the dm-linear and dm-stripe targets - Dm-io cleansups and refactoring - Remove unused 'struct thunk' in dm-cache - Handle minor device numbers > 255 in dm-init - Dm-verity refactoring & enabling platform keyring - Fix warning in dm-raid - Improve dm-crypt performance - split bios to smaller pieces, so that They could be processed concurrently - Stop using blk_limits_io_{min,opt} - Dm-vdo cleanup and refactoring - Remove max_write_zeroes_granularity and max_secure_erase_granularity - Dm-multipath cleanup & refactoring - Add dm-crypt and dm-integrity support for non-power-of-2 sector size - Fix reshape in dm-raid - Make dm_block_validator const * tag 'for-6.11/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (33 commits) dm vdo: fix a minor formatting issue in vdo.rst dm vdo int-map: fix kerneldoc formatting dm vdo repair: add missing kerneldoc fields dm: Constify struct dm_block_validator dm-integrity: introduce the Inline mode dm: introduce the target flag mempool_needs_integrity dm raid: fix stripes adding reshape size issues dm raid: move _get_reshape_sectors() as prerequisite to fixing reshape size issues dm-crypt: support for per-sector NVMe metadata dm mpath: don't call dm_get_device in multipath_message dm: factor out helper function from dm_get_device dm-verity: fix dm_is_verity_target() when dm-verity is builtin dm: Remove max_secure_erase_granularity dm: Remove max_write_zeroes_granularity dm vdo indexer: use swap() instead of open coding it dm vdo: remove unused struct 'uds_attribute' dm: stop using blk_limits_io_{min,opt} dm-crypt: limit the size of encryption requests dm verity: add support for signature verification with platform keyring dm-raid: Fix WARN_ON_ONCE check for sync_thread in raid_resume ...
2 parents afd81d9 + 7f1c490 commit 661fb4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+947
-582
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ 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+
164+
Module parameters::
165+
max_read_size
166+
max_write_size
167+
Maximum size of read or write requests. When a request larger than this size
168+
is received, dm-crypt will split the request. The splitting improves
169+
concurrency (the split requests could be encrypted in parallel by multiple
170+
cores), but it also causes overhead. The user should tune these parameters to
171+
fit the actual workload.
172+
173+
163174
Example scripts
164175
===============
165176
LUKS (Linux Unified Key Setup) is now the preferred way to set up disk

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ Messages
241241
All vdo devices accept messages in the form:
242242

243243
::
244+
244245
dmsetup message <target-name> 0 <message-name> <message-parameters>
245246

246247
The messages are:

drivers/md/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,16 @@ config DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING
540540

541541
If unsure, say N.
542542

543+
config DM_VERITY_VERIFY_ROOTHASH_SIG_PLATFORM_KEYRING
544+
bool "Verity data device root hash signature verification with platform keyring"
545+
default DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING
546+
depends on DM_VERITY_VERIFY_ROOTHASH_SIG
547+
depends on INTEGRITY_PLATFORM_KEYRING
548+
help
549+
Rely also on the platform keyring to verify dm-verity signatures.
550+
551+
If unsure, say N.
552+
543553
config DM_VERITY_FEC
544554
bool "Verity forward error correction support"
545555
depends on DM_VERITY

drivers/md/dm-cache-metadata.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct dm_cache_metadata {
170170
*/
171171
#define SUPERBLOCK_CSUM_XOR 9031977
172172

173-
static void sb_prepare_for_write(struct dm_block_validator *v,
173+
static void sb_prepare_for_write(const struct dm_block_validator *v,
174174
struct dm_block *b,
175175
size_t sb_block_size)
176176
{
@@ -195,7 +195,7 @@ static int check_metadata_version(struct cache_disk_superblock *disk_super)
195195
return 0;
196196
}
197197

198-
static int sb_check(struct dm_block_validator *v,
198+
static int sb_check(const struct dm_block_validator *v,
199199
struct dm_block *b,
200200
size_t sb_block_size)
201201
{
@@ -228,7 +228,7 @@ static int sb_check(struct dm_block_validator *v,
228228
return check_metadata_version(disk_super);
229229
}
230230

231-
static struct dm_block_validator sb_validator = {
231+
static const struct dm_block_validator sb_validator = {
232232
.name = "superblock",
233233
.prepare_for_write = sb_prepare_for_write,
234234
.check = sb_check
@@ -1282,15 +1282,6 @@ int dm_cache_insert_mapping(struct dm_cache_metadata *cmd,
12821282
return r;
12831283
}
12841284

1285-
struct thunk {
1286-
load_mapping_fn fn;
1287-
void *context;
1288-
1289-
struct dm_cache_metadata *cmd;
1290-
bool respect_dirty_flags;
1291-
bool hints_valid;
1292-
};
1293-
12941285
static bool policy_unchanged(struct dm_cache_metadata *cmd,
12951286
struct dm_cache_policy *policy)
12961287
{

drivers/md/dm-cache-target.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,8 +3416,8 @@ static void cache_io_hints(struct dm_target *ti, struct queue_limits *limits)
34163416
*/
34173417
if (io_opt_sectors < cache->sectors_per_block ||
34183418
do_div(io_opt_sectors, cache->sectors_per_block)) {
3419-
blk_limits_io_min(limits, cache->sectors_per_block << SECTOR_SHIFT);
3420-
blk_limits_io_opt(limits, cache->sectors_per_block << SECTOR_SHIFT);
3419+
limits->io_min = cache->sectors_per_block << SECTOR_SHIFT;
3420+
limits->io_opt = cache->sectors_per_block << SECTOR_SHIFT;
34213421
}
34223422

34233423
disable_passdown_if_not_supported(cache);

drivers/md/dm-clone-metadata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct dm_clone_metadata {
163163
/*
164164
* Superblock validation.
165165
*/
166-
static void sb_prepare_for_write(struct dm_block_validator *v,
166+
static void sb_prepare_for_write(const struct dm_block_validator *v,
167167
struct dm_block *b, size_t sb_block_size)
168168
{
169169
struct superblock_disk *sb;
@@ -177,7 +177,7 @@ static void sb_prepare_for_write(struct dm_block_validator *v,
177177
sb->csum = cpu_to_le32(csum);
178178
}
179179

180-
static int sb_check(struct dm_block_validator *v, struct dm_block *b,
180+
static int sb_check(const struct dm_block_validator *v, struct dm_block *b,
181181
size_t sb_block_size)
182182
{
183183
struct superblock_disk *sb;
@@ -220,7 +220,7 @@ static int sb_check(struct dm_block_validator *v, struct dm_block *b,
220220
return 0;
221221
}
222222

223-
static struct dm_block_validator sb_validator = {
223+
static const struct dm_block_validator sb_validator = {
224224
.name = "superblock",
225225
.prepare_for_write = sb_prepare_for_write,
226226
.check = sb_check

drivers/md/dm-clone-target.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,8 @@ static void clone_io_hints(struct dm_target *ti, struct queue_limits *limits)
20732073
*/
20742074
if (io_opt_sectors < clone->region_size ||
20752075
do_div(io_opt_sectors, clone->region_size)) {
2076-
blk_limits_io_min(limits, clone->region_size << SECTOR_SHIFT);
2077-
blk_limits_io_opt(limits, clone->region_size << SECTOR_SHIFT);
2076+
limits->io_min = clone->region_size << SECTOR_SHIFT;
2077+
limits->io_opt = clone->region_size << SECTOR_SHIFT;
20782078
}
20792079

20802080
disable_passdown_if_not_supported(clone);

drivers/md/dm-core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ struct dm_table {
206206

207207
bool integrity_supported:1;
208208
bool singleton:1;
209+
/* set if all the targets in the table have "flush_bypasses_map" set */
210+
bool flush_bypasses_map:1;
209211

210212
/*
211213
* Indicates the rw permissions for the new logical device. This

drivers/md/dm-crypt.c

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ struct crypt_config {
214214

215215
unsigned int integrity_tag_size;
216216
unsigned int integrity_iv_size;
217-
unsigned int on_disk_tag_size;
217+
unsigned int used_tag_size;
218+
unsigned int tuple_size;
218219

219220
/*
220221
* pool for per bio private data, crypto requests,
@@ -241,6 +242,31 @@ static unsigned int dm_crypt_clients_n;
241242
static volatile unsigned long dm_crypt_pages_per_client;
242243
#define DM_CRYPT_MEMORY_PERCENT 2
243244
#define DM_CRYPT_MIN_PAGES_PER_CLIENT (BIO_MAX_VECS * 16)
245+
#define DM_CRYPT_DEFAULT_MAX_READ_SIZE 131072
246+
#define DM_CRYPT_DEFAULT_MAX_WRITE_SIZE 131072
247+
248+
static unsigned int max_read_size = 0;
249+
module_param(max_read_size, uint, 0644);
250+
MODULE_PARM_DESC(max_read_size, "Maximum size of a read request");
251+
static unsigned int max_write_size = 0;
252+
module_param(max_write_size, uint, 0644);
253+
MODULE_PARM_DESC(max_write_size, "Maximum size of a write request");
254+
static unsigned get_max_request_size(struct crypt_config *cc, bool wrt)
255+
{
256+
unsigned val, sector_align;
257+
val = !wrt ? READ_ONCE(max_read_size) : READ_ONCE(max_write_size);
258+
if (likely(!val))
259+
val = !wrt ? DM_CRYPT_DEFAULT_MAX_READ_SIZE : DM_CRYPT_DEFAULT_MAX_WRITE_SIZE;
260+
if (wrt || cc->used_tag_size) {
261+
if (unlikely(val > BIO_MAX_VECS << PAGE_SHIFT))
262+
val = BIO_MAX_VECS << PAGE_SHIFT;
263+
}
264+
sector_align = max(bdev_logical_block_size(cc->dev->bdev), (unsigned)cc->sector_size);
265+
val = round_down(val, sector_align);
266+
if (unlikely(!val))
267+
val = sector_align;
268+
return val >> SECTOR_SHIFT;
269+
}
244270

245271
static void crypt_endio(struct bio *clone);
246272
static void kcryptd_queue_crypt(struct dm_crypt_io *io);
@@ -1151,14 +1177,14 @@ static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio)
11511177
unsigned int tag_len;
11521178
int ret;
11531179

1154-
if (!bio_sectors(bio) || !io->cc->on_disk_tag_size)
1180+
if (!bio_sectors(bio) || !io->cc->tuple_size)
11551181
return 0;
11561182

11571183
bip = bio_integrity_alloc(bio, GFP_NOIO, 1);
11581184
if (IS_ERR(bip))
11591185
return PTR_ERR(bip);
11601186

1161-
tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift);
1187+
tag_len = io->cc->tuple_size * (bio_sectors(bio) >> io->cc->sector_shift);
11621188

11631189
bip->bip_iter.bi_sector = io->cc->start + io->sector;
11641190

@@ -1182,18 +1208,18 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti)
11821208
return -EINVAL;
11831209
}
11841210

1185-
if (bi->tag_size != cc->on_disk_tag_size ||
1186-
bi->tuple_size != cc->on_disk_tag_size) {
1211+
if (bi->tuple_size < cc->used_tag_size) {
11871212
ti->error = "Integrity profile tag size mismatch.";
11881213
return -EINVAL;
11891214
}
1215+
cc->tuple_size = bi->tuple_size;
11901216
if (1 << bi->interval_exp != cc->sector_size) {
11911217
ti->error = "Integrity profile sector size mismatch.";
11921218
return -EINVAL;
11931219
}
11941220

11951221
if (crypt_integrity_aead(cc)) {
1196-
cc->integrity_tag_size = cc->on_disk_tag_size - cc->integrity_iv_size;
1222+
cc->integrity_tag_size = cc->used_tag_size - cc->integrity_iv_size;
11971223
DMDEBUG("%s: Integrity AEAD, tag size %u, IV size %u.", dm_device_name(md),
11981224
cc->integrity_tag_size, cc->integrity_iv_size);
11991225

@@ -1205,7 +1231,7 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti)
12051231
DMDEBUG("%s: Additional per-sector space %u bytes for IV.", dm_device_name(md),
12061232
cc->integrity_iv_size);
12071233

1208-
if ((cc->integrity_tag_size + cc->integrity_iv_size) != bi->tag_size) {
1234+
if ((cc->integrity_tag_size + cc->integrity_iv_size) > cc->tuple_size) {
12091235
ti->error = "Not enough space for integrity tag in the profile.";
12101236
return -EINVAL;
12111237
}
@@ -1284,7 +1310,7 @@ static void *tag_from_dmreq(struct crypt_config *cc,
12841310
struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);
12851311

12861312
return &io->integrity_metadata[*org_tag_of_dmreq(cc, dmreq) *
1287-
cc->on_disk_tag_size];
1313+
cc->tuple_size];
12881314
}
12891315

12901316
static void *iv_tag_from_dmreq(struct crypt_config *cc,
@@ -1365,9 +1391,9 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
13651391
aead_request_set_crypt(req, dmreq->sg_in, dmreq->sg_out,
13661392
cc->sector_size, iv);
13671393
r = crypto_aead_encrypt(req);
1368-
if (cc->integrity_tag_size + cc->integrity_iv_size != cc->on_disk_tag_size)
1394+
if (cc->integrity_tag_size + cc->integrity_iv_size != cc->tuple_size)
13691395
memset(tag + cc->integrity_tag_size + cc->integrity_iv_size, 0,
1370-
cc->on_disk_tag_size - (cc->integrity_tag_size + cc->integrity_iv_size));
1396+
cc->tuple_size - (cc->integrity_tag_size + cc->integrity_iv_size));
13711397
} else {
13721398
aead_request_set_crypt(req, dmreq->sg_in, dmreq->sg_out,
13731399
cc->sector_size + cc->integrity_tag_size, iv);
@@ -1797,7 +1823,7 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
17971823
return;
17981824

17991825
if (likely(!io->ctx.aead_recheck) && unlikely(io->ctx.aead_failed) &&
1800-
cc->on_disk_tag_size && bio_data_dir(base_bio) == READ) {
1826+
cc->used_tag_size && bio_data_dir(base_bio) == READ) {
18011827
io->ctx.aead_recheck = true;
18021828
io->ctx.aead_failed = false;
18031829
io->error = 0;
@@ -3181,7 +3207,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
31813207
ti->error = "Invalid integrity arguments";
31823208
return -EINVAL;
31833209
}
3184-
cc->on_disk_tag_size = val;
3210+
cc->used_tag_size = val;
31853211
sval = strchr(opt_string + strlen("integrity:"), ':') + 1;
31863212
if (!strcasecmp(sval, "aead")) {
31873213
set_bit(CRYPT_MODE_INTEGRITY_AEAD, &cc->cipher_flags);
@@ -3393,12 +3419,12 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
33933419
if (ret)
33943420
goto bad;
33953421

3396-
cc->tag_pool_max_sectors = POOL_ENTRY_SIZE / cc->on_disk_tag_size;
3422+
cc->tag_pool_max_sectors = POOL_ENTRY_SIZE / cc->tuple_size;
33973423
if (!cc->tag_pool_max_sectors)
33983424
cc->tag_pool_max_sectors = 1;
33993425

34003426
ret = mempool_init_kmalloc_pool(&cc->tag_pool, MIN_IOS,
3401-
cc->tag_pool_max_sectors * cc->on_disk_tag_size);
3427+
cc->tag_pool_max_sectors * cc->tuple_size);
34023428
if (ret) {
34033429
ti->error = "Cannot allocate integrity tags mempool";
34043430
goto bad;
@@ -3474,6 +3500,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
34743500
{
34753501
struct dm_crypt_io *io;
34763502
struct crypt_config *cc = ti->private;
3503+
unsigned max_sectors;
34773504

34783505
/*
34793506
* If bio is REQ_PREFLUSH or REQ_OP_DISCARD, just bypass crypt queues.
@@ -3492,9 +3519,9 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
34923519
/*
34933520
* Check if bio is too large, split as needed.
34943521
*/
3495-
if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_VECS << PAGE_SHIFT)) &&
3496-
(bio_data_dir(bio) == WRITE || cc->on_disk_tag_size))
3497-
dm_accept_partial_bio(bio, ((BIO_MAX_VECS << PAGE_SHIFT) >> SECTOR_SHIFT));
3522+
max_sectors = get_max_request_size(cc, bio_data_dir(bio) == WRITE);
3523+
if (unlikely(bio_sectors(bio) > max_sectors))
3524+
dm_accept_partial_bio(bio, max_sectors);
34983525

34993526
/*
35003527
* Ensure that bio is a multiple of internal sector encryption size
@@ -3509,8 +3536,8 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
35093536
io = dm_per_bio_data(bio, cc->per_bio_data_size);
35103537
crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector));
35113538

3512-
if (cc->on_disk_tag_size) {
3513-
unsigned int tag_len = cc->on_disk_tag_size * (bio_sectors(bio) >> cc->sector_shift);
3539+
if (cc->tuple_size) {
3540+
unsigned int tag_len = cc->tuple_size * (bio_sectors(bio) >> cc->sector_shift);
35143541

35153542
if (unlikely(tag_len > KMALLOC_MAX_SIZE))
35163543
io->integrity_metadata = NULL;
@@ -3582,7 +3609,7 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
35823609
num_feature_args += test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags);
35833610
num_feature_args += cc->sector_size != (1 << SECTOR_SHIFT);
35843611
num_feature_args += test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags);
3585-
if (cc->on_disk_tag_size)
3612+
if (cc->used_tag_size)
35863613
num_feature_args++;
35873614
if (num_feature_args) {
35883615
DMEMIT(" %d", num_feature_args);
@@ -3598,8 +3625,8 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
35983625
DMEMIT(" no_read_workqueue");
35993626
if (test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags))
36003627
DMEMIT(" no_write_workqueue");
3601-
if (cc->on_disk_tag_size)
3602-
DMEMIT(" integrity:%u:%s", cc->on_disk_tag_size, cc->cipher_auth);
3628+
if (cc->used_tag_size)
3629+
DMEMIT(" integrity:%u:%s", cc->used_tag_size, cc->cipher_auth);
36033630
if (cc->sector_size != (1 << SECTOR_SHIFT))
36043631
DMEMIT(" sector_size:%d", cc->sector_size);
36053632
if (test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags))
@@ -3621,9 +3648,9 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
36213648
DMEMIT(",iv_large_sectors=%c", test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags) ?
36223649
'y' : 'n');
36233650

3624-
if (cc->on_disk_tag_size)
3651+
if (cc->used_tag_size)
36253652
DMEMIT(",integrity_tag_size=%u,cipher_auth=%s",
3626-
cc->on_disk_tag_size, cc->cipher_auth);
3653+
cc->used_tag_size, cc->cipher_auth);
36273654
if (cc->sector_size != (1 << SECTOR_SHIFT))
36283655
DMEMIT(",sector_size=%d", cc->sector_size);
36293656
if (cc->cipher_string)
@@ -3731,7 +3758,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
37313758

37323759
static struct target_type crypt_target = {
37333760
.name = "crypt",
3734-
.version = {1, 26, 0},
3761+
.version = {1, 27, 0},
37353762
.module = THIS_MODULE,
37363763
.ctr = crypt_ctr,
37373764
.dtr = crypt_dtr,

drivers/md/dm-ebs-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static void ebs_io_hints(struct dm_target *ti, struct queue_limits *limits)
428428
limits->logical_block_size = to_bytes(ec->e_bs);
429429
limits->physical_block_size = to_bytes(ec->u_bs);
430430
limits->alignment_offset = limits->physical_block_size;
431-
blk_limits_io_min(limits, limits->logical_block_size);
431+
limits->io_min = limits->logical_block_size;
432432
}
433433

434434
static int ebs_iterate_devices(struct dm_target *ti,

0 commit comments

Comments
 (0)