hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/include/linux/device-mapper.h
....@@ -10,12 +10,15 @@
1010
1111 #include <linux/bio.h>
1212 #include <linux/blkdev.h>
13
+#include <linux/dm-ioctl.h>
1314 #include <linux/math64.h>
1415 #include <linux/ratelimit.h>
16
+#include <linux/android_kabi.h>
1517
1618 struct dm_dev;
1719 struct dm_target;
1820 struct dm_table;
21
+struct dm_report_zones_args;
1922 struct mapped_device;
2023 struct bio_vec;
2124
....@@ -26,9 +29,7 @@
2629 DM_TYPE_NONE = 0,
2730 DM_TYPE_BIO_BASED = 1,
2831 DM_TYPE_REQUEST_BASED = 2,
29
- DM_TYPE_MQ_REQUEST_BASED = 3,
30
- DM_TYPE_DAX_BIO_BASED = 4,
31
- DM_TYPE_NVME_BIO_BASED = 5,
32
+ DM_TYPE_DAX_BIO_BASED = 3,
3233 };
3334
3435 typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
....@@ -93,6 +94,10 @@
9394
9495 typedef int (*dm_prepare_ioctl_fn) (struct dm_target *ti, struct block_device **bdev);
9596
97
+typedef int (*dm_report_zones_fn) (struct dm_target *ti,
98
+ struct dm_report_zones_args *args,
99
+ unsigned int nr_zones);
100
+
96101 /*
97102 * These iteration functions are typically used to check (and combine)
98103 * properties of underlying devices.
....@@ -136,6 +141,8 @@
136141 long nr_pages, void **kaddr, pfn_t *pfn);
137142 typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff,
138143 void *addr, size_t bytes, struct iov_iter *i);
144
+typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff,
145
+ size_t nr_pages);
139146 #define PAGE_SECTORS (PAGE_SIZE / 512)
140147
141148 void dm_error(const char *message);
....@@ -181,12 +188,19 @@
181188 dm_status_fn status;
182189 dm_message_fn message;
183190 dm_prepare_ioctl_fn prepare_ioctl;
191
+#ifdef CONFIG_BLK_DEV_ZONED
192
+ dm_report_zones_fn report_zones;
193
+#endif
184194 dm_busy_fn busy;
185195 dm_iterate_devices_fn iterate_devices;
186196 dm_io_hints_fn io_hints;
187197 dm_dax_direct_access_fn direct_access;
188198 dm_dax_copy_iter_fn dax_copy_from_iter;
189199 dm_dax_copy_iter_fn dax_copy_to_iter;
200
+ dm_dax_zero_page_range_fn dax_zero_page_range;
201
+
202
+ ANDROID_KABI_RESERVE(1);
203
+ ANDROID_KABI_RESERVE(2);
190204
191205 /* For internal device-mapper use. */
192206 struct list_head list;
....@@ -236,10 +250,35 @@
236250 #define dm_target_passes_integrity(type) ((type)->features & DM_TARGET_PASSES_INTEGRITY)
237251
238252 /*
239
- * Indicates that a target supports host-managed zoned block devices.
253
+ * Indicates support for zoned block devices:
254
+ * - DM_TARGET_ZONED_HM: the target also supports host-managed zoned
255
+ * block devices but does not support combining different zoned models.
256
+ * - DM_TARGET_MIXED_ZONED_MODEL: the target supports combining multiple
257
+ * devices with different zoned models.
240258 */
241259 #define DM_TARGET_ZONED_HM 0x00000040
242260 #define dm_target_supports_zoned_hm(type) ((type)->features & DM_TARGET_ZONED_HM)
261
+
262
+/*
263
+ * A target handles REQ_NOWAIT
264
+ */
265
+#define DM_TARGET_NOWAIT 0x00000080
266
+#define dm_target_supports_nowait(type) ((type)->features & DM_TARGET_NOWAIT)
267
+
268
+/*
269
+ * A target supports passing through inline crypto support.
270
+ */
271
+#define DM_TARGET_PASSES_CRYPTO 0x00000100
272
+#define dm_target_passes_crypto(type) ((type)->features & DM_TARGET_PASSES_CRYPTO)
273
+
274
+#ifdef CONFIG_BLK_DEV_ZONED
275
+#define DM_TARGET_MIXED_ZONED_MODEL 0x00000200
276
+#define dm_target_supports_mixed_zoned_model(type) \
277
+ ((type)->features & DM_TARGET_MIXED_ZONED_MODEL)
278
+#else
279
+#define DM_TARGET_MIXED_ZONED_MODEL 0x00000000
280
+#define dm_target_supports_mixed_zoned_model(type) (false)
281
+#endif
243282
244283 struct dm_target {
245284 struct dm_table *table;
....@@ -311,27 +350,19 @@
311350 bool discards_supported:1;
312351
313352 /*
314
- * Set if the target required discard bios to be split
315
- * on max_io_len boundary.
353
+ * Set if we need to limit the number of in-flight bios when swapping.
316354 */
317
- bool split_discard_bios:1;
355
+ bool limit_swap_bios:1;
318356
319
- /*
320
- * Set if inline crypto capabilities from this target's underlying
321
- * device(s) can be exposed via the device-mapper device.
322
- */
323
- bool may_passthrough_inline_crypto:1;
324
-};
325
-
326
-/* Each target can link one of these into the table */
327
-struct dm_target_callbacks {
328
- struct list_head list;
329
- int (*congested_fn) (struct dm_target_callbacks *, int);
357
+ ANDROID_KABI_RESERVE(1);
358
+ ANDROID_KABI_RESERVE(2);
330359 };
331360
332361 void *dm_per_bio_data(struct bio *bio, size_t data_size);
333362 struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size);
334363 unsigned dm_bio_get_target_bio_nr(const struct bio *bio);
364
+
365
+u64 dm_start_time_ns_from_clone(struct bio *bio);
335366
336367 int dm_register_target(struct target_type *t);
337368 void dm_unregister_target(struct target_type *t);
....@@ -428,9 +459,30 @@
428459 int dm_post_suspending(struct dm_target *ti);
429460 int dm_noflush_suspending(struct dm_target *ti);
430461 void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors);
431
-void dm_remap_zone_report(struct dm_target *ti, struct bio *bio,
432
- sector_t start);
433462 union map_info *dm_get_rq_mapinfo(struct request *rq);
463
+
464
+#ifdef CONFIG_BLK_DEV_ZONED
465
+struct dm_report_zones_args {
466
+ struct dm_target *tgt;
467
+ sector_t next_sector;
468
+
469
+ void *orig_data;
470
+ report_zones_cb orig_cb;
471
+ unsigned int zone_idx;
472
+
473
+ /* must be filled by ->report_zones before calling dm_report_zones_cb */
474
+ sector_t start;
475
+};
476
+int dm_report_zones_cb(struct blk_zone *zone, unsigned int idx, void *data);
477
+#endif /* CONFIG_BLK_DEV_ZONED */
478
+
479
+/*
480
+ * Device mapper functions to parse and create devices specified by the
481
+ * parameter "dm-mod.create="
482
+ */
483
+int __init dm_early_create(struct dm_ioctl *dmi,
484
+ struct dm_target_spec **spec_array,
485
+ char **target_params_array);
434486
435487 struct queue_limits *dm_get_queue_limits(struct mapped_device *md);
436488
....@@ -455,11 +507,6 @@
455507 */
456508 int dm_table_add_target(struct dm_table *t, const char *type,
457509 sector_t start, sector_t len, char *params);
458
-
459
-/*
460
- * Target_ctr should call this if it needs to add any callbacks.
461
- */
462
-void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callbacks *cb);
463510
464511 /*
465512 * Target can use this to set the table's type.
....@@ -498,6 +545,7 @@
498545 unsigned int dm_table_get_num_targets(struct dm_table *t);
499546 fmode_t dm_table_get_mode(struct dm_table *t);
500547 struct mapped_device *dm_table_get_md(struct dm_table *t);
548
+const char *dm_table_device_name(struct dm_table *t);
501549
502550 /*
503551 * Trigger an event.
....@@ -517,6 +565,11 @@
517565 struct dm_table *t);
518566
519567 /*
568
+ * Table keyslot manager functions
569
+ */
570
+void dm_destroy_keyslot_manager(struct blk_keyslot_manager *ksm);
571
+
572
+/*
520573 * A wrapper around vmalloc.
521574 */
522575 void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
....@@ -526,33 +579,19 @@
526579 *---------------------------------------------------------------*/
527580 #define DM_NAME "device-mapper"
528581
529
-#define DM_RATELIMIT(pr_func, fmt, ...) \
530
-do { \
531
- static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, \
532
- DEFAULT_RATELIMIT_BURST); \
533
- \
534
- if (__ratelimit(&rs)) \
535
- pr_func(DM_FMT(fmt), ##__VA_ARGS__); \
536
-} while (0)
537
-
538582 #define DM_FMT(fmt) DM_NAME ": " DM_MSG_PREFIX ": " fmt "\n"
539583
540584 #define DMCRIT(fmt, ...) pr_crit(DM_FMT(fmt), ##__VA_ARGS__)
541585
542586 #define DMERR(fmt, ...) pr_err(DM_FMT(fmt), ##__VA_ARGS__)
543
-#define DMERR_LIMIT(fmt, ...) DM_RATELIMIT(pr_err, fmt, ##__VA_ARGS__)
587
+#define DMERR_LIMIT(fmt, ...) pr_err_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
544588 #define DMWARN(fmt, ...) pr_warn(DM_FMT(fmt), ##__VA_ARGS__)
545
-#define DMWARN_LIMIT(fmt, ...) DM_RATELIMIT(pr_warn, fmt, ##__VA_ARGS__)
589
+#define DMWARN_LIMIT(fmt, ...) pr_warn_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
546590 #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
547
-#define DMINFO_LIMIT(fmt, ...) DM_RATELIMIT(pr_info, fmt, ##__VA_ARGS__)
591
+#define DMINFO_LIMIT(fmt, ...) pr_info_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
548592
549
-#ifdef CONFIG_DM_DEBUG
550
-#define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
551
-#define DMDEBUG_LIMIT(fmt, ...) DM_RATELIMIT(pr_debug, fmt, ##__VA_ARGS__)
552
-#else
553
-#define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
554
-#define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
555
-#endif
593
+#define DMDEBUG(fmt, ...) pr_debug(DM_FMT(fmt), ##__VA_ARGS__)
594
+#define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
556595
557596 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
558597 0 : scnprintf(result + sz, maxlen - sz, x))
....@@ -599,9 +638,6 @@
599638 * ceiling(n / size) * size
600639 */
601640 #define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
602
-
603
-#define dm_array_too_big(fixed, obj, num) \
604
- ((num) > (UINT_MAX - (fixed)) / (obj))
605641
606642 /*
607643 * Sector offset taken relative to the start of the target instead of