| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $ */ | | 1 | /* $NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1982, 1986, 1989, 1993 | | 4 | * Copyright (c) 1982, 1986, 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | * | | 30 | * |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/proc.h> | | 38 | #include <sys/proc.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/mount.h> | | 40 | #include <sys/mount.h> |
41 | #include <sys/vnode.h> | | 41 | #include <sys/vnode.h> |
42 | #include <sys/kmem.h> | | 42 | #include <sys/kmem.h> |
43 | #include <sys/kauth.h> | | 43 | #include <sys/kauth.h> |
44 | #include <sys/fstrans.h> | | 44 | #include <sys/fstrans.h> |
45 | #include <sys/buf.h> | | 45 | #include <sys/buf.h> |
46 | | | 46 | |
47 | #include <miscfs/genfs/genfs.h> | | 47 | #include <miscfs/genfs/genfs.h> |
| @@ -511,26 +511,28 @@ genfs_getpages_read(struct vnode *vp, st | | | @@ -511,26 +511,28 @@ genfs_getpages_read(struct vnode *vp, st |
511 | struct uvm_object * const uobj = &vp->v_uobj; | | 511 | struct uvm_object * const uobj = &vp->v_uobj; |
512 | const int fs_bshift = (vp->v_type != VBLK) ? | | 512 | const int fs_bshift = (vp->v_type != VBLK) ? |
513 | vp->v_mount->mnt_fs_bshift : DEV_BSHIFT; | | 513 | vp->v_mount->mnt_fs_bshift : DEV_BSHIFT; |
514 | const int dev_bshift = (vp->v_type != VBLK) ? | | 514 | const int dev_bshift = (vp->v_type != VBLK) ? |
515 | vp->v_mount->mnt_dev_bshift : DEV_BSHIFT; | | 515 | vp->v_mount->mnt_dev_bshift : DEV_BSHIFT; |
516 | kauth_cred_t const cred = curlwp->l_cred; /* XXXUBC curlwp */ | | 516 | kauth_cred_t const cred = curlwp->l_cred; /* XXXUBC curlwp */ |
517 | size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; | | 517 | size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; |
518 | vaddr_t kva; | | 518 | vaddr_t kva; |
519 | struct buf *bp, *mbp; | | 519 | struct buf *bp, *mbp; |
520 | bool sawhole = false; | | 520 | bool sawhole = false; |
521 | int i; | | 521 | int i; |
522 | int error = 0; | | 522 | int error = 0; |
523 | | | 523 | |
| | | 524 | UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist); |
| | | 525 | |
524 | /* | | 526 | /* |
525 | * read the desired page(s). | | 527 | * read the desired page(s). |
526 | */ | | 528 | */ |
527 | | | 529 | |
528 | totalbytes = npages << PAGE_SHIFT; | | 530 | totalbytes = npages << PAGE_SHIFT; |
529 | bytes = MIN(totalbytes, MAX(diskeof - startoffset, 0)); | | 531 | bytes = MIN(totalbytes, MAX(diskeof - startoffset, 0)); |
530 | tailbytes = totalbytes - bytes; | | 532 | tailbytes = totalbytes - bytes; |
531 | skipbytes = 0; | | 533 | skipbytes = 0; |
532 | | | 534 | |
533 | kva = uvm_pagermapin(pgs, npages, | | 535 | kva = uvm_pagermapin(pgs, npages, |
534 | UVMPAGER_MAPIN_READ | (async ? 0 : UVMPAGER_MAPIN_WAITOK)); | | 536 | UVMPAGER_MAPIN_READ | (async ? 0 : UVMPAGER_MAPIN_WAITOK)); |
535 | if (kva == 0) | | 537 | if (kva == 0) |
536 | return EBUSY; | | 538 | return EBUSY; |