Darrick J. Wong b844fe6918 dm cache: fix writes to cache device in writethrough mode
The dm-cache writethrough strategy introduced by commit e2e74d617eadc15
("dm cache: fix race in writethrough implementation") issues a bio to
the origin device, remaps and then issues the bio to the cache device.
This more conservative in-series approach was selected to favor
correctness over performance (of the previous parallel writethrough).
However, this in-series implementation that reuses the same bio to write
both the origin and cache device didn't take into account that the block
layer's req_bio_endio() modifies a completing bio's bi_sector and
bi_size.  So the new writethrough strategy needs to preserve these bio
fields, and restore them before submission to the cache device,
otherwise nothing gets written to the cache (because bi_size is 0).

This patch adds a struct dm_bio_details field to struct per_bio_data,
and uses dm_bio_record() and dm_bio_restore() to ensure the bio is
restored before reissuing to the cache device.  Adding such a large
structure to the per_bio_data is not ideal but we can improve this
later, for now correctness is the important thing.

This problem initially went unnoticed because the dm-cache test-suite
uses a linear DM device for the dm-cache device's origin device.
Writethrough worked as expected because DM submits a *clone* of the
original bio, so the original bio which was reused for the cache was
never touched.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2013-04-05 15:36:32 +01:00
..
2013-02-22 23:31:31 -05:00
2013-03-01 22:45:51 +00:00
2013-03-01 22:45:51 +00:00
2013-03-20 17:21:25 +00:00
2012-03-28 18:41:29 +01:00
2013-03-01 22:45:51 +00:00
2012-07-30 17:25:16 -07:00
2013-03-05 17:22:08 -08:00
2013-03-20 17:21:25 +00:00
2013-03-01 22:45:47 +00:00
2013-03-01 22:45:49 +00:00
2012-12-21 20:23:38 +00:00
2012-10-22 10:44:55 +11:00
2013-03-05 17:22:08 -08:00
2012-10-11 13:08:44 +11:00
2013-03-01 22:45:52 +00:00
2013-03-23 15:49:49 -07:00