dm io: discards don't take a payload
authorChristoph Hellwig <hch@lst.de>
Wed, 5 Apr 2017 17:21:04 +0000 (19:21 +0200)
committerJens Axboe <axboe@fb.com>
Sat, 8 Apr 2017 17:25:38 +0000 (11:25 -0600)
Fix up do_region to not allocate a bio_vec for discards.  We've
got rid of the discard payload allocated by the caller years ago.

Obviously this wasn't actually harmful given how long it's been
there, but it's still good to avoid the pointless allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/md/dm-io.c

index 03940bf36f6ccf79b52ec5552cb636d69274b42d..b808cbe22678b121ed2f12e3bdd7068f3b8cb27b 100644 (file)
@@ -328,11 +328,17 @@ static void do_region(int op, int op_flags, unsigned region,
                /*
                 * Allocate a suitably sized-bio.
                 */
-               if ((op == REQ_OP_DISCARD) || (op == REQ_OP_WRITE_SAME))
+               switch (op) {
+               case REQ_OP_DISCARD:
+                       num_bvecs = 0;
+                       break;
+               case REQ_OP_WRITE_SAME:
                        num_bvecs = 1;
-               else
+                       break;
+               default:
                        num_bvecs = min_t(int, BIO_MAX_PAGES,
                                          dm_sector_div_up(remaining, (PAGE_SIZE >> SECTOR_SHIFT)));
+               }
 
                bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
                bio->bi_iter.bi_sector = where->sector + (where->count - remaining);