diff options
| author | haad <haad@NetBSD.org> | 2009-04-06 22:58:10 +0000 |
|---|---|---|
| committer | haad <haad@NetBSD.org> | 2009-04-06 22:58:10 +0000 |
| commit | ba7fcfeeb5aa605a8b013b145dcb4660a1d7b810 (patch) | |
| tree | 75827033971576a37a0ff375309c14f2b2045d89 /sys/dev | |
| parent | 57fb98e3bfed1466091bb338a3317e436d30f9d5 (diff) | |
Use functions from disk(9) framework. Initialize disk/disklabel during
dm_device_create_ioctl, before calling dmgetdisklabel.
Use disk_busy/disk_unbusy in dmstrategy to display LVM LV's in iostat
output.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/dm/device-mapper.c | 70 | ||||
| -rw-r--r-- | sys/dev/dm/dm_ioctl.c | 18 |
2 files changed, 55 insertions, 33 deletions
diff --git a/sys/dev/dm/device-mapper.c b/sys/dev/dm/device-mapper.c index 5e3697a9636..8ec9f75c8e1 100644 --- a/sys/dev/dm/device-mapper.c +++ b/sys/dev/dm/device-mapper.c @@ -1,4 +1,4 @@ -/* $NetBSD: device-mapper.c,v 1.5 2009/01/22 04:56:06 agc Exp $ */ +/* $NetBSD: device-mapper.c,v 1.6 2009/04/06 22:58:10 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -55,7 +55,6 @@ static dev_type_read(dmread); static dev_type_write(dmwrite); static dev_type_ioctl(dmioctl); static dev_type_strategy(dmstrategy); -static dev_type_dump(dmdump); static dev_type_size(dmsize); /* attach and detach routines */ @@ -69,12 +68,31 @@ static void dmminphys(struct buf *); /* ***Variable-definitions*** */ const struct bdevsw dm_bdevsw = { - dmopen, dmclose, dmstrategy, dmioctl, dmdump, dmsize, D_DISK | D_MPSAFE + .d_open = dmopen, + .d_close = dmclose, + .d_strategy = dmstrategy, + .d_ioctl = dmioctl, + .d_dump = nodump, + .d_psize = dmsize, + .d_flag = D_DISK | D_MPSAFE }; const struct cdevsw dm_cdevsw = { - dmopen, dmclose, dmread, dmwrite, dmioctl, - nostop, notty, nopoll, nommap, nokqfilter, D_DISK | D_MPSAFE + .d_open = dmopen, + .d_close = dmclose, + .d_read = dmread, + .d_write = dmwrite, + .d_ioctl = dmioctl, + .d_stop = nostop, + .d_tty = notty, + .d_poll = nopoll, + .d_mmap = nommap, + .d_kqfilter = nokqfilter, + .d_flag = D_DISK | D_MPSAFE +}; + +const struct dkdriver dmdkdriver = { + .d_strategy = dmstrategy }; extern uint64_t dev_counter; @@ -89,21 +107,21 @@ extern uint64_t dev_counter; * */ struct cmd_function cmd_fn[] = { - {"version", dm_get_version_ioctl}, - {"targets", dm_list_versions_ioctl}, - {"create", dm_dev_create_ioctl}, - {"info", dm_dev_status_ioctl}, - {"mknodes", dm_dev_status_ioctl}, - {"names", dm_dev_list_ioctl}, - {"suspend", dm_dev_suspend_ioctl}, - {"remove", dm_dev_remove_ioctl}, - {"rename", dm_dev_rename_ioctl}, - {"resume", dm_dev_resume_ioctl}, - {"clear", dm_table_clear_ioctl}, - {"deps", dm_table_deps_ioctl}, - {"reload", dm_table_load_ioctl}, - {"status", dm_table_status_ioctl}, - {"table", dm_table_status_ioctl}, + { .cmd = "version", .fn = dm_get_version_ioctl}, + { .cmd = "targets", .fn = dm_list_versions_ioctl}, + { .cmd = "create", .fn = dm_dev_create_ioctl}, + { .cmd = "info", .fn = dm_dev_status_ioctl}, + { .cmd = "mknodes", .fn = dm_dev_status_ioctl}, + { .cmd = "names", .fn = dm_dev_list_ioctl}, + { .cmd = "suspend", .fn = dm_dev_suspend_ioctl}, + { .cmd = "remove", .fn = dm_dev_remove_ioctl}, + { .cmd = "rename", .fn = dm_dev_rename_ioctl}, + { .cmd = "resume", .fn = dm_dev_resume_ioctl}, + { .cmd = "clear", .fn = dm_table_clear_ioctl}, + { .cmd = "deps", .fn = dm_table_deps_ioctl}, + { .cmd = "reload", .fn = dm_table_load_ioctl}, + { .cmd = "status", .fn = dm_table_status_ioctl}, + { .cmd = "table", .fn = dm_table_status_ioctl}, {NULL, NULL} }; @@ -383,6 +401,9 @@ dmstrategy(struct buf *bp) biodone(bp); return; } + + /* FIXME: have to be called with IPL_BIO*/ + disk_busy(dmv->diskp); /* Select active table */ tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE); @@ -438,6 +459,9 @@ dmstrategy(struct buf *bp) if (issued_len < buf_len) nestiobuf_done(bp, buf_len - issued_len, EINVAL); + /* FIXME have to be called with SPL_BIO*/ + disk_unbusy(dmv->diskp, buf_len, bp != NULL ? bp->b_flags & B_READ : 0); + dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE); dm_dev_unbusy(dmv); @@ -458,12 +482,6 @@ dmwrite(dev_t dev, struct uio *uio, int flag) } static int -dmdump(dev_t dev, daddr_t blkno, void *va, size_t size) -{ - return ENODEV; -} - -static int dmsize(dev_t dev) { dm_dev_t *dmv; diff --git a/sys/dev/dm/dm_ioctl.c b/sys/dev/dm/dm_ioctl.c index 9d76065083e..0f3feada2c5 100644 --- a/sys/dev/dm/dm_ioctl.c +++ b/sys/dev/dm/dm_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_ioctl.c,v 1.9 2009/03/08 02:07:38 agc Exp $ */ +/* $NetBSD: dm_ioctl.c,v 1.10 2009/04/06 22:58:10 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -93,6 +93,7 @@ #include "dm.h" static uint64_t sc_minor_num; +extern const struct dkdriver dmdkdriver; uint64_t dev_counter; #define DM_REMOVE_FLAG(flag, name) do { \ @@ -247,9 +248,12 @@ dm_dev_create_ioctl(prop_dictionary_t dm_dict) prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); - disk_init(dmv->diskp, dmv->name, NULL); - + disk_init(dmv->diskp, dmv->name, &dmdkdriver); + disk_attach(dmv->diskp); + if ((r = dm_dev_insert(dmv)) != 0){ + mutex_destroy(&dmv->dev_mtx); + cv_destroy(&dmv->dev_cv); dm_dev_free(dmv); } @@ -398,6 +402,10 @@ dm_dev_remove_ioctl(prop_dictionary_t dm_dict) mutex_destroy(&dmv->dev_mtx); cv_destroy(&dmv->dev_cv); + + /* Destroy disk device structure */ + disk_detach(dmv->diskp); + disk_destroy(dmv->diskp); /* Destroy device */ (void)dm_dev_free(dmv); @@ -535,16 +543,12 @@ dm_dev_resume_ioctl(prop_dictionary_t dm_dict) atomic_and_32(&dmv->flags, ~(DM_SUSPEND_FLAG | DM_INACTIVE_PRESENT_FLAG)); atomic_or_32(&dmv->flags, DM_ACTIVE_PRESENT_FLAG); - dm_table_switch_tables(&dmv->table_head); DM_ADD_FLAG(flags, DM_EXISTS_FLAG); dmgetdisklabel(dmv->diskp->dk_label, &dmv->table_head); - - disk_attach(dmv->diskp); - dmgetdisklabel(dmv->diskp->dk_label, &dmv->table_head); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, dmv->flags); |
