Skip to content

Commit eb40c0a

Browse files
idryomovsnitm
authored andcommitted
dm table: propagate BDI_CAP_STABLE_WRITES to fix sporadic checksum errors
Some devices don't use blk_integrity but still want stable pages because they do their own checksumming. Examples include rbd and iSCSI when data digests are negotiated. Stacking DM (and thus LVM) on top of these devices results in sporadic checksum errors. Set BDI_CAP_STABLE_WRITES if any underlying device has it set. Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 75ae193 commit eb40c0a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

drivers/md/dm-table.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,36 @@ static bool dm_table_supports_secure_erase(struct dm_table *t)
18441844
return true;
18451845
}
18461846

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+
18471877
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18481878
struct queue_limits *limits)
18491879
{
@@ -1896,6 +1926,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18961926

18971927
dm_table_verify_integrity(t);
18981928

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+
18991938
/*
19001939
* Determine whether or not this queue's I/O timings contribute
19011940
* to the entropy pool, Only request-based targets use this.

0 commit comments

Comments
 (0)