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

Function breada

freebsd/kern/vfs_bio.c:2091–2132  ·  view source on GitHub ↗

* Attempt to initiate asynchronous I/O on read-ahead blocks. We must * clear BIO_ERROR and B_INVAL prior to initiating I/O . If B_CACHE is set, * the buffer is valid and we do not have to do anything. */

Source from the content-addressed store, hash-verified

2089 * the buffer is valid and we do not have to do anything.
2090 */
2091static void
2092breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, int cnt,
2093 struct ucred * cred, int flags, void (*ckhashfunc)(struct buf *))
2094{
2095 struct buf *rabp;
2096 struct thread *td;
2097 int i;
2098
2099 td = curthread;
2100
2101 for (i = 0; i < cnt; i++, rablkno++, rabsize++) {
2102 if (inmem(vp, *rablkno))
2103 continue;
2104 rabp = getblk(vp, *rablkno, *rabsize, 0, 0, 0);
2105 if ((rabp->b_flags & B_CACHE) != 0) {
2106 brelse(rabp);
2107 continue;
2108 }
2109#ifdef RACCT
2110 if (racct_enable) {
2111 PROC_LOCK(curproc);
2112 racct_add_buf(curproc, rabp, 0);
2113 PROC_UNLOCK(curproc);
2114 }
2115#endif /* RACCT */
2116 td->td_ru.ru_inblock++;
2117 rabp->b_flags |= B_ASYNC;
2118 rabp->b_flags &= ~B_INVAL;
2119 if ((flags & GB_CKHASH) != 0) {
2120 rabp->b_flags |= B_CKHASH;
2121 rabp->b_ckhashcalc = ckhashfunc;
2122 }
2123 rabp->b_ioflags &= ~BIO_ERROR;
2124 rabp->b_iocmd = BIO_READ;
2125 if (rabp->b_rcred == NOCRED && cred != NOCRED)
2126 rabp->b_rcred = crhold(cred);
2127 vfs_busy_pages(rabp, 0);
2128 BUF_KERNPROC(rabp);
2129 rabp->b_iooffset = dbtob(rabp->b_blkno);
2130 bstrategy(rabp);
2131 }
2132}
2133
2134/*
2135 * Entry point for bread() and breadn() via #defines in sys/buf.h.

Callers 1

breadn_flagsFunction · 0.85

Calls 7

inmemFunction · 0.85
getblkFunction · 0.85
brelseFunction · 0.85
racct_add_bufFunction · 0.85
vfs_busy_pagesFunction · 0.85
bstrategyFunction · 0.85
crholdFunction · 0.70

Tested by

no test coverage detected