hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/md/dm-bow.c
....@@ -599,6 +599,7 @@
599599 struct bow_context *bc = (struct bow_context *) ti->private;
600600 struct kobject *kobj;
601601
602
+ mutex_lock(&bc->ranges_lock);
602603 while (rb_first(&bc->ranges)) {
603604 struct bow_range *br = container_of(rb_first(&bc->ranges),
604605 struct bow_range, node);
....@@ -606,6 +607,8 @@
606607 rb_erase(&br->node, &bc->ranges);
607608 kfree(br);
608609 }
610
+ mutex_unlock(&bc->ranges_lock);
611
+
609612 if (bc->workqueue)
610613 destroy_workqueue(bc->workqueue);
611614 if (bc->bufio)
....@@ -627,7 +630,7 @@
627630 const unsigned int block_size = bc->block_size;
628631
629632 limits->logical_block_size =
630
- max_t(unsigned short, limits->logical_block_size, block_size);
633
+ max_t(unsigned int, limits->logical_block_size, block_size);
631634 limits->physical_block_size =
632635 max_t(unsigned int, limits->physical_block_size, block_size);
633636 limits->io_min = max_t(unsigned int, limits->io_min, block_size);
....@@ -643,8 +646,7 @@
643646 }
644647 }
645648
646
-static int dm_bow_ctr_optional(struct dm_target *ti, unsigned int argc,
647
- char **argv)
649
+static int dm_bow_ctr_optional(struct dm_target *ti, unsigned int argc, char **argv)
648650 {
649651 struct bow_context *bc = ti->private;
650652 struct dm_arg_set as;
....@@ -717,7 +719,8 @@
717719 goto bad;
718720 }
719721
720
- bc->block_size = bc->dev->bdev->bd_queue->limits.logical_block_size;
722
+ bc->block_size =
723
+ bdev_get_queue(bc->dev->bdev)->limits.logical_block_size;
721724 if (argc > 1) {
722725 ret = dm_bow_ctr_optional(ti, argc - 1, &argv[1]);
723726 if (ret)
....@@ -788,7 +791,6 @@
788791 rb_insert_color(&br->node, &bc->ranges);
789792
790793 ti->discards_supported = true;
791
- ti->may_passthrough_inline_crypto = true;
792794
793795 return 0;
794796
....@@ -1182,6 +1184,7 @@
11821184 return;
11831185 }
11841186
1187
+ mutex_lock(&bc->ranges_lock);
11851188 for (i = rb_first(&bc->ranges); i; i = rb_next(i)) {
11861189 struct bow_range *br = container_of(i, struct bow_range, node);
11871190
....@@ -1189,11 +1192,11 @@
11891192 readable_type[br->type],
11901193 (unsigned long long)br->sector);
11911194 if (result >= end)
1192
- return;
1195
+ goto unlock;
11931196
11941197 result += scnprintf(result, end - result, "\n");
11951198 if (result >= end)
1196
- return;
1199
+ goto unlock;
11971200
11981201 if (br->type == TRIMMED)
11991202 ++trimmed_range_count;
....@@ -1215,19 +1218,22 @@
12151218 if (!rb_next(i)) {
12161219 scnprintf(result, end - result,
12171220 "\nERROR: Last range not of type TOP");
1218
- return;
1221
+ goto unlock;
12191222 }
12201223
12211224 if (br->sector > range_top(br)) {
12221225 scnprintf(result, end - result,
12231226 "\nERROR: sectors out of order");
1224
- return;
1227
+ goto unlock;
12251228 }
12261229 }
12271230
12281231 if (trimmed_range_count != trimmed_list_length)
12291232 scnprintf(result, end - result,
12301233 "\nERROR: not all trimmed ranges in trimmed list");
1234
+
1235
+unlock:
1236
+ mutex_unlock(&bc->ranges_lock);
12311237 }
12321238
12331239 static void dm_bow_status(struct dm_target *ti, status_type_t type,
....@@ -1267,6 +1273,7 @@
12671273 static struct target_type bow_target = {
12681274 .name = "bow",
12691275 .version = {1, 2, 0},
1276
+ .features = DM_TARGET_PASSES_CRYPTO,
12701277 .module = THIS_MODULE,
12711278 .ctr = dm_bow_ctr,
12721279 .dtr = dm_bow_dtr,