MCPcopy Create free account
hub / github.com/F-Stack/f-stack / physio

Function physio

freebsd/kern/kern_physio.c:44–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42#include <vm/vm_map.h>
43
44int
45physio(struct cdev *dev, struct uio *uio, int ioflag)
46{
47 struct cdevsw *csw;
48 struct buf *pbuf;
49 struct bio *bp;
50 struct vm_page **pages;
51 char *base, *sa;
52 u_int iolen, poff;
53 int error, i, npages, maxpages;
54 vm_prot_t prot;
55
56 csw = dev->si_devsw;
57 npages = 0;
58 sa = NULL;
59 /* check if character device is being destroyed */
60 if (csw == NULL)
61 return (ENXIO);
62
63 /* XXX: sanity check */
64 if(dev->si_iosize_max < PAGE_SIZE) {
65 printf("WARNING: %s si_iosize_max=%d, using DFLTPHYS.\n",
66 devtoname(dev), dev->si_iosize_max);
67 dev->si_iosize_max = DFLTPHYS;
68 }
69
70 /*
71 * If the driver does not want I/O to be split, that means that we
72 * need to reject any requests that will not fit into one buffer.
73 */
74 if (dev->si_flags & SI_NOSPLIT &&
75 (uio->uio_resid > dev->si_iosize_max || uio->uio_resid > maxphys ||
76 uio->uio_iovcnt > 1)) {
77 /*
78 * Tell the user why his I/O was rejected.
79 */
80 if (uio->uio_resid > dev->si_iosize_max)
81 uprintf("%s: request size=%zd > si_iosize_max=%d; "
82 "cannot split request\n", devtoname(dev),
83 uio->uio_resid, dev->si_iosize_max);
84 if (uio->uio_resid > maxphys)
85 uprintf("%s: request size=%zd > maxphys=%lu; "
86 "cannot split request\n", devtoname(dev),
87 uio->uio_resid, maxphys);
88 if (uio->uio_iovcnt > 1)
89 uprintf("%s: request vectors=%d > 1; "
90 "cannot split request\n", devtoname(dev),
91 uio->uio_iovcnt);
92 return (EFBIG);
93 }
94
95 /*
96 * Keep the process UPAGES from being swapped. Processes swapped
97 * out while holding pbufs, used by swapper, may lead to deadlock.
98 */
99 PHOLD(curproc);
100
101 bp = g_alloc_bio();

Callers

nothing calls this directly

Calls 13

uprintfFunction · 0.85
mallocFunction · 0.85
biowaitFunction · 0.85
vm_page_unhold_pagesFunction · 0.85
printfFunction · 0.70
devtonameFunction · 0.70
racct_add_forceFunction · 0.70
freeFunction · 0.70
uma_zallocFunction · 0.50
pmap_qenterFunction · 0.50
pmap_qremoveFunction · 0.50

Tested by

no test coverage detected