block: Do away with the notion of hardsect_size
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / md / dm-table.c
index e8361b191b9b223baef941bfc14212dc052d127f..65e2d9759857d9b0ef06332b0412b836aee54d9c 100644 (file)
@@ -52,8 +52,6 @@ struct dm_table {
        sector_t *highs;
        struct dm_target *targets;
 
-       unsigned barriers_supported:1;
-
        /*
         * Indicates the rw permissions for the new logical
         * device.  This should be a combination of FMODE_READ
@@ -110,7 +108,8 @@ static void combine_restrictions_low(struct io_restrictions *lhs,
        lhs->max_hw_segments =
                min_not_zero(lhs->max_hw_segments, rhs->max_hw_segments);
 
-       lhs->hardsect_size = max(lhs->hardsect_size, rhs->hardsect_size);
+       lhs->logical_block_size = max(lhs->logical_block_size,
+                                     rhs->logical_block_size);
 
        lhs->max_segment_size =
                min_not_zero(lhs->max_segment_size, rhs->max_segment_size);
@@ -243,7 +242,6 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
 
        INIT_LIST_HEAD(&t->devices);
        atomic_set(&t->holders, 0);
-       t->barriers_supported = 1;
 
        if (!num_targets)
                num_targets = KEYS_PER_NODE;
@@ -532,7 +530,8 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
        rs->max_hw_segments =
                min_not_zero(rs->max_hw_segments, q->max_hw_segments);
 
-       rs->hardsect_size = max(rs->hardsect_size, q->hardsect_size);
+       rs->logical_block_size = max(rs->logical_block_size,
+                                    queue_logical_block_size(q));
 
        rs->max_segment_size =
                min_not_zero(rs->max_segment_size, q->max_segment_size);
@@ -686,8 +685,8 @@ static void check_for_valid_limits(struct io_restrictions *rs)
                rs->max_phys_segments = MAX_PHYS_SEGMENTS;
        if (!rs->max_hw_segments)
                rs->max_hw_segments = MAX_HW_SEGMENTS;
-       if (!rs->hardsect_size)
-               rs->hardsect_size = 1 << SECTOR_SHIFT;
+       if (!rs->logical_block_size)
+               rs->logical_block_size = 1 << SECTOR_SHIFT;
        if (!rs->max_segment_size)
                rs->max_segment_size = MAX_SEGMENT_SIZE;
        if (!rs->seg_boundary_mask)
@@ -751,10 +750,6 @@ int dm_table_add_target(struct dm_table *t, const char *type,
        /* FIXME: the plan is to combine high here and then have
         * the merge fn apply the target level restrictions. */
        combine_restrictions_low(&t->limits, &tgt->limits);
-
-       if (!(tgt->type->features & DM_TARGET_SUPPORTS_BARRIERS))
-               t->barriers_supported = 0;
-
        return 0;
 
  bad:
@@ -799,12 +794,6 @@ int dm_table_complete(struct dm_table *t)
 
        check_for_valid_limits(&t->limits);
 
-       /*
-        * We only support barriers if there is exactly one underlying device.
-        */
-       if (!list_is_singular(&t->devices))
-               t->barriers_supported = 0;
-
        /* how many indexes will the btree have ? */
        leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
        t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
@@ -879,6 +868,45 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
        return &t->targets[(KEYS_PER_NODE * n) + k];
 }
 
+/*
+ * Set the integrity profile for this device if all devices used have
+ * matching profiles.
+ */
+static void dm_table_set_integrity(struct dm_table *t)
+{
+       struct list_head *devices = dm_table_get_devices(t);
+       struct dm_dev_internal *prev = NULL, *dd = NULL;
+
+       if (!blk_get_integrity(dm_disk(t->md)))
+               return;
+
+       list_for_each_entry(dd, devices, list) {
+               if (prev &&
+                   blk_integrity_compare(prev->dm_dev.bdev->bd_disk,
+                                         dd->dm_dev.bdev->bd_disk) < 0) {
+                       DMWARN("%s: integrity not set: %s and %s mismatch",
+                              dm_device_name(t->md),
+                              prev->dm_dev.bdev->bd_disk->disk_name,
+                              dd->dm_dev.bdev->bd_disk->disk_name);
+                       goto no_integrity;
+               }
+               prev = dd;
+       }
+
+       if (!prev || !bdev_get_integrity(prev->dm_dev.bdev))
+               goto no_integrity;
+
+       blk_integrity_register(dm_disk(t->md),
+                              bdev_get_integrity(prev->dm_dev.bdev));
+
+       return;
+
+no_integrity:
+       blk_integrity_register(dm_disk(t->md), NULL);
+
+       return;
+}
+
 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q)
 {
        /*
@@ -888,7 +916,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q)
        blk_queue_max_sectors(q, t->limits.max_sectors);
        q->max_phys_segments = t->limits.max_phys_segments;
        q->max_hw_segments = t->limits.max_hw_segments;
-       q->hardsect_size = t->limits.hardsect_size;
+       q->logical_block_size = t->limits.logical_block_size;
        q->max_segment_size = t->limits.max_segment_size;
        q->max_hw_sectors = t->limits.max_hw_sectors;
        q->seg_boundary_mask = t->limits.seg_boundary_mask;
@@ -899,6 +927,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q)
        else
                queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q);
 
+       dm_table_set_integrity(t);
 }
 
 unsigned int dm_table_get_num_targets(struct dm_table *t)
@@ -1019,12 +1048,6 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
        return t->md;
 }
 
-int dm_table_barrier_ok(struct dm_table *t)
-{
-       return t->barriers_supported;
-}
-EXPORT_SYMBOL(dm_table_barrier_ok);
-
 EXPORT_SYMBOL(dm_vcalloc);
 EXPORT_SYMBOL(dm_get_device);
 EXPORT_SYMBOL(dm_put_device);