diff options
| -rw-r--r-- | drivers/md/dm-table.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index ba9481f1bf3c..cde3b49b2a91 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
| @@ -1844,6 +1844,36 @@ static bool dm_table_supports_secure_erase(struct dm_table *t) | |||
| 1844 | return true; | 1844 | return true; |
| 1845 | } | 1845 | } |
| 1846 | 1846 | ||
| 1847 | static int device_requires_stable_pages(struct dm_target *ti, | ||
| 1848 | struct dm_dev *dev, sector_t start, | ||
| 1849 | sector_t len, void *data) | ||
| 1850 | { | ||
| 1851 | struct request_queue *q = bdev_get_queue(dev->bdev); | ||
| 1852 | |||
| 1853 | return q && bdi_cap_stable_pages_required(q->backing_dev_info); | ||
| 1854 | } | ||
| 1855 | |||
| 1856 | /* | ||
| 1857 | * If any underlying device requires stable pages, a table must require | ||
| 1858 | * them as well. Only targets that support iterate_devices are considered: | ||
| 1859 | * don't want error, zero, etc to require stable pages. | ||
| 1860 | */ | ||
| 1861 | static bool dm_table_requires_stable_pages(struct dm_table *t) | ||
| 1862 | { | ||
| 1863 | struct dm_target *ti; | ||
| 1864 | unsigned i; | ||
| 1865 | |||
| 1866 | for (i = 0; i < dm_table_get_num_targets(t); i++) { | ||
| 1867 | ti = dm_table_get_target(t, i); | ||
| 1868 | |||
| 1869 | if (ti->type->iterate_devices && | ||
| 1870 | ti->type->iterate_devices(ti, device_requires_stable_pages, NULL)) | ||
| 1871 | return true; | ||
| 1872 | } | ||
| 1873 | |||
| 1874 | return false; | ||
| 1875 | } | ||
| 1876 | |||
| 1847 | void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, | 1877 | void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, |
| 1848 | struct queue_limits *limits) | 1878 | struct queue_limits *limits) |
| 1849 | { | 1879 | { |
| @@ -1897,6 +1927,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, | |||
| 1897 | dm_table_verify_integrity(t); | 1927 | dm_table_verify_integrity(t); |
| 1898 | 1928 | ||
| 1899 | /* | 1929 | /* |
| 1930 | * Some devices don't use blk_integrity but still want stable pages | ||
| 1931 | * because they do their own checksumming. | ||
| 1932 | */ | ||
| 1933 | if (dm_table_requires_stable_pages(t)) | ||
| 1934 | q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; | ||
| 1935 | else | ||
| 1936 | q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; | ||
| 1937 | |||
| 1938 | /* | ||
| 1900 | * Determine whether or not this queue's I/O timings contribute | 1939 | * Determine whether or not this queue's I/O timings contribute |
| 1901 | * to the entropy pool, Only request-based targets use this. | 1940 | * to the entropy pool, Only request-based targets use this. |
| 1902 | * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not | 1941 | * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not |
