Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[firefly-linux-kernel-4.4.55.git] / drivers / md / dm-io.c
index c09359db3a90730dbd32b3bd733709f3c6444192..37de0173b6d2324ed15de95442df37bc5a990e16 100644 (file)
@@ -290,6 +290,12 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
        unsigned short logical_block_size = queue_logical_block_size(q);
        sector_t num_sectors;
 
+       /* Reject unsupported discard requests */
+       if ((rw & REQ_DISCARD) && !blk_queue_discard(q)) {
+               dec_count(io, region, -EOPNOTSUPP);
+               return;
+       }
+
        /*
         * where->count may be zero if rw holds a flush and we need to
         * send a zero-sized flush.