Commit fe7af2d3babefabd96a39e8b0d58ede88f3c7993

Authored by Alasdair G Kergon
1 parent 0f640dca08

dm: fix write same requests counting

When processing write same requests, fix dm to send the configured
number of WRITE SAME requests to the target rather than the number of
discards, which is not always the same.

Device-mapper WRITE SAME support was introduced by commit
23508a96cd2e857d57044a2ed7d305f2d9daf441 ("dm: add WRITE SAME support").

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

... ... @@ -1188,6 +1188,7 @@
1188 1188 {
1189 1189 struct dm_target *ti;
1190 1190 sector_t len;
  1191 + unsigned num_requests;
1191 1192  
1192 1193 do {
1193 1194 ti = dm_table_find_target(ci->map, ci->sector);
... ... @@ -1200,7 +1201,8 @@
1200 1201 * reconfiguration might also have changed that since the
1201 1202 * check was performed.
1202 1203 */
1203   - if (!get_num_requests || !get_num_requests(ti))
  1204 + num_requests = get_num_requests ? get_num_requests(ti) : 0;
  1205 + if (!num_requests)
1204 1206 return -EOPNOTSUPP;
1205 1207  
1206 1208 if (is_split_required && !is_split_required(ti))
... ... @@ -1208,7 +1210,7 @@
1208 1210 else
1209 1211 len = min(ci->sector_count, max_io_len(ci->sector, ti));
1210 1212  
1211   - __issue_target_requests(ci, ti, ti->num_discard_requests, len);
  1213 + __issue_target_requests(ci, ti, num_requests, len);
1212 1214  
1213 1215 ci->sector += len;
1214 1216 } while (ci->sector_count -= len);