hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/md/dm-linear.c
....@@ -62,7 +62,6 @@
6262 ti->num_secure_erase_bios = 1;
6363 ti->num_write_same_bios = 1;
6464 ti->num_write_zeroes_bios = 1;
65
- ti->may_passthrough_inline_crypto = true;
6665 ti->private = lc;
6766 return 0;
6867
....@@ -91,7 +90,7 @@
9190 struct linear_c *lc = ti->private;
9291
9392 bio_set_dev(bio, lc->dev->bdev);
94
- if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET)
93
+ if (bio_sectors(bio) || op_is_zone_mgmt(bio_op(bio)))
9594 bio->bi_iter.bi_sector =
9695 linear_map_sector(ti, bio->bi_iter.bi_sector);
9796 }
....@@ -102,19 +101,6 @@
102101
103102 return DM_MAPIO_REMAPPED;
104103 }
105
-
106
-#ifdef CONFIG_BLK_DEV_ZONED
107
-static int linear_end_io(struct dm_target *ti, struct bio *bio,
108
- blk_status_t *error)
109
-{
110
- struct linear_c *lc = ti->private;
111
-
112
- if (!*error && bio_op(bio) == REQ_OP_ZONE_REPORT)
113
- dm_remap_zone_report(ti, bio, lc->start);
114
-
115
- return DM_ENDIO_DONE;
116
-}
117
-#endif
118104
119105 static void linear_status(struct dm_target *ti, status_type_t type,
120106 unsigned status_flags, char *result, unsigned maxlen)
....@@ -148,6 +134,19 @@
148134 return 1;
149135 return 0;
150136 }
137
+
138
+#ifdef CONFIG_BLK_DEV_ZONED
139
+static int linear_report_zones(struct dm_target *ti,
140
+ struct dm_report_zones_args *args, unsigned int nr_zones)
141
+{
142
+ struct linear_c *lc = ti->private;
143
+ sector_t sector = linear_map_sector(ti, args->next_sector);
144
+
145
+ args->start = lc->start;
146
+ return blkdev_report_zones(lc->dev->bdev, sector, nr_zones,
147
+ dm_report_zones_cb, args);
148
+}
149
+#endif
151150
152151 static int linear_iterate_devices(struct dm_target *ti,
153152 iterate_devices_callout_fn fn, void *data)
....@@ -202,20 +201,39 @@
202201 return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i);
203202 }
204203
204
+static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
205
+ size_t nr_pages)
206
+{
207
+ int ret;
208
+ struct linear_c *lc = ti->private;
209
+ struct block_device *bdev = lc->dev->bdev;
210
+ struct dax_device *dax_dev = lc->dev->dax_dev;
211
+ sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
212
+
213
+ dev_sector = linear_map_sector(ti, sector);
214
+ ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages << PAGE_SHIFT, &pgoff);
215
+ if (ret)
216
+ return ret;
217
+ return dax_zero_page_range(dax_dev, pgoff, nr_pages);
218
+}
219
+
205220 #else
206221 #define linear_dax_direct_access NULL
207222 #define linear_dax_copy_from_iter NULL
208223 #define linear_dax_copy_to_iter NULL
224
+#define linear_dax_zero_page_range NULL
209225 #endif
210226
211227 static struct target_type linear_target = {
212228 .name = "linear",
213229 .version = {1, 4, 0},
214230 #ifdef CONFIG_BLK_DEV_ZONED
215
- .end_io = linear_end_io,
216
- .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_ZONED_HM,
231
+ .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_NOWAIT |
232
+ DM_TARGET_ZONED_HM | DM_TARGET_PASSES_CRYPTO,
233
+ .report_zones = linear_report_zones,
217234 #else
218
- .features = DM_TARGET_PASSES_INTEGRITY,
235
+ .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_NOWAIT |
236
+ DM_TARGET_PASSES_CRYPTO,
219237 #endif
220238 .module = THIS_MODULE,
221239 .ctr = linear_ctr,
....@@ -227,6 +245,7 @@
227245 .direct_access = linear_dax_direct_access,
228246 .dax_copy_from_iter = linear_dax_copy_from_iter,
229247 .dax_copy_to_iter = linear_dax_copy_to_iter,
248
+ .dax_zero_page_range = linear_dax_zero_page_range,
230249 };
231250
232251 int __init dm_linear_init(void)