| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xbdback_xenbus.c,v 1.28 2009/10/25 13:47:43 bouyer Exp $ */ | | 1 | /* $NetBSD: xbdback_xenbus.c,v 1.29 2009/12/15 00:19:52 haad Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006 Manuel Bouyer. | | 4 | * Copyright (c) 2006 Manuel Bouyer. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | * | | 25 | * |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.28 2009/10/25 13:47:43 bouyer Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.29 2009/12/15 00:19:52 haad Exp $"); |
30 | | | 30 | |
31 | #include <sys/types.h> | | 31 | #include <sys/types.h> |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/malloc.h> | | 34 | #include <sys/malloc.h> |
35 | #include <sys/queue.h> | | 35 | #include <sys/queue.h> |
36 | #include <sys/kernel.h> | | 36 | #include <sys/kernel.h> |
37 | #include <sys/conf.h> | | 37 | #include <sys/conf.h> |
38 | #include <sys/disk.h> | | 38 | #include <sys/disk.h> |
39 | #include <sys/disklabel.h> | | 39 | #include <sys/disklabel.h> |
40 | #include <sys/fcntl.h> | | 40 | #include <sys/fcntl.h> |
41 | #include <sys/vnode.h> | | 41 | #include <sys/vnode.h> |
42 | #include <sys/kauth.h> | | 42 | #include <sys/kauth.h> |
| @@ -711,44 +711,46 @@ xbdback_backend_changed(struct xenbus_wa | | | @@ -711,44 +711,46 @@ xbdback_backend_changed(struct xenbus_wa |
711 | printf("xbdback %s: can't vn_lock device 0x%"PRIx64": %d\n", | | 711 | printf("xbdback %s: can't vn_lock device 0x%"PRIx64": %d\n", |
712 | xbusd->xbusd_path, xbdi->xbdi_dev, err); | | 712 | xbusd->xbusd_path, xbdi->xbdi_dev, err); |
713 | vrele(xbdi->xbdi_vp); | | 713 | vrele(xbdi->xbdi_vp); |
714 | return; | | 714 | return; |
715 | } | | 715 | } |
716 | err = VOP_OPEN(xbdi->xbdi_vp, FREAD, NOCRED); | | 716 | err = VOP_OPEN(xbdi->xbdi_vp, FREAD, NOCRED); |
717 | if (err) { | | 717 | if (err) { |
718 | printf("xbdback %s: can't VOP_OPEN device 0x%"PRIx64": %d\n", | | 718 | printf("xbdback %s: can't VOP_OPEN device 0x%"PRIx64": %d\n", |
719 | xbusd->xbusd_path, xbdi->xbdi_dev, err); | | 719 | xbusd->xbusd_path, xbdi->xbdi_dev, err); |
720 | vput(xbdi->xbdi_vp); | | 720 | vput(xbdi->xbdi_vp); |
721 | return; | | 721 | return; |
722 | } | | 722 | } |
723 | VOP_UNLOCK(xbdi->xbdi_vp, 0); | | 723 | VOP_UNLOCK(xbdi->xbdi_vp, 0); |
724 | if (strcmp(devname, "dk") == 0) { | | 724 | |
725 | /* dk device; get wedge data */ | | 725 | /* dk device; get wedge data */ |
726 | struct dkwedge_info wi; | | 726 | struct dkwedge_info wi; |
727 | err = VOP_IOCTL(xbdi->xbdi_vp, DIOCGWEDGEINFO, &wi, | | 727 | if ((err = VOP_IOCTL(xbdi->xbdi_vp, DIOCGWEDGEINFO, &wi, |
728 | FREAD, NOCRED); | | 728 | FREAD, NOCRED)) == 0) { |
729 | if (err) { | | | |
730 | printf("xbdback %s: can't DIOCGWEDGEINFO device " | | | |
731 | "0x%"PRIx64": %d\n", xbusd->xbusd_path, | | | |
732 | xbdi->xbdi_dev, err); | | | |
733 | xbdi->xbdi_size = xbdi->xbdi_dev = 0; | | | |
734 | vn_close(xbdi->xbdi_vp, FREAD, NOCRED); | | | |
735 | xbdi->xbdi_vp = NULL; | | | |
736 | return; | | | |
737 | } | | | |
738 | xbdi->xbdi_size = wi.dkw_size; | | 729 | xbdi->xbdi_size = wi.dkw_size; |
739 | printf("xbd backend: attach device %s (size %" PRIu64 ") " | | 730 | printf("xbd backend: attach device %s (size %" PRIu64 ") " |
740 | "for domain %d\n", wi.dkw_devname, xbdi->xbdi_size, | | 731 | "for domain %d\n", wi.dkw_devname, xbdi->xbdi_size, |
741 | xbdi->xbdi_domid); | | 732 | xbdi->xbdi_domid); |
| | | 733 | } |
| | | 734 | /* ENOTTY should be returned only when device doesn't implement |
| | | 735 | DIOCGWEDGEINFO and we are working with non wedge like device. */ |
| | | 736 | if (err != ENOTTY) { |
| | | 737 | printf("xbdback %s: can't DIOCGWEDGEINFO device " |
| | | 738 | "0x%"PRIx64": %d\n", xbusd->xbusd_path, |
| | | 739 | xbdi->xbdi_dev, err); |
| | | 740 | xbdi->xbdi_size = xbdi->xbdi_dev = 0; |
| | | 741 | vn_close(xbdi->xbdi_vp, FREAD, NOCRED); |
| | | 742 | xbdi->xbdi_vp = NULL; |
| | | 743 | return; |
742 | } else { | | 744 | } else { |
743 | /* disk device, get partition data */ | | 745 | /* disk device, get partition data */ |
744 | struct partinfo dpart; | | 746 | struct partinfo dpart; |
745 | err = VOP_IOCTL(xbdi->xbdi_vp, DIOCGPART, &dpart, FREAD, 0); | | 747 | err = VOP_IOCTL(xbdi->xbdi_vp, DIOCGPART, &dpart, FREAD, 0); |
746 | if (err) { | | 748 | if (err) { |
747 | printf("xbdback %s: can't DIOCGPART device 0x%"PRIx64": %d\n", | | 749 | printf("xbdback %s: can't DIOCGPART device 0x%"PRIx64": %d\n", |
748 | xbusd->xbusd_path, xbdi->xbdi_dev, err); | | 750 | xbusd->xbusd_path, xbdi->xbdi_dev, err); |
749 | xbdi->xbdi_size = xbdi->xbdi_dev = 0; | | 751 | xbdi->xbdi_size = xbdi->xbdi_dev = 0; |
750 | vn_close(xbdi->xbdi_vp, FREAD, NOCRED); | | 752 | vn_close(xbdi->xbdi_vp, FREAD, NOCRED); |
751 | xbdi->xbdi_vp = NULL; | | 753 | xbdi->xbdi_vp = NULL; |
752 | return; | | 754 | return; |
753 | } | | 755 | } |
754 | xbdi->xbdi_size = dpart.part->p_size; | | 756 | xbdi->xbdi_size = dpart.part->p_size; |