diff options
Diffstat (limited to 'drivers/md/dm.c')
| -rw-r--r-- | drivers/md/dm.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 1fb1333fefec..5475081dcbd6 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -1107,6 +1107,25 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, | |||
| 1107 | return ret; | 1107 | return ret; |
| 1108 | } | 1108 | } |
| 1109 | 1109 | ||
| 1110 | static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bdev, | ||
| 1111 | int blocksize, sector_t start, sector_t len) | ||
| 1112 | { | ||
| 1113 | struct mapped_device *md = dax_get_private(dax_dev); | ||
| 1114 | struct dm_table *map; | ||
| 1115 | int srcu_idx; | ||
| 1116 | bool ret; | ||
| 1117 | |||
| 1118 | map = dm_get_live_table(md, &srcu_idx); | ||
| 1119 | if (!map) | ||
| 1120 | return false; | ||
| 1121 | |||
| 1122 | ret = dm_table_supports_dax(map, blocksize); | ||
| 1123 | |||
| 1124 | dm_put_live_table(md, srcu_idx); | ||
| 1125 | |||
| 1126 | return ret; | ||
| 1127 | } | ||
| 1128 | |||
| 1110 | static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, | 1129 | static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, |
| 1111 | void *addr, size_t bytes, struct iov_iter *i) | 1130 | void *addr, size_t bytes, struct iov_iter *i) |
| 1112 | { | 1131 | { |
| @@ -1469,7 +1488,7 @@ static unsigned get_num_write_zeroes_bios(struct dm_target *ti) | |||
| 1469 | static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti, | 1488 | static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti, |
| 1470 | unsigned num_bios) | 1489 | unsigned num_bios) |
| 1471 | { | 1490 | { |
| 1472 | unsigned len = ci->sector_count; | 1491 | unsigned len; |
| 1473 | 1492 | ||
| 1474 | /* | 1493 | /* |
| 1475 | * Even though the device advertised support for this type of | 1494 | * Even though the device advertised support for this type of |
| @@ -1480,6 +1499,8 @@ static int __send_changing_extent_only(struct clone_info *ci, struct dm_target * | |||
| 1480 | if (!num_bios) | 1499 | if (!num_bios) |
| 1481 | return -EOPNOTSUPP; | 1500 | return -EOPNOTSUPP; |
| 1482 | 1501 | ||
| 1502 | len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti)); | ||
| 1503 | |||
| 1483 | __send_duplicate_bios(ci, ti, num_bios, &len); | 1504 | __send_duplicate_bios(ci, ti, num_bios, &len); |
| 1484 | 1505 | ||
| 1485 | ci->sector += len; | 1506 | ci->sector += len; |
| @@ -3192,6 +3213,7 @@ static const struct block_device_operations dm_blk_dops = { | |||
| 3192 | 3213 | ||
| 3193 | static const struct dax_operations dm_dax_ops = { | 3214 | static const struct dax_operations dm_dax_ops = { |
| 3194 | .direct_access = dm_dax_direct_access, | 3215 | .direct_access = dm_dax_direct_access, |
| 3216 | .dax_supported = dm_dax_supported, | ||
| 3195 | .copy_from_iter = dm_dax_copy_from_iter, | 3217 | .copy_from_iter = dm_dax_copy_from_iter, |
| 3196 | .copy_to_iter = dm_dax_copy_to_iter, | 3218 | .copy_to_iter = dm_dax_copy_to_iter, |
| 3197 | }; | 3219 | }; |
