summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2020-09-19 13:12:48 -0400
committerMike Snitzer <snitzer@redhat.com>2020-09-29 16:33:04 -0400
commit3720281db9ad4905c3afc1bf389314d64e145093 (patch)
tree48db4440859ad67533ec886e6d9e1af0e46b2c8e /drivers/md
parent094ee64d7de8ab72b495ff9c03d86a60272da56d (diff)
downloadlinux-3720281db9ad4905c3afc1bf389314d64e145093.tar.bz2
dm: optimize max_io_len() by inlining max_io_len_target_boundary()
Saves redundant dm_target_offset() math. Also, reverse argument order for max_io_len() to be consistent with other similar functions. Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index e1cb3b9fd207..0d3639414be7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1041,16 +1041,16 @@ static void clone_endio(struct bio *bio)
* Return maximum size of I/O possible at the supplied sector up to the current
* target boundary.
*/
-static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti)
+static inline sector_t max_io_len_target_boundary(struct dm_target *ti,
+ sector_t target_offset)
{
- sector_t target_offset = dm_target_offset(ti, sector);
-
return ti->len - target_offset;
}
-static sector_t max_io_len(sector_t sector, struct dm_target *ti)
+static sector_t max_io_len(struct dm_target *ti, sector_t sector)
{
- sector_t len = max_io_len_target_boundary(sector, ti);
+ sector_t target_offset = dm_target_offset(ti, sector);
+ sector_t len = max_io_len_target_boundary(ti, target_offset);
sector_t max_len;
/*
@@ -1060,7 +1060,7 @@ static sector_t max_io_len(sector_t sector, struct dm_target *ti)
* - blk_max_size_offset() also respects q->limits.max_sectors
*/
max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue,
- dm_target_offset(ti, sector));
+ target_offset);
if (len > max_len)
len = max_len;
@@ -1115,7 +1115,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
goto out;
if (!ti->type->direct_access)
goto out;
- len = max_io_len(sector, ti) / PAGE_SECTORS;
+ len = max_io_len(ti, sector) / PAGE_SECTORS;
if (len < 1)
goto out;
nr_pages = min(len, nr_pages);
@@ -1497,7 +1497,8 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *
if (!num_bios)
return -EOPNOTSUPP;
- len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
+ len = min_t(sector_t, ci->sector_count,
+ max_io_len_target_boundary(ti, dm_target_offset(ti, ci->sector)));
__send_duplicate_bios(ci, ti, num_bios, &len);
@@ -1578,7 +1579,7 @@ static int __split_and_process_non_flush(struct clone_info *ci)
if (__process_abnormal_io(ci, ti, &r))
return r;
- len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);
+ len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count);
r = __clone_and_map_data_bio(ci, ti, ci->sector, &len);
if (r < 0)