summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-04-21 12:02:57 +0000
committerpjd <pjd@FreeBSD.org>2007-04-21 12:02:57 +0000
commit24d44898020531c24ba8914b294876e52f304e4f (patch)
tree932d85fefa7fcb86834f441607b2a4438d5b0c0f /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
parente60ce7e12076f27ac5471441a6940e2254378506 (diff)
downloadFreeBSD-src-24d44898020531c24ba8914b294876e52f304e4f.zip
FreeBSD-src-24d44898020531c24ba8914b294876e52f304e4f.tar.gz
MFp4:
@118370 Correct typo. @118371 Integrate changes from vendor. @118491 Show backtrace on unexpected code paths. @118494 Integrate changes from vendor. @118504 Fix sendfile(2). I had two ways of fixing it: 1. Fixing sendfile(2) itself to use VOP_GETPAGES() instead of hacking around with vn_rdwr(UIO_NOCOPY), which was suggested by ups. 2. Modify ZFS behaviour to handle this special case. Although 1 is more correct, I've choosen 2, because hack from 1 have a side-effect of beeing faster - it reads ahead MAXBSIZE bytes instead of reading page by page. This is not easy to implement with VOP_GETPAGES(), at least not for me in this very moment. Reported by: Andrey V. Elsukov <bu7cher@yandex.ru> @118525 Reorganize the code to reduce diff. @118526 This code path is expected. It is simply when file is opened with O_FSYNC flag. Reported by: kris Reported by: Michal Suszko <dry@dry.pl>
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index 5f74eb8..7af6b20 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -165,10 +165,8 @@ zfs_open(ap)
int flag = ap->a_mode;
/* Keep a count of the synchronous opens in the znode */
- if (flag & FFSYNC) {
+ if (flag & FFSYNC)
atomic_inc_32(&zp->z_sync_cnt);
- ZFS_LOG(0, "Unexpected code path, report to pjd@FreeBSD.org");
- }
vnode_create_vobject(vp, zp->z_phys->zp_size, ap->a_td);
return (0);
@@ -188,10 +186,8 @@ zfs_close(ap)
int flag = ap->a_fflag;
/* Decrement the synchronous opens in the znode */
- if (flag & FFSYNC) {
+ if (flag & FFSYNC)
atomic_dec_32(&zp->z_sync_cnt);
- ZFS_LOG(0, "Unexpected code path, report to pjd@FreeBSD.org");
- }
return (0);
}
@@ -362,6 +358,7 @@ mappedread(vnode_t *vp, int nbytes, uio_t *uio)
vm_page_t m;
struct sf_buf *sf;
int64_t start, off;
+ caddr_t va;
int len = nbytes;
int error = 0;
@@ -378,8 +375,6 @@ mappedread(vnode_t *vp, int nbytes, uio_t *uio)
again:
if ((m = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL &&
vm_page_is_valid(m, (vm_offset_t)off, bytes)) {
- caddr_t va;
-
if (vm_page_sleep_if_busy(m, FALSE, "zfsmrb"))
goto again;
vm_page_busy(m);
@@ -392,6 +387,21 @@ again:
sched_unpin();
VM_OBJECT_LOCK(obj);
vm_page_wakeup(m);
+ } else if (m != NULL && uio->uio_segflg == UIO_NOCOPY) {
+ if (vm_page_sleep_if_busy(m, FALSE, "zfsmrb"))
+ goto again;
+ vm_page_busy(m);
+ VM_OBJECT_UNLOCK(obj);
+ sched_pin();
+ sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
+ va = (caddr_t)sf_buf_kva(sf);
+ error = dmu_read(os, zp->z_id, start + off, bytes,
+ (void *)(va + off));
+ sf_buf_free(sf);
+ sched_unpin();
+ VM_OBJECT_LOCK(obj);
+ vm_page_wakeup(m);
+ uio->uio_resid -= bytes;
} else {
VM_OBJECT_UNLOCK(obj);
error = dmu_read_uio(os, zp->z_id, uio, bytes);
@@ -2461,7 +2471,7 @@ top:
if (tvp)
vrele(tvp);
else {
- ZFS_LOG(0, "Unexpected code path, report to pjd@FreeBSD.org");
+ ZFS_LOG(0x100, "Unexpected code path, report to pjd@FreeBSD.org");
tvp = ZTOV(tzp);
vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, curthread);
}
OpenPOWER on IntegriCloud