Skip to content

Commit

Permalink
dm: remove indirect calls from __send_changing_extent_only()
Browse files Browse the repository at this point in the history
No need to be so fancy.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mike Snitzer committed Dec 18, 2018
1 parent 935fcc5 commit 53b4716
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,23 +1486,20 @@ static bool is_split_required_for_discard(struct dm_target *ti)
}

static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
get_num_bios_fn get_num_bios,
is_split_required_fn is_split_required)
unsigned num_bios, bool is_split_required)
{
unsigned len;
unsigned num_bios;

/*
* Even though the device advertised support for this type of
* request, that does not mean every target supports it, and
* reconfiguration might also have changed that since the
* check was performed.
*/
num_bios = get_num_bios ? get_num_bios(ti) : 0;
if (!num_bios)
return -EOPNOTSUPP;

if (is_split_required && !is_split_required(ti))
if (!is_split_required)
len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
else
len = min((sector_t)ci->sector_count, max_io_len(ci->sector, ti));
Expand All @@ -1517,23 +1514,23 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *

static int __send_discard(struct clone_info *ci, struct dm_target *ti)
{
return __send_changing_extent_only(ci, ti, get_num_discard_bios,
is_split_required_for_discard);
return __send_changing_extent_only(ci, ti, get_num_discard_bios(ti),
is_split_required_for_discard(ti));
}

static int __send_secure_erase(struct clone_info *ci, struct dm_target *ti)
{
return __send_changing_extent_only(ci, ti, get_num_secure_erase_bios, NULL);
return __send_changing_extent_only(ci, ti, get_num_secure_erase_bios(ti), false);
}

static int __send_write_same(struct clone_info *ci, struct dm_target *ti)
{
return __send_changing_extent_only(ci, ti, get_num_write_same_bios, NULL);
return __send_changing_extent_only(ci, ti, get_num_write_same_bios(ti), false);
}

static int __send_write_zeroes(struct clone_info *ci, struct dm_target *ti)
{
return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios, NULL);
return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios(ti), false);
}

static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
Expand Down

0 comments on commit 53b4716

Please sign in to comment.