Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dm Add support for DIOCCACHESYNC ioctl for dm device...
details: https://anonhg.NetBSD.org/src/rev/73840e870b43
branches: trunk
changeset: 754978:73840e870b43
user: haad <haad%NetBSD.org@localhost>
date: Tue May 18 15:10:38 2010 +0000
description:
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:
sys/dev/dm/device-mapper.c | 32 +++++++++++++++++++++++++++++++-
sys/dev/dm/dm_target.c | 32 +++-----------------------------
sys/dev/dm/dm_target_error.c | 19 ++++++++++++++++++-
sys/dev/dm/dm_target_linear.c | 18 +++++++++++++++++-
sys/dev/dm/dm_target_mirror.c | 19 ++++++++++++++++++-
sys/dev/dm/dm_target_snapshot.c | 38 +++++++++++++++++++++++++++++++++++---
sys/dev/dm/dm_target_zero.c | 19 ++++++++++++++++++-
7 files changed, 140 insertions(+), 37 deletions(-)
diffs (truncated from 364 to 300 lines):
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/device-mapper.c Tue May 18 15:10:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device-mapper.c,v 1.22 2010/03/26 15:46:04 jakllsch Exp $ */
+/* $NetBSD: device-mapper.c,v 1.23 2010/05/18 15:10:38 haad Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -152,6 +152,7 @@
static int
dm_modcmd(modcmd_t cmd, void *arg)
{
+#ifdef _MODULE
int error, bmajor, cmajor;
error = 0;
@@ -209,6 +210,9 @@
}
return error;
+#else
+ return ENOTTY;
+#endif
}
#endif /* _MODULE */
@@ -470,6 +474,32 @@
dm_dev_unbusy(dmv);
break;
}
+
+ case DIOCCACHESYNC:
+ {
+ dm_table_entry_t *table_en;
+ dm_table_t *tbl;
+ int err;
+
+ if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
+ return ENODEV;
+
+ /* Select active table */
+ tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
+
+ /*
+ * Call sync target routine for all table entries. Target sync
+ * routine basically call DIOCCACHESYNC on underlying devices.
+ */
+ SLIST_FOREACH(table_en, tbl, next)
+ {
+ err = table_en->target->sync(table_en);
+ }
+ dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
+ dm_dev_unbusy(dmv);
+ break;
+ }
+
default:
aprint_debug("unknown disk_ioctl called\n");
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/dm_target.c Tue May 18 15:10:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target.c,v 1.12 2010/01/04 00:14:41 haad Exp $ */
+/* $NetBSD: dm_target.c,v 1.13 2010/05/18 15:10:38 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -289,6 +289,7 @@
dmt->init = &dm_target_linear_init;
dmt->status = &dm_target_linear_status;
dmt->strategy = &dm_target_linear_strategy;
+ dmt->sync = &dm_target_linear_sync;
dmt->deps = &dm_target_linear_deps;
dmt->destroy = &dm_target_linear_destroy;
dmt->upcall = &dm_target_linear_upcall;
@@ -302,39 +303,12 @@
dmt3->init = &dm_target_stripe_init;
dmt3->status = &dm_target_stripe_status;
dmt3->strategy = &dm_target_stripe_strategy;
+ dmt3->sync = &dm_target_stripe_sync;
dmt3->deps = &dm_target_stripe_deps;
dmt3->destroy = &dm_target_stripe_destroy;
dmt3->upcall = &dm_target_stripe_upcall;
r = dm_target_insert(dmt3);
-#ifdef notyet
- dmt5->version[0] = 1;
- dmt5->version[1] = 0;
- dmt5->version[2] = 5;
- strlcpy(dmt5->name, "snapshot", DM_MAX_TYPE_NAME);
- dmt5->init = &dm_target_snapshot_init;
- dmt5->status = &dm_target_snapshot_status;
- dmt5->strategy = &dm_target_snapshot_strategy;
- dmt5->deps = &dm_target_snapshot_deps;
- dmt5->destroy = &dm_target_snapshot_destroy;
- dmt5->upcall = &dm_target_snapshot_upcall;
-
- r = dm_target_insert(dmt5);
-
- dmt6->version[0] = 1;
- dmt6->version[1] = 0;
- dmt6->version[2] = 5;
- strlcpy(dmt6->name, "snapshot-origin", DM_MAX_TYPE_NAME);
- dmt6->init = &dm_target_snapshot_orig_init;
- dmt6->status = &dm_target_snapshot_orig_status;
- dmt6->strategy = &dm_target_snapshot_orig_strategy;
- dmt6->deps = &dm_target_snapshot_orig_deps;
- dmt6->destroy = &dm_target_snapshot_orig_destroy;
- dmt6->upcall = &dm_target_snapshot_orig_upcall;
-
- r = dm_target_insert(dmt6);
-#endif
-
return r;
}
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/dm_target_error.c Tue May 18 15:10:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_error.c,v 1.10 2010/01/04 00:12:22 haad Exp $ */
+/* $NetBSD: dm_target_error.c,v 1.11 2010/05/18 15:10:38 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -39,6 +39,15 @@
#include "dm.h"
+/* dm_target_error.c */
+int dm_target_error_init(dm_dev_t *, void**, char *);
+char * dm_target_error_status(void *);
+int dm_target_error_strategy(dm_table_entry_t *, struct buf *);
+int dm_target_error_sync(dm_table_entry_t *);
+int dm_target_error_deps(dm_table_entry_t *, prop_array_t);
+int dm_target_error_destroy(dm_table_entry_t *);
+int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
+
#ifdef DM_TARGET_MODULE
/*
* Every target can be compiled directly to dm driver or as a
@@ -74,6 +83,7 @@
dmt->init = &dm_target_error_init;
dmt->status = &dm_target_error_status;
dmt->strategy = &dm_target_error_strategy;
+ dmt->sync = &dm_target_error_sync;
dmt->deps = &dm_target_error_deps;
dmt->destroy = &dm_target_error_destroy;
dmt->upcall = &dm_target_error_upcall;
@@ -130,6 +140,13 @@
return 0;
}
+/* Sync underlying disk caches. */
+int
+dm_target_error_sync(dm_table_entry_t * table_en)
+{
+
+ return 0;
+}
/* Doesn't do anything here. */
int
dm_target_error_destroy(dm_table_entry_t * table_en)
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/dm_target_linear.c
--- a/sys/dev/dm/dm_target_linear.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/dm_target_linear.c Tue May 18 15:10:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_linear.c,v 1.9 2010/01/04 00:14:41 haad Exp $ */
+/* $NetBSD: dm_target_linear.c,v 1.10 2010/05/18 15:10:38 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -141,6 +141,22 @@
}
/*
+ * Sync underlying disk caches.
+ */
+int
+dm_target_linear_sync(dm_table_entry_t * table_en)
+{
+ int cmd;
+ dm_target_linear_config_t *tlc;
+
+ tlc = table_en->target_config;
+
+ cmd = 1;
+
+ return VOP_IOCTL(tlc->pdev->pdev_vnode, DIOCCACHESYNC, &cmd,
+ FREAD|FWRITE, kauth_cred_get());
+}
+/*
* Destroy target specific data. Decrement table pdevs.
*/
int
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/dm_target_mirror.c
--- a/sys/dev/dm/dm_target_mirror.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/dm_target_mirror.c Tue May 18 15:10:38 2010 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_mirror.c,v 1.8 2010/01/04 00:12:22 haad Exp $*/
+/*$NetBSD: dm_target_mirror.c,v 1.9 2010/05/18 15:10:38 haad Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -39,6 +39,15 @@
#include "dm.h"
+/* dm_target_mirror.c */
+int dm_target_mirror_init(dm_dev_t *, void**, char *);
+char * dm_target_mirror_status(void *);
+int dm_target_mirror_strategy(dm_table_entry_t *, struct buf *);
+int dm_target_mirror_sync(dm_table_entry_t *);
+int dm_target_mirror_deps(dm_table_entry_t *, prop_array_t);
+int dm_target_mirror_destroy(dm_table_entry_t *);
+int dm_target_mirror_upcall(dm_table_entry_t *, struct buf *);
+
#ifdef DM_TARGET_MODULE
/*
* Every target can be compiled directly to dm driver or as a
@@ -74,6 +83,7 @@
dmt->init = &dm_target_mirror_init;
dmt->status = &dm_target_mirror_status;
dmt->strategy = &dm_target_mirror_strategy;
+ dmt->sync = &dm_target_mirror_sync;
dmt->deps = &dm_target_mirror_deps;
dmt->destroy = &dm_target_mirror_destroy;
dmt->upcall = &dm_target_mirror_upcall;
@@ -134,6 +144,13 @@
return 0;
}
+/* Sync underlying disk caches. */
+int
+dm_target_mirror_sync(dm_table_entry_t * table_en)
+{
+
+ return 0;
+}
/* Doesn't do anything here. */
int
dm_target_mirror_destroy(dm_table_entry_t * table_en)
diff -r 75ad64d07028 -r 73840e870b43 sys/dev/dm/dm_target_snapshot.c
--- a/sys/dev/dm/dm_target_snapshot.c Tue May 18 15:07:50 2010 +0000
+++ b/sys/dev/dm/dm_target_snapshot.c Tue May 18 15:10:38 2010 +0000
@@ -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 @@
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 @@
* 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 @@
return 0;
}
+/*
Home |
Main Index |
Thread Index |
Old Index