Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+61 -70
+54 -2
drivers/md/dm-core.h
··· 11 11 12 12 #include <linux/kthread.h> 13 13 #include <linux/ktime.h> 14 + #include <linux/genhd.h> 14 15 #include <linux/blk-mq.h> 15 16 16 17 #include <trace/events/block.h> ··· 26 25 }; 27 26 28 27 /* 29 - * DM core internal structure that used directly by dm.c and dm-rq.c 30 - * DM targets must _not_ deference a mapped_device to directly access its members! 28 + * DM core internal structures used directly by dm.c, dm-rq.c and dm-table.c. 29 + * DM targets must _not_ deference a mapped_device or dm_table to directly 30 + * access their members! 31 31 */ 32 + 32 33 struct mapped_device { 33 34 struct mutex suspend_lock; 34 35 ··· 121 118 void disable_discard(struct mapped_device *md); 122 119 void disable_write_same(struct mapped_device *md); 123 120 void disable_write_zeroes(struct mapped_device *md); 121 + 122 + static inline sector_t dm_get_size(struct mapped_device *md) 123 + { 124 + return get_capacity(md->disk); 125 + } 126 + 127 + static inline struct dm_stats *dm_get_stats(struct mapped_device *md) 128 + { 129 + return &md->stats; 130 + } 131 + 132 + #define DM_TABLE_MAX_DEPTH 16 133 + 134 + struct dm_table { 135 + struct mapped_device *md; 136 + enum dm_queue_mode type; 137 + 138 + /* btree table */ 139 + unsigned int depth; 140 + unsigned int counts[DM_TABLE_MAX_DEPTH]; /* in nodes */ 141 + sector_t *index[DM_TABLE_MAX_DEPTH]; 142 + 143 + unsigned int num_targets; 144 + unsigned int num_allocated; 145 + sector_t *highs; 146 + struct dm_target *targets; 147 + 148 + struct target_type *immutable_target_type; 149 + 150 + bool integrity_supported:1; 151 + bool singleton:1; 152 + unsigned integrity_added:1; 153 + 154 + /* 155 + * Indicates the rw permissions for the new logical 156 + * device. This should be a combination of FMODE_READ 157 + * and FMODE_WRITE. 158 + */ 159 + fmode_t mode; 160 + 161 + /* a list of devices used by this table */ 162 + struct list_head devices; 163 + 164 + /* events get handed up using this callback */ 165 + void (*event_fn)(void *); 166 + void *event_context; 167 + 168 + struct dm_md_mempools *mempools; 169 + }; 124 170 125 171 static inline struct completion *dm_get_completion_from_kobject(struct kobject *kobj) 126 172 {
+1 -1
drivers/md/dm-rq.c
··· 175 175 176 176 void dm_mq_kick_requeue_list(struct mapped_device *md) 177 177 { 178 - __dm_mq_kick_requeue_list(dm_get_md_queue(md), 0); 178 + __dm_mq_kick_requeue_list(md->queue, 0); 179 179 } 180 180 EXPORT_SYMBOL(dm_mq_kick_requeue_list); 181 181
+2 -45
drivers/md/dm-table.c
··· 25 25 26 26 #define DM_MSG_PREFIX "table" 27 27 28 - #define MAX_DEPTH 16 29 28 #define NODE_SIZE L1_CACHE_BYTES 30 29 #define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t)) 31 30 #define CHILDREN_PER_NODE (KEYS_PER_NODE + 1) 32 - 33 - struct dm_table { 34 - struct mapped_device *md; 35 - enum dm_queue_mode type; 36 - 37 - /* btree table */ 38 - unsigned int depth; 39 - unsigned int counts[MAX_DEPTH]; /* in nodes */ 40 - sector_t *index[MAX_DEPTH]; 41 - 42 - unsigned int num_targets; 43 - unsigned int num_allocated; 44 - sector_t *highs; 45 - struct dm_target *targets; 46 - 47 - struct target_type *immutable_target_type; 48 - 49 - bool integrity_supported:1; 50 - bool singleton:1; 51 - unsigned integrity_added:1; 52 - 53 - /* 54 - * Indicates the rw permissions for the new logical 55 - * device. This should be a combination of FMODE_READ 56 - * and FMODE_WRITE. 57 - */ 58 - fmode_t mode; 59 - 60 - /* a list of devices used by this table */ 61 - struct list_head devices; 62 - 63 - /* events get handed up using this callback */ 64 - void (*event_fn)(void *); 65 - void *event_context; 66 - 67 - struct dm_md_mempools *mempools; 68 - }; 69 31 70 32 /* 71 33 * Similar to ceiling(log_size(n)) ··· 2047 2085 2048 2086 void dm_table_run_md_queue_async(struct dm_table *t) 2049 2087 { 2050 - struct mapped_device *md; 2051 - struct request_queue *queue; 2052 - 2053 2088 if (!dm_table_request_based(t)) 2054 2089 return; 2055 2090 2056 - md = dm_table_get_md(t); 2057 - queue = dm_get_md_queue(md); 2058 - if (queue) 2059 - blk_mq_run_hw_queues(queue, true); 2091 + if (t->md->queue) 2092 + blk_mq_run_hw_queues(t->md->queue, true); 2060 2093 } 2061 2094 EXPORT_SYMBOL(dm_table_run_md_queue_async); 2062 2095
+4 -19
drivers/md/dm.c
··· 422 422 dm_deferred_remove(); 423 423 } 424 424 425 - sector_t dm_get_size(struct mapped_device *md) 426 - { 427 - return get_capacity(md->disk); 428 - } 429 - 430 - struct request_queue *dm_get_md_queue(struct mapped_device *md) 431 - { 432 - return md->queue; 433 - } 434 - 435 - struct dm_stats *dm_get_stats(struct mapped_device *md) 436 - { 437 - return &md->stats; 438 - } 439 - 440 425 static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo) 441 426 { 442 427 struct mapped_device *md = bdev->bd_disk->private_data; ··· 1042 1057 * blk_max_size_offset() provides required splitting. 1043 1058 * - blk_max_size_offset() also respects q->limits.max_sectors 1044 1059 */ 1045 - max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue, 1060 + max_len = blk_max_size_offset(ti->table->md->queue, 1046 1061 target_offset); 1047 1062 if (len > max_len) 1048 1063 len = max_len; ··· 2916 2931 2917 2932 int dm_suspended(struct dm_target *ti) 2918 2933 { 2919 - return dm_suspended_md(dm_table_get_md(ti->table)); 2934 + return dm_suspended_md(ti->table->md); 2920 2935 } 2921 2936 EXPORT_SYMBOL_GPL(dm_suspended); 2922 2937 2923 2938 int dm_post_suspending(struct dm_target *ti) 2924 2939 { 2925 - return dm_post_suspending_md(dm_table_get_md(ti->table)); 2940 + return dm_post_suspending_md(ti->table->md); 2926 2941 } 2927 2942 EXPORT_SYMBOL_GPL(dm_post_suspending); 2928 2943 2929 2944 int dm_noflush_suspending(struct dm_target *ti) 2930 2945 { 2931 - return __noflush_suspending(dm_table_get_md(ti->table)); 2946 + return __noflush_suspending(ti->table->md); 2932 2947 } 2933 2948 EXPORT_SYMBOL_GPL(dm_noflush_suspending); 2934 2949
-3
drivers/md/dm.h
··· 179 179 int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only_deferred); 180 180 int dm_cancel_deferred_remove(struct mapped_device *md); 181 181 int dm_request_based(struct mapped_device *md); 182 - sector_t dm_get_size(struct mapped_device *md); 183 - struct request_queue *dm_get_md_queue(struct mapped_device *md); 184 182 int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode, 185 183 struct dm_dev **result); 186 184 void dm_put_table_device(struct mapped_device *md, struct dm_dev *d); 187 - struct dm_stats *dm_get_stats(struct mapped_device *md); 188 185 189 186 int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, 190 187 unsigned cookie);