FreeBSD kernel kern code
vfs_vnops.c File Reference
#include <sys/cdefs.h>
#include "opt_hwpmc_hooks.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/disk.h>
#include <sys/fail.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/kdb.h>
#include <sys/ktr.h>
#include <sys/stat.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/filio.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/prng.h>
#include <sys/sx.h>
#include <sys/sleepqueue.h>
#include <sys/sysctl.h>
#include <sys/ttycom.h>
#include <sys/conf.h>
#include <sys/syslog.h>
#include <sys/unistd.h>
#include <sys/user.h>
#include <sys/ktrace.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
Include dependency graph for vfs_vnops.c:

Go to the source code of this file.

Data Structures

struct  vn_io_fault_args
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_INT (_debug, OID_AUTO, vn_io_fault_enable, CTLFLAG_RWTUN, &vn_io_fault_enable, 0, "Enable vn_io_fault lock avoidance")
 
 SYSCTL_INT (_debug, OID_AUTO, vn_io_fault_prefault, CTLFLAG_RWTUN, &vn_io_fault_prefault, 0, "Enable vn_io_fault prefaulting")
 
 SYSCTL_INT (_debug, OID_AUTO, vn_io_pgcache_read_enable, CTLFLAG_RWTUN, &vn_io_pgcache_read_enable, 0, "Enable copying from page cache for reads, avoiding fs")
 
 SYSCTL_ULONG (_debug, OID_AUTO, vn_io_faults, CTLFLAG_RD, &vn_io_faults_cnt, 0, "Count of vn_io_fault lock avoidance triggers")
 
 SYSCTL_INT (_security_bsd, OID_AUTO, allow_read_dir, CTLFLAG_RW, &vfs_allow_read_dir, 0, "Enable read(2) of directory by root for filesystems that support it")
 
static bool do_vn_io_fault (struct vnode *vp, struct uio *uio)
 
static int vn_io_fault1 (struct vnode *vp, struct uio *uio, struct vn_io_fault_args *args, struct thread *td)
 
int vn_open (struct nameidata *ndp, int *flagp, int cmode, struct file *fp)
 
static uint64_t open2nameif (int fmode, u_int vn_open_flags)
 
int vn_open_cred (struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags, struct ucred *cred, struct file *fp)
 
static int vn_open_vnode_advlock (struct vnode *vp, int fmode, struct file *fp)
 
int vn_open_vnode (struct vnode *vp, int fmode, struct ucred *cred, struct thread *td, struct file *fp)
 
int vn_writechk (struct vnode *vp)
 
static int vn_close1 (struct vnode *vp, int flags, struct ucred *file_cred, struct thread *td, bool keep_ref)
 
int vn_close (struct vnode *vp, int flags, struct ucred *file_cred, struct thread *td)
 
static int sequential_heuristic (struct uio *uio, struct file *fp)
 
int vn_rdwr (enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset, enum uio_seg segflg, int ioflg, struct ucred *active_cred, struct ucred *file_cred, ssize_t *aresid, struct thread *td)
 
int vn_rdwr_inchunks (enum uio_rw rw, struct vnode *vp, void *base, size_t len, off_t offset, enum uio_seg segflg, int ioflg, struct ucred *active_cred, struct ucred *file_cred, size_t *aresid, struct thread *td)
 
off_t foffset_lock (struct file *fp, int flags)
 
void foffset_unlock (struct file *fp, off_t val, int flags)
 
void foffset_lock_uio (struct file *fp, struct uio *uio, int flags)
 
void foffset_unlock_uio (struct file *fp, struct uio *uio, int flags)
 
static int get_advice (struct file *fp, struct uio *uio)
 
static int get_write_ioflag (struct file *fp)
 
int vn_read_from_obj (struct vnode *vp, struct uio *uio)
 
static int vn_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int vn_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int vn_io_fault_doio (struct vn_io_fault_args *args, struct uio *uio, struct thread *td)
 
static int vn_io_fault_touch (char *base, const struct uio *uio)
 
static int vn_io_fault_prefault_user (const struct uio *uio)
 
static int vn_io_fault (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
int vn_io_fault_uiomove (char *data, int xfersize, struct uio *uio)
 
int vn_io_fault_pgmove (vm_page_t ma[], vm_offset_t offset, int xfersize, struct uio *uio)
 
static int vn_truncate (struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
 
int vn_truncate_locked (struct vnode *vp, off_t length, bool sync, struct ucred *cred)
 
int vn_statfile (struct file *fp, struct stat *sb, struct ucred *active_cred)
 
static int vn_ioctl (struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td)
 
static int vn_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static int __noinline _vn_lock_fallback (struct vnode *vp, int flags, const char *file, int line, int error)
 
int _vn_lock (struct vnode *vp, int flags, const char *file, int line)
 
static int vn_closefile (struct file *fp, struct thread *td)
 
static int vn_start_write_refed (struct mount *mp, int flags, bool mplocked)
 
int vn_start_write (struct vnode *vp, struct mount **mpp, int flags)
 
int vn_start_secondary_write (struct vnode *vp, struct mount **mpp, int flags)
 
void vn_finished_write (struct mount *mp)
 
void vn_finished_secondary_write (struct mount *mp)
 
int vfs_write_suspend (struct mount *mp, int flags)
 
void vfs_write_resume (struct mount *mp, int flags)
 
int vfs_write_suspend_umnt (struct mount *mp)
 
static int vn_kqfilter (struct file *fp, struct knote *kn)
 
int vn_kqfilter_opath (struct file *fp, struct knote *kn)
 
int vn_extattr_get (struct vnode *vp, int ioflg, int attrnamespace, const char *attrname, int *buflen, char *buf, struct thread *td)
 
int vn_extattr_set (struct vnode *vp, int ioflg, int attrnamespace, const char *attrname, int buflen, char *buf, struct thread *td)
 
int vn_extattr_rm (struct vnode *vp, int ioflg, int attrnamespace, const char *attrname, struct thread *td)
 
static int vn_get_ino_alloc_vget (struct mount *mp, void *arg, int lkflags, struct vnode **rvp)
 
int vn_vget_ino (struct vnode *vp, ino_t ino, int lkflags, struct vnode **rvp)
 
int vn_vget_ino_gen (struct vnode *vp, vn_get_ino_t alloc, void *alloc_arg, int lkflags, struct vnode **rvp)
 
int vn_rlimit_fsize (const struct vnode *vp, const struct uio *uio, struct thread *td)
 
int vn_chmod (struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
 
int vn_chown (struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
 
void vn_pages_remove (struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
 
void vn_pages_remove_valid (struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
 
int vn_bmap_seekhole_locked (struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred)
 
int vn_bmap_seekhole (struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred)
 
int vn_seek (struct file *fp, off_t offset, int whence, struct thread *td)
 
int vn_utimes_perm (struct vnode *vp, struct vattr *vap, struct ucred *cred, struct thread *td)
 
int vn_fill_kinfo (struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 
static void vn_fill_junk (struct kinfo_file *kif)
 
int vn_fill_kinfo_vnode (struct vnode *vp, struct kinfo_file *kif)
 
int vn_mmap (struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, vm_prot_t cap_maxprot, int flags, vm_ooffset_t foff, struct thread *td)
 
void vn_fsid (struct vnode *vp, struct vattr *va)
 
int vn_fsync_buf (struct vnode *vp, int waitfor)
 
int vn_copy_file_range (struct vnode *invp, off_t *inoffp, struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags, struct ucred *incred, struct ucred *outcred, struct thread *fsize_td)
 
static bool mem_iszero (void *dat, int len)
 
static off_t vn_skip_hole (struct vnode *outvp, off_t xfer2, off_t *outoffp, off_t *xferp, off_t *dataoffp, off_t *holeoffp, struct ucred *cred)
 
static int vn_write_outvp (struct vnode *outvp, char *dat, off_t outoff, off_t xfer, u_long blksize, bool growfile, bool checkhole, struct ucred *cred)
 
int vn_generic_copy_file_range (struct vnode *invp, off_t *inoffp, struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags, struct ucred *incred, struct ucred *outcred, struct thread *fsize_td)
 
static int vn_fallocate (struct file *fp, off_t offset, off_t len, struct thread *td)
 
static int vn_deallocate_impl (struct vnode *vp, off_t *offset, off_t *length, int flags, int ioflag, struct ucred *cred, struct ucred *active_cred, struct ucred *file_cred)
 
int vn_deallocate (struct vnode *vp, off_t *offset, off_t *length, int flags, int ioflag, struct ucred *active_cred, struct ucred *file_cred)
 
static int vn_fspacectl (struct file *fp, int cmd, off_t *offset, off_t *length, int flags, struct ucred *active_cred, struct thread *td)
 
 SYSCTL_ULONG (_debug, OID_AUTO, vn_lock_pair_pause, CTLFLAG_RD, &vn_lock_pair_pause_cnt, 0, "Count of vn_lock_pair deadlocks")
 
 SYSCTL_UINT (_debug, OID_AUTO, vn_lock_pair_pause_max, CTLFLAG_RW, &vn_lock_pair_pause_max, 0, "Max ticks for vn_lock_pair deadlock avoidance sleep")
 
static void vn_lock_pair_pause (const char *wmesg)
 
void vn_lock_pair (struct vnode *vp1, bool vp1_locked, struct vnode *vp2, bool vp2_locked)
 
int vn_lktype_write (struct mount *mp, struct vnode *vp)
 

Variables

static fo_rdwr_t vn_read
 
static fo_rdwr_t vn_write
 
static fo_rdwr_t vn_io_fault
 
static fo_truncate_t vn_truncate
 
static fo_ioctl_t vn_ioctl
 
static fo_poll_t vn_poll
 
static fo_kqfilter_t vn_kqfilter
 
static fo_close_t vn_closefile
 
static fo_mmap_t vn_mmap
 
static fo_fallocate_t vn_fallocate
 
static fo_fspacectl_t vn_fspacectl
 
struct fileops vnops
 
const u_int io_hold_cnt = 16
 
static int vn_io_fault_enable = 1
 
static int vn_io_fault_prefault = 0
 
static int vn_io_pgcache_read_enable = 1
 
static u_long vn_io_faults_cnt
 
static int vfs_allow_read_dir = 0
 
static u_long vn_lock_pair_pause_cnt
 
u_int vn_lock_pair_pause_max
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _vn_lock()

int _vn_lock ( struct vnode *  vp,
int  flags,
const char *  file,
int  line 
)

Definition at line 1804 of file vfs_vnops.c.

References _vn_lock_fallback(), and flags.

Here is the call graph for this function:

◆ _vn_lock_fallback()

static int __noinline _vn_lock_fallback ( struct vnode *  vp,
int  flags,
const char *  file,
int  line,
int  error 
)
static

Definition at line 1767 of file vfs_vnops.c.

References flags.

Referenced by _vn_lock().

Here is the caller graph for this function:

◆ do_vn_io_fault()

static bool do_vn_io_fault ( struct vnode *  vp,
struct uio *  uio 
)
static

Definition at line 156 of file vfs_vnops.c.

References vn_io_fault_enable.

Referenced by vn_io_fault(), and vn_rdwr().

Here is the caller graph for this function:

◆ foffset_lock()

off_t foffset_lock ( struct file *  fp,
int  flags 
)

Definition at line 757 of file vfs_vnops.c.

References flags, vn_io_fault_args::fp, res, sleepq_add(), sleepq_lock(), sleepq_release(), and sleepq_wait().

Referenced by foffset_lock_uio(), kern_getdirentries(), shm_seek(), and vn_seek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foffset_lock_uio()

void foffset_lock_uio ( struct file *  fp,
struct uio *  uio,
int  flags 
)

Definition at line 884 of file vfs_vnops.c.

References flags, and foffset_lock().

Referenced by shm_read(), shm_write(), and vn_io_fault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foffset_unlock()

void foffset_unlock ( struct file *  fp,
off_t  val,
int  flags 
)

Definition at line 803 of file vfs_vnops.c.

References flags, vn_io_fault_args::fp, sleepq_broadcast(), sleepq_lock(), and sleepq_release().

Referenced by foffset_unlock_uio(), kern_getdirentries(), shm_seek(), and vn_seek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ foffset_unlock_uio()

void foffset_unlock_uio ( struct file *  fp,
struct uio *  uio,
int  flags 
)

Definition at line 892 of file vfs_vnops.c.

References flags, and foffset_unlock().

Referenced by shm_read(), shm_write(), and vn_io_fault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_advice()

static int get_advice ( struct file *  fp,
struct uio *  uio 
)
static

Definition at line 900 of file vfs_vnops.c.

References mtx, mtx_pool_find(), and mtxpool_sleep.

Referenced by vn_read(), and vn_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_write_ioflag()

static int get_write_ioflag ( struct file *  fp)
static

Definition at line 920 of file vfs_vnops.c.

Referenced by vn_fspacectl(), and vn_write().

Here is the caller graph for this function:

◆ mem_iszero()

static bool mem_iszero ( void *  dat,
int  len 
)
static

Definition at line 2998 of file vfs_vnops.c.

Referenced by vn_generic_copy_file_range().

Here is the caller graph for this function:

◆ open2nameif()

static uint64_t open2nameif ( int  fmode,
u_int  vn_open_flags 
)
static

Definition at line 199 of file vfs_vnops.c.

References res.

Referenced by vn_open_cred().

Here is the caller graph for this function:

◆ sequential_heuristic()

static int sequential_heuristic ( struct uio *  uio,
struct file *  fp 
)
static

Definition at line 564 of file vfs_vnops.c.

Referenced by vn_read(), and vn_write().

Here is the caller graph for this function:

◆ SYSCTL_INT() [1/4]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
vn_io_fault_enable  ,
CTLFLAG_RWTUN  ,
vn_io_fault_enable,
,
"Enable vn_io_fault lock avoidance"   
)

◆ SYSCTL_INT() [2/4]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
vn_io_fault_prefault  ,
CTLFLAG_RWTUN  ,
vn_io_fault_prefault,
,
"Enable vn_io_fault prefaulting"   
)

◆ SYSCTL_INT() [3/4]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
vn_io_pgcache_read_enable  ,
CTLFLAG_RWTUN  ,
vn_io_pgcache_read_enable,
,
"Enable copying from page cache for  reads,
avoiding fs"   
)

◆ SYSCTL_INT() [4/4]

SYSCTL_INT ( _security_bsd  ,
OID_AUTO  ,
allow_read_dir  ,
CTLFLAG_RW  ,
vfs_allow_read_dir,
,
"Enable read(2) of directory by root for filesystems that support it"   
)

◆ SYSCTL_UINT()

SYSCTL_UINT ( _debug  ,
OID_AUTO  ,
vn_lock_pair_pause_max  ,
CTLFLAG_RW  ,
vn_lock_pair_pause_max,
,
"Max ticks for vn_lock_pair deadlock avoidance sleep"   
)

◆ SYSCTL_ULONG() [1/2]

SYSCTL_ULONG ( _debug  ,
OID_AUTO  ,
vn_io_faults  ,
CTLFLAG_RD  ,
vn_io_faults_cnt,
,
"Count of vn_io_fault lock avoidance triggers"   
)

◆ SYSCTL_ULONG() [2/2]

SYSCTL_ULONG ( _debug  ,
OID_AUTO  ,
vn_lock_pair_pause  ,
CTLFLAG_RD  ,
vn_lock_pair_pause_cnt,
,
"Count of vn_lock_pair deadlocks"   
)

◆ vfs_write_resume()

void vfs_write_resume ( struct mount *  mp,
int  flags 
)

Definition at line 2114 of file vfs_vnops.c.

References flags, vfs_op_exit(), vn_start_write_refed(), and wakeup().

Referenced by resume_all_fs(), and vfs_write_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vfs_write_suspend()

int vfs_write_suspend ( struct mount *  mp,
int  flags 
)

Definition at line 2065 of file vfs_vnops.c.

References flags, vfs_op_enter(), vfs_op_exit_locked(), and vfs_write_resume().

Referenced by suspend_all_fs(), and vfs_write_suspend_umnt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vfs_write_suspend_umnt()

int vfs_write_suspend_umnt ( struct mount *  mp)

Definition at line 2147 of file vfs_vnops.c.

References vfs_write_suspend(), vn_finished_write(), vn_start_write(), and wakeup().

Here is the call graph for this function:

◆ vn_bmap_seekhole()

int vn_bmap_seekhole ( struct vnode *  vp,
u_long  cmd,
off_t *  off,
struct ucred *  cred 
)

Definition at line 2520 of file vfs_vnops.c.

References vn_bmap_seekhole_locked().

Here is the call graph for this function:

◆ vn_bmap_seekhole_locked()

int vn_bmap_seekhole_locked ( struct vnode *  vp,
u_long  cmd,
off_t *  off,
struct ucred *  cred 
)

Definition at line 2467 of file vfs_vnops.c.

Referenced by vn_bmap_seekhole(), and vop_stddeallocate().

Here is the caller graph for this function:

◆ vn_chmod()

int vn_chmod ( struct file *  fp,
mode_t  mode,
struct ucred *  active_cred,
struct thread *  td 
)

Definition at line 2403 of file vfs_vnops.c.

References mode, and setfmode().

Referenced by pipe_chmod().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_chown()

int vn_chown ( struct file *  fp,
uid_t  uid,
gid_t  gid,
struct ucred *  active_cred,
struct thread *  td 
)

Definition at line 2418 of file vfs_vnops.c.

References setfown().

Referenced by pipe_chown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_close()

int vn_close ( struct vnode *  vp,
int  flags,
struct ucred *  file_cred,
struct thread *  td 
)

Definition at line 553 of file vfs_vnops.c.

References flags, and vn_close1().

Referenced by acct_disable(), alq_shutdown(), coredump(), corefile_open_last(), link_elf_ctf_get(), link_elf_load_file(), linker_hints_lookup(), linker_lookup_file(), sys_acct(), sys_ktrace(), vfs_mountroot_readconf(), vnode_close_locked(), and vop_stdvptocnp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_close1()

static int vn_close1 ( struct vnode *  vp,
int  flags,
struct ucred *  file_cred,
struct thread *  td,
bool  keep_ref 
)
static

Definition at line 523 of file vfs_vnops.c.

References flags, vn_finished_write(), vn_start_write(), and vput().

Referenced by vn_close(), and vn_closefile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_closefile()

static int vn_closefile ( struct file *  fp,
struct thread *  td 
)
static

Definition at line 1821 of file vfs_vnops.c.

References badfileops, vn_close1(), and vrele().

Here is the call graph for this function:

◆ vn_copy_file_range()

int vn_copy_file_range ( struct vnode *  invp,
off_t *  inoffp,
struct vnode *  outvp,
off_t *  outoffp,
size_t *  lenp,
unsigned int  flags,
struct ucred *  incred,
struct ucred *  outcred,
struct thread *  fsize_td 
)

Definition at line 2943 of file vfs_vnops.c.

References flags, and vn_generic_copy_file_range().

Referenced by kern_copy_file_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_deallocate()

int vn_deallocate ( struct vnode *  vp,
off_t *  offset,
off_t *  length,
int  flags,
int  ioflag,
struct ucred *  active_cred,
struct ucred *  file_cred 
)

Definition at line 3584 of file vfs_vnops.c.

References flags, and vn_deallocate_impl().

Here is the call graph for this function:

◆ vn_deallocate_impl()

static int vn_deallocate_impl ( struct vnode *  vp,
off_t *  offset,
off_t *  length,
int  flags,
int  ioflag,
struct ucred *  cred,
struct ucred *  active_cred,
struct ucred *  file_cred 
)
static

Definition at line 3510 of file vfs_vnops.c.

References bwillwrite(), flags, maybe_yield(), vn_finished_write(), vn_lktype_write(), and vn_start_write().

Referenced by vn_deallocate(), and vn_fspacectl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_extattr_get()

int vn_extattr_get ( struct vnode *  vp,
int  ioflg,
int  attrnamespace,
const char *  attrname,
int *  buflen,
char *  buf,
struct thread *  td 
)

Definition at line 2199 of file vfs_vnops.c.

References attrnamespace, and buf.

◆ vn_extattr_rm()

int vn_extattr_rm ( struct vnode *  vp,
int  ioflg,
int  attrnamespace,
const char *  attrname,
struct thread *  td 
)

Definition at line 2279 of file vfs_vnops.c.

References attrnamespace, vn_finished_write(), and vn_start_write().

Here is the call graph for this function:

◆ vn_extattr_set()

int vn_extattr_set ( struct vnode *  vp,
int  ioflg,
int  attrnamespace,
const char *  attrname,
int  buflen,
char *  buf,
struct thread *  td 
)

Definition at line 2240 of file vfs_vnops.c.

References attrnamespace, buf, vn_finished_write(), and vn_start_write().

Here is the call graph for this function:

◆ vn_fallocate()

static int vn_fallocate ( struct file *  fp,
off_t  offset,
off_t  len,
struct thread *  td 
)
static

Definition at line 3452 of file vfs_vnops.c.

References bwillwrite(), maybe_yield(), panic(), vn_finished_write(), and vn_start_write().

Here is the call graph for this function:

◆ vn_fill_junk()

static void vn_fill_junk ( struct kinfo_file *  kif)
inlinestatic

Definition at line 2650 of file vfs_vnops.c.

Referenced by vn_fill_kinfo_vnode().

Here is the caller graph for this function:

◆ vn_fill_kinfo()

int vn_fill_kinfo ( struct file *  fp,
struct kinfo_file *  kif,
struct filedesc *  fdp 
)

Definition at line 2631 of file vfs_vnops.c.

References vn_fill_kinfo_vnode(), vref(), and vrele().

Referenced by pipe_fill_kinfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_fill_kinfo_vnode()

int vn_fill_kinfo_vnode ( struct vnode *  vp,
struct kinfo_file *  kif 
)

Definition at line 2668 of file vfs_vnops.c.

References free(), vn_fill_junk(), vn_fullpath(), and vntype_to_kinfo().

Referenced by export_vnode_to_kinfo(), and vn_fill_kinfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_finished_secondary_write()

void vn_finished_secondary_write ( struct mount *  mp)

Definition at line 2046 of file vfs_vnops.c.

References panic(), and wakeup().

Referenced by vgonel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_finished_write()

◆ vn_fsid()

void vn_fsid ( struct vnode *  vp,
struct vattr *  va 
)

Definition at line 2829 of file vfs_vnops.c.

◆ vn_fspacectl()

static int vn_fspacectl ( struct file *  fp,
int  cmd,
off_t *  offset,
off_t *  length,
int  flags,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 3601 of file vfs_vnops.c.

References flags, get_write_ioflag(), panic(), and vn_deallocate_impl().

Here is the call graph for this function:

◆ vn_fsync_buf()

int vn_fsync_buf ( struct vnode *  vp,
int  waitfor 
)

Definition at line 2840 of file vfs_vnops.c.

References bawrite(), bremfree(), buf, bufobj_wwait(), hz, panic(), vfs_bio_awrite(), and vn_printf().

Referenced by vop_stdfdatasync_buf(), and vop_stdfsync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_generic_copy_file_range()

int vn_generic_copy_file_range ( struct vnode *  invp,
off_t *  inoffp,
struct vnode *  outvp,
off_t *  outoffp,
size_t *  lenp,
unsigned int  flags,
struct ucred *  incred,
struct ucred *  outcred,
struct thread *  fsize_td 
)

Definition at line 3167 of file vfs_vnops.c.

References flags, free(), getnanouptime(), malloc(), mem_iszero(), sig_intr(), vn_finished_write(), vn_rdwr(), vn_rlimit_fsize(), vn_start_write(), vn_truncate_locked(), and vn_write_outvp().

Referenced by vn_copy_file_range(), and vop_stdcopy_file_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_get_ino_alloc_vget()

static int vn_get_ino_alloc_vget ( struct mount *  mp,
void *  arg,
int  lkflags,
struct vnode **  rvp 
)
static

Definition at line 2308 of file vfs_vnops.c.

Referenced by vn_vget_ino().

Here is the caller graph for this function:

◆ vn_io_fault()

static int vn_io_fault ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

◆ vn_io_fault1()

static int vn_io_fault1 ( struct vnode *  vp,
struct uio *  uio,
struct vn_io_fault_args args,
struct thread *  td 
)
static

Definition at line 1327 of file vfs_vnops.c.

References addr, cloneuio(), free(), io_hold_cnt, uiomove(), vn_io_fault_doio(), vn_io_fault_prefault, vn_io_fault_prefault_user(), and vn_io_faults_cnt.

Referenced by vn_io_fault(), and vn_rdwr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_io_fault_doio()

static int vn_io_fault_doio ( struct vn_io_fault_args args,
struct uio *  uio,
struct thread *  td 
)
static

Definition at line 1237 of file vfs_vnops.c.

References vn_io_fault_args::args, vn_io_fault_args::cred, vn_io_fault_args::flags, vn_io_fault_args::fop_args, vn_io_fault_args::kind, panic(), and vn_io_fault_args::vop_args.

Referenced by vn_io_fault1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_io_fault_pgmove()

int vn_io_fault_pgmove ( vm_page_t  ma[],
vm_offset_t  offset,
int  xfersize,
struct uio *  uio 
)

Definition at line 1564 of file vfs_vnops.c.

Referenced by vn_read_from_obj().

Here is the caller graph for this function:

◆ vn_io_fault_prefault_user()

static int vn_io_fault_prefault_user ( const struct uio *  uio)
static

Definition at line 1278 of file vfs_vnops.c.

References vn_io_fault_touch().

Referenced by vn_io_fault1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_io_fault_touch()

static int vn_io_fault_touch ( char *  base,
const struct uio *  uio 
)
static

Definition at line 1267 of file vfs_vnops.c.

Referenced by vn_io_fault_prefault_user().

Here is the caller graph for this function:

◆ vn_io_fault_uiomove()

int vn_io_fault_uiomove ( char *  data,
int  xfersize,
struct uio *  uio 
)

Definition at line 1508 of file vfs_vnops.c.

References data, and uiomove().

Here is the call graph for this function:

◆ vn_ioctl()

static int vn_ioctl ( struct file *  fp,
u_long  com,
void *  data,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1689 of file vfs_vnops.c.

References data.

◆ vn_kqfilter()

static int vn_kqfilter ( struct file *  fp,
struct knote kn 
)
static

Definition at line 2179 of file vfs_vnops.c.

◆ vn_kqfilter_opath()

int vn_kqfilter_opath ( struct file *  fp,
struct knote kn 
)

Definition at line 2186 of file vfs_vnops.c.

References vn_kqfilter.

◆ vn_lktype_write()

int vn_lktype_write ( struct mount *  mp,
struct vnode *  vp 
)

Definition at line 3724 of file vfs_vnops.c.

Referenced by kern_fsync(), vn_deallocate_impl(), vn_rdwr(), vn_write(), and vn_write_outvp().

Here is the caller graph for this function:

◆ vn_lock_pair()

void vn_lock_pair ( struct vnode *  vp1,
bool  vp1_locked,
struct vnode *  vp2,
bool  vp2_locked 
)

Definition at line 3659 of file vfs_vnops.c.

References vn_lock_pair_pause().

Referenced by vfs_domount_first().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_lock_pair_pause()

static void vn_lock_pair_pause ( const char *  wmesg)
static

Definition at line 3641 of file vfs_vnops.c.

References prng32_bounded(), vn_lock_pair_pause_cnt, and vn_lock_pair_pause_max.

Referenced by vn_lock_pair().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_mmap()

int vn_mmap ( struct file *  fp,
vm_map_t  map,
vm_offset_t *  addr,
vm_size_t  size,
vm_prot_t  prot,
vm_prot_t  cap_maxprot,
int  flags,
vm_ooffset_t  foff,
struct thread *  td 
)

Definition at line 2715 of file vfs_vnops.c.

References addr, and flags.

◆ vn_open()

int vn_open ( struct nameidata *  ndp,
int *  flagp,
int  cmode,
struct file *  fp 
)

Definition at line 191 of file vfs_vnops.c.

References vn_open_cred().

Referenced by kern_openat(), link_elf_ctf_get(), link_elf_load_file(), linker_hints_lookup(), linker_lookup_file(), sys_acct(), sys_ktrace(), and vfs_mountroot_readconf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_open_cred()

int vn_open_cred ( struct nameidata *  ndp,
int *  flagp,
int  cmode,
u_int  vn_open_flags,
struct ucred *  cred,
struct file *  fp 
)

Definition at line 228 of file vfs_vnops.c.

References bwillwrite(), namei(), NDFREE(), open2nameif(), vn_finished_write(), vn_open_vnode(), vn_start_write(), vput(), vrele(), and wakeup().

Referenced by alq_open_flags(), corefile_open(), corefile_open_last(), vn_open(), and vop_stdvptocnp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_open_vnode()

int vn_open_vnode ( struct vnode *  vp,
int  fmode,
struct ucred *  cred,
struct thread *  td,
struct file *  fp 
)

Definition at line 391 of file vfs_vnops.c.

References accmode, badfileops, vn_open_vnode_advlock(), vnops, and vref().

Referenced by kern_fhopen(), and vn_open_cred().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_open_vnode_advlock()

static int vn_open_vnode_advlock ( struct vnode *  vp,
int  fmode,
struct file *  fp 
)
static

Definition at line 354 of file vfs_vnops.c.

References type.

Referenced by vn_open_vnode().

Here is the caller graph for this function:

◆ vn_pages_remove()

void vn_pages_remove ( struct vnode *  vp,
vm_pindex_t  start,
vm_pindex_t  end 
)

Definition at line 2437 of file vfs_vnops.c.

References start.

Referenced by v_inval_buf_range().

Here is the caller graph for this function:

◆ vn_pages_remove_valid()

void vn_pages_remove_valid ( struct vnode *  vp,
vm_pindex_t  start,
vm_pindex_t  end 
)

Definition at line 2455 of file vfs_vnops.c.

References start.

◆ vn_poll()

static int vn_poll ( struct file *  fp,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1741 of file vfs_vnops.c.

◆ vn_rdwr()

int vn_rdwr ( enum uio_rw  rw,
struct vnode *  vp,
void *  base,
int  len,
off_t  offset,
enum uio_seg  segflg,
int  ioflg,
struct ucred *  active_cred,
struct ucred *  file_cred,
ssize_t *  aresid,
struct thread *  td 
)

◆ vn_rdwr_inchunks()

int vn_rdwr_inchunks ( enum uio_rw  rw,
struct vnode *  vp,
void *  base,
size_t  len,
off_t  offset,
enum uio_seg  segflg,
int  ioflg,
struct ucred *  active_cred,
struct ucred *  file_cred,
size_t *  aresid,
struct thread *  td 
)

Definition at line 718 of file vfs_vnops.c.

References bwillwrite(), kern_yield(), vn_rdwr(), and vn_io_fault_args::vp.

Referenced by core_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_read()

static int vn_read ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 1059 of file vfs_vnops.c.

References flags, get_advice(), sequential_heuristic(), and vn_io_pgcache_read_enable.

Here is the call graph for this function:

◆ vn_read_from_obj()

int vn_read_from_obj ( struct vnode *  vp,
struct uio *  uio 
)

Definition at line 949 of file vfs_vnops.c.

References io_hold_cnt, and vn_io_fault_pgmove().

Here is the call graph for this function:

◆ vn_rlimit_fsize()

int vn_rlimit_fsize ( const struct vnode *  vp,
const struct uio *  uio,
struct thread *  td 
)

Definition at line 2367 of file vfs_vnops.c.

References kern_psignal(), and lim_cur().

Referenced by vn_generic_copy_file_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_seek()

int vn_seek ( struct file *  fp,
off_t  offset,
int  whence,
struct thread *  td 
)

Definition at line 2535 of file vfs_vnops.c.

References foffset_lock(), and foffset_unlock().

Here is the call graph for this function:

◆ vn_skip_hole()

static off_t vn_skip_hole ( struct vnode *  outvp,
off_t  xfer2,
off_t *  outoffp,
off_t *  xferp,
off_t *  dataoffp,
off_t *  holeoffp,
struct ucred *  cred 
)
static

Definition at line 3025 of file vfs_vnops.c.

Referenced by vn_write_outvp().

Here is the caller graph for this function:

◆ vn_start_secondary_write()

int vn_start_secondary_write ( struct vnode *  vp,
struct mount **  mpp,
int  flags 
)

Definition at line 1946 of file vfs_vnops.c.

References flags, and vfs_rel().

Referenced by vgonel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_start_write()

◆ vn_start_write_refed()

static int vn_start_write_refed ( struct mount *  mp,
int  flags,
bool  mplocked 
)
static

Definition at line 1852 of file vfs_vnops.c.

References flags.

Referenced by vfs_write_resume(), and vn_start_write().

Here is the caller graph for this function:

◆ vn_statfile()

int vn_statfile ( struct file *  fp,
struct stat *  sb,
struct ucred *  active_cred 
)

Definition at line 1673 of file vfs_vnops.c.

◆ vn_truncate()

static int vn_truncate ( struct file *  fp,
off_t  length,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1605 of file vfs_vnops.c.

References vn_finished_write(), vn_start_write(), and vn_truncate_locked().

Here is the call graph for this function:

◆ vn_truncate_locked()

int vn_truncate_locked ( struct vnode *  vp,
off_t  length,
bool  sync,
struct ucred *  cred 
)

Definition at line 1651 of file vfs_vnops.c.

Referenced by core_output(), vn_generic_copy_file_range(), vn_truncate(), and vn_write_outvp().

Here is the caller graph for this function:

◆ vn_utimes_perm()

int vn_utimes_perm ( struct vnode *  vp,
struct vattr *  vap,
struct ucred *  cred,
struct thread *  td 
)

Definition at line 2608 of file vfs_vnops.c.

◆ vn_vget_ino()

int vn_vget_ino ( struct vnode *  vp,
ino_t  ino,
int  lkflags,
struct vnode **  rvp 
)

Definition at line 2316 of file vfs_vnops.c.

References vn_get_ino_alloc_vget(), and vn_vget_ino_gen().

Here is the call graph for this function:

◆ vn_vget_ino_gen()

int vn_vget_ino_gen ( struct vnode *  vp,
vn_get_ino_t  alloc,
void *  alloc_arg,
int  lkflags,
struct vnode **  rvp 
)

Definition at line 2324 of file vfs_vnops.c.

References vfs_busy(), vfs_ref(), vfs_rel(), vfs_unbusy(), vput(), and vunref().

Referenced by vn_vget_ino().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_write()

static int vn_write ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 1130 of file vfs_vnops.c.

References bwillwrite(), flags, get_advice(), get_write_ioflag(), sequential_heuristic(), vn_finished_write(), vn_lktype_write(), and vn_start_write().

Here is the call graph for this function:

◆ vn_write_outvp()

static int vn_write_outvp ( struct vnode *  outvp,
char *  dat,
off_t  outoff,
off_t  xfer,
u_long  blksize,
bool  growfile,
bool  checkhole,
struct ucred *  cred 
)
static

Definition at line 3100 of file vfs_vnops.c.

References bwillwrite(), vn_finished_write(), vn_lktype_write(), vn_rdwr(), vn_skip_hole(), vn_start_write(), and vn_truncate_locked().

Referenced by vn_generic_copy_file_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vn_writechk()

int vn_writechk ( struct vnode *  vp)

Definition at line 504 of file vfs_vnops.c.

Referenced by kern_truncate(), and vn_access().

Here is the caller graph for this function:

Variable Documentation

◆ io_hold_cnt

const u_int io_hold_cnt = 16

Definition at line 131 of file vfs_vnops.c.

Referenced by vn_io_fault1(), and vn_read_from_obj().

◆ vfs_allow_read_dir

int vfs_allow_read_dir = 0
static

Definition at line 146 of file vfs_vnops.c.

Referenced by vn_io_fault().

◆ vn_closefile

fo_close_t vn_closefile
static

Definition at line 106 of file vfs_vnops.c.

◆ vn_fallocate

fo_fallocate_t vn_fallocate
static

Definition at line 108 of file vfs_vnops.c.

◆ vn_fspacectl

fo_fspacectl_t vn_fspacectl
static

Definition at line 109 of file vfs_vnops.c.

◆ vn_io_fault

fo_rdwr_t vn_io_fault
static

Definition at line 101 of file vfs_vnops.c.

◆ vn_io_fault_enable

int vn_io_fault_enable = 1
static

Definition at line 132 of file vfs_vnops.c.

Referenced by do_vn_io_fault().

◆ vn_io_fault_prefault

int vn_io_fault_prefault = 0
static

Definition at line 135 of file vfs_vnops.c.

Referenced by vn_io_fault1().

◆ vn_io_faults_cnt

u_long vn_io_faults_cnt
static

Definition at line 142 of file vfs_vnops.c.

Referenced by vn_io_fault1().

◆ vn_io_pgcache_read_enable

int vn_io_pgcache_read_enable = 1
static

Definition at line 138 of file vfs_vnops.c.

Referenced by vn_read().

◆ vn_ioctl

fo_ioctl_t vn_ioctl
static

Definition at line 103 of file vfs_vnops.c.

◆ vn_kqfilter

fo_kqfilter_t vn_kqfilter
static

Definition at line 105 of file vfs_vnops.c.

Referenced by vn_kqfilter_opath().

◆ vn_lock_pair_pause_cnt

u_long vn_lock_pair_pause_cnt
static

Definition at line 3630 of file vfs_vnops.c.

Referenced by vn_lock_pair_pause().

◆ vn_lock_pair_pause_max

u_int vn_lock_pair_pause_max

Definition at line 3635 of file vfs_vnops.c.

Referenced by init_param1(), and vn_lock_pair_pause().

◆ vn_mmap

fo_mmap_t vn_mmap
static

Definition at line 107 of file vfs_vnops.c.

◆ vn_poll

fo_poll_t vn_poll
static

Definition at line 104 of file vfs_vnops.c.

◆ vn_read

fo_rdwr_t vn_read
static

Definition at line 99 of file vfs_vnops.c.

Referenced by vn_io_fault().

◆ vn_truncate

fo_truncate_t vn_truncate
static

Definition at line 102 of file vfs_vnops.c.

◆ vn_write

fo_rdwr_t vn_write
static

Definition at line 100 of file vfs_vnops.c.

Referenced by vn_io_fault().

◆ vnops

struct fileops vnops
Initial value:
= {
.fo_read = vn_io_fault,
.fo_write = vn_io_fault,
.fo_truncate = vn_truncate,
.fo_ioctl = vn_ioctl,
.fo_poll = vn_poll,
.fo_kqfilter = vn_kqfilter,
.fo_stat = vn_statfile,
.fo_close = vn_closefile,
.fo_chmod = vn_chmod,
.fo_chown = vn_chown,
.fo_sendfile = vn_sendfile,
.fo_seek = vn_seek,
.fo_fill_kinfo = vn_fill_kinfo,
.fo_mmap = vn_mmap,
.fo_fallocate = vn_fallocate,
.fo_fspacectl = vn_fspacectl,
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
}
int vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags, struct thread *td)
int vn_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
Definition: vfs_vnops.c:2631
static fo_poll_t vn_poll
Definition: vfs_vnops.c:104
int vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
Definition: vfs_vnops.c:2418
int vn_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
Definition: vfs_vnops.c:2403
static fo_ioctl_t vn_ioctl
Definition: vfs_vnops.c:103
int vn_statfile(struct file *fp, struct stat *sb, struct ucred *active_cred)
Definition: vfs_vnops.c:1673
static fo_fallocate_t vn_fallocate
Definition: vfs_vnops.c:108
int vn_seek(struct file *fp, off_t offset, int whence, struct thread *td)
Definition: vfs_vnops.c:2535
static fo_truncate_t vn_truncate
Definition: vfs_vnops.c:102
static fo_fspacectl_t vn_fspacectl
Definition: vfs_vnops.c:109
static fo_kqfilter_t vn_kqfilter
Definition: vfs_vnops.c:105
static fo_rdwr_t vn_io_fault
Definition: vfs_vnops.c:101
static fo_mmap_t vn_mmap
Definition: vfs_vnops.c:107
static fo_close_t vn_closefile
Definition: vfs_vnops.c:106

Definition at line 111 of file vfs_vnops.c.

Referenced by kern_fhopen(), kern_openat(), pipe_close(), pipe_kqfilter(), pipe_stat(), pipe_truncate(), ptsdev_close(), and vn_open_vnode().