Skip to content

Commit 4815519

Browse files
committed
Merge tag 'for-5.10/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - Improve DM core's bio splitting to use blk_max_size_offset(). Also fix bio splitting for bios that were deferred to the worker thread due to a DM device being suspended. - Remove DM core's special handling of NVMe devices now that block core has internalized efficiencies drivers previously needed to be concerned about (via now removed direct_make_request). - Fix request-based DM to not bounce through indirect dm_submit_bio; instead have block core make direct call to blk_mq_submit_bio(). - Various DM core cleanups to simplify and improve code. - Update DM cryot to not use drivers that set CRYPTO_ALG_ALLOCATES_MEMORY. - Fix DM raid's raid1 and raid10 discard limits for the purposes of linux-stable. But then remove DM raid's discard limits settings now that MD raid can efficiently handle large discards. - A couple small cleanups across various targets. * tag 'for-5.10/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm: fix request-based DM to not bounce through indirect dm_submit_bio dm: remove special-casing of bio-based immutable singleton target on NVMe dm: export dm_copy_name_and_uuid dm: fix comment in __dm_suspend() dm: fold dm_process_bio() into dm_submit_bio() dm: fix missing imposition of queue_limits from dm_wq_work() thread dm snap persistent: simplify area_io() dm thin metadata: Remove unused local variable when create thin and snap dm raid: remove unnecessary discard limits for raid10 dm raid: fix discard limits for raid1 and raid10 dm crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY dm: use dm_table_get_device_name() where appropriate in targets dm table: make 'struct dm_table' definition accessible to all of DM core dm: eliminate need for start_io_acct() forward declaration dm: simplify __process_abnormal_io() dm: push use of on-stack flush_bio down to __send_empty_flush() dm: optimize max_io_len() by inlining max_io_len_target_boundary() dm: push md->immutable_target optimization down to __process_bio() dm: change max_io_len() to use blk_max_size_offset() dm table: stack 'chunk_sectors' limit to account for target-specific splitting
2 parents 6e4dc3d + 681cc5e commit 4815519

File tree

16 files changed

+224
-397
lines changed

16 files changed

+224
-397
lines changed

block/blk-mq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,6 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
22702270
blk_queue_exit(q);
22712271
return BLK_QC_T_NONE;
22722272
}
2273-
EXPORT_SYMBOL_GPL(blk_mq_submit_bio); /* only for request based dm */
22742273

22752274
void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
22762275
unsigned int hctx_idx)

drivers/md/dm-cache-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ static enum cache_metadata_mode get_cache_mode(struct cache *cache)
925925

926926
static const char *cache_device_name(struct cache *cache)
927927
{
928-
return dm_device_name(dm_table_get_md(cache->ti->table));
928+
return dm_table_device_name(cache->ti->table);
929929
}
930930

931931
static void notify_mode_switch(struct cache *cache, enum cache_metadata_mode mode)

drivers/md/dm-core.h

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <linux/kthread.h>
1313
#include <linux/ktime.h>
14+
#include <linux/genhd.h>
1415
#include <linux/blk-mq.h>
1516

1617
#include <trace/events/block.h>
@@ -25,9 +26,11 @@ struct dm_kobject_holder {
2526
};
2627

2728
/*
28-
* DM core internal structure that used directly by dm.c and dm-rq.c
29-
* DM targets must _not_ deference a mapped_device to directly access its members!
29+
* DM core internal structures used directly by dm.c, dm-rq.c and dm-table.c.
30+
* DM targets must _not_ deference a mapped_device or dm_table to directly
31+
* access their members!
3032
*/
33+
3134
struct mapped_device {
3235
struct mutex suspend_lock;
3336

@@ -119,6 +122,55 @@ void disable_discard(struct mapped_device *md);
119122
void disable_write_same(struct mapped_device *md);
120123
void disable_write_zeroes(struct mapped_device *md);
121124

125+
static inline sector_t dm_get_size(struct mapped_device *md)
126+
{
127+
return get_capacity(md->disk);
128+
}
129+
130+
static inline struct dm_stats *dm_get_stats(struct mapped_device *md)
131+
{
132+
return &md->stats;
133+
}
134+
135+
#define DM_TABLE_MAX_DEPTH 16
136+
137+
struct dm_table {
138+
struct mapped_device *md;
139+
enum dm_queue_mode type;
140+
141+
/* btree table */
142+
unsigned int depth;
143+
unsigned int counts[DM_TABLE_MAX_DEPTH]; /* in nodes */
144+
sector_t *index[DM_TABLE_MAX_DEPTH];
145+
146+
unsigned int num_targets;
147+
unsigned int num_allocated;
148+
sector_t *highs;
149+
struct dm_target *targets;
150+
151+
struct target_type *immutable_target_type;
152+
153+
bool integrity_supported:1;
154+
bool singleton:1;
155+
unsigned integrity_added:1;
156+
157+
/*
158+
* Indicates the rw permissions for the new logical
159+
* device. This should be a combination of FMODE_READ
160+
* and FMODE_WRITE.
161+
*/
162+
fmode_t mode;
163+
164+
/* a list of devices used by this table */
165+
struct list_head devices;
166+
167+
/* events get handed up using this callback */
168+
void (*event_fn)(void *);
169+
void *event_context;
170+
171+
struct dm_md_mempools *mempools;
172+
};
173+
122174
static inline struct completion *dm_get_completion_from_kobject(struct kobject *kobj)
123175
{
124176
return &container_of(kobj, struct dm_kobject_holder, kobj)->completion;

drivers/md/dm-crypt.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ static int crypt_iv_lmk_ctr(struct crypt_config *cc, struct dm_target *ti,
424424
return -EINVAL;
425425
}
426426

427-
lmk->hash_tfm = crypto_alloc_shash("md5", 0, 0);
427+
lmk->hash_tfm = crypto_alloc_shash("md5", 0,
428+
CRYPTO_ALG_ALLOCATES_MEMORY);
428429
if (IS_ERR(lmk->hash_tfm)) {
429430
ti->error = "Error initializing LMK hash";
430431
return PTR_ERR(lmk->hash_tfm);
@@ -586,7 +587,8 @@ static int crypt_iv_tcw_ctr(struct crypt_config *cc, struct dm_target *ti,
586587
return -EINVAL;
587588
}
588589

589-
tcw->crc32_tfm = crypto_alloc_shash("crc32", 0, 0);
590+
tcw->crc32_tfm = crypto_alloc_shash("crc32", 0,
591+
CRYPTO_ALG_ALLOCATES_MEMORY);
590592
if (IS_ERR(tcw->crc32_tfm)) {
591593
ti->error = "Error initializing CRC32 in TCW";
592594
return PTR_ERR(tcw->crc32_tfm);
@@ -773,7 +775,8 @@ static int crypt_iv_elephant_ctr(struct crypt_config *cc, struct dm_target *ti,
773775
struct iv_elephant_private *elephant = &cc->iv_gen_private.elephant;
774776
int r;
775777

776-
elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0);
778+
elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0,
779+
CRYPTO_ALG_ALLOCATES_MEMORY);
777780
if (IS_ERR(elephant->tfm)) {
778781
r = PTR_ERR(elephant->tfm);
779782
elephant->tfm = NULL;
@@ -2154,7 +2157,8 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode)
21542157
return -ENOMEM;
21552158

21562159
for (i = 0; i < cc->tfms_count; i++) {
2157-
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0);
2160+
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0,
2161+
CRYPTO_ALG_ALLOCATES_MEMORY);
21582162
if (IS_ERR(cc->cipher_tfm.tfms[i])) {
21592163
err = PTR_ERR(cc->cipher_tfm.tfms[i]);
21602164
crypt_free_tfms(cc);
@@ -2180,7 +2184,8 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode)
21802184
if (!cc->cipher_tfm.tfms)
21812185
return -ENOMEM;
21822186

2183-
cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0, 0);
2187+
cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0,
2188+
CRYPTO_ALG_ALLOCATES_MEMORY);
21842189
if (IS_ERR(cc->cipher_tfm.tfms_aead[0])) {
21852190
err = PTR_ERR(cc->cipher_tfm.tfms_aead[0]);
21862191
crypt_free_tfms(cc);
@@ -2667,7 +2672,7 @@ static int crypt_ctr_auth_cipher(struct crypt_config *cc, char *cipher_api)
26672672
return -ENOMEM;
26682673
strncpy(mac_alg, start, end - start);
26692674

2670-
mac = crypto_alloc_ahash(mac_alg, 0, 0);
2675+
mac = crypto_alloc_ahash(mac_alg, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
26712676
kfree(mac_alg);
26722677

26732678
if (IS_ERR(mac))

drivers/md/dm-ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
20442044

20452045
return r;
20462046
}
2047-
2047+
EXPORT_SYMBOL_GPL(dm_copy_name_and_uuid);
20482048

20492049
/**
20502050
* dm_early_create - create a mapped device in early boot.

drivers/md/dm-mpath.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,8 @@ static struct pgpath *choose_pgpath(struct multipath *m, size_t nr_bytes)
466466
*/
467467
#define dm_report_EIO(m) \
468468
do { \
469-
struct mapped_device *md = dm_table_get_md((m)->ti->table); \
470-
\
471469
DMDEBUG_LIMIT("%s: returning EIO; QIFNP = %d; SQIFNP = %d; DNFS = %d", \
472-
dm_device_name(md), \
470+
dm_table_device_name((m)->ti->table), \
473471
test_bit(MPATHF_QUEUE_IF_NO_PATH, &(m)->flags), \
474472
test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &(m)->flags), \
475473
dm_noflush_suspending((m)->ti)); \
@@ -736,7 +734,7 @@ static int queue_if_no_path(struct multipath *m, bool queue_if_no_path,
736734
{
737735
unsigned long flags;
738736
bool queue_if_no_path_bit, saved_queue_if_no_path_bit;
739-
const char *dm_dev_name = dm_device_name(dm_table_get_md(m->ti->table));
737+
const char *dm_dev_name = dm_table_device_name(m->ti->table);
740738

741739
DMDEBUG("%s: %s caller=%s queue_if_no_path=%d save_old_value=%d",
742740
dm_dev_name, __func__, caller, queue_if_no_path, save_old_value);
@@ -781,9 +779,9 @@ static int queue_if_no_path(struct multipath *m, bool queue_if_no_path,
781779
static void queue_if_no_path_timeout_work(struct timer_list *t)
782780
{
783781
struct multipath *m = from_timer(m, t, nopath_timer);
784-
struct mapped_device *md = dm_table_get_md(m->ti->table);
785782

786-
DMWARN("queue_if_no_path timeout on %s, failing queued IO", dm_device_name(md));
783+
DMWARN("queue_if_no_path timeout on %s, failing queued IO",
784+
dm_table_device_name(m->ti->table));
787785
queue_if_no_path(m, false, false, __func__);
788786
}
789787

@@ -1334,7 +1332,7 @@ static int fail_path(struct pgpath *pgpath)
13341332
goto out;
13351333

13361334
DMWARN("%s: Failing path %s.",
1337-
dm_device_name(dm_table_get_md(m->ti->table)),
1335+
dm_table_device_name(m->ti->table),
13381336
pgpath->path.dev->name);
13391337

13401338
pgpath->pg->ps.type->fail_path(&pgpath->pg->ps, &pgpath->path);
@@ -1375,7 +1373,7 @@ static int reinstate_path(struct pgpath *pgpath)
13751373
goto out;
13761374

13771375
DMWARN("%s: Reinstating path %s.",
1378-
dm_device_name(dm_table_get_md(m->ti->table)),
1376+
dm_table_device_name(m->ti->table),
13791377
pgpath->path.dev->name);
13801378

13811379
r = pgpath->pg->ps.type->reinstate_path(&pgpath->pg->ps, &pgpath->path);
@@ -1766,7 +1764,7 @@ static void multipath_resume(struct dm_target *ti)
17661764
}
17671765

17681766
DMDEBUG("%s: %s finished; QIFNP = %d; SQIFNP = %d",
1769-
dm_device_name(dm_table_get_md(m->ti->table)), __func__,
1767+
dm_table_device_name(m->ti->table), __func__,
17701768
test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags),
17711769
test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags));
17721770

drivers/md/dm-raid.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,15 +3728,6 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits)
37283728

37293729
blk_limits_io_min(limits, chunk_size_bytes);
37303730
blk_limits_io_opt(limits, chunk_size_bytes * mddev_data_stripes(rs));
3731-
3732-
/*
3733-
* RAID1 and RAID10 personalities require bio splitting,
3734-
* RAID0/4/5/6 don't and process large discard bios properly.
3735-
*/
3736-
if (rs_is_raid1(rs) || rs_is_raid10(rs)) {
3737-
limits->discard_granularity = chunk_size_bytes;
3738-
limits->max_discard_sectors = rs->md.chunk_sectors;
3739-
}
37403731
}
37413732

37423733
static void raid_postsuspend(struct dm_target *ti)

drivers/md/dm-rq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static void __dm_mq_kick_requeue_list(struct request_queue *q, unsigned long mse
175175

176176
void dm_mq_kick_requeue_list(struct mapped_device *md)
177177
{
178-
__dm_mq_kick_requeue_list(dm_get_md_queue(md), 0);
178+
__dm_mq_kick_requeue_list(md->queue, 0);
179179
}
180180
EXPORT_SYMBOL(dm_mq_kick_requeue_list);
181181

drivers/md/dm-snap-persistent.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,9 @@ static void skip_metadata(struct pstore *ps)
284284
*/
285285
static int area_io(struct pstore *ps, int op, int op_flags)
286286
{
287-
int r;
288-
chunk_t chunk;
289-
290-
chunk = area_location(ps, ps->current_area);
291-
292-
r = chunk_io(ps, ps->area, chunk, op, op_flags, 0);
293-
if (r)
294-
return r;
287+
chunk_t chunk = area_location(ps, ps->current_area);
295288

296-
return 0;
289+
return chunk_io(ps, ps->area, chunk, op, op_flags, 0);
297290
}
298291

299292
static void zero_memory_area(struct pstore *ps)

0 commit comments

Comments
 (0)