@@ -1509,6 +1509,12 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
return &t->targets[(KEYS_PER_NODE * n) + k];
}
+static int device_not_poll_capable(struct dm_target *ti, struct dm_dev *dev,
+ sector_t start, sector_t len, void *data)
+{
+ return !blk_queue_poll(bdev_get_queue(dev->bdev));
+}
+
/*
* type->iterate_devices() should be called when the sanity check needs to
* iterate and check all underlying data devices. iterate_devices() will
@@ -1559,6 +1565,11 @@ static int count_device(struct dm_target *ti, struct dm_dev *dev,
return 0;
}
+int dm_table_supports_poll(struct dm_table *t)
+{
+ return !dm_table_any_dev_attr(t, device_not_poll_capable, NULL);
+}
+
/*
* Check whether a table has no data devices attached using each
* target's iterate_devices method.
@@ -2079,6 +2090,19 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
dm_update_keyslot_manager(q, t);
blk_queue_update_readahead(q);
+
+ /*
+ * Check for request-based device is remained to
+ * dm_mq_init_request_queue()->blk_mq_init_allocated_queue().
+ * For bio-based device, only set QUEUE_FLAG_POLL when all underlying
+ * devices supporting polling.
+ */
+ if (__table_type_bio_based(t->type)) {
+ if (dm_table_supports_poll(t))
+ blk_queue_flag_set(QUEUE_FLAG_POLL, q);
+ else
+ blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
+ }
}
unsigned int dm_table_get_num_targets(struct dm_table *t)
@@ -1720,6 +1720,19 @@ static blk_qc_t dm_submit_bio(struct bio *bio)
return ret;
}
+static bool dm_poll_capable(struct gendisk *disk)
+{
+ int ret, srcu_idx;
+ struct mapped_device *md = disk->private_data;
+ struct dm_table *t;
+
+ t = dm_get_live_table(md, &srcu_idx);
+ ret = dm_table_supports_poll(t);
+ dm_put_live_table(md, srcu_idx);
+
+ return ret;
+}
+
/*-----------------------------------------------------------------
* An IDR is used to keep track of allocated minor numbers.
*---------------------------------------------------------------*/
@@ -3132,6 +3145,7 @@ static const struct pr_ops dm_pr_ops = {
};
static const struct block_device_operations dm_blk_dops = {
+ .poll_capable = dm_poll_capable,
.submit_bio = dm_submit_bio,
.open = dm_blk_open,
.release = dm_blk_close,
@@ -538,6 +538,7 @@ unsigned int dm_table_get_num_targets(struct dm_table *t);
fmode_t dm_table_get_mode(struct dm_table *t);
struct mapped_device *dm_table_get_md(struct dm_table *t);
const char *dm_table_device_name(struct dm_table *t);
+int dm_table_supports_poll(struct dm_table *t);
/*
* Trigger an event.