diff options
author | Mike Snitzer <snitzer@redhat.com> | 2020-09-19 13:09:11 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2020-09-29 16:33:07 -0400 |
commit | 33bd6f0693857492ab19869d79801437ac1e42ba (patch) | |
tree | 1ccd06964552349271e8a3b713ff190429ce588c /drivers/md/dm-core.h | |
parent | 7465d7ac50edb3158c5eb957c5ecd3a5310e1c68 (diff) | |
download | lwn-33bd6f0693857492ab19869d79801437ac1e42ba.tar.gz lwn-33bd6f0693857492ab19869d79801437ac1e42ba.zip |
dm table: make 'struct dm_table' definition accessible to all of DM core
Move 'struct dm_table' definition from dm-table.c to dm-core.h and
update DM core to access its members directly.
Helps optimize max_io_len() and other methods slightly.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-core.h')
-rw-r--r-- | drivers/md/dm-core.h | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index c4ef1fceead6..d522093cb39d 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -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> @@ -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; @@ -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; |