diff options
| author | haad <haad@NetBSD.org> | 2010-05-18 15:10:38 +0000 |
|---|---|---|
| committer | haad <haad@NetBSD.org> | 2010-05-18 15:10:38 +0000 |
| commit | fb8751aba4474091bdc25a5cce462d526a403d72 (patch) | |
| tree | ffedb891877783c792ef6cf3dfa4f8b7b2790683 /sys/dev/dm/dm_target_snapshot.c | |
| parent | 923bf0dda043333f52a68e794027abbb3f111b5a (diff) | |
Add support for DIOCCACHESYNC ioctl for dm devices. Add new sync function
pointer to dm_target_t because that is the only part of dm which know real
block device. disk_ioctl_switch parses whole device table and for every
entry it calls particular sync routine which propagates DIOCCACHESYNC
to real disk.
While I was here implement some KNF fixes and remove unneeded symbols from
dm.h.
Problem reported on port-xen@ by Hugo Silva.
Diffstat (limited to 'sys/dev/dm/dm_target_snapshot.c')
| -rw-r--r-- | sys/dev/dm/dm_target_snapshot.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/sys/dev/dm/dm_target_snapshot.c b/sys/dev/dm/dm_target_snapshot.c index 3a7709e8072..ce66470e764 100644 --- a/sys/dev/dm/dm_target_snapshot.c +++ b/sys/dev/dm/dm_target_snapshot.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_snapshot.c,v 1.12 2010/01/04 00:12:22 haad Exp $ */ +/* $NetBSD: dm_target_snapshot.c,v 1.13 2010/05/18 15:10:38 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -85,6 +85,23 @@ #include "dm.h" +/* dm_target_snapshot.c */ +int dm_target_snapshot_init(dm_dev_t *, void**, char *); +char * dm_target_snapshot_status(void *); +int dm_target_snapshot_strategy(dm_table_entry_t *, struct buf *); +int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t); +int dm_target_snapshot_destroy(dm_table_entry_t *); +int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *); + +/* dm snapshot origin driver */ +int dm_target_snapshot_orig_init(dm_dev_t *, void**, char *); +char * dm_target_snapshot_orig_status(void *); +int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *); +int dm_target_snapshot_orig_sync(dm_table_entry_t *); +int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t); +int dm_target_snapshot_orig_destroy(dm_table_entry_t *); +int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); + #ifdef DM_TARGET_MODULE /* * Every target can be compiled directly to dm driver or as a @@ -140,6 +157,7 @@ dm_target_snapshot_modcmd(modcmd_t cmd, void *arg) dmt1->init = &dm_target_snapshot_orig_init; dmt1->status = &dm_target_snapshot_orig_status; dmt1->strategy = &dm_target_snapshot_orig_strategy; + dmt1->sync = &dm_target_snapshot_orig_sync; dmt1->deps = &dm_target_snapshot_orig_deps; dmt1->destroy = &dm_target_snapshot_orig_destroy; dmt1->upcall = &dm_target_snapshot_orig_upcall; @@ -381,8 +399,7 @@ dm_target_snapshot_upcall(dm_table_entry_t * table_en, struct buf * bp) * argv: /dev/mapper/my_data_real */ int -dm_target_snapshot_orig_init(dm_dev_t * dmv, void **target_config, - prop_dictionary_t dict) +dm_target_snapshot_orig_init(dm_dev_t * dmv, void **target_config, char *params) { dm_target_snapshot_origin_config_t *tsoc; dm_pdev_t *dmp_real; @@ -456,6 +473,21 @@ dm_target_snapshot_orig_strategy(dm_table_entry_t * table_en, struct buf * bp) return 0; } +/* + * Sync underlying disk caches. + */ +int +dm_target_snapshot_orig_sync(dm_table_entry_t * table_en) +{ + int cmd; + dm_target_snapshot_origin_config_t *tsoc; + + tsoc = table_en->target_config; + + cmd = 1; + + return VOP_IOCTL(tsoc->tsoc_real_dev->pdev_vnode, DIOCCACHESYNC, &cmd, FREAD|FWRITE, kauth_cred_get()); +} /* Decrement pdev and free allocated space. */ int dm_target_snapshot_orig_destroy(dm_table_entry_t * table_en) |
