runner: allow handlers to override default unmap limits
If the handler has unmap limits that are different from the normal
IO limits, they can now set them in open to override the default
settings.
@@ -726,7 +726,6 @@ static int dev_added(struct tcmu_device *dev)
struct list_head group_list;
struct tcmur_device *rdev;
int32_t block_size, max_sectors;
- uint32_t max_xfer_length;
int64_t dev_size;
int ret;
@@ -757,6 +756,14 @@ static int dev_added(struct tcmu_device *dev)
goto free_rdev;
tcmu_set_dev_max_xfer_len(dev, max_sectors);
+ /*
+ * Set the optimal unmap granularity to max xfer len. Optimal unmap
+ * alignment starts at the begining of the device. Handlers can
+ * override in their open function.
+ */
+ tcmu_set_dev_opt_unmap_gran(dev, max_sectors);
+ tcmu_set_dev_unmap_gran_align(dev, 0);
+
tcmu_dev_dbg(dev, "Got block_size %d, size in bytes %"PRId64"\n",
block_size, dev_size);
@@ -801,14 +808,6 @@ static int dev_added(struct tcmu_device *dev)
if (ret < 0)
goto close_dev;
- /*
- * Set the optimal unmap granularity to max xfer len. Optimal unmap
- * alignment starts at the begining of the device.
- */
- max_xfer_length = tcmu_get_dev_max_xfer_len(dev);
- tcmu_set_dev_opt_unmap_gran(dev, max_xfer_length);
- tcmu_set_dev_unmap_gran_align(dev, 0);
-
ret = pthread_create(&rdev->cmdproc_thread, NULL, tcmur_cmdproc_thread,
dev);
if (ret < 0)
