diff --git a/sys/kern/vfs_jops.c b/sys/kern/vfs_jops.c index b92dbc2..56a4ecf 100644 --- a/sys/kern/vfs_jops.c +++ b/sys/kern/vfs_jops.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include diff --git a/sys/kern/vfs_journal.c b/sys/kern/vfs_journal.c index 3892939..2efd1d1 100644 --- a/sys/kern/vfs_journal.c +++ b/sys/kern/vfs_journal.c @@ -76,7 +76,7 @@ #include #include #include -#include +#include #include #include @@ -86,7 +86,9 @@ #include #include #include +#include #include +#include #include #include @@ -1334,13 +1336,10 @@ jrecord_write_pagelist(struct jrecord *jrec, int16_t rectype, struct vm_page **pglist, int *rtvals, int pgcount, off_t offset) { - struct msf_buf *msf; - int error; - int b; + struct sf_buf *sf; int i; - i = 0; - while (i < pgcount) { + for (i = 0; i < pgcount; ++i) { /* * Find the next valid section. Skip any invalid elements */ @@ -1350,70 +1349,62 @@ jrecord_write_pagelist(struct jrecord *jrec, int16_t rectype, continue; } - /* - * Figure out how big the valid section is, capping I/O at what the - * MSFBUF can represent. - */ - b = i; - while (i < pgcount && i - b != XIO_INTERNAL_PAGES && - rtvals[i] == VM_PAGER_OK - ) { - ++i; - } - - /* - * And write it out. - */ - if (i - b) { - error = msf_map_pagelist(&msf, pglist + b, i - b, 0); - if (error == 0) { - kprintf("RECORD PUTPAGES %d\n", msf_buf_bytes(msf)); - jrecord_leaf(jrec, JLEAF_SEEKPOS, &offset, sizeof(offset)); - jrecord_leaf(jrec, rectype, - msf_buf_kva(msf), msf_buf_bytes(msf)); - msf_buf_free(msf); - } else { - kprintf("jrecord_write_pagelist: mapping failure\n"); - } - offset += (off_t)(i - b) << PAGE_SHIFT; - } + sf = sf_buf_alloc(pglist[i], SFB_CPUPRIVATE); + jrecord_leaf(jrec, rectype, (void *)sf_buf_kva(sf), PAGE_SIZE); + sf_buf_free(sf); } } /* * Write out the data represented by a UIO. */ -struct jwuio_info { - struct jrecord *jrec; - int16_t rectype; -}; - -static int jrecord_write_uio_callback(void *info, char *buf, int bytes); - void jrecord_write_uio(struct jrecord *jrec, int16_t rectype, struct uio *uio) { - struct jwuio_info info = { jrec, rectype }; - int error; + struct iovec *iov; + struct sf_buf *sf; + int i; if (uio->uio_segflg != UIO_NOCOPY) { jrecord_leaf(jrec, JLEAF_SEEKPOS, &uio->uio_offset, sizeof(uio->uio_offset)); - error = msf_uio_iterate(uio, jrecord_write_uio_callback, &info); - if (error) - kprintf("XXX warning uio iterate failed %d\n", error); + if (uio->uio_segflg == UIO_SYSSPACE) { + for (i = 0; i < uio->uio_iovcnt; ++i) { + iov = &uio->uio_iov[i]; + if (iov->iov_len != 0) + jrecord_leaf(jrec, rectype, iov->iov_base, iov->iov_len); + } + } else { /* UIO_USERSPACE */ + size_t iov_offset, page_offset, bytes; + vm_offset_t addr; + vm_paddr_t paddr; + + for (i = 0; i < uio->uio_iovcnt; ++i) { + iov = &uio->uio_iov[i]; + page_offset = (size_t)iov->iov_base & PAGE_MASK; + iov_offset = 0; + + while (iov_offset < iov->iov_len) { + bytes = iov->iov_len - iov_offset; + if (bytes + page_offset > PAGE_SIZE) + bytes = PAGE_SIZE - page_offset; + + addr = trunc_page((vm_offset_t)iov->iov_base + iov_offset); + paddr = pmap_extract(&curthread->td_lwp->lwp_vmspace->vm_pmap, + addr); + + sf = sf_buf_alloc(PHYS_TO_VM_PAGE(paddr), SFB_CPUPRIVATE); + jrecord_leaf(jrec, rectype, (char *)sf_buf_kva(sf) + + page_offset, bytes); + sf_buf_free(sf); + + iov_offset += bytes; + } + } + } } } -static int -jrecord_write_uio_callback(void *info_arg, char *buf, int bytes) -{ - struct jwuio_info *info = info_arg; - - jrecord_leaf(info->jrec, info->rectype, buf, bytes); - return(0); -} - void jrecord_file_data(struct jrecord *jrec, struct vnode *vp, off_t off, off_t bytes)