Skip to content

Commit b6bcb84

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
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>
1 parent 00065f9 commit b6bcb84

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/md/dm-target.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args)
119119
* Return error for discards instead of -EOPNOTSUPP
120120
*/
121121
tt->num_discard_bios = 1;
122+
tt->discards_supported = true;
122123

123124
return 0;
124125
}
@@ -145,6 +146,13 @@ static void io_err_release_clone_rq(struct request *clone,
145146
{
146147
}
147148

149+
static void io_err_io_hints(struct dm_target *ti, struct queue_limits *limits)
150+
{
151+
limits->max_discard_sectors = UINT_MAX;
152+
limits->max_hw_discard_sectors = UINT_MAX;
153+
limits->discard_granularity = 512;
154+
}
155+
148156
static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
149157
long nr_pages, enum dax_access_mode mode, void **kaddr,
150158
pfn_t *pfn)
@@ -154,13 +162,14 @@ static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
154162

155163
static struct target_type error_target = {
156164
.name = "error",
157-
.version = {1, 5, 0},
165+
.version = {1, 6, 0},
158166
.features = DM_TARGET_WILDCARD,
159167
.ctr = io_err_ctr,
160168
.dtr = io_err_dtr,
161169
.map = io_err_map,
162170
.clone_and_map_rq = io_err_clone_and_map_rq,
163171
.release_clone_rq = io_err_release_clone_rq,
172+
.io_hints = io_err_io_hints,
164173
.direct_access = io_err_dax_direct_access,
165174
};
166175

0 commit comments

Comments
 (0)