Home | History | Annotate | Download | only in coda
History log of /src/sys/coda/coda_psdev.c
RevisionDateAuthorComments
 1.65  17-May-2024  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.64  13-Feb-2024  andvar s/enqueing/enqueuing/ in debug messages (took a bait from recent Nick's commit)
s/occaision/occasion/ in comment.
 1.63  03-Aug-2023  rin coda_call(): Appease GCC 12.3.0 -Wmisleading-indentation
No binary changes.
 1.62  03-May-2022  andvar fix various typos, mainly s/trasfering/transferring/ and s/theese/these/.
 1.61  28-Mar-2022  riastradh driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this. (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back. To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
 1.60  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.59  19-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.58  25-Oct-2017  maya branches: 1.58.16;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.57  07-Jul-2016  msaitoh branches: 1.57.8;
KNF. Remove extra spaces. No functional change.
 1.56  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.55  06-May-2015  hannken Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@
 1.54  13-Dec-2014  hannken Move the definition of NVCODA and CODA_COMPAT_5 to coda.h,
remove them from coda_vfsops.c and coda_psdev.c.
 1.53  25-Jul-2014  dholland branches: 1.53.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.52  16-Mar-2014  dholland branches: 1.52.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.51  18-Oct-2013  riz C requires a statement after a label, and a declaration is not a
statement, so create a block using {}. From christos.
 1.50  17-Oct-2013  christos move module code inside module ifdef
 1.49  04-Aug-2012  christos branches: 1.49.2; 1.49.4;
Don't increment the mount reference count here. Otherwise we are left with
refcount of one when we unmount, and vfs_destroy does not... Who is expected
to decrement this anyway?!?!
 1.48  26-Apr-2012  christos re-arrange things so that vcoda does not depend on coda.
 1.47  11-Jan-2009  christos branches: 1.47.14; 1.47.18;
merge christos-time_t
 1.46  30-Dec-2008  pooka #ifdef _LKM -> #ifndef _KERNEL_OPT
 1.45  06-May-2008  ad branches: 1.45.2; 1.45.8; 1.45.12;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
 1.44  29-Apr-2008  ad kern/38135 vfs_busy/vfs_trybusy confusion

The symptom was that sometimes file systems would occasionally not appear
in output from 'df' or 'mount' if the system was busy. Resolution:

- Make mount locks work somewhat like vm_map locks.
- vfs_trybusy() now only fails if the mount is gone, or if someone is
unmounting the file system. Simple contention on mnt_lock doesn't
cause it to fail.
- vfs_busy() will wait even if the file system is being unmounted.
 1.43  24-Apr-2008  ad branches: 1.43.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.42  21-Mar-2008  plunky branches: 1.42.2;
when queueing a message back to Venus, prioritise signals by inserting
them at the head of the queue.

The original code had a comment saying to do this but the INSQUE did
not have any way to do that so it didn't actually
 1.41  21-Mar-2008  plunky convert more insque/remque style queuing to use a queue(3) TAILQ,
this necessitates using a flag to indicate vc_open instead of abusing
the queue pointer but apart from that there is no functional
difference.
 1.40  01-Mar-2008  plunky remove some unnecessary casting
 1.39  01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.38  30-Jan-2008  ad branches: 1.38.2; 1.38.6;
PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.
 1.37  05-Dec-2007  pooka Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.36  04-Mar-2007  christos branches: 1.36.14; 1.36.16; 1.36.22; 1.36.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35  09-Feb-2007  ad branches: 1.35.2;
Merge newlock2 to head.
 1.34  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.33  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32  29-Aug-2006  christos branches: 1.32.2; 1.32.4;
Fix incomplete initializer
 1.31  11-Dec-2005  christos branches: 1.31.4; 1.31.8;
merge ktrace-lwp.
 1.30  30-Aug-2005  xtraeme oops, fix previous.
 1.29  30-Aug-2005  xtraeme * Remove __P()
* Use ANSI function declarations
 1.28  29-May-2005  christos branches: 1.28.2;
- sprinkle const
- avoid shadowed variables.
 1.27  26-Feb-2005  perry nuke trailing whitespace
 1.26  29-Jun-2003  fvdl branches: 1.26.2; 1.26.10; 1.26.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.25  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.24  24-Jan-2003  jdolecek fix typo in comment, and add (perhaps redundant) note that this depends
on file-system CODA
 1.23  06-Jan-2003  wiz interrupt with two rs.
 1.22  26-Nov-2002  christos s/si_/sel_/g
 1.21  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.20  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.19  23-Nov-2001  perry branches: 1.19.4; 1.19.8;
__FUNCTION__ -> __func__
 1.18  12-Nov-2001  lukem add RCSIDs
 1.17  18-Jul-2001  thorpej branches: 1.17.2;
bzero -> memset
 1.16  16-Apr-2001  thorpej branches: 1.16.2;
When unmounting a file system, acquire the syncer_lock before
vfs_busy'ing just before the dounmount() call. This is to avoid
sleeping with the mountlist_slock held -- but we must acquire
syncer_lock before vfs_busy because the syncer itself uses
syncer_lock -> vfs_busy locking order.
 1.15  27-Dec-2000  jdolecek branches: 1.15.2;
update commented out code to recent changes of signal structures
 1.14  22-Dec-2000  jdolecek split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.13  30-Mar-2000  augustss Kill register declarations.
 1.12  17-Oct-1999  cgd branches: 1.12.2;
nuke RCS "Log" tags. They cause problems for third parties importing
our sources, and for NetBSD release engineering folks. (They've
been against the NetBSD coding style forever, but they crept in anyway.)
 1.11  18-Sep-1999  matt branches: 1.11.2;
Make this compile on alpha again.
 1.10  29-Apr-1999  rvb Typo/braino?
 1.9  11-Nov-1998  rvb branches: 1.9.4;
Lookup now passes up an extra flag. But old veni will
be ok; new veni will check /dev/cfs0 to make sure that a new
kernel is running.
Also, a bug in vc_nb_close iff CODA_SIGNAL's were seen has been
fixed.
 1.8  09-Nov-1998  rvb Change the way unmounting happens to guarantee that the
client programs are allowed to finish up (coda_call is
forced to complete) and release their locks. Thus there
is a reasonable chance that the vflush implicit in the
unmount will not get hung on held locks.
 1.7  28-Sep-1998  rvb I want to distinguish from DEBUG printouts and CODA_VERBOSE printouts.
The latter are normal informational messages that are sometimes
interesting to view.
 1.6  26-Sep-1998  tv DIAGNOSTIC -> DEBUG for all non-panic messages. DIAGNOSTIC is only for
sanity checks and should not turn on any messages not already printed
without it.
 1.5  25-Sep-1998  rvb Conditionalize "stray" printouts under DIAGNOSTIC and DEBUG.
Make files compile if DEBUG is on (from Alan Barrett). Finally,
make coda an lkm.
 1.4  15-Sep-1998  rvb Final piece of rename cfs->coda
 1.3  12-Sep-1998  rvb Change cfs/CFS in symbols, strings and constants to coda/CODA
to avoid fs conflicts.
 1.2  08-Sep-1998  rvb Pass2 complete
 1.1  29-Aug-1998  rvb branches: 1.1.1;
Initial revision
 1.1.1.1  29-Aug-1998  rvb Very Preliminary Coda
 1.9.4.1  29-Apr-1999  rvb branches: 1.9.4.1.2;
pullup 1.9->1.10 (rvb)
 1.9.4.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.2.3  21-Apr-2001  bouyer Sync with HEAD
 1.12.2.2  05-Jan-2001  bouyer Sync with HEAD
 1.12.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.2.10  07-Jan-2003  thorpej Sync with HEAD.
 1.15.2.9  11-Dec-2002  thorpej Sync with HEAD.
 1.15.2.8  11-Nov-2002  nathanw Catch up to -current
 1.15.2.7  17-Sep-2002  nathanw Catch up to -current.
 1.15.2.6  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.15.2.5  08-Jan-2002  nathanw Catch up to -current.
 1.15.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.15.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.15.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.15.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.16.2.5  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.16.2.4  02-Oct-2002  jdolecek fix mistake in filt_*() - mistakely used kn_data rather than kn_hook
drop (void *) casts for kn_hook which are not needed anymore
 1.16.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.16.2.2  08-Sep-2001  thorpej Add kqueue support.
 1.16.2.1  03-Aug-2001  lukem update to -current
 1.17.2.3  01-Oct-2001  fvdl Catch up with -current.
 1.17.2.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.17.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.19.8.1  16-May-2002  gehenna Add the character device switch.
 1.19.4.1  11-Mar-2002  thorpej Make syncer_lock an adaptive mutex and rename it to syncer_mutex.
 1.26.12.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.10.1  29-Apr-2005  kent sync with -current
 1.26.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.26.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.26.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.28.2.8  24-Mar-2008  yamt sync with head.
 1.28.2.7  17-Mar-2008  yamt sync with head.
 1.28.2.6  04-Feb-2008  yamt sync with head.
 1.28.2.5  07-Dec-2007  yamt sync with head
 1.28.2.4  03-Sep-2007  yamt sync with head.
 1.28.2.3  26-Feb-2007  yamt sync with head.
 1.28.2.2  30-Dec-2006  yamt sync with head.
 1.28.2.1  21-Jun-2006  yamt sync with head.
 1.31.8.1  03-Sep-2006  yamt sync with head.
 1.31.4.1  09-Sep-2006  rpaulo sync with head
 1.32.4.2  10-Dec-2006  yamt sync with head.
 1.32.4.1  22-Oct-2006  yamt sync with head
 1.32.2.5  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.32.2.4  29-Dec-2006  ad Checkpoint work in progress.
 1.32.2.3  18-Nov-2006  ad Sync with head.
 1.32.2.2  17-Nov-2006  ad Checkpoint work in progress.
 1.32.2.1  20-Oct-2006  ad syncer_lock -> syncer_mutex
 1.35.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.36.24.1  08-Dec-2007  ad Sync with head.
 1.36.22.2  18-Feb-2008  mjf Sync with HEAD.
 1.36.22.1  08-Dec-2007  mjf Sync with HEAD.
 1.36.16.2  23-Mar-2008  matt sync with HEAD
 1.36.16.1  09-Jan-2008  matt sync with HEAD
 1.36.14.1  09-Dec-2007  jmcneill Sync with HEAD.
 1.38.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.38.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.38.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.38.2.1  24-Mar-2008  keiichi sync with head.
 1.42.2.1  18-May-2008  yamt sync with head.
 1.43.2.2  04-May-2009  yamt sync with head.
 1.43.2.1  16-May-2008  yamt sync with head.
 1.45.12.3  30-Dec-2008  christos sync with head.
 1.45.12.2  09-Nov-2008  christos account for major and minor being unsigned long long
 1.45.12.1  06-May-2008  christos file coda_psdev.c was added on branch christos-time_t on 2008-11-09 01:58:50 +0000
 1.45.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.45.2.2  14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.45.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.47.18.1  29-Apr-2012  mrg sync to latest -current.
 1.47.14.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.14.2  30-Oct-2012  yamt sync with head
 1.47.14.1  23-May-2012  yamt sync with head.
 1.49.4.1  18-May-2014  rmind sync with head
 1.49.2.2  03-Dec-2017  jdolecek update from HEAD
 1.49.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.2.1  10-Aug-2014  tls Rebase.
 1.53.4.4  09-Jul-2016  skrll Sync with HEAD
 1.53.4.3  22-Sep-2015  skrll Sync with HEAD
 1.53.4.2  06-Jun-2015  skrll Sync with HEAD
 1.53.4.1  06-Apr-2015  skrll Sync with HEAD
 1.57.8.2  29-Apr-2017  pgoyette Revise previous. Rather than explicitly including <sys/localcount.h>
in all the places where {b,c}devsw is initialized, just include it
from <sys/conf.h>. This avoids an include-sequence dependancy.
 1.57.8.1  29-Apr-2017  pgoyette Add DEVSW_MODULE_INIT to existing device-driver modules, so that they
willl have a localcount defined and thus be permitted to load. Without
a localcount, loading the module will return EINVAL.

XXX the dtrace and drm stuff might need to be fed back upstream?
 1.58.16.1  03-Jan-2021  thorpej Sync w/ HEAD.

RSS XML Feed