Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/external/cddl/osnet/dist/uts/common/fs/zfs Pull up follow...



details:   https://anonhg.NetBSD.org/src/rev/96be3c65359e
branches:  netbsd-9
changeset: 1000977:96be3c65359e
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Oct 15 18:17:06 2019 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #308):

        external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c: revision 1.21
        external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c: revision 1.3
        external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c: revision 1.4
        external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h: revision 1.4

Change dmu_diff() back to use a "file" instead of a "vnode".

Command "zfs diff" calls it with a pipe, not a plain file.

Fixes PR kern/54541: kernel panic using "zfs diff"

 -

Add missing "#ifdef _KERNEL" to fix the build of userland zfs libraries.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c  |  35 ++++++++---------
 external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h   |   5 --
 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c |   4 --
 3 files changed, 17 insertions(+), 27 deletions(-)

diffs (125 lines):

diff -r e641067c3151 -r 96be3c65359e external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c     Tue Oct 15 18:13:55 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_diff.c     Tue Oct 15 18:17:06 2019 +0000
@@ -43,16 +43,13 @@
 struct diffarg {
 #ifdef __FreeBSD__
        kthread_t *da_td;
+#endif
        struct file *da_fp;             /* file to which we are reporting */
-#else
-       struct vnode *da_vp;            /* file to which we are reporting */
-#endif
        offset_t *da_offp;
        int da_err;                     /* error that stopped diff search */
        dmu_diff_record_t da_ddr;
 };
 
-#ifdef __FreeBSD__
 static int
 write_bytes(struct diffarg *da)
 {
@@ -66,18 +63,32 @@
        auio.uio_resid = aiov.iov_len;
        auio.uio_rw = UIO_WRITE;
        auio.uio_offset = (off_t)-1;
+#ifdef __FreeBSD__
        auio.uio_segflg = UIO_SYSSPACE;
        auio.uio_td = da->da_td;
+#else
 #ifdef _KERNEL
+       auio.uio_vmspace = vmspace_kernel();
+#endif
+#endif /* __FreeBSD__ */
+#ifdef _KERNEL
+#ifdef __FreeBSD__
        if (da->da_fp->f_type == DTYPE_VNODE)
                bwillwrite();
        return (fo_write(da->da_fp, &auio, da->da_td->td_ucred, 0, da->da_td));
 #else
+       int flags = 0;
+
+       if (da->da_fp->f_type == DTYPE_VNODE)
+               flags |= FOF_UPDATE_OFFSET;
+       return (*da->da_fp->f_ops->fo_write)(da->da_fp, &da->da_fp->f_offset,
+           &auio, da->da_fp->f_cred, flags);
+#endif /* __FreeBSD__ */
+#else
        fprintf(stderr, "%s: returning EOPNOTSUPP\n", __func__);
        return (EOPNOTSUPP);
 #endif
 }
-#endif /* __FreeBSD__ */
 
 static int
 write_record(struct diffarg *da)
@@ -89,13 +100,7 @@
                return (0);
        }
 
-#ifdef __FreeBSD__
        da->da_err = write_bytes(da);
-#else
-       da->da_err = vn_rdwr(UIO_WRITE, da->da_vp, (caddr_t)&da->da_ddr,
-           sizeof (da->da_ddr), 0, UIO_SYSSPACE, FAPPEND,
-           RLIM64_INFINITY, CRED(), &resid);
-#endif
        *da->da_offp += sizeof (da->da_ddr);
        return (da->da_err);
 }
@@ -193,11 +198,7 @@
 
 int
 dmu_diff(const char *tosnap_name, const char *fromsnap_name,
-#ifdef __FreeBSD__
     struct file *fp, offset_t *offp)
-#else
-    struct vnode *vp, offset_t *offp)
-#endif
 {
        struct diffarg da;
        dsl_dataset_t *fromsnap;
@@ -242,10 +243,8 @@
 
 #ifdef __FreeBSD__
        da.da_td = curthread;
+#endif
        da.da_fp = fp;
-#else
-       da.da_vp = vp;
-#endif
        da.da_offp = offp;
        da.da_ddr.ddr_type = DDR_NONE;
        da.da_ddr.ddr_first = da.da_ddr.ddr_last = 0;
diff -r e641067c3151 -r 96be3c65359e external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h      Tue Oct 15 18:13:55 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dmu.h      Tue Oct 15 18:17:06 2019 +0000
@@ -957,13 +957,8 @@
 void dmu_traverse_objset(objset_t *os, uint64_t txg_start,
     dmu_traverse_cb_t cb, void *arg);
 
-#ifdef __FreeBSD__
 int dmu_diff(const char *tosnap_name, const char *fromsnap_name,
     struct file *fp, offset_t *offp);
-#else
-int dmu_diff(const char *tosnap_name, const char *fromsnap_name,
-    struct vnode *vp, offset_t *offp);
-#endif
 
 /* CRC64 table */
 #define        ZFS_CRC64_POLY  0xC96C5795D7870F42ULL   /* ECMA-182, reflected form */
diff -r e641067c3151 -r 96be3c65359e external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c    Tue Oct 15 18:13:55 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c    Tue Oct 15 18:17:06 2019 +0000
@@ -5296,11 +5296,7 @@
 
        off = fp->f_offset;
 
-#ifdef __FreeBSD__
        error = dmu_diff(zc->zc_name, zc->zc_value, fp, &off);
-#else
-       error = dmu_diff(zc->zc_name, zc->zc_value, fp->f_vnode, &off);
-#endif
 
        if (off >= 0 && off <= MAXOFFSET_T)
                fp->f_offset = off;



Home | Main Index | Thread Index | Old Index