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

Function vnode_pager_input_old

freebsd/vm/vnode_pager.c:661–720  ·  view source on GitHub ↗

* old style vnode pager input routine */

Source from the content-addressed store, hash-verified

659 * old style vnode pager input routine
660 */
661static int
662vnode_pager_input_old(vm_object_t object, vm_page_t m)
663{
664 struct uio auio;
665 struct iovec aiov;
666 int error;
667 int size;
668 struct sf_buf *sf;
669 struct vnode *vp;
670
671 VM_OBJECT_ASSERT_WLOCKED(object);
672 error = 0;
673
674 /*
675 * Return failure if beyond current EOF
676 */
677 if (IDX_TO_OFF(m->pindex) >= object->un_pager.vnp.vnp_size) {
678 return VM_PAGER_BAD;
679 } else {
680 size = PAGE_SIZE;
681 if (IDX_TO_OFF(m->pindex) + size > object->un_pager.vnp.vnp_size)
682 size = object->un_pager.vnp.vnp_size - IDX_TO_OFF(m->pindex);
683 vp = object->handle;
684 VM_OBJECT_WUNLOCK(object);
685
686 /*
687 * Allocate a kernel virtual address and initialize so that
688 * we can use VOP_READ/WRITE routines.
689 */
690 sf = sf_buf_alloc(m, 0);
691
692 aiov.iov_base = (caddr_t)sf_buf_kva(sf);
693 aiov.iov_len = size;
694 auio.uio_iov = &aiov;
695 auio.uio_iovcnt = 1;
696 auio.uio_offset = IDX_TO_OFF(m->pindex);
697 auio.uio_segflg = UIO_SYSSPACE;
698 auio.uio_rw = UIO_READ;
699 auio.uio_resid = size;
700 auio.uio_td = curthread;
701
702 error = VOP_READ(vp, &auio, 0, curthread->td_ucred);
703 if (!error) {
704 int count = size - auio.uio_resid;
705
706 if (count == 0)
707 error = EINVAL;
708 else if (count != PAGE_SIZE)
709 bzero((caddr_t)sf_buf_kva(sf) + count,
710 PAGE_SIZE - count);
711 }
712 sf_buf_free(sf);
713
714 VM_OBJECT_WLOCK(object);
715 }
716 KASSERT(m->dirty == 0, ("vnode_pager_input_old: page %p is dirty", m));
717 if (!error)
718 vm_page_valid(m);

Callers 1

Calls 5

bzeroFunction · 0.85
vm_page_validFunction · 0.85
sf_buf_allocFunction · 0.50
sf_buf_kvaFunction · 0.50
sf_buf_freeFunction · 0.50

Tested by

no test coverage detected