2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* Internal header file for device mapper
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2001, 2002 Sistina Software
|
2006-06-26 00:27:32 -07:00
|
|
|
* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
|
* This file is released under the LGPL.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DM_INTERNAL_H
|
|
|
|
|
#define DM_INTERNAL_H
|
|
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
|
#include <linux/device-mapper.h>
|
|
|
|
|
#include <linux/list.h>
|
2016-05-12 16:28:10 -04:00
|
|
|
#include <linux/moduleparam.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/blkdev.h>
|
2015-05-22 17:13:32 -04:00
|
|
|
#include <linux/backing-dev.h>
|
2006-03-27 01:17:54 -08:00
|
|
|
#include <linux/hdreg.h>
|
2014-01-06 23:01:22 -05:00
|
|
|
#include <linux/completion.h>
|
2014-01-13 19:37:54 -05:00
|
|
|
#include <linux/kobject.h>
|
2017-10-20 10:37:38 +03:00
|
|
|
#include <linux/refcount.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-08-16 10:54:23 -04:00
|
|
|
#include "dm-stats.h"
|
|
|
|
|
|
2006-12-08 02:41:04 -08:00
|
|
|
/*
|
|
|
|
|
* Suspend feature flags
|
|
|
|
|
*/
|
|
|
|
|
#define DM_SUSPEND_LOCKFS_FLAG (1 << 0)
|
2006-12-08 02:41:07 -08:00
|
|
|
#define DM_SUSPEND_NOFLUSH_FLAG (1 << 1)
|
2006-12-08 02:41:04 -08:00
|
|
|
|
2012-07-27 15:08:16 +01:00
|
|
|
/*
|
|
|
|
|
* Status feature flags
|
|
|
|
|
*/
|
|
|
|
|
#define DM_STATUS_NOFLUSH_FLAG (1 << 0)
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* List of devices that a metadevice uses and should open/close.
|
|
|
|
|
*/
|
2008-10-10 13:37:09 +01:00
|
|
|
struct dm_dev_internal {
|
2005-04-16 15:20:36 -07:00
|
|
|
struct list_head list;
|
2017-10-20 10:37:38 +03:00
|
|
|
refcount_t count;
|
2014-08-13 13:53:43 -05:00
|
|
|
struct dm_dev *dm_dev;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct dm_table;
|
2009-06-22 10:12:36 +01:00
|
|
|
struct dm_md_mempools;
|
2021-05-26 06:25:00 +09:00
|
|
|
struct dm_target_io;
|
|
|
|
|
struct dm_io;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
2006-06-26 00:27:33 -07:00
|
|
|
* Internal table functions.
|
2005-04-16 15:20:36 -07:00
|
|
|
*---------------------------------------------------------------*/
|
|
|
|
|
void dm_table_event_callback(struct dm_table *t,
|
|
|
|
|
void (*fn)(void *), void *context);
|
|
|
|
|
struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index);
|
|
|
|
|
struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector);
|
2012-09-26 23:45:45 +01:00
|
|
|
bool dm_table_has_no_data_devices(struct dm_table *table);
|
2009-06-22 10:12:34 +01:00
|
|
|
int dm_calculate_queue_limits(struct dm_table *table,
|
|
|
|
|
struct queue_limits *limits);
|
2021-05-26 06:25:00 +09:00
|
|
|
int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
|
|
|
|
|
struct queue_limits *limits);
|
2005-04-16 15:20:36 -07:00
|
|
|
struct list_head *dm_table_get_devices(struct dm_table *t);
|
|
|
|
|
void dm_table_presuspend_targets(struct dm_table *t);
|
2014-10-28 20:13:31 -04:00
|
|
|
void dm_table_presuspend_undo_targets(struct dm_table *t);
|
2005-04-16 15:20:36 -07:00
|
|
|
void dm_table_postsuspend_targets(struct dm_table *t);
|
2006-10-03 01:15:36 -07:00
|
|
|
int dm_table_resume_targets(struct dm_table *t);
|
2017-04-27 10:11:23 -07:00
|
|
|
enum dm_queue_mode dm_table_get_type(struct dm_table *t);
|
2011-10-31 20:19:04 +00:00
|
|
|
struct target_type *dm_table_get_immutable_target_type(struct dm_table *t);
|
2016-01-31 17:22:27 -05:00
|
|
|
struct dm_target *dm_table_get_immutable_target(struct dm_table *t);
|
2016-02-06 18:38:46 -05:00
|
|
|
struct dm_target *dm_table_get_wildcard_target(struct dm_table *t);
|
2016-06-22 17:54:53 -06:00
|
|
|
bool dm_table_bio_based(struct dm_table *t);
|
2009-06-22 10:12:36 +01:00
|
|
|
bool dm_table_request_based(struct dm_table *t);
|
|
|
|
|
void dm_table_free_md_mempools(struct dm_table *t);
|
|
|
|
|
struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);
|
2019-07-05 19:33:25 +05:30
|
|
|
bool dm_table_supports_dax(struct dm_table *t, iterate_devices_callout_fn fn,
|
|
|
|
|
int *blocksize);
|
2021-02-08 22:34:36 -05:00
|
|
|
int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev,
|
2019-07-05 19:33:25 +05:30
|
|
|
sector_t start, sector_t len, void *data);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-08-12 04:14:01 +01:00
|
|
|
void dm_lock_md_type(struct mapped_device *md);
|
|
|
|
|
void dm_unlock_md_type(struct mapped_device *md);
|
2017-04-27 10:11:23 -07:00
|
|
|
void dm_set_md_type(struct mapped_device *md, enum dm_queue_mode type);
|
|
|
|
|
enum dm_queue_mode dm_get_md_type(struct mapped_device *md);
|
2011-10-31 20:19:04 +00:00
|
|
|
struct target_type *dm_get_immutable_target_type(struct mapped_device *md);
|
2010-08-12 04:14:01 +01:00
|
|
|
|
2016-01-31 12:05:42 -05:00
|
|
|
int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t);
|
2010-08-12 04:14:02 +01:00
|
|
|
|
2013-08-22 18:21:38 -04:00
|
|
|
/*
|
|
|
|
|
* To check whether the target type is bio-based or not (request-based).
|
|
|
|
|
*/
|
|
|
|
|
#define dm_target_bio_based(t) ((t)->type->map != NULL)
|
|
|
|
|
|
2009-06-22 10:12:36 +01:00
|
|
|
/*
|
|
|
|
|
* To check whether the target type is request-based or not (bio-based).
|
|
|
|
|
*/
|
2017-01-22 18:32:46 +01:00
|
|
|
#define dm_target_request_based(t) ((t)->type->clone_and_map_rq != NULL)
|
2009-06-22 10:12:36 +01:00
|
|
|
|
2013-08-22 18:21:38 -04:00
|
|
|
/*
|
|
|
|
|
* To check whether the target type is a hybrid (capable of being
|
|
|
|
|
* either request-based or bio-based).
|
|
|
|
|
*/
|
|
|
|
|
#define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t))
|
|
|
|
|
|
2021-05-26 06:24:56 +09:00
|
|
|
/*
|
|
|
|
|
* Zoned targets related functions.
|
|
|
|
|
*/
|
2021-05-26 06:25:00 +09:00
|
|
|
int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q);
|
|
|
|
|
void dm_zone_endio(struct dm_io *io, struct bio *clone);
|
2021-05-26 06:24:56 +09:00
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
2021-05-26 06:25:00 +09:00
|
|
|
void dm_cleanup_zoned_dev(struct mapped_device *md);
|
2021-05-26 06:24:56 +09:00
|
|
|
int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
|
|
|
|
|
unsigned int nr_zones, report_zones_cb cb, void *data);
|
2021-05-26 06:24:58 +09:00
|
|
|
bool dm_is_zone_write(struct mapped_device *md, struct bio *bio);
|
2021-05-26 06:25:00 +09:00
|
|
|
int dm_zone_map_bio(struct dm_target_io *io);
|
2021-05-26 06:24:56 +09:00
|
|
|
#else
|
2021-05-26 06:25:00 +09:00
|
|
|
static inline void dm_cleanup_zoned_dev(struct mapped_device *md) {}
|
2021-05-26 06:24:56 +09:00
|
|
|
#define dm_blk_report_zones NULL
|
2021-05-26 06:24:58 +09:00
|
|
|
static inline bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-05-26 06:25:00 +09:00
|
|
|
static inline int dm_zone_map_bio(struct dm_target_io *tio)
|
|
|
|
|
{
|
|
|
|
|
return DM_MAPIO_KILL;
|
|
|
|
|
}
|
2021-05-26 06:24:56 +09:00
|
|
|
#endif
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
|
* A registry of target types.
|
|
|
|
|
*---------------------------------------------------------------*/
|
|
|
|
|
int dm_target_init(void);
|
|
|
|
|
void dm_target_exit(void);
|
|
|
|
|
struct target_type *dm_get_target_type(const char *name);
|
2009-04-02 19:55:28 +01:00
|
|
|
void dm_put_target_type(struct target_type *tt);
|
2005-04-16 15:20:36 -07:00
|
|
|
int dm_target_iterate(void (*iter_func)(struct target_type *tt,
|
|
|
|
|
void *param), void *param);
|
|
|
|
|
|
|
|
|
|
int dm_split_args(int *argc, char ***argvp, char *input);
|
|
|
|
|
|
2009-12-10 23:52:20 +00:00
|
|
|
/*
|
|
|
|
|
* Is this mapped_device being deleted?
|
|
|
|
|
*/
|
|
|
|
|
int dm_deleting_md(struct mapped_device *md);
|
|
|
|
|
|
2009-12-10 23:52:26 +00:00
|
|
|
/*
|
|
|
|
|
* Is this mapped_device suspended?
|
|
|
|
|
*/
|
|
|
|
|
int dm_suspended_md(struct mapped_device *md);
|
|
|
|
|
|
2014-10-28 18:34:52 -04:00
|
|
|
/*
|
|
|
|
|
* Internal suspend and resume methods.
|
|
|
|
|
*/
|
|
|
|
|
int dm_suspended_internally_md(struct mapped_device *md);
|
|
|
|
|
void dm_internal_suspend_fast(struct mapped_device *md);
|
|
|
|
|
void dm_internal_resume_fast(struct mapped_device *md);
|
|
|
|
|
void dm_internal_suspend_noflush(struct mapped_device *md);
|
|
|
|
|
void dm_internal_resume(struct mapped_device *md);
|
|
|
|
|
|
2013-11-01 18:27:41 -04:00
|
|
|
/*
|
|
|
|
|
* Test if the device is scheduled for deferred remove.
|
|
|
|
|
*/
|
|
|
|
|
int dm_test_deferred_remove_flag(struct mapped_device *md);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Try to remove devices marked for deferred removal.
|
|
|
|
|
*/
|
|
|
|
|
void dm_deferred_remove(void);
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* The device-mapper can be driven through one of two interfaces;
|
|
|
|
|
* ioctl or filesystem, depending which patch you have applied.
|
|
|
|
|
*/
|
|
|
|
|
int dm_interface_init(void);
|
|
|
|
|
void dm_interface_exit(void);
|
|
|
|
|
|
2009-01-06 03:05:12 +00:00
|
|
|
/*
|
|
|
|
|
* sysfs interface
|
|
|
|
|
*/
|
|
|
|
|
int dm_sysfs_init(struct mapped_device *md);
|
|
|
|
|
void dm_sysfs_exit(struct mapped_device *md);
|
|
|
|
|
struct kobject *dm_kobject(struct mapped_device *md);
|
|
|
|
|
struct mapped_device *dm_get_from_kobject(struct kobject *kobj);
|
2014-01-13 19:37:54 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The kobject helper
|
|
|
|
|
*/
|
|
|
|
|
void dm_kobject_release(struct kobject *kobj);
|
2009-01-06 03:05:12 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* Targets for linear and striped mappings
|
|
|
|
|
*/
|
|
|
|
|
int dm_linear_init(void);
|
|
|
|
|
void dm_linear_exit(void);
|
|
|
|
|
|
|
|
|
|
int dm_stripe_init(void);
|
|
|
|
|
void dm_stripe_exit(void);
|
|
|
|
|
|
2010-08-12 04:13:56 +01:00
|
|
|
/*
|
|
|
|
|
* mapped_device operations
|
|
|
|
|
*/
|
|
|
|
|
void dm_destroy(struct mapped_device *md);
|
|
|
|
|
void dm_destroy_immediate(struct mapped_device *md);
|
2006-06-26 00:27:34 -07:00
|
|
|
int dm_open_count(struct mapped_device *md);
|
2013-11-01 18:27:41 -04:00
|
|
|
int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only_deferred);
|
|
|
|
|
int dm_cancel_deferred_remove(struct mapped_device *md);
|
2013-08-16 10:54:23 -04:00
|
|
|
int dm_request_based(struct mapped_device *md);
|
2014-08-13 13:53:43 -05:00
|
|
|
int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode,
|
|
|
|
|
struct dm_dev **result);
|
|
|
|
|
void dm_put_table_device(struct mapped_device *md, struct dm_dev *d);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-03-06 02:32:31 +00:00
|
|
|
int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
|
|
|
|
|
unsigned cookie);
|
2007-12-13 14:15:57 +00:00
|
|
|
|
2013-08-16 10:54:23 -04:00
|
|
|
void dm_internal_suspend(struct mapped_device *md);
|
|
|
|
|
void dm_internal_resume(struct mapped_device *md);
|
|
|
|
|
|
2009-12-10 23:51:57 +00:00
|
|
|
int dm_io_init(void);
|
|
|
|
|
void dm_io_exit(void);
|
|
|
|
|
|
2008-04-24 21:43:49 +01:00
|
|
|
int dm_kcopyd_init(void);
|
|
|
|
|
void dm_kcopyd_exit(void);
|
|
|
|
|
|
2009-06-22 10:12:36 +01:00
|
|
|
/*
|
|
|
|
|
* Mempool operations
|
|
|
|
|
*/
|
2017-04-27 10:11:23 -07:00
|
|
|
struct dm_md_mempools *dm_alloc_md_mempools(struct mapped_device *md, enum dm_queue_mode type,
|
2017-12-08 14:40:52 -05:00
|
|
|
unsigned integrity, unsigned per_bio_data_size,
|
|
|
|
|
unsigned min_pool_size);
|
2009-06-22 10:12:36 +01:00
|
|
|
void dm_free_md_mempools(struct dm_md_mempools *pools);
|
|
|
|
|
|
2013-08-16 10:54:23 -04:00
|
|
|
/*
|
2016-05-12 16:28:10 -04:00
|
|
|
* Various helpers
|
2013-08-16 10:54:23 -04:00
|
|
|
*/
|
2013-09-12 18:06:12 -04:00
|
|
|
unsigned dm_get_reserved_bio_based_ios(void);
|
2015-02-26 00:50:28 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|