Commit 61697a6a authored by Mike Snitzer's avatar Mike Snitzer

dm: eliminate 'split_discard_bios' flag from DM target interface

There is no need to have DM core split discards on behalf of a DM target
now that blk_queue_split() handles splitting discards based on the
queue_limits.  A DM target just needs to set max_discard_sectors,
discard_granularity, etc, in queue_limits.
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 568c73a3
...@@ -2496,7 +2496,6 @@ static int cache_create(struct cache_args *ca, struct cache **result) ...@@ -2496,7 +2496,6 @@ static int cache_create(struct cache_args *ca, struct cache **result)
ti->num_discard_bios = 1; ti->num_discard_bios = 1;
ti->discards_supported = true; ti->discards_supported = true;
ti->split_discard_bios = false;
ti->per_io_data_size = sizeof(struct per_bio_data); ti->per_io_data_size = sizeof(struct per_bio_data);
......
...@@ -2986,11 +2986,6 @@ static void configure_discard_support(struct raid_set *rs) ...@@ -2986,11 +2986,6 @@ static void configure_discard_support(struct raid_set *rs)
} }
} }
/*
* RAID1 and RAID10 personalities require bio splitting,
* RAID0/4/5/6 don't and process large discard bios properly.
*/
ti->split_discard_bios = !!(rs_is_raid1(rs) || rs_is_raid10(rs));
ti->num_discard_bios = 1; ti->num_discard_bios = 1;
} }
...@@ -3747,6 +3742,15 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits) ...@@ -3747,6 +3742,15 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits)
blk_limits_io_min(limits, chunk_size); blk_limits_io_min(limits, chunk_size);
blk_limits_io_opt(limits, chunk_size * mddev_data_stripes(rs)); blk_limits_io_opt(limits, chunk_size * mddev_data_stripes(rs));
/*
* RAID1 and RAID10 personalities require bio splitting,
* RAID0/4/5/6 don't and process large discard bios properly.
*/
if (rs_is_raid1(rs) || rs_is_raid10(rs)) {
limits->discard_granularity = chunk_size;
limits->max_discard_sectors = chunk_size;
}
} }
static void raid_postsuspend(struct dm_target *ti) static void raid_postsuspend(struct dm_target *ti)
......
...@@ -4227,7 +4227,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -4227,7 +4227,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
if (tc->pool->pf.discard_enabled) { if (tc->pool->pf.discard_enabled) {
ti->discards_supported = true; ti->discards_supported = true;
ti->num_discard_bios = 1; ti->num_discard_bios = 1;
ti->split_discard_bios = false;
} }
mutex_unlock(&dm_thin_pool_table.mutex); mutex_unlock(&dm_thin_pool_table.mutex);
......
...@@ -727,7 +727,6 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -727,7 +727,6 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->per_io_data_size = sizeof(struct dmz_bioctx); ti->per_io_data_size = sizeof(struct dmz_bioctx);
ti->flush_supported = true; ti->flush_supported = true;
ti->discards_supported = true; ti->discards_supported = true;
ti->split_discard_bios = true;
/* The exposed capacity is the number of chunks that can be mapped */ /* The exposed capacity is the number of chunks that can be mapped */
ti->len = (sector_t)dmz_nr_chunks(dmz->metadata) << dev->zone_nr_sectors_shift; ti->len = (sector_t)dmz_nr_chunks(dmz->metadata) << dev->zone_nr_sectors_shift;
......
...@@ -1478,17 +1478,10 @@ static unsigned get_num_write_zeroes_bios(struct dm_target *ti) ...@@ -1478,17 +1478,10 @@ static unsigned get_num_write_zeroes_bios(struct dm_target *ti)
return ti->num_write_zeroes_bios; return ti->num_write_zeroes_bios;
} }
typedef bool (*is_split_required_fn)(struct dm_target *ti);
static bool is_split_required_for_discard(struct dm_target *ti)
{
return ti->split_discard_bios;
}
static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti, static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios, bool is_split_required) unsigned num_bios)
{ {
unsigned len; unsigned len = ci->sector_count;
/* /*
* Even though the device advertised support for this type of * Even though the device advertised support for this type of
...@@ -1499,11 +1492,6 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target * ...@@ -1499,11 +1492,6 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *
if (!num_bios) if (!num_bios)
return -EOPNOTSUPP; return -EOPNOTSUPP;
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));
__send_duplicate_bios(ci, ti, num_bios, &len); __send_duplicate_bios(ci, ti, num_bios, &len);
ci->sector += len; ci->sector += len;
...@@ -1514,23 +1502,22 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target * ...@@ -1514,23 +1502,22 @@ 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) static int __send_discard(struct clone_info *ci, struct dm_target *ti)
{ {
return __send_changing_extent_only(ci, ti, get_num_discard_bios(ti), 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) 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(ti), false); return __send_changing_extent_only(ci, ti, get_num_secure_erase_bios(ti));
} }
static int __send_write_same(struct clone_info *ci, struct dm_target *ti) 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(ti), false); return __send_changing_extent_only(ci, ti, get_num_write_same_bios(ti));
} }
static int __send_write_zeroes(struct clone_info *ci, struct dm_target *ti) 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(ti), false); return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios(ti));
} }
static bool is_abnormal_io(struct bio *bio) static bool is_abnormal_io(struct bio *bio)
......
...@@ -315,12 +315,6 @@ struct dm_target { ...@@ -315,12 +315,6 @@ struct dm_target {
* whether or not its underlying devices have support. * whether or not its underlying devices have support.
*/ */
bool discards_supported:1; bool discards_supported:1;
/*
* Set if the target required discard bios to be split
* on max_io_len boundary.
*/
bool split_discard_bios:1;
}; };
/* Each target can link one of these into the table */ /* Each target can link one of these into the table */
......
...@@ -270,9 +270,9 @@ enum { ...@@ -270,9 +270,9 @@ enum {
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
#define DM_VERSION_MAJOR 4 #define DM_VERSION_MAJOR 4
#define DM_VERSION_MINOR 39 #define DM_VERSION_MINOR 40
#define DM_VERSION_PATCHLEVEL 0 #define DM_VERSION_PATCHLEVEL 0
#define DM_VERSION_EXTRA "-ioctl (2018-04-03)" #define DM_VERSION_EXTRA "-ioctl (2019-01-18)"
/* Status bits */ /* Status bits */
#define DM_READONLY_FLAG (1 << 0) /* In/Out */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */
......
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