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

Function vnode_pager_generic_getpages_done

freebsd/vm/vnode_pager.c:1117–1199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115}
1116
1117static int
1118vnode_pager_generic_getpages_done(struct buf *bp)
1119{
1120 vm_object_t object;
1121 off_t tfoff, nextoff;
1122 int i, error;
1123
1124 KASSERT((bp->b_ioflags & BIO_ERROR) == 0 || bp->b_error != 0,
1125 ("%s: buf error but b_error == 0\n", __func__));
1126 error = (bp->b_ioflags & BIO_ERROR) != 0 ? bp->b_error : 0;
1127 object = bp->b_vp->v_object;
1128
1129 if (error == 0 && bp->b_bcount != bp->b_npages * PAGE_SIZE) {
1130 if (!buf_mapped(bp)) {
1131 bp->b_data = bp->b_kvabase;
1132 pmap_qenter((vm_offset_t)bp->b_data, bp->b_pages,
1133 bp->b_npages);
1134 }
1135 bzero(bp->b_data + bp->b_bcount,
1136 PAGE_SIZE * bp->b_npages - bp->b_bcount);
1137 }
1138 if (buf_mapped(bp)) {
1139 pmap_qremove((vm_offset_t)bp->b_data, bp->b_npages);
1140 bp->b_data = unmapped_buf;
1141 }
1142
1143 /*
1144 * If the read failed, we must free any read ahead/behind pages here.
1145 * The requested pages are freed by the caller (for sync requests)
1146 * or by the bp->b_pgiodone callback (for async requests).
1147 */
1148 if (error != 0) {
1149 VM_OBJECT_WLOCK(object);
1150 for (i = 0; i < bp->b_pgbefore; i++)
1151 vm_page_free_invalid(bp->b_pages[i]);
1152 for (i = bp->b_npages - bp->b_pgafter; i < bp->b_npages; i++)
1153 vm_page_free_invalid(bp->b_pages[i]);
1154 VM_OBJECT_WUNLOCK(object);
1155 return (error);
1156 }
1157
1158 /* Read lock to protect size. */
1159 VM_OBJECT_RLOCK(object);
1160 for (i = 0, tfoff = IDX_TO_OFF(bp->b_pages[0]->pindex);
1161 i < bp->b_npages; i++, tfoff = nextoff) {
1162 vm_page_t mt;
1163
1164 nextoff = tfoff + PAGE_SIZE;
1165 mt = bp->b_pages[i];
1166 if (mt == bogus_page)
1167 continue;
1168
1169 if (nextoff <= object->un_pager.vnp.vnp_size) {
1170 /*
1171 * Read filled up entire page.
1172 */
1173 vm_page_valid(mt);
1174 KASSERT(mt->dirty == 0,

Calls 10

buf_mappedFunction · 0.85
bzeroFunction · 0.85
vm_page_free_invalidFunction · 0.85
vm_page_validFunction · 0.85
vm_page_set_valid_rangeFunction · 0.85
vm_page_bitsFunction · 0.85
vm_page_readahead_finishFunction · 0.85
pmap_qenterFunction · 0.50
pmap_qremoveFunction · 0.50
pmap_page_is_mappedFunction · 0.50

Tested by

no test coverage detected