Home | History | Annotate | Download | only in specfs
History log of /src/sys/miscfs/specfs/specdev.h
RevisionDateAuthorComments
 1.54  22-Apr-2023  hannken Remove unused specdev member sd_rdev.

Ride 10.99.4
 1.53  26-Oct-2022  riastradh miscfs/specfs/specdev.h: New home for extern spec_vnodeop_opv_desc.

Also use it for extern spec_vnodeop_p, which is already there.
 1.52  28-Mar-2022  riastradh specfs: Reorder struct specnode members to save padding.

Shrinks from 40 bytes to 32 bytes on LP64 systems this way.
 1.51  28-Mar-2022  riastradh specfs: Let spec_node_lookup_by_dev wait for reclaim to finish.

vdevgone relies on this to ensure that if there is a concurrent
revoke in progress, it will wait for that revoke to finish -- that
way, it can guarantee all I/O operations have completed and the
device is closed.
 1.50  28-Mar-2022  riastradh specfs: Prevent new opens while close is waiting to drain.

Otherwise, bdev/cdev_close could have cancelled all _existing_ opens,
and waited for them to complete (and freed resources used by them) --
but a new one could start, and hang (e.g., a tty), at the same time
spec_close tries to drain all pending I/O operations, one of which
(the new open) is now hanging indefinitely.

Preventing the new open from even starting until bdev/cdev_close is
finished and all I/O operations have drained avoids this deadlock.
 1.49  28-Mar-2022  riastradh specfs: Drain all I/O operations after last .d_close call.

New kind of I/O reference on specdevs, sd_iocnt. This could be done
with psref instead; I chose a reference count instead for now because
we already have to take a per-object lock anyway, v_interlock, for
vdead_check, so another atomic is not likely to hurt much more. We
can always change the mechanism inside spec_io_enter/exit/drain later
on.

Make sure every access to vp->v_rdev or vp->v_specnode and every call
to a devsw operation is protected either:

- by the vnode lock (with vdead_check if we unlocked/relocked),
- by positive sd_opencnt,
- by spec_io_enter/exit, or
- by sd_opencnt management in open/close.
 1.48  28-Mar-2022  riastradh specfs: Resolve a race between close and a failing reopen.
 1.47  28-Mar-2022  riastradh specfs: Document sn_opencnt, sd_opencnt, sd_refcnt.
 1.46  18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.45  18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.44  23-Jun-2015  hannken branches: 1.44.34;
Add a vfs_newvnode() method to deadfs and use it to create
anonymous device vnodes with bdevvp() and cdevvp().

Implement spec_inactive() and spec_reclaim() to handle these nodes.
 1.43  25-Jul-2014  dholland branches: 1.43.4;
Implement spec_fdiscard() using bdev_discard() and cdev_discard().
Also define spec_fallocate() to genfs_eopnotsupp().
 1.42  30-Sep-2013  hannken branches: 1.42.2;
Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.41  21-Apr-2013  dholland branches: 1.41.4;
add missing spec_whiteout
 1.40  13-Feb-2013  hannken Make the spec_node table implementation private to spec_vnops.c.

To retrieve a spec_node, two new lookup functions (by device or by mount)
are implemented. Both return a referenced vnode, for an opened block device
the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
will not fire. Otherwise any vnode matching the criteria gets returned.

No objections on tech-kern.

Welcome to 6.99.17
 1.39  14-Nov-2009  elad branches: 1.39.2; 1.39.12; 1.39.22;
- Move kauth_init() a little bit higher.

- Add spec_init() to authorize special device actions (and passthru too for
the time being). Move policy out of secmodel_suser.
 1.38  06-Oct-2009  elad Factor out a block of code that appears in three places (Veriexec, keylock,
and securelevel) so that others can use it as well.
 1.37  29-Dec-2008  pooka Rename specfs_lock as device_lock and move it from specfs to devsw.
Relaxes kernel dependency on vfs.
 1.36  28-Apr-2008  martin branches: 1.36.8;
Remove clause 3 and 4 from TNF licenses
 1.35  25-Jan-2008  ad branches: 1.35.6; 1.35.8; 1.35.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.34  24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.33  07-Oct-2007  hannken branches: 1.33.4;
Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
 1.32  03-Aug-2007  pooka branches: 1.32.2; 1.32.4; 1.32.6; 1.32.8;
cleanup unused prototype
 1.31  22-Jul-2007  pooka Retire uvn_attach() - it abuses VXLOCK and its functionality,
setting vnode sizes, is handled elsewhere: file system vnode creation
or spec_open() for regular files or block special files, respectively.

Add a call to VOP_MMAP() to the pagedvn exec path, since the vnode
is being memory mapped.

reviewed by tech-kern & wrstuden
 1.30  14-May-2006  elad branches: 1.30.18; 1.30.28;
integrate kauth.
 1.29  11-Dec-2005  christos branches: 1.29.4; 1.29.6; 1.29.8; 1.29.10; 1.29.12;
merge ktrace-lwp.
 1.28  02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.27  30-Aug-2005  xtraeme branches: 1.27.2;
Remove __P()
 1.26  25-May-2004  hannken branches: 1.26.12;
Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
Snapshots may not be opened for writing and the attributes are read-only.
Use the mtime as the time this snapshot was taken.
Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
 1.25  14-Feb-2004  hannken Add a generic copy-on-write hook to add/remove functions that will be
called with every buffer written through spec_strategy().

Used by fss(4). Future file-system-internal snapshots will need them too.

Welcome to 1.6ZK

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
 1.24  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.23  06-Jan-2003  matt branches: 1.23.2;
Add multiple inclusion protection.
 1.22  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.21  12-May-2002  matt Extern speclisth
 1.20  17-Aug-2001  chs branches: 1.20.2;
add definitions for UBCification of block devices.
 1.19  08-Dec-1999  sommerfeld branches: 1.19.6; 1.19.8;
Add appropriate VOP_FCNTL handlers to deadfs and specfs ops vectors.
 1.18  15-Nov-1999  fvdl Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O
 1.17  01-Mar-1998  fvdl branches: 1.17.14; 1.17.16; 1.17.20;
Merge with Lite2 + local changes
 1.16  11-Apr-1997  kleink Implement a POSIX compliant genfs VOP_SEEK() and use it in the appropriate
places; by Chris G. Demetriou and myself.
 1.15  02-Apr-1997  kleink added advisory record locking support
 1.14  07-Sep-1996  mycroft Implement poll(2).
 1.13  01-Sep-1996  mycroft Add a set of generic file system operations that most file systems use.
Also, fix some time stamp bogosities.
 1.12  13-Feb-1996  mycroft GC *_nullop(). Minor nits.
 1.11  09-Feb-1996  christos miscfs prototype changes
 1.10  15-Oct-1995  mycroft Implement VOP_BWRITE() using vn_bwrite(), per r_friedl@informatik.uni-kl.de.
 1.9  13-Dec-1994  mycroft branches: 1.9.2;
Turn lease_check() into a vnode op, per CSRG.
 1.8  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.7  08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.6  22-Dec-1993  cgd fix return type of vnode print routine
 1.5  07-Sep-1993  ws Changes to VFS readdir semantics
NFS changes for better cookie support
ISOFS changes for better Rockridge support and support for generation numbers
 1.4  27-Jun-1993  andrew ANSIfications - lots of function prototyping.
 1.3  20-May-1993  cgd add rcs ids as necessary, and also clean up headers
 1.2  19-Apr-1993  mycroft Add consistent multiple-inclusion protection.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.2.1  15-Oct-1995  mycroft Update from main branch.
 1.17.20.2  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.17.20.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.17.16.2  26-Oct-1999  fvdl Merge changes in the trickle-sync and softdep code as done by Kirk McKusick
in FreeBSD since the version that we based the branch on. Merging mostly
done by Ethan Solomita <ethan@geocast.com>.

Also, make sure the syncer thread/process isn't active when we're
unmounting a filesystem. This could wreak havoc. XXX should be done
on a per-mountpoint basis, but especially the softdep code would
end up to be a big pile of vfs_busy() calls.
 1.17.16.1  19-Oct-1999  fvdl Bring in Kirk McKusick's FFS softdep code on a branch.
 1.17.14.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.19.8.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.19.8.2  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.19.8.1  10-Jul-2001  lukem add spec_kqfilter()
 1.19.6.4  07-Jan-2003  thorpej Sync with HEAD.
 1.19.6.3  11-Nov-2002  nathanw Catch up to -current
 1.19.6.2  20-Jun-2002  nathanw Catch up to -current.
 1.19.6.1  24-Aug-2001  nathanw Catch up with -current.
 1.20.2.5  01-Oct-2001  fvdl Catch up with -current.
 1.20.2.4  27-Sep-2001  fvdl Do real locking for cloned vnodes (most filesystems have real locking
for spec vnodes, so clones should have it too). Could probably do locking
all the time for spec vnodes, but need to check if vnodes created
during bootstrap with {b,c}devvp will cause trouble if they have actual
locks.
 1.20.2.3  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.20.2.2  18-Sep-2001  fvdl Various changes to make cloning devices possible:

* Add an extra argument (struct vnode **) to VOP_OPEN. If it is
not NULL, specfs will create a cloned (aliased) vnode during
the call, and return it there. The caller should release and
unlock the original vnode if a new vnode was returned. The
new vnode is returned locked.

* Add a flag field to the cdevsw and bdevsw structures.
DF_CLONING indicates that it wants a new vnode for each
open (XXX is there a better way? devprop?)

* If a device is cloning, always call the close entry
point for a VOP_CLOSE.


Also, rewrite cons.c to do the right thing with vnodes. Use VOPs
rather then direct device entry calls. Suggested by mycroft@

Light to moderate testing done an i386 system (arch doesn't matter
though, these are MI changes).
 1.20.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.23.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.23.2.1  03-Aug-2004  skrll Sync with HEAD
 1.26.12.4  04-Feb-2008  yamt sync with head.
 1.26.12.3  27-Oct-2007  yamt sync with head.
 1.26.12.2  03-Sep-2007  yamt sync with head.
 1.26.12.1  21-Jun-2006  yamt sync with head.
 1.27.2.1  20-Oct-2005  yamt adapt specfs and fifofs.
 1.29.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.29.10.1  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.29.8.1  24-May-2006  yamt sync with head.
 1.29.6.1  01-Jun-2006  kardel Sync with head.
 1.29.4.1  09-Sep-2006  rpaulo sync with head
 1.30.28.1  15-Aug-2007  skrll Sync with HEAD.
 1.30.18.3  09-Oct-2007  ad Sync with head.
 1.30.18.2  20-Aug-2007  ad Sync with HEAD.
 1.30.18.1  13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.32.8.2  03-Aug-2007  pooka cleanup unused prototype
 1.32.8.1  03-Aug-2007  pooka file specdev.h was added on branch matt-mips64 on 2007-08-03 08:50:24 +0000
 1.32.6.1  14-Oct-2007  yamt sync with head.
 1.32.4.2  23-Mar-2008  matt sync with HEAD
 1.32.4.1  06-Nov-2007  matt sync with HEAD
 1.32.2.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.2.1  03-Aug-2007  joerg file specdev.h was added on branch jmcneill-pm on 2007-10-26 15:48:57 +0000
 1.33.4.1  18-Feb-2008  mjf Sync with HEAD.
 1.35.10.3  11-Mar-2010  yamt sync with head
 1.35.10.2  04-May-2009  yamt sync with head.
 1.35.10.1  16-May-2008  yamt sync with head.
 1.35.8.1  18-May-2008  yamt sync with head.
 1.35.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.35.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.36.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.39.22.4  03-Dec-2017  jdolecek update from HEAD
 1.39.22.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.22.2  23-Jun-2013  tls resync from head
 1.39.22.1  25-Feb-2013  tls resync with head
 1.39.12.1  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.39.2.3  28-May-2010  uebayasi specdev::v_phys_addr is now specdev::v_physseg.
 1.39.2.2  28-Apr-2010  uebayasi When mounting a block device as XIP, pass registered struct vm_physseg
* as a cookie from the block device to the caller (== mount code).
struct vm_physseg * will be passed to XIP vnode pager
(genfs_do_getpages_xip()), then converted back to paddr_t.

(My future plan is to pass struct vm_physseg * back to the fault handler,
and to pmap_enter() as is.)
 1.39.2.1  23-Mar-2010  uebayasi Put run-time XIP-specific per-mount data in struct specdev, not struct mount.
 1.41.4.1  18-May-2014  rmind sync with head
 1.42.2.1  10-Aug-2014  tls Rebase.
 1.43.4.1  22-Sep-2015  skrll Sync with HEAD
 1.44.34.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed