mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 15:04:27 +08:00
dm error: add discard support
Add io_err_io_hints() and set discard limits so that the zero target advertises support for discards. The error target will return -EIO for discards. This is useful when the user combines dm-error with other discard-supporting targets in the same table; without dm-error support, discards would be disabled for the whole combined device. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Tested-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
This commit is contained in:
parent
00065f925e
commit
b6bcb84446
@ -119,6 +119,7 @@ static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args)
|
|||||||
* Return error for discards instead of -EOPNOTSUPP
|
* Return error for discards instead of -EOPNOTSUPP
|
||||||
*/
|
*/
|
||||||
tt->num_discard_bios = 1;
|
tt->num_discard_bios = 1;
|
||||||
|
tt->discards_supported = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -145,6 +146,13 @@ static void io_err_release_clone_rq(struct request *clone,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void io_err_io_hints(struct dm_target *ti, struct queue_limits *limits)
|
||||||
|
{
|
||||||
|
limits->max_discard_sectors = UINT_MAX;
|
||||||
|
limits->max_hw_discard_sectors = UINT_MAX;
|
||||||
|
limits->discard_granularity = 512;
|
||||||
|
}
|
||||||
|
|
||||||
static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
|
static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
|
||||||
long nr_pages, enum dax_access_mode mode, void **kaddr,
|
long nr_pages, enum dax_access_mode mode, void **kaddr,
|
||||||
pfn_t *pfn)
|
pfn_t *pfn)
|
||||||
@ -154,13 +162,14 @@ static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
|
|||||||
|
|
||||||
static struct target_type error_target = {
|
static struct target_type error_target = {
|
||||||
.name = "error",
|
.name = "error",
|
||||||
.version = {1, 5, 0},
|
.version = {1, 6, 0},
|
||||||
.features = DM_TARGET_WILDCARD,
|
.features = DM_TARGET_WILDCARD,
|
||||||
.ctr = io_err_ctr,
|
.ctr = io_err_ctr,
|
||||||
.dtr = io_err_dtr,
|
.dtr = io_err_dtr,
|
||||||
.map = io_err_map,
|
.map = io_err_map,
|
||||||
.clone_and_map_rq = io_err_clone_and_map_rq,
|
.clone_and_map_rq = io_err_clone_and_map_rq,
|
||||||
.release_clone_rq = io_err_release_clone_rq,
|
.release_clone_rq = io_err_release_clone_rq,
|
||||||
|
.io_hints = io_err_io_hints,
|
||||||
.direct_access = io_err_dax_direct_access,
|
.direct_access = io_err_dax_direct_access,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user