From owner-cvs-all@FreeBSD.ORG Wed Oct 15 13:36:57 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15DFA16A4B3 for ; Wed, 15 Oct 2003 13:36:57 -0700 (PDT) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 220DC43FA3 for ; Wed, 15 Oct 2003 13:36:55 -0700 (PDT) (envelope-from nate@rootlabs.com) Received: (qmail 35245 invoked by uid 1000); 15 Oct 2003 20:36:56 -0000 Date: Wed, 15 Oct 2003 13:36:56 -0700 (PDT) From: Nate Lawson To: Poul-Henning Kamp In-Reply-To: <20031015200134.3404116A558@hub.freebsd.org> Message-ID: <20031015133353.W35236@root.org> References: <20031015200134.3404116A558@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys conf.h src/sys/fs/specfs spec_vnops.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2003 20:36:57 -0000 On Wed, 15 Oct 2003, Poul-Henning Kamp wrote: > Modified files: > sys/sys conf.h > sys/fs/specfs spec_vnops.c > Log: > Introduce a new optional memberfunction for cdevsw, fdopen() which > passes the fdidx from VOP_OPEN down. > > This is for all I know the final API for this functionality, but > the locking semantics for messing with the filedescriptor from > the device driver are not settled at this time. > > Revision Changes Path > 1.211 +7 -2 src/sys/fs/specfs/spec_vnops.c > 1.178 +2 -0 src/sys/sys/conf.h > > > Index: src/sys/fs/specfs/spec_vnops.c > diff -u src/sys/fs/specfs/spec_vnops.c:1.210 src/sys/fs/specfs/spec_vnops.c:1.211 > --- src/sys/fs/specfs/spec_vnops.c:1.210 Sat Oct 4 02:20:00 2003 > +++ src/sys/fs/specfs/spec_vnops.c Wed Oct 15 13:00:59 2003 > @@ -196,9 +196,14 @@ > VOP_UNLOCK(vp, 0, td); > if(dsw->d_flags & D_NOGIANT) { > DROP_GIANT(); > - error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); > + if (dsw->d_fdopen != NULL) > + error = dsw->d_fdopen(dev, ap->a_mode, td, ap->a_fdidx); > + else > + error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); > PICKUP_GIANT(); > - } else > + } else if (dsw->d_fdopen != NULL) > + error = dsw->d_fdopen(dev, ap->a_mode, td, ap->a_fdidx); > + else > error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); > vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); I assume this is to avoid a trip through a vnode when doing IO to a device? Can you point me at the analysis of this approach? I've heard you talking about it before but don't have a reference. > Index: src/sys/sys/conf.h > diff -u src/sys/sys/conf.h:1.177 src/sys/sys/conf.h:1.178 > --- src/sys/sys/conf.h:1.177 Sun Sep 28 13:50:36 2003 > +++ src/sys/sys/conf.h Wed Oct 15 13:00:58 2003 > @@ -145,6 +145,7 @@ > typedef struct thread d_thread_t; > > typedef int d_open_t(dev_t dev, int oflags, int devtype, struct thread *td); > +typedef int d_fdopen_t(dev_t dev, int oflags, struct thread *td, int fdidx); > typedef int d_close_t(dev_t dev, int fflag, int devtype, struct thread *td); > typedef void d_strategy_t(struct bio *bp); > typedef int d_ioctl_t(dev_t dev, u_long cmd, caddr_t data, > @@ -223,6 +224,7 @@ > u_int d_flags; > const char *d_name; > d_open_t *d_open; > + d_fdopen_t *d_fdopen; > d_close_t *d_close; > d_read_t *d_read; > d_write_t *d_write; Sure we have C99 now but for binary compatibility with third party drivers, shouldn't this be added at the end of the structure? Especially since this is an optional function. -Nate