From owner-freebsd-fs@FreeBSD.ORG Sun Oct 25 16:00:18 2009 Return-Path: Delivered-To: freebsd-fs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4D271065676 for ; Sun, 25 Oct 2009 16:00:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D3E1A8FC13 for ; Sun, 25 Oct 2009 16:00:18 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n9PG0IiN019964 for ; Sun, 25 Oct 2009 16:00:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n9PG0IeL019956; Sun, 25 Oct 2009 16:00:18 GMT (envelope-from gnats) Date: Sun, 25 Oct 2009 16:00:18 GMT Message-Id: <200910251600.n9PG0IeL019956@freefall.freebsd.org> To: freebsd-fs@FreeBSD.org From: Carl Chave Cc: Subject: Re: kern/139806: [zfs] [panic] Write attempt to file in ZFS snapshot dir causes panic X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Carl Chave List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 16:00:19 -0000 The following reply was made to PR kern/139806; it has been noted by GNATS. From: Carl Chave To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/139806: [zfs] [panic] Write attempt to file in ZFS snapshot dir causes panic Date: Sun, 25 Oct 2009 10:47:40 -0400 Rebuilt zfs.ko using: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c (version 197861 + this patch) head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c (version 197861) head/sys/cddl/compat/opensolaris/sys/policy.h (version 197861) Resulting zfs.ko works as expected and does not panic when attempting to modify an existing snapshot file as described in the original PR. On Thu, Oct 22, 2009 at 3:50 PM, Jaakko Heinonen wrote: > > Hi, > > On 2009-10-21, Carl Chave wrote: >> Fixit# echo hello >> test.txt >> panic: dirtying snapshot! > > The problem seems to be that in certain conditions zfs_freebsd_access() > uses only vaccess(9) for access check. However vaccess(9) doesn't handle > the read-only file system case. > > Could you try this patch? > > --- patch begins here --- > Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c =A0(revisi= on 198368) > +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c =A0(workin= g copy) > @@ -3989,7 +3989,12 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct thread *a_td; > =A0 =A0 =A0 =A0} */ *ap; > =A0{ > + =A0 =A0 =A0 int error; > > + =A0 =A0 =A0 error =3D zfs_access(ap->a_vp, ap->a_accmode, 0, ap->a_cred= , NULL); > + =A0 =A0 =A0 if (error !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (error); > + > =A0 =A0 =A0 =A0/* > =A0 =A0 =A0 =A0 * ZFS itself only knowns about VREAD, VWRITE and VEXEC, t= he rest > =A0 =A0 =A0 =A0 * we have to handle by calling vaccess(). > @@ -3999,11 +4004,11 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0znode_t *zp =3D VTOZ(vp); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0znode_phys_t *zphys =3D zp->z_phys; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (vaccess(vp->v_type, zphys->zp_mode,= zphys->zp_uid, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zphys->zp_gid, ap->a_accmode, ap->a= _cred, NULL)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D vaccess(vp->v_type, zphys->zp_mod= e, zphys->zp_uid, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 zphys->zp_gid, ap->a_accmode, ap->a= _cred, NULL); > =A0 =A0 =A0 =A0} > > - =A0 =A0 =A0 return (zfs_access(ap->a_vp, ap->a_accmode, 0, ap->a_cred, = NULL)); > + =A0 =A0 =A0 return (error); > =A0} > > =A0static int > --- patch ends here --- > > -- > Jaakko >