| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xbdback_xenbus.c,v 1.83 2020/04/20 16:12:28 jdolecek Exp $ */ | | 1 | /* $NetBSD: xbdback_xenbus.c,v 1.84 2020/04/20 19:20:35 bouyer 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.83 2020/04/20 16:12:28 jdolecek Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.84 2020/04/20 19:20:35 bouyer Exp $"); |
30 | | | 30 | |
31 | #include <sys/atomic.h> | | 31 | #include <sys/atomic.h> |
32 | #include <sys/buf.h> | | 32 | #include <sys/buf.h> |
33 | #include <sys/condvar.h> | | 33 | #include <sys/condvar.h> |
34 | #include <sys/conf.h> | | 34 | #include <sys/conf.h> |
35 | #include <sys/disk.h> | | 35 | #include <sys/disk.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/fcntl.h> | | 37 | #include <sys/fcntl.h> |
38 | #include <sys/kauth.h> | | 38 | #include <sys/kauth.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/kthread.h> | | 41 | #include <sys/kthread.h> |
42 | #include <sys/mutex.h> | | 42 | #include <sys/mutex.h> |
| @@ -1039,27 +1039,26 @@ xbdback_co_main_incr(struct xbdback_inst | | | @@ -1039,27 +1039,26 @@ xbdback_co_main_incr(struct xbdback_inst |
1039 | | | 1039 | |
1040 | return xbdi; | | 1040 | return xbdi; |
1041 | } | | 1041 | } |
1042 | | | 1042 | |
1043 | /* | | 1043 | /* |
1044 | * Check for requests in the instance's ring. In case there are, start again | | 1044 | * Check for requests in the instance's ring. In case there are, start again |
1045 | * from the beginning. If not, stall. | | 1045 | * from the beginning. If not, stall. |
1046 | */ | | 1046 | */ |
1047 | static void * | | 1047 | static void * |
1048 | xbdback_co_main_done2(struct xbdback_instance *xbdi, void *obj) | | 1048 | xbdback_co_main_done2(struct xbdback_instance *xbdi, void *obj) |
1049 | { | | 1049 | { |
1050 | int work_to_do; | | 1050 | int work_to_do; |
1051 | | | 1051 | |
1052 | KASSERT(xbdi->xbdio_io == NULL); | | | |
1053 | RING_FINAL_CHECK_FOR_REQUESTS(&xbdi->xbdi_ring.ring_n, work_to_do); | | 1052 | RING_FINAL_CHECK_FOR_REQUESTS(&xbdi->xbdi_ring.ring_n, work_to_do); |
1054 | if (work_to_do) | | 1053 | if (work_to_do) |
1055 | xbdi->xbdi_cont = xbdback_co_main; | | 1054 | xbdi->xbdi_cont = xbdback_co_main; |
1056 | else | | 1055 | else |
1057 | xbdi->xbdi_cont = NULL; | | 1056 | xbdi->xbdi_cont = NULL; |
1058 | | | 1057 | |
1059 | return xbdi; | | 1058 | return xbdi; |
1060 | } | | 1059 | } |
1061 | | | 1060 | |
1062 | /* | | 1061 | /* |
1063 | * Frontend requested a cache flush operation. | | 1062 | * Frontend requested a cache flush operation. |
1064 | */ | | 1063 | */ |
1065 | static void * | | 1064 | static void * |
| @@ -1223,27 +1222,26 @@ xbdback_io_error(struct xbdback_io *xbd_ | | | @@ -1223,27 +1222,26 @@ xbdback_io_error(struct xbdback_io *xbd_ |
1223 | { | | 1222 | { |
1224 | xbd_io->xio_buf.b_error = error; | | 1223 | xbd_io->xio_buf.b_error = error; |
1225 | xbdback_iodone(&xbd_io->xio_buf); | | 1224 | xbdback_iodone(&xbd_io->xio_buf); |
1226 | } | | 1225 | } |
1227 | | | 1226 | |
1228 | /* | | 1227 | /* |
1229 | * Main xbdback I/O routine. It can either perform a flush operation or | | 1228 | * Main xbdback I/O routine. It can either perform a flush operation or |
1230 | * schedule a read/write operation. | | 1229 | * schedule a read/write operation. |
1231 | */ | | 1230 | */ |
1232 | static void * | | 1231 | static void * |
1233 | xbdback_co_do_io(struct xbdback_instance *xbdi, void *obj) | | 1232 | xbdback_co_do_io(struct xbdback_instance *xbdi, void *obj) |
1234 | { | | 1233 | { |
1235 | struct xbdback_io *xbd_io = xbdi->xbdi_io; | | 1234 | struct xbdback_io *xbd_io = xbdi->xbdi_io; |
1236 | int nsegs __diagused; | | | |
1237 | | | 1235 | |
1238 | switch (xbd_io->xio_operation) { | | 1236 | switch (xbd_io->xio_operation) { |
1239 | case BLKIF_OP_FLUSH_DISKCACHE: | | 1237 | case BLKIF_OP_FLUSH_DISKCACHE: |
1240 | { | | 1238 | { |
1241 | int error; | | 1239 | int error; |
1242 | int force = 1; | | 1240 | int force = 1; |
1243 | | | 1241 | |
1244 | error = VOP_IOCTL(xbdi->xbdi_vp, DIOCCACHESYNC, &force, FWRITE, | | 1242 | error = VOP_IOCTL(xbdi->xbdi_vp, DIOCCACHESYNC, &force, FWRITE, |
1245 | kauth_cred_get()); | | 1243 | kauth_cred_get()); |
1246 | if (error) { | | 1244 | if (error) { |
1247 | aprint_error("xbdback %s: DIOCCACHESYNC returned %d\n", | | 1245 | aprint_error("xbdback %s: DIOCCACHESYNC returned %d\n", |
1248 | xbdi->xbdi_xbusd->xbusd_path, error); | | 1246 | xbdi->xbdi_xbusd->xbusd_path, error); |
1249 | if (error == EOPNOTSUPP || error == ENOTTY) | | 1247 | if (error == EOPNOTSUPP || error == ENOTTY) |