| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xbd_xenbus.c,v 1.85 2018/08/21 18:45:16 jdolecek Exp $ */ | | 1 | /* $NetBSD: xbd_xenbus.c,v 1.86 2018/08/21 18:55:08 jdolecek 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 | * |
| @@ -40,27 +40,27 @@ | | | @@ -40,27 +40,27 @@ |
40 | * - initiate request: xbdread/write/open/ioctl/.. | | 40 | * - initiate request: xbdread/write/open/ioctl/.. |
41 | * - depending on operation, it is handled directly by disk(9) subsystem or | | 41 | * - depending on operation, it is handled directly by disk(9) subsystem or |
42 | * goes through physio(9) first. | | 42 | * goes through physio(9) first. |
43 | * - the request is ultimately processed by xbd_diskstart() that prepares the | | 43 | * - the request is ultimately processed by xbd_diskstart() that prepares the |
44 | * xbd requests, post them in the ring I/O queue, then signal the backend. | | 44 | * xbd requests, post them in the ring I/O queue, then signal the backend. |
45 | * | | 45 | * |
46 | * When a response is available in the queue, the backend signals the frontend | | 46 | * When a response is available in the queue, the backend signals the frontend |
47 | * via its event channel. This triggers xbd_handler(), which will link back | | 47 | * via its event channel. This triggers xbd_handler(), which will link back |
48 | * the response to its request through the request ID, and mark the I/O as | | 48 | * the response to its request through the request ID, and mark the I/O as |
49 | * completed. | | 49 | * completed. |
50 | */ | | 50 | */ |
51 | | | 51 | |
52 | #include <sys/cdefs.h> | | 52 | #include <sys/cdefs.h> |
53 | __KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.85 2018/08/21 18:45:16 jdolecek Exp $"); | | 53 | __KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.86 2018/08/21 18:55:08 jdolecek Exp $"); |
54 | | | 54 | |
55 | #include "opt_xen.h" | | 55 | #include "opt_xen.h" |
56 | | | 56 | |
57 | | | 57 | |
58 | #include <sys/param.h> | | 58 | #include <sys/param.h> |
59 | #include <sys/buf.h> | | 59 | #include <sys/buf.h> |
60 | #include <sys/bufq.h> | | 60 | #include <sys/bufq.h> |
61 | #include <sys/device.h> | | 61 | #include <sys/device.h> |
62 | #include <sys/disk.h> | | 62 | #include <sys/disk.h> |
63 | #include <sys/disklabel.h> | | 63 | #include <sys/disklabel.h> |
64 | #include <sys/conf.h> | | 64 | #include <sys/conf.h> |
65 | #include <sys/fcntl.h> | | 65 | #include <sys/fcntl.h> |
66 | #include <sys/kernel.h> | | 66 | #include <sys/kernel.h> |
| @@ -683,26 +683,27 @@ again: | | | @@ -683,26 +683,27 @@ again: |
683 | xengnt_status(xbdreq->req_gntref[seg]))) { | | 683 | xengnt_status(xbdreq->req_gntref[seg]))) { |
684 | aprint_verbose_dev(sc->sc_dksc.sc_dev, | | 684 | aprint_verbose_dev(sc->sc_dksc.sc_dev, |
685 | "grant still used by backend\n"); | | 685 | "grant still used by backend\n"); |
686 | sc->sc_ring.rsp_cons = i; | | 686 | sc->sc_ring.rsp_cons = i; |
687 | xbdreq->req_nr_segments = seg + 1; | | 687 | xbdreq->req_nr_segments = seg + 1; |
688 | goto done; | | 688 | goto done; |
689 | } | | 689 | } |
690 | xengnt_revoke_access(xbdreq->req_gntref[seg]); | | 690 | xengnt_revoke_access(xbdreq->req_gntref[seg]); |
691 | xbdreq->req_nr_segments--; | | 691 | xbdreq->req_nr_segments--; |
692 | } | | 692 | } |
693 | KASSERT(xbdreq->req_nr_segments == 0); | | 693 | KASSERT(xbdreq->req_nr_segments == 0); |
694 | | | 694 | |
695 | bp = xbdreq->req_bp; | | 695 | bp = xbdreq->req_bp; |
| | | 696 | KASSERT(bp != NULL); |
696 | xbdreq->req_bp = NULL; | | 697 | xbdreq->req_bp = NULL; |
697 | DPRINTF(("%s(%p): b_bcount = %ld\n", __func__, | | 698 | DPRINTF(("%s(%p): b_bcount = %ld\n", __func__, |
698 | bp, (long)bp->b_bcount)); | | 699 | bp, (long)bp->b_bcount)); |
699 | | | 700 | |
700 | if (rep->status != BLKIF_RSP_OKAY) { | | 701 | if (rep->status != BLKIF_RSP_OKAY) { |
701 | bp->b_error = EIO; | | 702 | bp->b_error = EIO; |
702 | bp->b_resid = bp->b_bcount; | | 703 | bp->b_resid = bp->b_bcount; |
703 | goto next; | | 704 | goto next; |
704 | } | | 705 | } |
705 | /* b_resid was set in dk_start */ | | 706 | /* b_resid was set in dk_start */ |
706 | next: | | 707 | next: |
707 | dk_done(&sc->sc_dksc, bp); | | 708 | dk_done(&sc->sc_dksc, bp); |
708 | | | 709 | |