diff options
author | Mike Snitzer <snitzer@redhat.com> | 2010-08-11 23:14:09 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2010-08-11 23:14:09 -0400 |
commit | 06a426cee9b35505aeb7516a67bd26496ca7ed08 (patch) | |
tree | 008d8d20b667b195dbe7e53a53e5003aec0a0a5f /drivers/md | |
parent | 5ae89a8720c28caf35c4e53711d77df2856c404e (diff) |
dm: use common __issue_target_request for flush and discard support
Rename __flush_target to __issue_target_request now that it is used to
issue both flush and discard requests.
Introduce __issue_target_requests as a convenient wrapper to
__issue_target_request 'num_flush_requests' or 'num_discard_requests'
times per target.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 44aba29154fc..3dd846e801fb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -1182,30 +1182,42 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, | |||
1182 | return tio; | 1182 | return tio; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | static void __flush_target(struct clone_info *ci, struct dm_target *ti, | 1185 | static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, |
1186 | unsigned request_nr) | 1186 | unsigned request_nr) |
1187 | { | 1187 | { |
1188 | struct dm_target_io *tio = alloc_tio(ci, ti); | 1188 | struct dm_target_io *tio = alloc_tio(ci, ti); |
1189 | struct bio *clone; | 1189 | struct bio *clone; |
1190 | 1190 | ||
1191 | tio->info.target_request_nr = request_nr; | 1191 | tio->info.target_request_nr = request_nr; |
1192 | 1192 | ||
1193 | clone = bio_alloc_bioset(GFP_NOIO, 0, ci->md->bs); | 1193 | /* |
1194 | * Discard requests require the bio's inline iovecs be initialized. | ||
1195 | * ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush | ||
1196 | * and discard, so no need for concern about wasted bvec allocations. | ||
1197 | */ | ||
1198 | clone = bio_alloc_bioset(GFP_NOIO, ci->bio->bi_max_vecs, ci->md->bs); | ||
1194 | __bio_clone(clone, ci->bio); | 1199 | __bio_clone(clone, ci->bio); |
1195 | clone->bi_destructor = dm_bio_destructor; | 1200 | clone->bi_destructor = dm_bio_destructor; |
1196 | 1201 | ||
1197 | __map_bio(ti, clone, tio); | 1202 | __map_bio(ti, clone, tio); |
1198 | } | 1203 | } |
1199 | 1204 | ||
1205 | static void __issue_target_requests(struct clone_info *ci, struct dm_target *ti, | ||
1206 | unsigned num_requests) | ||
1207 | { | ||
1208 | unsigned request_nr; | ||
1209 | |||
1210 | for (request_nr = 0; request_nr < num_requests; request_nr++) | ||
1211 | __issue_target_request(ci, ti, request_nr); | ||
1212 | } | ||
1213 | |||
1200 | static int __clone_and_map_empty_barrier(struct clone_info *ci) | 1214 | static int __clone_and_map_empty_barrier(struct clone_info *ci) |
1201 | { | 1215 | { |
1202 | unsigned target_nr = 0, request_nr; | 1216 | unsigned target_nr = 0; |
1203 | struct dm_target *ti; | 1217 | struct dm_target *ti; |
1204 | 1218 | ||
1205 | while ((ti = dm_table_get_target(ci->map, target_nr++))) | 1219 | while ((ti = dm_table_get_target(ci->map, target_nr++))) |
1206 | for (request_nr = 0; request_nr < ti->num_flush_requests; | 1220 | __issue_target_requests(ci, ti, ti->num_flush_requests); |
1207 | request_nr++) | ||
1208 | __flush_target(ci, ti, request_nr); | ||
1209 | 1221 | ||
1210 | ci->sector_count = 0; | 1222 | ci->sector_count = 0; |
1211 | 1223 | ||
@@ -1254,7 +1266,9 @@ static int __clone_and_map_discard(struct clone_info *ci) | |||
1254 | */ | 1266 | */ |
1255 | return -EOPNOTSUPP; | 1267 | return -EOPNOTSUPP; |
1256 | 1268 | ||
1257 | __clone_and_map_simple(ci, ti); | 1269 | __issue_target_requests(ci, ti, ti->num_discard_requests); |
1270 | |||
1271 | ci->sector_count = 0; | ||
1258 | 1272 | ||
1259 | return 0; | 1273 | return 0; |
1260 | } | 1274 | } |