Skip to content

Commit

Permalink
Merge tag 'for-5.10/dm-changes' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
torvalds committed Oct 14, 2020
2 parents 6e4dc3d + 681cc5e commit 4815519
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 397 deletions.
1 change: 0 additions & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,6 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
blk_queue_exit(q);
return BLK_QC_T_NONE;
}
EXPORT_SYMBOL_GPL(blk_mq_submit_bio); /* only for request based dm */

void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
unsigned int hctx_idx)
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ static enum cache_metadata_mode get_cache_mode(struct cache *cache)

static const char *cache_device_name(struct cache *cache)
{
return dm_device_name(dm_table_get_md(cache->ti->table));
return dm_table_device_name(cache->ti->table);
}

static void notify_mode_switch(struct cache *cache, enum cache_metadata_mode mode)
Expand Down
56 changes: 54 additions & 2 deletions drivers/md/dm-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <linux/kthread.h>
#include <linux/ktime.h>
#include <linux/genhd.h>
#include <linux/blk-mq.h>

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

/*
* DM core internal structure that used directly by dm.c and dm-rq.c
* DM targets must _not_ deference a mapped_device to directly access its members!
* DM core internal structures used directly by dm.c, dm-rq.c and dm-table.c.
* DM targets must _not_ deference a mapped_device or dm_table to directly
* access their members!
*/

struct mapped_device {
struct mutex suspend_lock;

Expand Down Expand Up @@ -119,6 +122,55 @@ void disable_discard(struct mapped_device *md);
void disable_write_same(struct mapped_device *md);
void disable_write_zeroes(struct mapped_device *md);

static inline sector_t dm_get_size(struct mapped_device *md)
{
return get_capacity(md->disk);
}

static inline struct dm_stats *dm_get_stats(struct mapped_device *md)
{
return &md->stats;
}

#define DM_TABLE_MAX_DEPTH 16

struct dm_table {
struct mapped_device *md;
enum dm_queue_mode type;

/* btree table */
unsigned int depth;
unsigned int counts[DM_TABLE_MAX_DEPTH]; /* in nodes */
sector_t *index[DM_TABLE_MAX_DEPTH];

unsigned int num_targets;
unsigned int num_allocated;
sector_t *highs;
struct dm_target *targets;

struct target_type *immutable_target_type;

bool integrity_supported:1;
bool singleton:1;
unsigned integrity_added:1;

/*
* Indicates the rw permissions for the new logical
* device. This should be a combination of FMODE_READ
* and FMODE_WRITE.
*/
fmode_t mode;

/* a list of devices used by this table */
struct list_head devices;

/* events get handed up using this callback */
void (*event_fn)(void *);
void *event_context;

struct dm_md_mempools *mempools;
};

static inline struct completion *dm_get_completion_from_kobject(struct kobject *kobj)
{
return &container_of(kobj, struct dm_kobject_holder, kobj)->completion;
Expand Down
17 changes: 11 additions & 6 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ static int crypt_iv_lmk_ctr(struct crypt_config *cc, struct dm_target *ti,
return -EINVAL;
}

lmk->hash_tfm = crypto_alloc_shash("md5", 0, 0);
lmk->hash_tfm = crypto_alloc_shash("md5", 0,
CRYPTO_ALG_ALLOCATES_MEMORY);
if (IS_ERR(lmk->hash_tfm)) {
ti->error = "Error initializing LMK hash";
return PTR_ERR(lmk->hash_tfm);
Expand Down Expand Up @@ -586,7 +587,8 @@ static int crypt_iv_tcw_ctr(struct crypt_config *cc, struct dm_target *ti,
return -EINVAL;
}

tcw->crc32_tfm = crypto_alloc_shash("crc32", 0, 0);
tcw->crc32_tfm = crypto_alloc_shash("crc32", 0,
CRYPTO_ALG_ALLOCATES_MEMORY);
if (IS_ERR(tcw->crc32_tfm)) {
ti->error = "Error initializing CRC32 in TCW";
return PTR_ERR(tcw->crc32_tfm);
Expand Down Expand Up @@ -773,7 +775,8 @@ static int crypt_iv_elephant_ctr(struct crypt_config *cc, struct dm_target *ti,
struct iv_elephant_private *elephant = &cc->iv_gen_private.elephant;
int r;

elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0);
elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0,
CRYPTO_ALG_ALLOCATES_MEMORY);
if (IS_ERR(elephant->tfm)) {
r = PTR_ERR(elephant->tfm);
elephant->tfm = NULL;
Expand Down Expand Up @@ -2154,7 +2157,8 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode)
return -ENOMEM;

for (i = 0; i < cc->tfms_count; i++) {
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0);
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0,
CRYPTO_ALG_ALLOCATES_MEMORY);
if (IS_ERR(cc->cipher_tfm.tfms[i])) {
err = PTR_ERR(cc->cipher_tfm.tfms[i]);
crypt_free_tfms(cc);
Expand All @@ -2180,7 +2184,8 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode)
if (!cc->cipher_tfm.tfms)
return -ENOMEM;

cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0, 0);
cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0,
CRYPTO_ALG_ALLOCATES_MEMORY);
if (IS_ERR(cc->cipher_tfm.tfms_aead[0])) {
err = PTR_ERR(cc->cipher_tfm.tfms_aead[0]);
crypt_free_tfms(cc);
Expand Down Expand Up @@ -2667,7 +2672,7 @@ static int crypt_ctr_auth_cipher(struct crypt_config *cc, char *cipher_api)
return -ENOMEM;
strncpy(mac_alg, start, end - start);

mac = crypto_alloc_ahash(mac_alg, 0, 0);
mac = crypto_alloc_ahash(mac_alg, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
kfree(mac_alg);

if (IS_ERR(mac))
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)

return r;
}

EXPORT_SYMBOL_GPL(dm_copy_name_and_uuid);

/**
* dm_early_create - create a mapped device in early boot.
Expand Down
16 changes: 7 additions & 9 deletions drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,8 @@ static struct pgpath *choose_pgpath(struct multipath *m, size_t nr_bytes)
*/
#define dm_report_EIO(m) \
do { \
struct mapped_device *md = dm_table_get_md((m)->ti->table); \
\
DMDEBUG_LIMIT("%s: returning EIO; QIFNP = %d; SQIFNP = %d; DNFS = %d", \
dm_device_name(md), \
dm_table_device_name((m)->ti->table), \
test_bit(MPATHF_QUEUE_IF_NO_PATH, &(m)->flags), \
test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &(m)->flags), \
dm_noflush_suspending((m)->ti)); \
Expand Down Expand Up @@ -736,7 +734,7 @@ static int queue_if_no_path(struct multipath *m, bool queue_if_no_path,
{
unsigned long flags;
bool queue_if_no_path_bit, saved_queue_if_no_path_bit;
const char *dm_dev_name = dm_device_name(dm_table_get_md(m->ti->table));
const char *dm_dev_name = dm_table_device_name(m->ti->table);

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

DMWARN("queue_if_no_path timeout on %s, failing queued IO", dm_device_name(md));
DMWARN("queue_if_no_path timeout on %s, failing queued IO",
dm_table_device_name(m->ti->table));
queue_if_no_path(m, false, false, __func__);
}

Expand Down Expand Up @@ -1334,7 +1332,7 @@ static int fail_path(struct pgpath *pgpath)
goto out;

DMWARN("%s: Failing path %s.",
dm_device_name(dm_table_get_md(m->ti->table)),
dm_table_device_name(m->ti->table),
pgpath->path.dev->name);

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

DMWARN("%s: Reinstating path %s.",
dm_device_name(dm_table_get_md(m->ti->table)),
dm_table_device_name(m->ti->table),
pgpath->path.dev->name);

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

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

Expand Down
9 changes: 0 additions & 9 deletions drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3728,15 +3728,6 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits)

blk_limits_io_min(limits, chunk_size_bytes);
blk_limits_io_opt(limits, chunk_size_bytes * mddev_data_stripes(rs));

/*
* RAID1 and RAID10 personalities require bio splitting,
* RAID0/4/5/6 don't and process large discard bios properly.
*/
if (rs_is_raid1(rs) || rs_is_raid10(rs)) {
limits->discard_granularity = chunk_size_bytes;
limits->max_discard_sectors = rs->md.chunk_sectors;
}
}

static void raid_postsuspend(struct dm_target *ti)
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-rq.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void __dm_mq_kick_requeue_list(struct request_queue *q, unsigned long mse

void dm_mq_kick_requeue_list(struct mapped_device *md)
{
__dm_mq_kick_requeue_list(dm_get_md_queue(md), 0);
__dm_mq_kick_requeue_list(md->queue, 0);
}
EXPORT_SYMBOL(dm_mq_kick_requeue_list);

Expand Down
11 changes: 2 additions & 9 deletions drivers/md/dm-snap-persistent.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,9 @@ static void skip_metadata(struct pstore *ps)
*/
static int area_io(struct pstore *ps, int op, int op_flags)
{
int r;
chunk_t chunk;

chunk = area_location(ps, ps->current_area);

r = chunk_io(ps, ps->area, chunk, op, op_flags, 0);
if (r)
return r;
chunk_t chunk = area_location(ps, ps->current_area);

return 0;
return chunk_io(ps, ps->area, chunk, op, op_flags, 0);
}

static void zero_memory_area(struct pstore *ps)
Expand Down
Loading

0 comments on commit 4815519

Please sign in to comment.