From b7c11cdad5c40c8f5c14c46e6bc7f8a72aa34a44 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Fri, 13 Nov 2015 20:39:43 +0900 Subject: [PATCH] sys/dev/disk/dm: Cleanups * Fix comments. * Add a blank line between functions. * Some minor fixes on dm core. --- sys/dev/disk/dm/device-mapper.c | 29 ++--- sys/dev/disk/dm/dm.h | 112 ++++++++---------- sys/dev/disk/dm/dm_dev.c | 15 ++- sys/dev/disk/dm/dm_ioctl.c | 28 ++--- sys/dev/disk/dm/dm_pdev.c | 7 +- sys/dev/disk/dm/dm_table.c | 16 ++- sys/dev/disk/dm/dm_target.c | 25 ++-- sys/dev/disk/dm/dm_target_error.c | 2 - sys/dev/disk/dm/dm_target_zero.c | 3 - sys/dev/disk/dm/doc/design.txt | 2 +- .../disk/dm/targets/linear/dm_target_linear.c | 2 + .../disk/dm/targets/mirror/dm_target_mirror.c | 4 + .../dm/targets/snapshot/dm_target_snapshot.c | 6 + 13 files changed, 125 insertions(+), 126 deletions(-) diff --git a/sys/dev/disk/dm/device-mapper.c b/sys/dev/disk/dm/device-mapper.c index e8a8a5cd39..eedbf3ee49 100644 --- a/sys/dev/disk/dm/device-mapper.c +++ b/sys/dev/disk/dm/device-mapper.c @@ -36,7 +36,6 @@ #include #include - #include #include #include @@ -70,7 +69,6 @@ static int dm_ioctl_switch(u_long); static void dmminphys(struct buf *); #endif -/* ***Variable-definitions*** */ struct dev_ops dm_ops = { { "dm", 0, D_DISK | D_MPSAFE }, .d_open = dmopen, @@ -81,7 +79,6 @@ struct dev_ops dm_ops = { .d_strategy = dmstrategy, .d_psize = dmsize, .d_dump = dmdump, -/* D_DISK */ }; MALLOC_DEFINE(M_DM, "dm", "Device Mapper allocations"); @@ -137,7 +134,9 @@ static struct cmd_function { {.cmd = "message", .fn = dm_message_ioctl}, }; -/* New module handle routine */ +/* + * New module handle routine + */ static int dm_modcmd(module_t mod, int cmd, void *unused) { @@ -185,7 +184,9 @@ dm_doinit(void) dmcdev = make_dev(&dm_ops, 0, UID_ROOT, GID_OPERATOR, 0640, "mapper/control"); } -/* Destroy routine */ +/* + * Destroy routine + */ static int dmdestroy(void) { @@ -247,7 +248,7 @@ dmioctl(struct dev_ioctl_args *ap) cdev_t dev = ap->a_head.a_dev; u_long cmd = ap->a_cmd; void *data = ap->a_data; - struct plistref *pref = (struct plistref *)data; + struct plistref *pref; int r, err; prop_dictionary_t dm_dict_in; @@ -263,6 +264,7 @@ dmioctl(struct dev_ioctl_args *ap) if ((r = dm_ioctl_switch(cmd)) != 0) return r; /* Not NETBSD_DM_IOCTL */ + pref = (struct plistref *)data; /* data is for libprop */ if ((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0) return r; @@ -312,7 +314,9 @@ dm_cmd_to_fun(prop_dictionary_t dm_dict) return p->fn(dm_dict); } -/* Call apropriate ioctl handler function. */ +/* + * Call apropriate ioctl handler function. + */ static int dm_ioctl_switch(u_long cmd) { @@ -330,10 +334,9 @@ dm_ioctl_switch(u_long cmd) return 0; } - /* - * Check for disk specific ioctls. - */ - +/* + * Check for disk specific ioctls. + */ static int disk_ioctl_switch(cdev_t dev, u_long cmd, void *data) { @@ -384,7 +387,7 @@ dmstrategy(struct dev_strategy_args *ap) int bypass; dm_dev_t *dmv; - dm_table_t *tbl; + dm_table_t *tbl; dm_table_entry_t *table_en; struct buf *nestbuf; @@ -517,7 +520,6 @@ dmdump(struct dev_dump_args *ap) /* Select active table */ tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE); - /* * Find out what tables I want to select. */ @@ -669,4 +671,3 @@ dm_builtin_uninit(void *arg) TUNABLE_INT("debug.dm_debug", &dm_debug_level); SYSCTL_INT(_debug, OID_AUTO, dm_debug, CTLFLAG_RW, &dm_debug_level, 0, "Enable device mapper debugging"); - diff --git a/sys/dev/disk/dm/dm.h b/sys/dev/disk/dm/dm.h index 7cf5b910c2..d5c6de563c 100644 --- a/sys/dev/disk/dm/dm.h +++ b/sys/dev/disk/dm/dm.h @@ -32,7 +32,6 @@ #ifndef _DM_DEV_H_ #define _DM_DEV_H_ - #ifdef _KERNEL #include @@ -54,16 +53,19 @@ #include -#define DM_MAX_TYPE_NAME 16 -#define DM_NAME_LEN 128 -#define DM_UUID_LEN 129 - #define DM_VERSION_MAJOR 4 #define DM_VERSION_MINOR 16 - #define DM_VERSION_PATCHLEVEL 0 -/*** Internal device-mapper structures ***/ +#define DM_MAX_TYPE_NAME 16 +#define DM_MAX_DEV_NAME 32 +#define DM_MAX_PARAMS_SIZE 1024 + +#define DM_NAME_LEN 128 +#define DM_UUID_LEN 129 + +#define DM_TABLE_ACTIVE 0 +#define DM_TABLE_INACTIVE 1 typedef struct dm_mapping { union { @@ -102,17 +104,14 @@ typedef struct dm_table_head { int io_cnt; } dm_table_head_t; -#define MAX_DEV_NAME 32 - /* * This structure is used to store opened vnodes for disk with name. * I need this because devices can be opened only once, but I can * have more then one device on one partition. */ - typedef struct dm_pdev { - char name[MAX_DEV_NAME]; - char udev_name[MAX_DEV_NAME]; + char name[DM_MAX_DEV_NAME]; + char udev_name[DM_MAX_DEV_NAME]; udev_t udev; struct partinfo pdev_pinfo; /* partinfo of the underlying device */ @@ -140,7 +139,7 @@ typedef struct dm_dev { /* uint32_t event_nr; */ uint32_t ref_cnt; - uint32_t dev_type; + uint32_t dev_type; /* DM_XXX_DEV, but not used */ uint32_t is_open; dm_table_head_t table_head; @@ -165,10 +164,8 @@ typedef struct dm_dev { #define DM_RAID1_DEV (1 << 10) #define DM_DELAY_DEV (1 << 11) -/* for zero, error : dm_target->target_config == NULL */ - /* - * Target config is initiated with target_init function. + * Target config is initiated with dm_target_init function. */ /* constant dm_target structures for error, zero, linear, stripes etc. */ @@ -197,61 +194,53 @@ typedef struct dm_target { TAILQ_ENTRY(dm_target) dm_target_next; } dm_target_t; -/* Interface structures */ - -/* device-mapper */ +/* device-mapper.c */ void dmsetdiskinfo(struct disk *, dm_table_head_t *); +uint64_t atoi64(const char *); +char *dm_alloc_string(int len); +void dm_builtin_init(void *); +void dm_builtin_uninit(void *); +MALLOC_DECLARE(M_DM); +extern int dm_debug_level; /* dm_ioctl.c */ +int dm_list_versions_ioctl(prop_dictionary_t); int dm_dev_create_ioctl(prop_dictionary_t); int dm_dev_list_ioctl(prop_dictionary_t); +int dm_dev_rename_ioctl(prop_dictionary_t); int dm_dev_remove_ioctl(prop_dictionary_t); int dm_dev_remove_all_ioctl(prop_dictionary_t); -int dm_dev_rename_ioctl(prop_dictionary_t); -int dm_dev_resume_ioctl(prop_dictionary_t); int dm_dev_status_ioctl(prop_dictionary_t); int dm_dev_suspend_ioctl(prop_dictionary_t); - -int dm_check_version(prop_dictionary_t); -int dm_list_versions_ioctl(prop_dictionary_t); - +int dm_dev_resume_ioctl(prop_dictionary_t); int dm_table_clear_ioctl(prop_dictionary_t); int dm_table_deps_ioctl(prop_dictionary_t); int dm_table_load_ioctl(prop_dictionary_t); int dm_table_status_ioctl(prop_dictionary_t); int dm_message_ioctl(prop_dictionary_t); +int dm_check_version(prop_dictionary_t); /* dm_target.c */ -int dm_target_init(void); -int dm_target_uninit(void); -dm_target_t* dm_target_alloc(const char *); -int dm_target_free(dm_target_t *); +void dm_target_busy(dm_target_t *); +void dm_target_unbusy(dm_target_t *); dm_target_t* dm_target_autoload(const char *); -int dm_target_insert(dm_target_t *); -prop_array_t dm_target_prop_list(void); dm_target_t* dm_target_lookup(const char *); +int dm_target_insert(dm_target_t *); int dm_target_remove(char *); -void dm_target_unbusy(dm_target_t *); -void dm_target_busy(dm_target_t *); - -#define DM_MAX_PARAMS_SIZE 1024 - -/* Generic function used to convert char to string */ -uint64_t atoi64(const char *); - -char *dm_alloc_string(int len); +dm_target_t* dm_target_alloc(const char *); +int dm_target_free(dm_target_t *); +prop_array_t dm_target_prop_list(void); +int dm_target_init(void); +int dm_target_uninit(void); /* dm_table.c */ -#define DM_TABLE_ACTIVE 0 -#define DM_TABLE_INACTIVE 1 - +dm_table_t *dm_table_get_entry(dm_table_head_t *, uint8_t); +void dm_table_release(dm_table_head_t *, uint8_t s); +void dm_table_switch_tables(dm_table_head_t *); int dm_table_destroy(dm_table_head_t *, uint8_t); uint64_t dm_table_size(dm_table_head_t *); uint64_t dm_inactive_table_size(dm_table_head_t *); -dm_table_t *dm_table_get_entry(dm_table_head_t *, uint8_t); int dm_table_get_target_count(dm_table_head_t *, uint8_t); -void dm_table_release(dm_table_head_t *, uint8_t s); -void dm_table_switch_tables(dm_table_head_t *); void dm_table_head_init(dm_table_head_t *); void dm_table_head_destroy(dm_table_head_t *); void dm_table_init_target(dm_table_entry_t *table_en, uint32_t type, void *cfg); @@ -259,35 +248,28 @@ int dm_table_add_deps(dm_table_entry_t *table_en, dm_pdev_t *pdev); void dm_table_free_deps(dm_table_entry_t *table_en); /* dm_dev.c */ -int dm_dev_init(void); -int dm_dev_uninit(void); -void dm_dev_busy(dm_dev_t *); -int dm_dev_create(dm_dev_t **, const char *, const char *, int); -int dm_dev_remove(dm_dev_t *); -int dm_dev_remove_all(int); -int dm_dev_insert(dm_dev_t *); dm_dev_t* dm_dev_lookup(const char *, const char *, int); -prop_array_t dm_dev_prop_list(void); +int dm_dev_insert(dm_dev_t *); #if 0 dm_dev_t* dm_dev_lookup_evict(const char *, const char *, int); #endif +int dm_dev_create(dm_dev_t **, const char *, const char *, int); +int dm_dev_remove(dm_dev_t *); +int dm_dev_remove_all(int); +void dm_dev_busy(dm_dev_t *); void dm_dev_unbusy(dm_dev_t *); +prop_array_t dm_dev_prop_list(void); +int dm_dev_init(void); +int dm_dev_uninit(void); /* dm_pdev.c */ -int dm_pdev_init(void); -int dm_pdev_uninit(void); +off_t dm_pdev_correct_dump_offset(dm_pdev_t *, off_t); +dm_pdev_t* dm_pdev_insert(const char *); int dm_pdev_decr(dm_pdev_t *); uint64_t dm_pdev_get_udev(dm_pdev_t *); int dm_pdev_get_vattr(dm_pdev_t *, struct vattr *); -dm_pdev_t* dm_pdev_insert(const char *); -off_t dm_pdev_correct_dump_offset(dm_pdev_t *, off_t); - -/* dm builtin magic */ -void dm_builtin_init(void *); -void dm_builtin_uninit(void *); - -extern int dm_debug_level; -MALLOC_DECLARE(M_DM); +int dm_pdev_init(void); +int dm_pdev_uninit(void); #define dmdebug(format, ...) \ do { if (dm_debug_level) kprintf(format, ## __VA_ARGS__); } while(0) diff --git a/sys/dev/disk/dm/dm_dev.c b/sys/dev/disk/dm/dm_dev.c index 365cdd26a8..3e5c065f0a 100644 --- a/sys/dev/disk/dm/dm_dev.c +++ b/sys/dev/disk/dm/dm_dev.c @@ -33,7 +33,6 @@ #include #include #include - #include #include #include @@ -63,7 +62,9 @@ static struct lock dm_dev_mutex; static char dummy_uuid[DM_UUID_LEN]; -/* dm_dev_mutex must be held by caller before using disable_dev. */ +/* + * dm_dev_mutex must be held by caller before using disable_dev. + */ static void disable_dev(dm_dev_t *dmv) { @@ -100,8 +101,8 @@ _dm_dev_lookup(const char *name, const char *uuid, int minor) } /* - * Generic function used to lookup dm_dev_t. Calling with dm_dev_name - * and dm_dev_uuid NULL is allowed. + * Generic function used to lookup dm_dev_t. Calling with name NULL + * and uuid NULL is allowed. */ dm_dev_t * dm_dev_lookup(const char *name, const char *uuid, int minor) @@ -135,6 +136,7 @@ dm_dev_lookup_minor(int dm_dev_minor) return NULL; } + /* * Lookup device with it's device name. */ @@ -150,6 +152,7 @@ dm_dev_lookup_name(const char *dm_dev_name) return NULL; } + /* * Lookup device with it's device uuid. Used mostly by LVM2tools. */ @@ -165,6 +168,7 @@ dm_dev_lookup_uuid(const char *dm_dev_uuid) return NULL; } + /* * Insert new device to the global list of devices. */ @@ -368,6 +372,7 @@ dm_dev_alloc(const char *name, const char*uuid) return dmv; } + /* * Freed device entry. */ @@ -402,6 +407,7 @@ dm_dev_unbusy(dm_dev_t *dmv) cv_broadcast(&dmv->dev_cv); lockmgr(&dmv->dev_mtx, LK_RELEASE); } + /* * Return prop_array of dm_targer_list dictionaries. */ @@ -429,6 +435,7 @@ dm_dev_prop_list(void) lockmgr(&dm_dev_mutex, LK_RELEASE); return dev_array; } + /* * Initialize global device mutex. */ diff --git a/sys/dev/disk/dm/dm_ioctl.c b/sys/dev/disk/dm/dm_ioctl.c index 7915c8c285..0872e8fdc8 100644 --- a/sys/dev/disk/dm/dm_ioctl.c +++ b/sys/dev/disk/dm/dm_ioctl.c @@ -115,7 +115,7 @@ void dm_remove_flag(prop_dictionary_t dp, uint32_t *fp, const uint32_t val) } /* - * Print flags sent to the kernel from libevmapper. + * Print flags sent to the kernel from libdevmapper. */ static int dm_dbg_print_flags(uint32_t flags) @@ -156,6 +156,7 @@ dm_dbg_print_flags(uint32_t flags) return 0; } + /* * Get list of all available targets from global * target list and sent them back to libdevmapper. @@ -178,10 +179,10 @@ dm_list_versions_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Create in-kernel entry for device. Device attributes such as name, uuid are * taken from proplib dictionary. - * */ int dm_dev_create_ioctl(prop_dictionary_t dm_dict) @@ -219,8 +220,9 @@ dm_dev_create_ioctl(prop_dictionary_t dm_dict) return r; } + /* - * Get list of created device-mapper devices fromglobal list and + * Get list of created device-mapper devices from global list and * send it to kernel. * * Output dictionary: @@ -235,7 +237,6 @@ dm_dev_create_ioctl(prop_dictionary_t dm_dict) * ... * * - * */ int dm_dev_list_ioctl(prop_dictionary_t dm_dict) @@ -257,9 +258,10 @@ dm_dev_list_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Rename selected devices old name is in struct dm_ioctl. - * newname is taken from dictionary + * new name is taken from dictionary. * * cmd_data * @@ -414,9 +416,9 @@ dm_dev_status_ioctl(prop_dictionary_t dm_dict) * Add status flags for tables I have to check both active and * inactive tables. */ - if ((j = dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))) { + if ((j = dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))) dm_add_flag(dm_dict, &flags, DM_ACTIVE_PRESENT_FLAG); - } else + else dm_remove_flag(dm_dict, &flags, DM_ACTIVE_PRESENT_FLAG); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_TARGET_COUNT, j); @@ -430,10 +432,10 @@ dm_dev_status_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Set only flag to suggest that device is suspended. This call is * not supported in NetBSD. - * */ int dm_dev_suspend_ioctl(prop_dictionary_t dm_dict) @@ -470,6 +472,7 @@ dm_dev_suspend_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Simulate Linux behaviour better and switch tables here and not in * dm_table_load_ioctl. @@ -520,6 +523,7 @@ dm_dev_resume_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Table management routines * lvm2tools doens't send name/uuid to kernel with table @@ -529,7 +533,6 @@ dm_dev_resume_ioctl(prop_dictionary_t dm_dict) /* * Remove inactive table from device. Routines which work's with inactive tables * doesn't need to synchronise with dmstrategy. They can synchronise themselves with mutex?. - * */ int dm_table_clear_ioctl(prop_dictionary_t dm_dict) @@ -565,6 +568,7 @@ dm_table_clear_ioctl(prop_dictionary_t dm_dict) return 0; } + /* * Get list of physical devices for active table. * Get dev_t from pdev vnode and insert it into cmd_array. @@ -665,7 +669,6 @@ dm_table_deps(dm_table_entry_t *table_en, prop_array_t array) * * Load table to inactive slot table are switched in dm_device_resume_ioctl. * This simulates Linux behaviour better there should not be any difference. - * */ int dm_table_load_ioctl(prop_dictionary_t dm_dict) @@ -865,7 +868,6 @@ dm_table_init(dm_target_t *target, dm_table_entry_t *table_en, char *params) * ... * * - * */ int dm_table_status_ioctl(prop_dictionary_t dm_dict) @@ -915,9 +917,8 @@ dm_table_status_ioctl(prop_dictionary_t dm_dict) if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_INACTIVE)) dm_add_flag(dm_dict, &flags, DM_INACTIVE_PRESENT_FLAG); - else { + else dm_remove_flag(dm_dict, &flags, DM_INACTIVE_PRESENT_FLAG); - } } if (dmv->flags & DM_SUSPEND_FLAG) @@ -1057,7 +1058,6 @@ dm_message_ioctl(prop_dictionary_t dm_dict) dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); - kfree(msg, M_TEMP); dm_dev_unbusy(dmv); diff --git a/sys/dev/disk/dm/dm_pdev.c b/sys/dev/disk/dm/dm_pdev.c index 6898ab2f39..6984775497 100644 --- a/sys/dev/disk/dm/dm_pdev.c +++ b/sys/dev/disk/dm/dm_pdev.c @@ -31,7 +31,6 @@ */ #include - #include #include #include @@ -205,10 +204,11 @@ dm_pdev_alloc(const char *name) return NULL; if (name) - strlcpy(dmp->name, name, MAX_DEV_NAME); + strlcpy(dmp->name, name, DM_MAX_DEV_NAME); return dmp; } + /* * Destroy allocated dm_pdev. */ @@ -232,13 +232,12 @@ dm_pdev_free(dm_pdev_t *dmp) } /* - * This funcion is called from dm_dev_remove_ioctl. + * This funcion is called from targets' destroy() handler. * When I'm removing device from list, I have to decrement * reference counter. If reference counter is 0 I will remove * dmp from global list and from device list to. And I will CLOSE * dmp vnode too. */ - /* * Decrement pdev reference counter if 0 remove it. */ diff --git a/sys/dev/disk/dm/dm_table.c b/sys/dev/disk/dm/dm_table.c index 98650c99ee..58a1c473b3 100644 --- a/sys/dev/disk/dm/dm_table.c +++ b/sys/dev/disk/dm/dm_table.c @@ -31,9 +31,7 @@ */ #include - #include - #include /* @@ -74,6 +72,7 @@ dm_table_busy(dm_table_head_t *head, uint8_t table_id) return id; } + /* * Function release table lock and eventually wakeup all waiters. */ @@ -86,6 +85,7 @@ dm_table_unbusy(dm_table_head_t *head) lockmgr(&head->table_mtx, LK_RELEASE); } + /* * Return current active table to caller, increment io_cnt reference counter. */ @@ -98,6 +98,7 @@ dm_table_get_entry(dm_table_head_t *head, uint8_t table_id) return &head->tables[id]; } + /* * Decrement io reference counter and release shared lock. */ @@ -106,6 +107,7 @@ dm_table_release(dm_table_head_t *head, uint8_t table_id) { dm_table_unbusy(head); } + /* * Switch table from inactive to active mode. Have to wait until io_cnt is 0. */ @@ -118,6 +120,7 @@ dm_table_switch_tables(dm_table_head_t *head) lockmgr(&head->table_mtx, LK_RELEASE); } + /* * Destroy all table data. This function can run when there are no * readers on table lists. @@ -159,6 +162,7 @@ dm_table_destroy(dm_table_head_t *head, uint8_t table_id) return 0; } + /* * Return length of active or inactive table in device. */ @@ -203,7 +207,7 @@ dm_inactive_table_size(dm_table_head_t *head) * Return > 0 if table is at least one table entry (returns number of entries) * and return 0 if there is not. Target count returned from this function * doesn't need to be true when userspace user receive it (after return - * there can be dm_dev_resume_ioctl), therfore this isonly informative. + * there can be dm_dev_resume_ioctl), therefore this is only informative. */ int dm_table_get_target_count(dm_table_head_t *head, uint8_t table_id) @@ -224,9 +228,8 @@ dm_table_get_target_count(dm_table_head_t *head, uint8_t table_id) return target_count; } - /* - * Initialize table_head structures, I'm trying to keep this structure as + * Initialize dm_table_head_t structures, I'm trying to keep this structure as * opaque as possible. */ void @@ -241,6 +244,7 @@ dm_table_head_init(dm_table_head_t *head) lockinit(&head->table_mtx, "dmtbl", 0, LK_CANRECURSE); } + /* * Destroy all variables in table_head */ @@ -249,7 +253,7 @@ dm_table_head_destroy(dm_table_head_t *head) { KKASSERT(lockcount(&head->table_mtx) == 0); - /* tables doens't exists when I call this routine, therefore it + /* tables don't exist when I call this routine, therefore it * doesn't make sense to have io_cnt != 0 */ KKASSERT(head->io_cnt == 0); diff --git a/sys/dev/disk/dm/dm_target.c b/sys/dev/disk/dm/dm_target.c index 36d452bdba..4c0b0399b1 100644 --- a/sys/dev/disk/dm/dm_target.c +++ b/sys/dev/disk/dm/dm_target.c @@ -31,7 +31,6 @@ */ #include - #include #include #include @@ -45,14 +44,12 @@ static TAILQ_HEAD(, dm_target) dm_target_list; static struct lock dm_target_mutex; -/* - * Called indirectly from dm_table_load_ioctl to mark target as used. - */ void dm_target_busy(dm_target_t *target) { atomic_add_int(&target->ref_cnt, 1); } + /* * Release reference counter on target. */ @@ -117,8 +114,9 @@ dm_target_lookup(const char *dm_target_name) return dmt; } + /* - * Search for name in TAIL and return apropriate pointer. + * Search for name in TAILQ and return apropriate pointer. */ static dm_target_t * dm_target_lookup_name(const char *dm_target_name) @@ -132,10 +130,11 @@ dm_target_lookup_name(const char *dm_target_name) return NULL; } + /* - * Insert new target struct into the TAIL. - * dm_target - * contains name, version, function pointer to specifif target functions. + * Insert new target struct into the TAILQ. + * dm_target contains name, version, function pointer to specific target + * functions. */ int dm_target_insert(dm_target_t *dm_target) @@ -170,9 +169,8 @@ dm_target_insert(dm_target_t *dm_target) return 0; } - /* - * Remove target from TAIL, target is selected with it's name. + * Remove target from TAILQ, target is selected with it's name. */ int dm_target_remove(char *dm_target_name) @@ -192,8 +190,7 @@ dm_target_remove(char *dm_target_name) lockmgr(&dm_target_mutex, LK_RELEASE); return EBUSY; } - TAILQ_REMOVE(&dm_target_list, - dmt, dm_target_next); + TAILQ_REMOVE(&dm_target_list, dmt, dm_target_next); lockmgr(&dm_target_mutex, LK_RELEASE); @@ -268,7 +265,9 @@ dm_target_prop_list(void) return target_array; } -/* Initialize dm_target subsystem. */ +/* + * Initialize dm_target subsystem. + */ int dm_target_init(void) { diff --git a/sys/dev/disk/dm/dm_target_error.c b/sys/dev/disk/dm/dm_target_error.c index 17d2a6e73e..767bdb09f6 100644 --- a/sys/dev/disk/dm/dm_target_error.c +++ b/sys/dev/disk/dm/dm_target_error.c @@ -33,9 +33,7 @@ * This file implements initial version of device-mapper error target. */ #include - #include - #include /* Init function called from dm_table_load_ioctl. */ diff --git a/sys/dev/disk/dm/dm_target_zero.c b/sys/dev/disk/dm/dm_target_zero.c index 97580a293a..db707bd567 100644 --- a/sys/dev/disk/dm/dm_target_zero.c +++ b/sys/dev/disk/dm/dm_target_zero.c @@ -29,14 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ - /* * This file implements initial version of device-mapper zero target. */ #include - #include - #include /* diff --git a/sys/dev/disk/dm/doc/design.txt b/sys/dev/disk/dm/doc/design.txt index 49dd873021..1d6e91f7ec 100644 --- a/sys/dev/disk/dm/doc/design.txt +++ b/sys/dev/disk/dm/doc/design.txt @@ -244,7 +244,7 @@ Table describe how is dm device made. What blocks are mapped with what target. In our implementation every table contains pointer to target specific config data. These config_data are allocated in - DM_TABLE_LOAD function with target_init routine. Every table + DM_TABLE_LOAD function with dm_target_init routine. Every table contains pointer to used target. device-mapper targets -> target dm_target.c diff --git a/sys/dev/disk/dm/targets/linear/dm_target_linear.c b/sys/dev/disk/dm/targets/linear/dm_target_linear.c index 65e7bc8b3c..eaeffa99a9 100644 --- a/sys/dev/disk/dm/targets/linear/dm_target_linear.c +++ b/sys/dev/disk/dm/targets/linear/dm_target_linear.c @@ -87,6 +87,7 @@ dm_target_linear_init(dm_table_entry_t *table_en, int argc, char **argv) return 0; } + /* * Table routine is called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -108,6 +109,7 @@ dm_target_linear_table(void *target_config) return params; } + /* * Do IO operation, called from dmstrategy routine. */ diff --git a/sys/dev/disk/dm/targets/mirror/dm_target_mirror.c b/sys/dev/disk/dm/targets/mirror/dm_target_mirror.c index cdef71e837..e6ad94e170 100644 --- a/sys/dev/disk/dm/targets/mirror/dm_target_mirror.c +++ b/sys/dev/disk/dm/targets/mirror/dm_target_mirror.c @@ -72,12 +72,14 @@ dm_target_mirror_init(dm_table_entry_t *table_en, int argc, char **argv) return ENOSYS; } + /* Table routine called to get params string. */ char * dm_target_mirror_table(void *target_config) { return NULL; } + /* Strategy routine called from dm_strategy. */ int dm_target_mirror_strategy(dm_table_entry_t *table_en, struct buf *bp) @@ -92,6 +94,7 @@ dm_target_mirror_strategy(dm_table_entry_t *table_en, struct buf *bp) return 0; } + /* Doesn't do anything here. */ int dm_target_mirror_destroy(dm_table_entry_t *table_en) @@ -101,6 +104,7 @@ dm_target_mirror_destroy(dm_table_entry_t *table_en) return 0; } + /* Doesn't not need to do anything here. */ int dm_target_mirror_deps(dm_table_entry_t *table_en, prop_array_t prop_array) diff --git a/sys/dev/disk/dm/targets/snapshot/dm_target_snapshot.c b/sys/dev/disk/dm/targets/snapshot/dm_target_snapshot.c index c948666bc9..8c2024457e 100644 --- a/sys/dev/disk/dm/targets/snapshot/dm_target_snapshot.c +++ b/sys/dev/disk/dm/targets/snapshot/dm_target_snapshot.c @@ -156,6 +156,7 @@ dm_target_snapshot_init(dm_table_entry_t *table_en, int argc, char **argv) return 0; } + /* * Table routine is called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -203,6 +204,7 @@ dm_target_snapshot_table(void *target_config) return params; } + /* Strategy routine called from dm_strategy. */ int dm_target_snapshot_strategy(dm_table_entry_t *table_en, struct buf *bp) @@ -217,6 +219,7 @@ dm_target_snapshot_strategy(dm_table_entry_t *table_en, struct buf *bp) return 0; } + /* Doesn't do anything here. */ int dm_target_snapshot_destroy(dm_table_entry_t *table_en) @@ -285,6 +288,7 @@ dm_target_snapshot_orig_init(dm_table_entry_t *table_en, int argc, char **argv) return 0; } + /* * Table routine is called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -318,6 +322,7 @@ dm_target_snapshot_orig_table(void *target_config) return params; } + /* Strategy routine called from dm_strategy. */ int dm_target_snapshot_orig_strategy(dm_table_entry_t *table_en, struct buf *bp) @@ -332,6 +337,7 @@ dm_target_snapshot_orig_strategy(dm_table_entry_t *table_en, struct buf *bp) return 0; } + /* Decrement pdev and free allocated space. */ int dm_target_snapshot_orig_destroy(dm_table_entry_t *table_en) -- 2.41.0