Commit 2aec377a authored by Mike Snitzer's avatar Mike Snitzer

dm table: remove dm_table_get_num_targets() wrapper

More efficient and readable to just access table->num_targets directly.
Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent 8b211aac
...@@ -208,7 +208,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl ...@@ -208,7 +208,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
if (!target_data_buf) if (!target_data_buf)
goto error; goto error;
num_targets = dm_table_get_num_targets(table); num_targets = table->num_targets;
if (dm_ima_alloc_and_copy_device_data(table->md, &device_data_buf, num_targets, noio)) if (dm_ima_alloc_and_copy_device_data(table->md, &device_data_buf, num_targets, noio))
goto error; goto error;
......
...@@ -832,7 +832,7 @@ static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) ...@@ -832,7 +832,7 @@ static void __dev_status(struct mapped_device *md, struct dm_ioctl *param)
if (!(param->flags & DM_QUERY_INACTIVE_TABLE_FLAG)) { if (!(param->flags & DM_QUERY_INACTIVE_TABLE_FLAG)) {
if (get_disk_ro(disk)) if (get_disk_ro(disk))
param->flags |= DM_READONLY_FLAG; param->flags |= DM_READONLY_FLAG;
param->target_count = dm_table_get_num_targets(table); param->target_count = table->num_targets;
} }
param->flags |= DM_ACTIVE_PRESENT_FLAG; param->flags |= DM_ACTIVE_PRESENT_FLAG;
...@@ -845,7 +845,7 @@ static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) ...@@ -845,7 +845,7 @@ static void __dev_status(struct mapped_device *md, struct dm_ioctl *param)
if (table) { if (table) {
if (!(dm_table_get_mode(table) & FMODE_WRITE)) if (!(dm_table_get_mode(table) & FMODE_WRITE))
param->flags |= DM_READONLY_FLAG; param->flags |= DM_READONLY_FLAG;
param->target_count = dm_table_get_num_targets(table); param->target_count = table->num_targets;
} }
dm_put_live_table(md, srcu_idx); dm_put_live_table(md, srcu_idx);
} }
...@@ -1248,7 +1248,7 @@ static void retrieve_status(struct dm_table *table, ...@@ -1248,7 +1248,7 @@ static void retrieve_status(struct dm_table *table,
type = STATUSTYPE_INFO; type = STATUSTYPE_INFO;
/* Get all the target info */ /* Get all the target info */
num_targets = dm_table_get_num_targets(table); num_targets = table->num_targets;
for (i = 0; i < num_targets; i++) { for (i = 0; i < num_targets; i++) {
struct dm_target *ti = dm_table_get_target(table, i); struct dm_target *ti = dm_table_get_target(table, i);
size_t l; size_t l;
......
...@@ -593,7 +593,7 @@ static int validate_hardware_logical_block_alignment(struct dm_table *table, ...@@ -593,7 +593,7 @@ static int validate_hardware_logical_block_alignment(struct dm_table *table,
/* /*
* Check each entry in the table in turn. * Check each entry in the table in turn.
*/ */
for (i = 0; i < dm_table_get_num_targets(table); i++) { for (i = 0; i < table->num_targets; i++) {
ti = dm_table_get_target(table, i); ti = dm_table_get_target(table, i);
blk_set_stacking_limits(&ti_limits); blk_set_stacking_limits(&ti_limits);
...@@ -832,7 +832,7 @@ static bool dm_table_supports_dax(struct dm_table *t, ...@@ -832,7 +832,7 @@ static bool dm_table_supports_dax(struct dm_table *t,
unsigned i; unsigned i;
/* Ensure that all targets support DAX. */ /* Ensure that all targets support DAX. */
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!ti->type->direct_access) if (!ti->type->direct_access)
...@@ -987,7 +987,7 @@ struct dm_target *dm_table_get_wildcard_target(struct dm_table *t) ...@@ -987,7 +987,7 @@ struct dm_target *dm_table_get_wildcard_target(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned i; unsigned i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (dm_target_is_wildcard(ti->type)) if (dm_target_is_wildcard(ti->type))
return ti; return ti;
...@@ -1127,7 +1127,7 @@ static struct gendisk * dm_table_get_integrity_disk(struct dm_table *t) ...@@ -1127,7 +1127,7 @@ static struct gendisk * dm_table_get_integrity_disk(struct dm_table *t)
struct gendisk *prev_disk = NULL, *template_disk = NULL; struct gendisk *prev_disk = NULL, *template_disk = NULL;
unsigned i; unsigned i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
struct dm_target *ti = dm_table_get_target(t, i); struct dm_target *ti = dm_table_get_target(t, i);
if (!dm_target_passes_integrity(ti->type)) if (!dm_target_passes_integrity(ti->type))
goto no_integrity; goto no_integrity;
...@@ -1248,7 +1248,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile, ...@@ -1248,7 +1248,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile,
t = dm_get_live_table(md, &srcu_idx); t = dm_get_live_table(md, &srcu_idx);
if (!t) if (!t)
return 0; return 0;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!ti->type->iterate_devices) if (!ti->type->iterate_devices)
continue; continue;
...@@ -1318,7 +1318,7 @@ static int dm_table_construct_crypto_profile(struct dm_table *t) ...@@ -1318,7 +1318,7 @@ static int dm_table_construct_crypto_profile(struct dm_table *t)
memset(profile->modes_supported, 0xFF, memset(profile->modes_supported, 0xFF,
sizeof(profile->modes_supported)); sizeof(profile->modes_supported));
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!dm_target_passes_crypto(ti->type)) { if (!dm_target_passes_crypto(ti->type)) {
...@@ -1540,7 +1540,7 @@ static bool dm_table_any_dev_attr(struct dm_table *t, ...@@ -1540,7 +1540,7 @@ static bool dm_table_any_dev_attr(struct dm_table *t,
struct dm_target *ti; struct dm_target *ti;
unsigned int i; unsigned int i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (ti->type->iterate_devices && if (ti->type->iterate_devices &&
...@@ -1566,7 +1566,7 @@ static bool dm_table_supports_poll(struct dm_table *t) ...@@ -1566,7 +1566,7 @@ static bool dm_table_supports_poll(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned i = 0; unsigned i = 0;
while (i < dm_table_get_num_targets(t)) { while (i < t->num_targets) {
ti = dm_table_get_target(t, i++); ti = dm_table_get_target(t, i++);
if (!ti->type->iterate_devices || if (!ti->type->iterate_devices ||
...@@ -1588,7 +1588,7 @@ bool dm_table_has_no_data_devices(struct dm_table *table) ...@@ -1588,7 +1588,7 @@ bool dm_table_has_no_data_devices(struct dm_table *table)
struct dm_target *ti; struct dm_target *ti;
unsigned i, num_devices; unsigned i, num_devices;
for (i = 0; i < dm_table_get_num_targets(table); i++) { for (i = 0; i < table->num_targets; i++) {
ti = dm_table_get_target(table, i); ti = dm_table_get_target(table, i);
if (!ti->type->iterate_devices) if (!ti->type->iterate_devices)
...@@ -1625,7 +1625,7 @@ static bool dm_table_supports_zoned_model(struct dm_table *t, ...@@ -1625,7 +1625,7 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
struct dm_target *ti; struct dm_target *ti;
unsigned i; unsigned i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (dm_target_supports_zoned_hm(ti->type)) { if (dm_target_supports_zoned_hm(ti->type)) {
...@@ -1699,7 +1699,7 @@ int dm_calculate_queue_limits(struct dm_table *table, ...@@ -1699,7 +1699,7 @@ int dm_calculate_queue_limits(struct dm_table *table,
blk_set_stacking_limits(limits); blk_set_stacking_limits(limits);
for (i = 0; i < dm_table_get_num_targets(table); i++) { for (i = 0; i < table->num_targets; i++) {
blk_set_stacking_limits(&ti_limits); blk_set_stacking_limits(&ti_limits);
ti = dm_table_get_target(table, i); ti = dm_table_get_target(table, i);
...@@ -1819,7 +1819,7 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned long flush) ...@@ -1819,7 +1819,7 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned long flush)
* so we need to use iterate_devices here, which targets * so we need to use iterate_devices here, which targets
* supporting flushes must provide. * supporting flushes must provide.
*/ */
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!ti->num_flush_bios) if (!ti->num_flush_bios)
...@@ -1877,7 +1877,7 @@ static bool dm_table_supports_write_zeroes(struct dm_table *t) ...@@ -1877,7 +1877,7 @@ static bool dm_table_supports_write_zeroes(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned i = 0; unsigned i = 0;
while (i < dm_table_get_num_targets(t)) { while (i < t->num_targets) {
ti = dm_table_get_target(t, i++); ti = dm_table_get_target(t, i++);
if (!ti->num_write_zeroes_bios) if (!ti->num_write_zeroes_bios)
...@@ -1904,7 +1904,7 @@ static bool dm_table_supports_nowait(struct dm_table *t) ...@@ -1904,7 +1904,7 @@ static bool dm_table_supports_nowait(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned i = 0; unsigned i = 0;
while (i < dm_table_get_num_targets(t)) { while (i < t->num_targets) {
ti = dm_table_get_target(t, i++); ti = dm_table_get_target(t, i++);
if (!dm_target_supports_nowait(ti->type)) if (!dm_target_supports_nowait(ti->type))
...@@ -1929,7 +1929,7 @@ static bool dm_table_supports_discards(struct dm_table *t) ...@@ -1929,7 +1929,7 @@ static bool dm_table_supports_discards(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned i; unsigned i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!ti->num_discard_bios) if (!ti->num_discard_bios)
...@@ -1961,7 +1961,7 @@ static bool dm_table_supports_secure_erase(struct dm_table *t) ...@@ -1961,7 +1961,7 @@ static bool dm_table_supports_secure_erase(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned int i; unsigned int i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (!ti->num_secure_erase_bios) if (!ti->num_secure_erase_bios)
...@@ -2092,11 +2092,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, ...@@ -2092,11 +2092,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
return 0; return 0;
} }
unsigned int dm_table_get_num_targets(struct dm_table *t)
{
return t->num_targets;
}
struct list_head *dm_table_get_devices(struct dm_table *t) struct list_head *dm_table_get_devices(struct dm_table *t)
{ {
return &t->devices; return &t->devices;
......
...@@ -278,7 +278,7 @@ static bool dm_table_supports_zone_append(struct dm_table *t) ...@@ -278,7 +278,7 @@ static bool dm_table_supports_zone_append(struct dm_table *t)
struct dm_target *ti; struct dm_target *ti;
unsigned int i; unsigned int i;
for (i = 0; i < dm_table_get_num_targets(t); i++) { for (i = 0; i < t->num_targets; i++) {
ti = dm_table_get_target(t, i); ti = dm_table_get_target(t, i);
if (ti->emulate_zone_append) if (ti->emulate_zone_append)
......
...@@ -422,7 +422,7 @@ static int dm_prepare_ioctl(struct mapped_device *md, int *srcu_idx, ...@@ -422,7 +422,7 @@ static int dm_prepare_ioctl(struct mapped_device *md, int *srcu_idx,
return r; return r;
/* We only support devices that have a single target */ /* We only support devices that have a single target */
if (dm_table_get_num_targets(map) != 1) if (map->num_targets != 1)
return r; return r;
tgt = dm_table_get_target(map, 0); tgt = dm_table_get_target(map, 0);
...@@ -3092,7 +3092,7 @@ static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn, ...@@ -3092,7 +3092,7 @@ static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn,
goto out; goto out;
/* We only support devices that have a single target */ /* We only support devices that have a single target */
if (dm_table_get_num_targets(table) != 1) if (table->num_targets != 1)
goto out; goto out;
ti = dm_table_get_target(table, 0); ti = dm_table_get_target(table, 0);
......
...@@ -561,7 +561,6 @@ void dm_sync_table(struct mapped_device *md); ...@@ -561,7 +561,6 @@ void dm_sync_table(struct mapped_device *md);
* Queries * Queries
*/ */
sector_t dm_table_get_size(struct dm_table *t); sector_t dm_table_get_size(struct dm_table *t);
unsigned int dm_table_get_num_targets(struct dm_table *t);
fmode_t dm_table_get_mode(struct dm_table *t); fmode_t dm_table_get_mode(struct dm_table *t);
struct mapped_device *dm_table_get_md(struct dm_table *t); struct mapped_device *dm_table_get_md(struct dm_table *t);
const char *dm_table_device_name(struct dm_table *t); const char *dm_table_device_name(struct dm_table *t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment