dm: introduce split_discard_requests
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 27 Jul 2012 14:08:03 +0000 (15:08 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Fri, 27 Jul 2012 14:08:03 +0000 (15:08 +0100)
This patch introduces a new variable split_discard_requests. It can be
set by targets so that discard requests are split on max_io_len
boundaries.

When split_discard_requests is not set, discard requests are only split on
boundaries between targets, as was the case before this patch.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm.c
include/linux/device-mapper.h

index 415c2803c0c9a26488cd38a5f6a68ba961393316..4e09b6ff5b493403d4e51be0b4fee2d99643e276 100644 (file)
@@ -1215,7 +1215,10 @@ static int __clone_and_map_discard(struct clone_info *ci)
                if (!ti->num_discard_requests)
                        return -EOPNOTSUPP;
 
-               len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
+               if (!ti->split_discard_requests)
+                       len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
+               else
+                       len = min(ci->sector_count, max_io_len(ci->sector, ti));
 
                __issue_target_requests(ci, ti, ti->num_discard_requests, len);
 
index b19c1e189a6841576e1f4c148bc696ae1993d862..8bdbbfce759aff0f38ad77c32c6ef20f0ae09463 100644 (file)
@@ -217,6 +217,12 @@ struct dm_target {
         */
        unsigned discards_supported:1;
 
+       /*
+        * Set if the target required discard request to be split
+        * on max_io_len boundary.
+        */
+       unsigned split_discard_requests:1;
+
        /*
         * Set if this target does not return zeroes on discarded blocks.
         */