Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Internal header file for device mapper
0003  *
0004  * Copyright (C) 2001, 2002 Sistina Software
0005  * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
0006  *
0007  * This file is released under the LGPL.
0008  */
0009 
0010 #ifndef DM_INTERNAL_H
0011 #define DM_INTERNAL_H
0012 
0013 #include <linux/fs.h>
0014 #include <linux/device-mapper.h>
0015 #include <linux/list.h>
0016 #include <linux/moduleparam.h>
0017 #include <linux/blkdev.h>
0018 #include <linux/backing-dev.h>
0019 #include <linux/hdreg.h>
0020 #include <linux/completion.h>
0021 #include <linux/kobject.h>
0022 #include <linux/refcount.h>
0023 
0024 #include "dm-stats.h"
0025 
0026 /*
0027  * Suspend feature flags
0028  */
0029 #define DM_SUSPEND_LOCKFS_FLAG      (1 << 0)
0030 #define DM_SUSPEND_NOFLUSH_FLAG     (1 << 1)
0031 
0032 /*
0033  * Status feature flags
0034  */
0035 #define DM_STATUS_NOFLUSH_FLAG      (1 << 0)
0036 
0037 /*
0038  * List of devices that a metadevice uses and should open/close.
0039  */
0040 struct dm_dev_internal {
0041     struct list_head list;
0042     refcount_t count;
0043     struct dm_dev *dm_dev;
0044 };
0045 
0046 struct dm_table;
0047 struct dm_md_mempools;
0048 struct dm_target_io;
0049 struct dm_io;
0050 
0051 /*-----------------------------------------------------------------
0052  * Internal table functions.
0053  *---------------------------------------------------------------*/
0054 void dm_table_event_callback(struct dm_table *t,
0055                  void (*fn)(void *), void *context);
0056 struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector);
0057 bool dm_table_has_no_data_devices(struct dm_table *table);
0058 int dm_calculate_queue_limits(struct dm_table *table,
0059                   struct queue_limits *limits);
0060 int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
0061                   struct queue_limits *limits);
0062 struct list_head *dm_table_get_devices(struct dm_table *t);
0063 void dm_table_presuspend_targets(struct dm_table *t);
0064 void dm_table_presuspend_undo_targets(struct dm_table *t);
0065 void dm_table_postsuspend_targets(struct dm_table *t);
0066 int dm_table_resume_targets(struct dm_table *t);
0067 enum dm_queue_mode dm_table_get_type(struct dm_table *t);
0068 struct target_type *dm_table_get_immutable_target_type(struct dm_table *t);
0069 struct dm_target *dm_table_get_immutable_target(struct dm_table *t);
0070 struct dm_target *dm_table_get_wildcard_target(struct dm_table *t);
0071 bool dm_table_bio_based(struct dm_table *t);
0072 bool dm_table_request_based(struct dm_table *t);
0073 
0074 void dm_lock_md_type(struct mapped_device *md);
0075 void dm_unlock_md_type(struct mapped_device *md);
0076 void dm_set_md_type(struct mapped_device *md, enum dm_queue_mode type);
0077 enum dm_queue_mode dm_get_md_type(struct mapped_device *md);
0078 struct target_type *dm_get_immutable_target_type(struct mapped_device *md);
0079 
0080 int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t);
0081 
0082 /*
0083  * To check whether the target type is bio-based or not (request-based).
0084  */
0085 #define dm_target_bio_based(t) ((t)->type->map != NULL)
0086 
0087 /*
0088  * To check whether the target type is request-based or not (bio-based).
0089  */
0090 #define dm_target_request_based(t) ((t)->type->clone_and_map_rq != NULL)
0091 
0092 /*
0093  * To check whether the target type is a hybrid (capable of being
0094  * either request-based or bio-based).
0095  */
0096 #define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t))
0097 
0098 /*
0099  * Zoned targets related functions.
0100  */
0101 int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q);
0102 void dm_zone_endio(struct dm_io *io, struct bio *clone);
0103 #ifdef CONFIG_BLK_DEV_ZONED
0104 void dm_cleanup_zoned_dev(struct mapped_device *md);
0105 int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
0106             unsigned int nr_zones, report_zones_cb cb, void *data);
0107 bool dm_is_zone_write(struct mapped_device *md, struct bio *bio);
0108 int dm_zone_map_bio(struct dm_target_io *io);
0109 #else
0110 static inline void dm_cleanup_zoned_dev(struct mapped_device *md) {}
0111 #define dm_blk_report_zones NULL
0112 static inline bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
0113 {
0114     return false;
0115 }
0116 static inline int dm_zone_map_bio(struct dm_target_io *tio)
0117 {
0118     return DM_MAPIO_KILL;
0119 }
0120 #endif
0121 
0122 /*-----------------------------------------------------------------
0123  * A registry of target types.
0124  *---------------------------------------------------------------*/
0125 int dm_target_init(void);
0126 void dm_target_exit(void);
0127 struct target_type *dm_get_target_type(const char *name);
0128 void dm_put_target_type(struct target_type *tt);
0129 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
0130                     void *param), void *param);
0131 
0132 int dm_split_args(int *argc, char ***argvp, char *input);
0133 
0134 /*
0135  * Is this mapped_device being deleted?
0136  */
0137 int dm_deleting_md(struct mapped_device *md);
0138 
0139 /*
0140  * Is this mapped_device suspended?
0141  */
0142 int dm_suspended_md(struct mapped_device *md);
0143 
0144 /*
0145  * Internal suspend and resume methods.
0146  */
0147 int dm_suspended_internally_md(struct mapped_device *md);
0148 void dm_internal_suspend_fast(struct mapped_device *md);
0149 void dm_internal_resume_fast(struct mapped_device *md);
0150 void dm_internal_suspend_noflush(struct mapped_device *md);
0151 void dm_internal_resume(struct mapped_device *md);
0152 
0153 /*
0154  * Test if the device is scheduled for deferred remove.
0155  */
0156 int dm_test_deferred_remove_flag(struct mapped_device *md);
0157 
0158 /*
0159  * Try to remove devices marked for deferred removal.
0160  */
0161 void dm_deferred_remove(void);
0162 
0163 /*
0164  * The device-mapper can be driven through one of two interfaces;
0165  * ioctl or filesystem, depending which patch you have applied.
0166  */
0167 int dm_interface_init(void);
0168 void dm_interface_exit(void);
0169 
0170 /*
0171  * sysfs interface
0172  */
0173 int dm_sysfs_init(struct mapped_device *md);
0174 void dm_sysfs_exit(struct mapped_device *md);
0175 struct kobject *dm_kobject(struct mapped_device *md);
0176 struct mapped_device *dm_get_from_kobject(struct kobject *kobj);
0177 
0178 /*
0179  * The kobject helper
0180  */
0181 void dm_kobject_release(struct kobject *kobj);
0182 
0183 /*
0184  * Targets for linear and striped mappings
0185  */
0186 int dm_linear_init(void);
0187 void dm_linear_exit(void);
0188 
0189 int dm_stripe_init(void);
0190 void dm_stripe_exit(void);
0191 
0192 /*
0193  * mapped_device operations
0194  */
0195 void dm_destroy(struct mapped_device *md);
0196 void dm_destroy_immediate(struct mapped_device *md);
0197 int dm_open_count(struct mapped_device *md);
0198 int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only_deferred);
0199 int dm_cancel_deferred_remove(struct mapped_device *md);
0200 int dm_request_based(struct mapped_device *md);
0201 int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode,
0202             struct dm_dev **result);
0203 void dm_put_table_device(struct mapped_device *md, struct dm_dev *d);
0204 
0205 int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
0206               unsigned cookie);
0207 
0208 void dm_internal_suspend(struct mapped_device *md);
0209 void dm_internal_resume(struct mapped_device *md);
0210 
0211 int dm_io_init(void);
0212 void dm_io_exit(void);
0213 
0214 int dm_kcopyd_init(void);
0215 void dm_kcopyd_exit(void);
0216 
0217 /*
0218  * Mempool operations
0219  */
0220 void dm_free_md_mempools(struct dm_md_mempools *pools);
0221 
0222 /*
0223  * Various helpers
0224  */
0225 unsigned dm_get_reserved_bio_based_ios(void);
0226 
0227 #endif