* vm_hold_load_pages and vm_hold_free_pages get pages into * a buffers address space. The pages are anonymous and are * not associated with a file object. */
| 4876 | * not associated with a file object. |
| 4877 | */ |
| 4878 | static void |
| 4879 | vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to) |
| 4880 | { |
| 4881 | vm_offset_t pg; |
| 4882 | vm_page_t p; |
| 4883 | int index; |
| 4884 | |
| 4885 | BUF_CHECK_MAPPED(bp); |
| 4886 | |
| 4887 | to = round_page(to); |
| 4888 | from = round_page(from); |
| 4889 | index = (from - trunc_page((vm_offset_t)bp->b_data)) >> PAGE_SHIFT; |
| 4890 | MPASS((bp->b_flags & B_MAXPHYS) == 0); |
| 4891 | KASSERT(to - from <= maxbcachebuf, |
| 4892 | ("vm_hold_load_pages too large %p %#jx %#jx %u", |
| 4893 | bp, (uintmax_t)from, (uintmax_t)to, maxbcachebuf)); |
| 4894 | |
| 4895 | for (pg = from; pg < to; pg += PAGE_SIZE, index++) { |
| 4896 | /* |
| 4897 | * note: must allocate system pages since blocking here |
| 4898 | * could interfere with paging I/O, no matter which |
| 4899 | * process we are. |
| 4900 | */ |
| 4901 | p = vm_page_alloc(NULL, 0, VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ | |
| 4902 | VM_ALLOC_WIRED | VM_ALLOC_COUNT((to - pg) >> PAGE_SHIFT) | |
| 4903 | VM_ALLOC_WAITOK); |
| 4904 | pmap_qenter(pg, &p, 1); |
| 4905 | bp->b_pages[index] = p; |
| 4906 | } |
| 4907 | bp->b_npages = index; |
| 4908 | } |
| 4909 | |
| 4910 | /* Return pages associated with this buf to the vm system */ |
| 4911 | static void |
no test coverage detected