Bug 141177 - [zfs] fsync() on FIFO causes panic() on zfs
Summary: [zfs] fsync() on FIFO causes panic() on zfs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 8.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-04 22:40 UTC by Dominik Ernst
Modified: 2010-03-20 00:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Ernst 2009-12-04 22:40:02 UTC
Having created a FIFO on a zfs filesystem with someone reading on it, causes a panic() if you write() and fsync() on it. Seems zfs related since I could not reproduce it with a FIFO on a UFS filesystem.

Reproduced it so far on two different machines running 8.0/amd64 and once in VirtualBox using stock kernel and base system for 8.0/i386.

How-To-Repeat: mkfifo /mnt/zfs/testpipe
tail -f /mnt/zfs/testpipe &

cc test.c -o test
./test


with ./test.c being something like this:
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>

int main(void) {
        char fifo[] = "/mnt/zfs/testpipe";
        int fd;

        fd = open(fifo, O_WRONLY);
        if(fd < 0) {
                perror("open");
                return 1;
        }

        write(fd, "asdf\n", sizeof(char)*5);
        fsync(fd);

        close(fd);


        return 0;
}

alternatively vim from ports can be used too, typing something like this on an opened file:
:w >> /mnt/zfs/testpipe
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-12-04 23:07:15 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Kostik Belousov 2009-12-04 23:41:31 UTC
ZFS explicitely puts VOP_PANIC as fsync vop for fifos. I think
the following patch fixes it.

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 7608d76..4f61f5f 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
@@ -5009,7 +5009,7 @@ struct vop_vector zfs_vnodeops = {
 
 struct vop_vector zfs_fifoops = {
 	.vop_default =		&fifo_specops,
-	.vop_fsync =		VOP_PANIC,
+	.vop_fsync =		zfs_freebsd_fsync,
 	.vop_access =		zfs_freebsd_access,
 	.vop_getattr =		zfs_freebsd_getattr,
 	.vop_inactive =		zfs_freebsd_inactive,
Comment 3 dfilter service freebsd_committer freebsd_triage 2009-12-05 20:36:54 UTC
Author: kib
Date: Sat Dec  5 20:36:42 2009
New Revision: 200162
URL: http://svn.freebsd.org/changeset/base/200162

Log:
  Change VOP_FSYNC for zfs vnode from VOP_PANIC to zfs_freebsd_fsync(),
  both to not panic when fsync(2) is called for fifo on zfs
  filedescriptor, and to actually fsync fifo inode to permanent storage.
  
  PR:	kern/141177
  Reviewed by:	pjd
  MFC after:	1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Sat Dec  5 20:26:55 2009	(r200161)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Sat Dec  5 20:36:42 2009	(r200162)
@@ -5009,7 +5009,7 @@ struct vop_vector zfs_vnodeops = {
 
 struct vop_vector zfs_fifoops = {
 	.vop_default =		&fifo_specops,
-	.vop_fsync =		VOP_PANIC,
+	.vop_fsync =		zfs_freebsd_fsync,
 	.vop_access =		zfs_freebsd_access,
 	.vop_getattr =		zfs_freebsd_getattr,
 	.vop_inactive =		zfs_freebsd_inactive,
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 Dominik Ernst 2009-12-06 11:20:55 UTC
Thanks that seems to work as far as i can tell.


On Sat, 5 Dec 2009 01:41:31 +0200
Kostik Belousov <kostikbel@gmail.com> wrote:

> ZFS explicitely puts VOP_PANIC as fsync vop for fifos. I think
> the following patch fixes it.
> 
> 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
> 7608d76..4f61f5f 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 @@
> -5009,7 +5009,7 @@ struct vop_vector zfs_vnodeops = { struct
> vop_vector zfs_fifoops = { .vop_default =
> &fifo_specops,
> -	.vop_fsync =		VOP_PANIC,
> +	.vop_fsync =		zfs_freebsd_fsync,
>  	.vop_access =		zfs_freebsd_access,
>  	.vop_getattr =		zfs_freebsd_getattr,
>  	.vop_inactive =		zfs_freebsd_inactive,
>
Comment 5 Pawel Jakub Dawidek freebsd_committer freebsd_triage 2010-03-20 00:24:09 UTC
State Changed
From-To: open->closed

Problem fixed.