From owner-freebsd-emulation@FreeBSD.ORG  Tue Nov  7 17:19:42 2006
Return-Path: <owner-freebsd-emulation@FreeBSD.ORG>
X-Original-To: freebsd-emulation@FreeBSD.org
Delivered-To: freebsd-emulation@FreeBSD.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7D42A16A4CA;
	Tue,  7 Nov 2006 17:19:42 +0000 (UTC)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.176.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id ACF1043D96;
	Tue,  7 Nov 2006 17:19:10 +0000 (GMT)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (localhost [127.0.0.1])
	by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz)
	(8.13.8/8.13.7) with ESMTP id kA7HJ5e2051528
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Tue, 7 Nov 2006 18:19:05 +0100 (CET)
Received: (from xdivac02@localhost)
	by eva.fit.vutbr.cz (8.13.8/8.13.3/Submit) id kA7HJ5x7051527;
	Tue, 7 Nov 2006 18:19:05 +0100 (CET)
Date: Tue, 7 Nov 2006 18:19:04 +0100
From: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
To: Jung-uk Kim <jkim@FreeBSD.org>
Message-ID: <20061107171904.GA50772@stud.fit.vutbr.cz>
References: <20061106174033.GA70360@stud.fit.vutbr.cz>
	<17744.46794.149852.319567@gromit.timing.com>
	<200611071201.11899.jkim@FreeBSD.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200611071201.11899.jkim@FreeBSD.org>
User-Agent: Mutt/1.4.2.2i
X-Scanned-By: MIMEDefang 2.57 on 147.229.176.14
Cc: freebsd-emulation@FreeBSD.org
Subject: Re: [PATCH]: possible fix for the fifoor problem
X-BeenThere: freebsd-emulation@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Development of Emulators of other operating systems
	<freebsd-emulation.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-emulation>, 
	<mailto:freebsd-emulation-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-emulation>
List-Post: <mailto:freebsd-emulation@freebsd.org>
List-Help: <mailto:freebsd-emulation-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-emulation>, 
	<mailto:freebsd-emulation-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 07 Nov 2006 17:19:42 -0000

On Tue, Nov 07, 2006 at 12:01:07PM -0500, Jung-uk Kim wrote:
> On Tuesday 07 November 2006 11:39 am, John E Hein wrote:
> > Divacky Roman wrote at 18:40 +0100 on Nov  6, 2006:
> >  > pls test
> >  > www.stud.fit.vutbr.cz/~xdivac02/linux-fifoor.patch
> >  >
> >  > and tell me if that helps you with fifoor affected tests (dup05,
> >  > select03)
> >  >
> >  > I cannot afford panic now so I am unable to test ;( and wider
> >  > testing never hurts :)
> >
> > The patch fails against RELENG_6 and -CURRENT.
> > It is probably against a local or p4 version?
> >
> > Here's one against RELENG_6 (that should also work for current).
> >
> > Index: sys/compat/linux/linux_file.c
> > ===================================================================
> > RCS file: /base/FreeBSD-CVS/src/sys/compat/linux/linux_file.c,v
> > retrieving revision 1.91.2.1
> > diff -u -p -r1.91.2.1 linux_file.c
> > --- sys/compat/linux/linux_file.c	17 Sep 2006 10:56:15
> > -0000	1.91.2.1 +++ sys/compat/linux/linux_file.c	7 Nov 2006
> > 15:52:21 -0000 @@ -92,6 +92,7 @@ linux_open(struct thread *td,
> > struct lin struct proc *p = td->td_proc;
> >      char *path;
> >      int bsd_flags, error;
> > +    struct stat sb;
> >
> >      if (args->flags & LINUX_O_CREAT)
> >  	LCONVPATHCREAT(td, args->path, &path);
> > @@ -129,6 +130,11 @@ linux_open(struct thread *td, struct lin
> >      if (args->flags & LINUX_O_NOCTTY)
> >  	bsd_flags |= O_NOCTTY;
> >
> > +    /* linux opens RDWR fifos in a nonblocking manner */
> > +    error = kern_stat(td, path, UIO_USERSPACE, &sb);
> > +    if (S_ISFIFO(sb.st_mode) && (bsd_flags & O_RDWR))
> > +	bsd_flags |= O_NONBLOCK;
> > +
> >      error = kern_open(td, path, UIO_SYSSPACE, bsd_flags,
> > args->mode); PROC_LOCK(p);
> >      if (!error && !(bsd_flags & O_NOCTTY) &&
> >
> >
> > Anyway, after patching RELENG_6 (today's source) with the above
> > patch, I tested it with:
> >
> > - run linux-seamonkey
> > - ctrl-p to bring up print dialog box
> > - check 'Print to File'
> > - click the Print button
> > - observe hang
> >
> > '/bin/ps -o wchan,command | grep seam' shows one process in the
> > fifoor state.
 
I might made mistake.... jung-uk kim seems to have better analysis 
 
> > It is killable with ctrl-c.
> >
> > I am using linux_base-fc-4_9.
> 
> Try the attached patch instead.

the patch is wrong.... this forces NONBLOCKing on all opened files
which is wrong.

according to a comment in linux source code linux never blocks for O_RDWR
which is what I tried to implement with my patch

roman