From f7ee62e6ccc3d3d94b57bcf1504514a4a79e53d9 Mon Sep 17 00:00:00 2001 From: pjd Date: Tue, 1 May 2007 12:09:45 +0000 Subject: Add a comment explaining why we call dmu_write() unconditionally, even if uiomove() fails, especially that it is different from what OpenSolaris does (I'm not entirely sure they are right). Suggested by: darrenr --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c | 9 +++++++++ sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c | 9 +++++++++ 2 files changed, 18 insertions(+) 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 5888e06..288bf9a 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 @@ -327,6 +327,15 @@ again: va = (caddr_t)sf_buf_kva(sf); woff = uio->uio_loffset - off; error = uiomove(va + off, bytes, UIO_WRITE, uio); + /* + * The uiomove() above could have been partially + * successful, that's why we call dmu_write() + * below unconditionally. The page was marked + * non-dirty above and we would lose the changes + * without doing so. If the uiomove() failed + * entirely, well, we just write what we got + * before one more time. + */ dmu_write(os, zp->z_id, woff, MIN(PAGESIZE, fsize - woff), va, tx); sf_buf_free(sf); diff --git a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index 5888e06..288bf9a 100644 --- a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -327,6 +327,15 @@ again: va = (caddr_t)sf_buf_kva(sf); woff = uio->uio_loffset - off; error = uiomove(va + off, bytes, UIO_WRITE, uio); + /* + * The uiomove() above could have been partially + * successful, that's why we call dmu_write() + * below unconditionally. The page was marked + * non-dirty above and we would lose the changes + * without doing so. If the uiomove() failed + * entirely, well, we just write what we got + * before one more time. + */ dmu_write(os, zp->z_id, woff, MIN(PAGESIZE, fsize - woff), va, tx); sf_buf_free(sf); -- cgit v1.1