Skip to content

Commit 775a2e2

Browse files
committed
Merge tag 'dm-4.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - various fixes and improvements to request-based DM and DM multipath - some locking improvements in DM bufio - add Kconfig option to disable the DM block manager's extra locking which mainly serves as a developer tool - a few bug fixes to DM's persistent-data - a couple changes to prepare for multipage biovec support in the block layer - various improvements and cleanups in the DM core, DM cache, DM raid and DM crypt - add ability to have DM crypt use keys from the kernel key retention service - add a new "error_writes" feature to the DM flakey target, reads are left unchanged in this mode * tag 'dm-4.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (40 commits) dm flakey: introduce "error_writes" feature dm cache policy smq: use hash_32() instead of hash_32_generic() dm crypt: reject key strings containing whitespace chars dm space map: always set ev if sm_ll_mutate() succeeds dm space map metadata: skip useless memcpy in metadata_ll_init_index() dm space map metadata: fix 'struct sm_metadata' leak on failed create Documentation: dm raid: define data_offset status field dm raid: fix discard support regression dm raid: don't allow "write behind" with raid4/5/6 dm mpath: use hw_handler_params if attached hw_handler is same as requested dm crypt: add ability to use keys from the kernel key retention service dm array: remove a dead assignment in populate_ablock_with_values() dm ioctl: use offsetof() instead of open-coding it dm rq: simplify use_blk_mq initialization dm: use blk_set_queue_dying() in __dm_destroy() dm bufio: drop the lock when doing GFP_NOIO allocation dm bufio: don't take the lock in dm_bufio_shrink_count dm bufio: avoid sleeping while holding the dm_bufio lock dm table: simplify dm_table_determine_type() dm table: an 'all_blk_mq' table must be loaded for a blk-mq DM device ...
2 parents 2a4c32e + ef548c5 commit 775a2e2

22 files changed

+461
-200
lines changed

Documentation/device-mapper/dm-crypt.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,30 @@ Parameters: <cipher> <key> <iv_offset> <device path> \
2121
/proc/crypto contains supported crypto modes
2222

2323
<key>
24-
Key used for encryption. It is encoded as a hexadecimal number.
24+
Key used for encryption. It is encoded either as a hexadecimal number
25+
or it can be passed as <key_string> prefixed with single colon
26+
character (':') for keys residing in kernel keyring service.
2527
You can only use key sizes that are valid for the selected cipher
2628
in combination with the selected iv mode.
2729
Note that for some iv modes the key string can contain additional
2830
keys (for example IV seed) so the key contains more parts concatenated
2931
into a single string.
3032

33+
<key_string>
34+
The kernel keyring key is identified by string in following format:
35+
<key_size>:<key_type>:<key_description>.
36+
37+
<key_size>
38+
The encryption key size in bytes. The kernel key payload size must match
39+
the value passed in <key_size>.
40+
41+
<key_type>
42+
Either 'logon' or 'user' kernel key type.
43+
44+
<key_description>
45+
The kernel keyring key description crypt target should look for
46+
when loading key of <key_type>.
47+
3148
<keycount>
3249
Multi-key compatibility mode. You can define <keycount> keys and
3350
then sectors are encrypted according to their offsets (sector 0 uses key0;
@@ -88,6 +105,12 @@ https://gitlab.com/cryptsetup/cryptsetup
88105
dmsetup create crypt1 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
89106
]]
90107

108+
[[
109+
#!/bin/sh
110+
# Create a crypt device using dmsetup when encryption key is stored in keyring service
111+
dmsetup create crypt2 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 :32:logon:my_prefix:my_key 0 $1 0"
112+
]]
113+
91114
[[
92115
#!/bin/sh
93116
# Create a crypt device using cryptsetup and LUKS header with default cipher

Documentation/device-mapper/dm-raid.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ recovery. Here is a fuller description of the individual fields:
242242
in RAID1/10 or wrong parity values found in RAID4/5/6.
243243
This value is valid only after a "check" of the array
244244
is performed. A healthy array has a 'mismatch_cnt' of 0.
245+
<data_offset> The current data offset to the start of the user data on
246+
each component device of a raid set (see the respective
247+
raid parameter to support out-of-place reshaping).
248+
245249

246250
Message Interface
247251
-----------------

drivers/md/Kconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,17 @@ config DM_BUFIO
240240
as a cache, holding recently-read blocks in memory and performing
241241
delayed writes.
242242

243+
config DM_DEBUG_BLOCK_MANAGER_LOCKING
244+
bool "Block manager locking"
245+
depends on DM_BUFIO
246+
---help---
247+
Block manager locking can catch various metadata corruption issues.
248+
249+
If unsure, say N.
250+
243251
config DM_DEBUG_BLOCK_STACK_TRACING
244252
bool "Keep stack trace of persistent data block lock holders"
245-
depends on STACKTRACE_SUPPORT && DM_BUFIO
253+
depends on STACKTRACE_SUPPORT && DM_DEBUG_BLOCK_MANAGER_LOCKING
246254
select STACKTRACE
247255
---help---
248256
Enable this for messages that may help debug problems with the

drivers/md/dm-bufio.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,14 @@ enum new_flag {
820820
static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client *c, enum new_flag nf)
821821
{
822822
struct dm_buffer *b;
823+
bool tried_noio_alloc = false;
823824

824825
/*
825826
* dm-bufio is resistant to allocation failures (it just keeps
826827
* one buffer reserved in cases all the allocations fail).
827828
* So set flags to not try too hard:
828-
* GFP_NOIO: don't recurse into the I/O layer
829+
* GFP_NOWAIT: don't wait; if we need to sleep we'll release our
830+
* mutex and wait ourselves.
829831
* __GFP_NORETRY: don't retry and rather return failure
830832
* __GFP_NOMEMALLOC: don't use emergency reserves
831833
* __GFP_NOWARN: don't print a warning in case of failure
@@ -835,14 +837,23 @@ static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client
835837
*/
836838
while (1) {
837839
if (dm_bufio_cache_size_latch != 1) {
838-
b = alloc_buffer(c, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
840+
b = alloc_buffer(c, GFP_NOWAIT | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
839841
if (b)
840842
return b;
841843
}
842844

843845
if (nf == NF_PREFETCH)
844846
return NULL;
845847

848+
if (dm_bufio_cache_size_latch != 1 && !tried_noio_alloc) {
849+
dm_bufio_unlock(c);
850+
b = alloc_buffer(c, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
851+
dm_bufio_lock(c);
852+
if (b)
853+
return b;
854+
tried_noio_alloc = true;
855+
}
856+
846857
if (!list_empty(&c->reserved_buffers)) {
847858
b = list_entry(c->reserved_buffers.next,
848859
struct dm_buffer, lru_list);
@@ -1585,18 +1596,9 @@ dm_bufio_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
15851596
static unsigned long
15861597
dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
15871598
{
1588-
struct dm_bufio_client *c;
1589-
unsigned long count;
1590-
1591-
c = container_of(shrink, struct dm_bufio_client, shrinker);
1592-
if (sc->gfp_mask & __GFP_FS)
1593-
dm_bufio_lock(c);
1594-
else if (!dm_bufio_trylock(c))
1595-
return 0;
1599+
struct dm_bufio_client *c = container_of(shrink, struct dm_bufio_client, shrinker);
15961600

1597-
count = c->n_buffers[LIST_CLEAN] + c->n_buffers[LIST_DIRTY];
1598-
dm_bufio_unlock(c);
1599-
return count;
1601+
return ACCESS_ONCE(c->n_buffers[LIST_CLEAN]) + ACCESS_ONCE(c->n_buffers[LIST_DIRTY]);
16001602
}
16011603

16021604
/*

drivers/md/dm-cache-metadata.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ static int __format_metadata(struct dm_cache_metadata *cmd)
383383
goto bad;
384384

385385
dm_disk_bitset_init(cmd->tm, &cmd->discard_info);
386-
387386
r = dm_bitset_empty(&cmd->discard_info, &cmd->discard_root);
388387
if (r < 0)
389388
goto bad;
@@ -789,7 +788,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev,
789788
static bool same_params(struct dm_cache_metadata *cmd, sector_t data_block_size)
790789
{
791790
if (cmd->data_block_size != data_block_size) {
792-
DMERR("data_block_size (%llu) different from that in metadata (%llu)\n",
791+
DMERR("data_block_size (%llu) different from that in metadata (%llu)",
793792
(unsigned long long) data_block_size,
794793
(unsigned long long) cmd->data_block_size);
795794
return false;

drivers/md/dm-cache-policy-smq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ static void smq_clear_dirty(struct dm_cache_policy *p, dm_oblock_t oblock)
13611361

13621362
static unsigned random_level(dm_cblock_t cblock)
13631363
{
1364-
return hash_32_generic(from_cblock(cblock), 9) & (NR_CACHE_LEVELS - 1);
1364+
return hash_32(from_cblock(cblock), 9) & (NR_CACHE_LEVELS - 1);
13651365
}
13661366

13671367
static int smq_load_mapping(struct dm_cache_policy *p,

drivers/md/dm-cache-target.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ static void set_cache_mode(struct cache *cache, enum cache_metadata_mode new_mod
989989
enum cache_metadata_mode old_mode = get_cache_mode(cache);
990990

991991
if (dm_cache_metadata_needs_check(cache->cmd, &needs_check)) {
992-
DMERR("unable to read needs_check flag, setting failure mode");
992+
DMERR("%s: unable to read needs_check flag, setting failure mode.",
993+
cache_device_name(cache));
993994
new_mode = CM_FAIL;
994995
}
995996

0 commit comments

Comments
 (0)