Skip to content

Commit a3ccea6

Browse files
committed
Merge tag 'for-6.1/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - Fix dm-bufio to use test_bit_acquire to properly test_bit on arches with weaker memory ordering. - DM core replace DMWARN with DMERR or DMCRIT for fatal errors. - Enable WQ_HIGHPRI on DM verity target's verify_wq. - Add documentation for DM verity's try_verify_in_tasklet option. - Various typo and redundant word fixes in code and/or comments. * tag 'for-6.1/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm clone: Fix typo in block_device format specifier dm: remove unnecessary assignment statement in alloc_dev() dm verity: Add documentation for try_verify_in_tasklet option dm cache: delete the redundant word 'each' in comment dm raid: fix typo in analyse_superblocks code comment dm verity: enable WQ_HIGHPRI on verify_wq dm raid: delete the redundant word 'that' in comment dm: change from DMWARN to DMERR or DMCRIT for fatal errors dm bufio: use the acquire memory barrier when testing for B_READING
2 parents aae703b + 5434ee8 commit a3ccea6

File tree

11 files changed

+110
-104
lines changed

11 files changed

+110
-104
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ root_hash_sig_key_desc <key_description>
141141
also gain new certificates at run time if they are signed by a certificate
142142
already in the secondary trusted keyring.
143143

144+
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.
147+
144148
Theory of operation
145149
===================
146150

drivers/md/dm-bufio.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ static void __make_buffer_clean(struct dm_buffer *b)
795795
{
796796
BUG_ON(b->hold_count);
797797

798-
if (!b->state) /* fast case */
798+
/* smp_load_acquire() pairs with read_endio()'s smp_mb__before_atomic() */
799+
if (!smp_load_acquire(&b->state)) /* fast case */
799800
return;
800801

801802
wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE);
@@ -816,7 +817,7 @@ static struct dm_buffer *__get_unclaimed_buffer(struct dm_bufio_client *c)
816817
BUG_ON(test_bit(B_DIRTY, &b->state));
817818

818819
if (static_branch_unlikely(&no_sleep_enabled) && c->no_sleep &&
819-
unlikely(test_bit(B_READING, &b->state)))
820+
unlikely(test_bit_acquire(B_READING, &b->state)))
820821
continue;
821822

822823
if (!b->hold_count) {
@@ -1058,7 +1059,7 @@ static struct dm_buffer *__bufio_new(struct dm_bufio_client *c, sector_t block,
10581059
* If the user called both dm_bufio_prefetch and dm_bufio_get on
10591060
* the same buffer, it would deadlock if we waited.
10601061
*/
1061-
if (nf == NF_GET && unlikely(test_bit(B_READING, &b->state)))
1062+
if (nf == NF_GET && unlikely(test_bit_acquire(B_READING, &b->state)))
10621063
return NULL;
10631064

10641065
b->hold_count++;
@@ -1218,7 +1219,7 @@ void dm_bufio_release(struct dm_buffer *b)
12181219
* invalid buffer.
12191220
*/
12201221
if ((b->read_error || b->write_error) &&
1221-
!test_bit(B_READING, &b->state) &&
1222+
!test_bit_acquire(B_READING, &b->state) &&
12221223
!test_bit(B_WRITING, &b->state) &&
12231224
!test_bit(B_DIRTY, &b->state)) {
12241225
__unlink_buffer(b);
@@ -1479,7 +1480,7 @@ EXPORT_SYMBOL_GPL(dm_bufio_release_move);
14791480

14801481
static void forget_buffer_locked(struct dm_buffer *b)
14811482
{
1482-
if (likely(!b->hold_count) && likely(!b->state)) {
1483+
if (likely(!b->hold_count) && likely(!smp_load_acquire(&b->state))) {
14831484
__unlink_buffer(b);
14841485
__free_buffer_wake(b);
14851486
}
@@ -1639,7 +1640,7 @@ static bool __try_evict_buffer(struct dm_buffer *b, gfp_t gfp)
16391640
{
16401641
if (!(gfp & __GFP_FS) ||
16411642
(static_branch_unlikely(&no_sleep_enabled) && b->c->no_sleep)) {
1642-
if (test_bit(B_READING, &b->state) ||
1643+
if (test_bit_acquire(B_READING, &b->state) ||
16431644
test_bit(B_WRITING, &b->state) ||
16441645
test_bit(B_DIRTY, &b->state))
16451646
return false;

drivers/md/dm-cache-policy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct dm_cache_policy_type {
166166
struct dm_cache_policy_type *real;
167167

168168
/*
169-
* Policies may store a hint for each each cache block.
169+
* Policies may store a hint for each cache block.
170170
* Currently the size of this hint must be 0 or 4 bytes but we
171171
* expect to relax this in future.
172172
*/

drivers/md/dm-clone-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ static void disable_passdown_if_not_supported(struct clone *clone)
20352035
reason = "max discard sectors smaller than a region";
20362036

20372037
if (reason) {
2038-
DMWARN("Destination device (%pd) %s: Disabling discard passdown.",
2038+
DMWARN("Destination device (%pg) %s: Disabling discard passdown.",
20392039
dest_dev, reason);
20402040
clear_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
20412041
}

drivers/md/dm-ioctl.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,
434434
hc = __get_name_cell(new);
435435

436436
if (hc) {
437-
DMWARN("Unable to change %s on mapped device %s to one that "
438-
"already exists: %s",
439-
change_uuid ? "uuid" : "name",
440-
param->name, new);
437+
DMERR("Unable to change %s on mapped device %s to one that "
438+
"already exists: %s",
439+
change_uuid ? "uuid" : "name",
440+
param->name, new);
441441
dm_put(hc->md);
442442
up_write(&_hash_lock);
443443
kfree(new_data);
@@ -449,8 +449,8 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,
449449
*/
450450
hc = __get_name_cell(param->name);
451451
if (!hc) {
452-
DMWARN("Unable to rename non-existent device, %s to %s%s",
453-
param->name, change_uuid ? "uuid " : "", new);
452+
DMERR("Unable to rename non-existent device, %s to %s%s",
453+
param->name, change_uuid ? "uuid " : "", new);
454454
up_write(&_hash_lock);
455455
kfree(new_data);
456456
return ERR_PTR(-ENXIO);
@@ -460,9 +460,9 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,
460460
* Does this device already have a uuid?
461461
*/
462462
if (change_uuid && hc->uuid) {
463-
DMWARN("Unable to change uuid of mapped device %s to %s "
464-
"because uuid is already set to %s",
465-
param->name, new, hc->uuid);
463+
DMERR("Unable to change uuid of mapped device %s to %s "
464+
"because uuid is already set to %s",
465+
param->name, new, hc->uuid);
466466
dm_put(hc->md);
467467
up_write(&_hash_lock);
468468
kfree(new_data);
@@ -750,7 +750,7 @@ static int get_target_version(struct file *filp, struct dm_ioctl *param, size_t
750750
static int check_name(const char *name)
751751
{
752752
if (strchr(name, '/')) {
753-
DMWARN("invalid device name");
753+
DMERR("invalid device name");
754754
return -EINVAL;
755755
}
756756

@@ -773,7 +773,7 @@ static struct dm_table *dm_get_inactive_table(struct mapped_device *md, int *src
773773
down_read(&_hash_lock);
774774
hc = dm_get_mdptr(md);
775775
if (!hc || hc->md != md) {
776-
DMWARN("device has been removed from the dev hash table.");
776+
DMERR("device has been removed from the dev hash table.");
777777
goto out;
778778
}
779779

@@ -1026,7 +1026,7 @@ static int dev_rename(struct file *filp, struct dm_ioctl *param, size_t param_si
10261026
if (new_data < param->data ||
10271027
invalid_str(new_data, (void *) param + param_size) || !*new_data ||
10281028
strlen(new_data) > (change_uuid ? DM_UUID_LEN - 1 : DM_NAME_LEN - 1)) {
1029-
DMWARN("Invalid new mapped device name or uuid string supplied.");
1029+
DMERR("Invalid new mapped device name or uuid string supplied.");
10301030
return -EINVAL;
10311031
}
10321032

@@ -1061,21 +1061,21 @@ static int dev_set_geometry(struct file *filp, struct dm_ioctl *param, size_t pa
10611061

10621062
if (geostr < param->data ||
10631063
invalid_str(geostr, (void *) param + param_size)) {
1064-
DMWARN("Invalid geometry supplied.");
1064+
DMERR("Invalid geometry supplied.");
10651065
goto out;
10661066
}
10671067

10681068
x = sscanf(geostr, "%lu %lu %lu %lu%c", indata,
10691069
indata + 1, indata + 2, indata + 3, &dummy);
10701070

10711071
if (x != 4) {
1072-
DMWARN("Unable to interpret geometry settings.");
1072+
DMERR("Unable to interpret geometry settings.");
10731073
goto out;
10741074
}
10751075

10761076
if (indata[0] > 65535 || indata[1] > 255 ||
10771077
indata[2] > 255 || indata[3] > ULONG_MAX) {
1078-
DMWARN("Geometry exceeds range limits.");
1078+
DMERR("Geometry exceeds range limits.");
10791079
goto out;
10801080
}
10811081

@@ -1387,15 +1387,15 @@ static int populate_table(struct dm_table *table,
13871387
char *target_params;
13881388

13891389
if (!param->target_count) {
1390-
DMWARN("populate_table: no targets specified");
1390+
DMERR("populate_table: no targets specified");
13911391
return -EINVAL;
13921392
}
13931393

13941394
for (i = 0; i < param->target_count; i++) {
13951395

13961396
r = next_target(spec, next, end, &spec, &target_params);
13971397
if (r) {
1398-
DMWARN("unable to find target");
1398+
DMERR("unable to find target");
13991399
return r;
14001400
}
14011401

@@ -1404,7 +1404,7 @@ static int populate_table(struct dm_table *table,
14041404
(sector_t) spec->length,
14051405
target_params);
14061406
if (r) {
1407-
DMWARN("error adding target to table");
1407+
DMERR("error adding target to table");
14081408
return r;
14091409
}
14101410

@@ -1451,8 +1451,8 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
14511451
if (immutable_target_type &&
14521452
(immutable_target_type != dm_table_get_immutable_target_type(t)) &&
14531453
!dm_table_get_wildcard_target(t)) {
1454-
DMWARN("can't replace immutable target type %s",
1455-
immutable_target_type->name);
1454+
DMERR("can't replace immutable target type %s",
1455+
immutable_target_type->name);
14561456
r = -EINVAL;
14571457
goto err_unlock_md_type;
14581458
}
@@ -1461,12 +1461,12 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
14611461
/* setup md->queue to reflect md's type (may block) */
14621462
r = dm_setup_md_queue(md, t);
14631463
if (r) {
1464-
DMWARN("unable to set up device queue for new table.");
1464+
DMERR("unable to set up device queue for new table.");
14651465
goto err_unlock_md_type;
14661466
}
14671467
} else if (!is_valid_type(dm_get_md_type(md), dm_table_get_type(t))) {
1468-
DMWARN("can't change device type (old=%u vs new=%u) after initial table load.",
1469-
dm_get_md_type(md), dm_table_get_type(t));
1468+
DMERR("can't change device type (old=%u vs new=%u) after initial table load.",
1469+
dm_get_md_type(md), dm_table_get_type(t));
14701470
r = -EINVAL;
14711471
goto err_unlock_md_type;
14721472
}
@@ -1477,7 +1477,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
14771477
down_write(&_hash_lock);
14781478
hc = dm_get_mdptr(md);
14791479
if (!hc || hc->md != md) {
1480-
DMWARN("device has been removed from the dev hash table.");
1480+
DMERR("device has been removed from the dev hash table.");
14811481
up_write(&_hash_lock);
14821482
r = -ENXIO;
14831483
goto err_destroy_table;
@@ -1686,19 +1686,19 @@ static int target_message(struct file *filp, struct dm_ioctl *param, size_t para
16861686

16871687
if (tmsg < (struct dm_target_msg *) param->data ||
16881688
invalid_str(tmsg->message, (void *) param + param_size)) {
1689-
DMWARN("Invalid target message parameters.");
1689+
DMERR("Invalid target message parameters.");
16901690
r = -EINVAL;
16911691
goto out;
16921692
}
16931693

16941694
r = dm_split_args(&argc, &argv, tmsg->message);
16951695
if (r) {
1696-
DMWARN("Failed to split target message parameters");
1696+
DMERR("Failed to split target message parameters");
16971697
goto out;
16981698
}
16991699

17001700
if (!argc) {
1701-
DMWARN("Empty message received.");
1701+
DMERR("Empty message received.");
17021702
r = -EINVAL;
17031703
goto out_argv;
17041704
}
@@ -1718,12 +1718,12 @@ static int target_message(struct file *filp, struct dm_ioctl *param, size_t para
17181718

17191719
ti = dm_table_find_target(table, tmsg->sector);
17201720
if (!ti) {
1721-
DMWARN("Target message sector outside device.");
1721+
DMERR("Target message sector outside device.");
17221722
r = -EINVAL;
17231723
} else if (ti->type->message)
17241724
r = ti->type->message(ti, argc, argv, result, maxlen);
17251725
else {
1726-
DMWARN("Target type does not support messages");
1726+
DMERR("Target type does not support messages");
17271727
r = -EINVAL;
17281728
}
17291729

@@ -1814,11 +1814,11 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
18141814

18151815
if ((DM_VERSION_MAJOR != version[0]) ||
18161816
(DM_VERSION_MINOR < version[1])) {
1817-
DMWARN("ioctl interface mismatch: "
1818-
"kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
1819-
DM_VERSION_MAJOR, DM_VERSION_MINOR,
1820-
DM_VERSION_PATCHLEVEL,
1821-
version[0], version[1], version[2], cmd);
1817+
DMERR("ioctl interface mismatch: "
1818+
"kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)",
1819+
DM_VERSION_MAJOR, DM_VERSION_MINOR,
1820+
DM_VERSION_PATCHLEVEL,
1821+
version[0], version[1], version[2], cmd);
18221822
r = -EINVAL;
18231823
}
18241824

@@ -1927,11 +1927,11 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
19271927

19281928
if (cmd == DM_DEV_CREATE_CMD) {
19291929
if (!*param->name) {
1930-
DMWARN("name not supplied when creating device");
1930+
DMERR("name not supplied when creating device");
19311931
return -EINVAL;
19321932
}
19331933
} else if (*param->uuid && *param->name) {
1934-
DMWARN("only supply one of name or uuid, cmd(%u)", cmd);
1934+
DMERR("only supply one of name or uuid, cmd(%u)", cmd);
19351935
return -EINVAL;
19361936
}
19371937

@@ -1978,7 +1978,7 @@ static int ctl_ioctl(struct file *file, uint command, struct dm_ioctl __user *us
19781978

19791979
fn = lookup_ioctl(cmd, &ioctl_flags);
19801980
if (!fn) {
1981-
DMWARN("dm_ctl_ioctl: unknown command 0x%x", command);
1981+
DMERR("dm_ctl_ioctl: unknown command 0x%x", command);
19821982
return -ENOTTY;
19831983
}
19841984

@@ -2203,7 +2203,7 @@ int __init dm_early_create(struct dm_ioctl *dmi,
22032203
(sector_t) spec_array[i]->length,
22042204
target_params_array[i]);
22052205
if (r) {
2206-
DMWARN("error adding target to table");
2206+
DMERR("error adding target to table");
22072207
goto err_destroy_table;
22082208
}
22092209
}
@@ -2216,7 +2216,7 @@ int __init dm_early_create(struct dm_ioctl *dmi,
22162216
/* setup md->queue to reflect md's type (may block) */
22172217
r = dm_setup_md_queue(md, t);
22182218
if (r) {
2219-
DMWARN("unable to set up device queue for new table.");
2219+
DMERR("unable to set up device queue for new table.");
22202220
goto err_destroy_table;
22212221
}
22222222

drivers/md/dm-raid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
25292529
* of the "sync" directive.
25302530
*
25312531
* With reshaping capability added, we must ensure that
2532-
* that the "sync" directive is disallowed during the reshape.
2532+
* the "sync" directive is disallowed during the reshape.
25332533
*/
25342534
if (test_bit(__CTR_FLAG_SYNC, &rs->ctr_flags))
25352535
continue;
@@ -2590,7 +2590,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
25902590

25912591
/*
25922592
* Adjust data_offset and new_data_offset on all disk members of @rs
2593-
* for out of place reshaping if requested by contructor
2593+
* for out of place reshaping if requested by constructor
25942594
*
25952595
* We need free space at the beginning of each raid disk for forward
25962596
* and at the end for backward reshapes which userspace has to provide

drivers/md/dm-rq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static void dm_done(struct request *clone, blk_status_t error, bool mapped)
238238
dm_requeue_original_request(tio, true);
239239
break;
240240
default:
241-
DMWARN("unimplemented target endio return value: %d", r);
241+
DMCRIT("unimplemented target endio return value: %d", r);
242242
BUG();
243243
}
244244
}
@@ -409,7 +409,7 @@ static int map_request(struct dm_rq_target_io *tio)
409409
dm_kill_unmapped_request(rq, BLK_STS_IOERR);
410410
break;
411411
default:
412-
DMWARN("unimplemented target map return value: %d", r);
412+
DMCRIT("unimplemented target map return value: %d", r);
413413
BUG();
414414
}
415415

drivers/md/dm-stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv,
12201220
return 2; /* this wasn't a stats message */
12211221

12221222
if (r == -EINVAL)
1223-
DMWARN("Invalid parameters for message %s", argv[0]);
1223+
DMCRIT("Invalid parameters for message %s", argv[0]);
12241224

12251225
return r;
12261226
}

0 commit comments

Comments
 (0)