FreeBSD ZFS
The Zettabyte File System
Data Structures | Defines | Typedefs | Functions | Variables

zfs_vnops.c File Reference

ZFS VNode operations. More...

#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/sysmacros.h>
#include <sys/resource.h>
#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/kmem.h>
#include <sys/taskq.h>
#include <sys/uio.h>
#include <sys/atomic.h>
#include <sys/namei.h>
#include <sys/mman.h>
#include <sys/cmn_err.h>
#include <sys/errno.h>
#include <sys/unistd.h>
#include <sys/zfs_dir.h>
#include <sys/zfs_ioctl.h>
#include <sys/fs/zfs.h>
#include <sys/dmu.h>
#include <sys/dmu_objset.h>
#include <sys/spa.h>
#include <sys/txg.h>
#include <sys/dbuf.h>
#include <sys/zap.h>
#include <sys/sa.h>
#include <sys/dirent.h>
#include <sys/policy.h>
#include <sys/sunddi.h>
#include <sys/filio.h>
#include <sys/sid.h>
#include <sys/zfs_ctldir.h>
#include <sys/zfs_fuid.h>
#include <sys/zfs_sa.h>
#include <sys/dnlc.h>
#include <sys/zfs_rlock.h>
#include <sys/extdirent.h>
#include <sys/kidmap.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/sf_buf.h>
#include <sys/sched.h>
#include <sys/acl.h>
#include <vm/vm_param.h>
#include <vm/vm_pageout.h>
#include <vm/vm_page.h>
Include dependency graph for zfs_vnops.c:

Go to the source code of this file.

Data Structures

struct  zfs_zlock

Defines

#define FLAG_CHECK(fflag, xflag, xfield)
#define FLAG_CHANGE(fflag, zflag, xflag, xfield)

Typedefs

typedef struct zfs_zlock zfs_zlock_t

Functions

static int zfs_open (vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
static int zfs_close (vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr, caller_context_t *ct)
static int zfs_holey (vnode_t *vp, u_long cmd, offset_t *off)
 Lseek support for finding holes (cmd == _FIO_SEEK_HOLE) and data (cmd == _FIO_SEEK_DATA).
static int zfs_ioctl (vnode_t *vp, u_long com, intptr_t data, int flag, cred_t *cred, int *rvalp, caller_context_t *ct)
static vm_page_t page_lookup (vnode_t *vp, int64_t start, int64_t off, int64_t nbytes)
static void page_unlock (vm_page_t pp)
static caddr_t zfs_map_page (vm_page_t pp, struct sf_buf **sfp)
static void zfs_unmap_page (struct sf_buf *sf)
static void update_pages (vnode_t *vp, int64_t start, int len, objset_t *os, uint64_t oid, int segflg, dmu_tx_t *tx)
 When a file is memory mapped, we must keep the IO data synchronized between the DMU cache and the memory mapped pages.
static int mappedread_sf (vnode_t *vp, int nbytes, uio_t *uio)
 Read with UIO_NOCOPY flag means that sendfile(2) requests ZFS to populate a range of page cache pages with data.
static int mappedread (vnode_t *vp, int nbytes, uio_t *uio)
 When a file is memory mapped, we must keep the IO data synchronized between the DMU cache and the memory mapped pages.
static int zfs_read (vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
 Read bytes from specified file into supplied buffer.
static int zfs_write (vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
 Write the bytes to a file.
void zfs_get_done (zgd_t *zgd, int error)
int zfs_get_data (void *arg, lr_write_t *lr, char *buf, zio_t *zio)
 Get data to generate a TX_WRITE intent log record.
static int zfs_access (vnode_t *vp, int mode, int flag, cred_t *cr, caller_context_t *ct)
static int specvp_check (vnode_t **vpp, cred_t *cr)
 If vnode is for a device return a specfs vnode instead.
static int zfs_lookup (vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp, int nameiop, cred_t *cr, kthread_t *td, int flags)
 Lookup an entry in a directory, or an extended attribute directory.
static int zfs_create (vnode_t *dvp, char *name, vattr_t *vap, int excl, int mode, vnode_t **vpp, cred_t *cr, kthread_t *td)
 Attempt to create a new entry in a directory.
static int zfs_remove (vnode_t *dvp, char *name, cred_t *cr, caller_context_t *ct, int flags)
 Remove an entry from a directory.
static int zfs_mkdir (vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr, caller_context_t *ct, int flags, vsecattr_t *vsecp)
 Create a new directory and insert it into dvp using the name provided.
static int zfs_rmdir (vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr, caller_context_t *ct, int flags)
 Remove a directory subdir entry.
static int zfs_readdir (vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp, int *ncookies, u_long **cookies)
 Read multiple directory entries.
static int zfs_fsync (vnode_t *vp, int syncflag, cred_t *cr, caller_context_t *ct)
static int zfs_getattr (vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, caller_context_t *ct)
 Get the requested file attributes and place them in the provided vattr structure.
static int zfs_setattr (vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, caller_context_t *ct)
 Set the file attributes to the values contained in the vattr structure.
static void zfs_rename_unlock (zfs_zlock_t **zlpp)
 Drop locks and release vnodes that were held by zfs_rename_lock().
static int zfs_rename_lock (znode_t *szp, znode_t *tdzp, znode_t *sdzp, zfs_zlock_t **zlpp)
 Search back through the directory tree, using the ".." entries.
static int zfs_rename (vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr, caller_context_t *ct, int flags)
 Move an entry from the provided source directory to the target directory.
static int zfs_symlink (vnode_t *dvp, vnode_t **vpp, char *name, vattr_t *vap, char *link, cred_t *cr, kthread_t *td)
 Insert the indicated symbolic reference entry into the directory.
static int zfs_readlink (vnode_t *vp, uio_t *uio, cred_t *cr, caller_context_t *ct)
 Return, in the buffer contained in the provided uio structure, the symbolic path referred to by vp.
static int zfs_link (vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr, caller_context_t *ct, int flags)
 Insert a new entry into directory tdvp referencing svp.
void zfs_inactive (vnode_t *vp, cred_t *cr, caller_context_t *ct)
 CTASSERT (sizeof(struct zfid_short)<=sizeof(struct fid))
 CTASSERT (sizeof(struct zfid_long)<=sizeof(struct fid))
static int zfs_fid (vnode_t *vp, fid_t *fidp, caller_context_t *ct)
static int zfs_pathconf (vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr, caller_context_t *ct)
static int zfs_getsecattr (vnode_t *vp, vsecattr_t *vsecp, int flag, cred_t *cr, caller_context_t *ct)
int zfs_setsecattr (vnode_t *vp, vsecattr_t *vsecp, int flag, cred_t *cr, caller_context_t *ct)
static int ioflags (int ioflags)
static int zfs_getpages (struct vnode *vp, vm_page_t *m, int count, int reqpage)
static int zfs_freebsd_getpages (struct vop_getpages_args *ap)
static int zfs_freebsd_open (struct vop_open_args *ap)
static int zfs_freebsd_close (struct vop_close_args *ap)
static int zfs_freebsd_ioctl (struct vop_ioctl_args *ap)
static int zfs_freebsd_read (struct vop_read_args *ap)
static int zfs_freebsd_write (struct vop_write_args *ap)
static int zfs_freebsd_access (struct vop_access_args *ap)
static int zfs_freebsd_lookup (struct vop_lookup_args *ap)
static int zfs_freebsd_create (struct vop_create_args *ap)
static int zfs_freebsd_remove (struct vop_remove_args *ap)
static int zfs_freebsd_mkdir (struct vop_mkdir_args *ap)
static int zfs_freebsd_rmdir (struct vop_rmdir_args *ap)
static int zfs_freebsd_readdir (struct vop_readdir_args *ap)
static int zfs_freebsd_fsync (struct vop_fsync_args *ap)
static int zfs_freebsd_getattr (struct vop_getattr_args *ap)
static int zfs_freebsd_setattr (struct vop_setattr_args *ap)
static int zfs_freebsd_rename (struct vop_rename_args *ap)
static int zfs_freebsd_symlink (struct vop_symlink_args *ap)
static int zfs_freebsd_readlink (struct vop_readlink_args *ap)
static int zfs_freebsd_link (struct vop_link_args *ap)
static int zfs_freebsd_inactive (struct vop_inactive_args *ap)
static void zfs_reclaim_complete (void *arg, int pending)
static int zfs_freebsd_reclaim (struct vop_reclaim_args *ap)
static int zfs_freebsd_fid (struct vop_fid_args *ap)
static int zfs_freebsd_pathconf (struct vop_pathconf_args *ap)
static int zfs_freebsd_fifo_pathconf (struct vop_pathconf_args *ap)
static int zfs_create_attrname (int attrnamespace, const char *name, char *attrname, size_t size)
static int zfs_getextattr (struct vop_getextattr_args *ap)
 Vnode operating to retrieve a named extended attribute.
int zfs_deleteextattr (struct vop_deleteextattr_args *ap)
static int zfs_setextattr (struct vop_setextattr_args *ap)
 Vnode operation to set a named attribute.
static int zfs_listextattr (struct vop_listextattr_args *ap)
 Vnode operation to retrieve extended attributes on a vnode.
int zfs_freebsd_getacl (struct vop_getacl_args *ap)
int zfs_freebsd_setacl (struct vop_setacl_args *ap)
int zfs_freebsd_aclcheck (struct vop_aclcheck_args *ap)

Variables

offset_t zfs_read_chunk_size = 1024 * 1024
uint64_t null_xattr = 0
ulong_t zfs_fsync_sync_cnt = 4
struct vop_vector zfs_vnodeops
struct vop_vector zfs_fifoops
struct vop_vector zfs_shareops

Detailed Description

ZFS VNode operations.

Entry points to the ZFS module

Programming rules.

Each vnode op performs some logical unit of work. To do this, the ZPL must properly lock its in-core state, create a DMU transaction, do the work, record this work in the intent log (ZIL), commit the DMU transaction, and wait for the intent log to commit if it is a synchronous operation. Moreover, the vnode ops must work in both normal and log replay context. The ordering of events is important to avoid deadlocks and references to freed memory. The example below illustrates the following Big Rules:

  1. A check must be made in each zfs thread for a mounted file system. This is done avoiding races using ZFS_ENTER(zfsvfs). A ZFS_EXIT(zfsvfs) is needed before all returns. Any znodes must be checked with ZFS_VERIFY_ZP(zp). Both of these macros can return EIO from the calling function.
  2. VN_RELE() should always be the last thing except for zil_commit() (if necessary) and ZFS_EXIT(). This is for 3 reasons: First, if it's the last reference, the vnode/znode can be freed, so the zp may point to freed memory. Second, the last reference will call zfs_zinactive(), which may induce a lot of work -- pushing cached pages (which acquires range locks) and syncing out cached atime changes. Third, zfs_zinactive() may require a new tx, which could deadlock the system if you were already holding one. If you must call VN_RELE() within a tx then use VN_RELE_ASYNC().
  3. All range locks must be grabbed before calling dmu_tx_assign(), as they can span dmu_tx_assign() calls.
  4. Always pass TXG_NOWAIT as the second argument to dmu_tx_assign(). This is critical because we don't want to block while holding locks. Note, in particular, that if a lock is sometimes acquired before the tx assigns, and sometimes after (e.g. z_lock), then failing to use a non-blocking assign can deadlock the system. The scenario:
    • Thread A has grabbed a lock before calling dmu_tx_assign().
    • Thread B is in an already-assigned tx, and blocks for this lock.
    • Thread A calls dmu_tx_assign(TXG_WAIT) and blocks in txg_wait_open() forever, because the previous txg can't quiesce until B's tx commits.
    If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is TXG_NOWAIT, then drop all locks, call dmu_tx_wait(), and try again.
  5. If the operation succeeded, generate the intent log entry for it before dropping locks. This ensures that the ordering of events in the intent log matches the order in which they actually occurred. During ZIL replay the zfs_log_* functions will update the sequence number to indicate the zil transaction has replayed.
  6. At the end of each vnode op, the DMU tx must always commit, regardless of whether there were any errors.
  7. After dropping all locks, invoke zil_commit(zilog, foid) to ensure that synchronous semantics are provided when necessary.

In general, this is how things should be ordered in each vnode op:

        ZFS_ENTER(zfsvfs);              // exit if unmounted
  top:
        zfs_dirent_lock(&dl, ...)       // lock directory entry (may VN_HOLD())
        rw_enter(...);                  // grab any other locks you need
        tx = dmu_tx_create(...);        // get DMU tx
        dmu_tx_hold_*();                // hold each object you might modify
        error = dmu_tx_assign(tx, TXG_NOWAIT);  // try to assign
        if (error) {
                rw_exit(...);           // drop locks
                zfs_dirent_unlock(dl);  // unlock directory entry
                VN_RELE(...);           // release held vnodes
                if (error == ERESTART) {
                        dmu_tx_wait(tx);
                        dmu_tx_abort(tx);
                        goto top;
                }
                dmu_tx_abort(tx);       // abort DMU tx
                ZFS_EXIT(zfsvfs);       // finished in zfs
                return (error);         // really out of space
        }
        error = do_real_work();         // do whatever this VOP does
        if (error == 0)
                zfs_log_*(...);         // on success, make ZIL entry
        dmu_tx_commit(tx);              // commit DMU tx -- error or not
        rw_exit(...);                   // drop locks
        zfs_dirent_unlock(dl);          // unlock directory entry
        VN_RELE(...);                   // release held vnodes
        zil_commit(zilog, foid);        // synchronous when necessary
        ZFS_EXIT(zfsvfs);               // finished in zfs
        return (error);                 // done, report error

Definition in file zfs_vnops.c.


Define Documentation

#define FLAG_CHANGE (   fflag,
  zflag,
  xflag,
  xfield 
)
Value:
do {            \
        if (((fflags & (fflag)) && !(zflags & (zflag))) ||              \
            ((zflags & (zflag)) && !(fflags & (fflag)))) {              \
                XVA_SET_REQ(&xvap, (xflag));                            \
                (xfield) = ((fflags & (fflag)) != 0);                   \
        }                                                               \
} while (0)
#define FLAG_CHECK (   fflag,
  xflag,
  xfield 
)
Value:
do {                    \
        if (XVA_ISSET_RTN(&xvap, (xflag)) && (xfield) != 0)             \
                fflags |= (fflag);                                      \
} while (0)

Typedef Documentation

typedef struct zfs_zlock zfs_zlock_t

Function Documentation

CTASSERT ( sizeof(struct zfid_short)<=sizeof(struct fid)  )
CTASSERT ( sizeof(struct zfid_long)<=sizeof(struct fid)  )
static int ioflags ( int  ioflags) [static]

Definition at line 5519 of file zfs_vnops.c.

static int mappedread ( vnode_t *  vp,
int  nbytes,
uio_t *  uio 
) [static]

When a file is memory mapped, we must keep the IO data synchronized between the DMU cache and the memory mapped pages.

What this means:

On Read: We "read" preferentially from memory mapped pages, else we default from the dmu buffer.

Note:
We will always "break up" the IO into PAGESIZE uiomoves when the file is memory mapped.

Definition at line 505 of file zfs_vnops.c.

static int mappedread_sf ( vnode_t *  vp,
int  nbytes,
uio_t *  uio 
) [static]

Read with UIO_NOCOPY flag means that sendfile(2) requests ZFS to populate a range of page cache pages with data.

Note:
This function could be optimized to pre-allocate all pages in advance, drain VPO_BUSY on all of them, map them into contiguous KVA region and populate them in one single dmu_read() call.

Definition at line 439 of file zfs_vnops.c.

static vm_page_t page_lookup ( vnode_t *  vp,
int64_t  start,
int64_t  off,
int64_t  nbytes 
) [static]

Definition at line 326 of file zfs_vnops.c.

static void page_unlock ( vm_page_t  pp) [static]

Definition at line 361 of file zfs_vnops.c.

static int specvp_check ( vnode_t **  vpp,
cred_t *  cr 
) [static]

If vnode is for a device return a specfs vnode instead.

Definition at line 1258 of file zfs_vnops.c.

static void update_pages ( vnode_t *  vp,
int64_t  start,
int  len,
objset_t os,
uint64_t  oid,
int  segflg,
dmu_tx_t tx 
) [static]

When a file is memory mapped, we must keep the IO data synchronized between the DMU cache and the memory mapped pages.

What this means:

On Write: If we find a memory mapped page, we write to *both* the page and the dmu buffer.

Definition at line 390 of file zfs_vnops.c.

static int zfs_access ( vnode_t *  vp,
int  mode,
int  flag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 1235 of file zfs_vnops.c.

static int zfs_close ( vnode_t *  vp,
int  flag,
int  count,
offset_t  offset,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 203 of file zfs_vnops.c.

static int zfs_create ( vnode_t *  dvp,
char *  name,
vattr_t *  vap,
int  excl,
int  mode,
vnode_t **  vpp,
cred_t *  cr,
kthread_t *  td 
) [static]

Attempt to create a new entry in a directory.

If the entry already exists, truncate the file if permissible, else return an error. Return the vp of the created or trunc'd file.

Parameters:
[in,out]dvpvnode of directory to put new file entry in. On return, ctime|mtime are updated if new entry created
[in]namename of new file entry.
[in]vapattributes of new file.
[in]exclflag indicating exclusive or non-exclusive mode.
[in]modemode to open file with.
[out]vppstorage for the returned vnode of created or trunc'd entry. On return, ctime|mtime are updated, and atime is updated if the file is new
[in]crcredentials of caller
Returns:
0 on success, error code on failure.

Timestamps:

  • dvp - ctime|mtime updated if new entry created
  • vp - ctime|mtime always, atime if new

Definition at line 1492 of file zfs_vnops.c.

static int zfs_create_attrname ( int  attrnamespace,
const char *  name,
char *  attrname,
size_t  size 
) [static]

Definition at line 6234 of file zfs_vnops.c.

int zfs_deleteextattr ( struct vop_deleteextattr_args *  ap)

Definition at line 6353 of file zfs_vnops.c.

static int zfs_fid ( vnode_t *  vp,
fid_t *  fidp,
caller_context_t *  ct 
) [static]

Definition at line 5003 of file zfs_vnops.c.

static int zfs_freebsd_access ( struct vop_access_args *  ap) [static]

Definition at line 5698 of file zfs_vnops.c.

int zfs_freebsd_aclcheck ( struct vop_aclcheck_args *  ap)

Definition at line 6679 of file zfs_vnops.c.

static int zfs_freebsd_close ( struct vop_close_args *  ap) [static]

Definition at line 5641 of file zfs_vnops.c.

static int zfs_freebsd_create ( struct vop_create_args *  ap) [static]

Definition at line 5760 of file zfs_vnops.c.

static int zfs_freebsd_fid ( struct vop_fid_args *  ap) [static]

Definition at line 6175 of file zfs_vnops.c.

static int zfs_freebsd_fifo_pathconf ( struct vop_pathconf_args *  ap) [static]

Definition at line 6205 of file zfs_vnops.c.

static int zfs_freebsd_fsync ( struct vop_fsync_args *  ap) [static]

Definition at line 5847 of file zfs_vnops.c.

int zfs_freebsd_getacl ( struct vop_getacl_args *  ap)

Definition at line 6605 of file zfs_vnops.c.

static int zfs_freebsd_getattr ( struct vop_getattr_args *  ap) [static]

Definition at line 5860 of file zfs_vnops.c.

static int zfs_freebsd_getpages ( struct vop_getpages_args *  ap) [static]

Definition at line 5608 of file zfs_vnops.c.

static int zfs_freebsd_inactive ( struct vop_inactive_args *  ap) [static]

Definition at line 6080 of file zfs_vnops.c.

static int zfs_freebsd_ioctl ( struct vop_ioctl_args *  ap) [static]

Definition at line 5654 of file zfs_vnops.c.

static int zfs_freebsd_link ( struct vop_link_args *  ap) [static]

Definition at line 6065 of file zfs_vnops.c.

static int zfs_freebsd_lookup ( struct vop_lookup_args *  ap) [static]

Definition at line 5742 of file zfs_vnops.c.

static int zfs_freebsd_mkdir ( struct vop_mkdir_args *  ap) [static]

Definition at line 5797 of file zfs_vnops.c.

static int zfs_freebsd_open ( struct vop_open_args *  ap) [static]

Definition at line 5622 of file zfs_vnops.c.

static int zfs_freebsd_pathconf ( struct vop_pathconf_args *  ap) [static]

Definition at line 6186 of file zfs_vnops.c.

static int zfs_freebsd_read ( struct vop_read_args *  ap) [static]

Definition at line 5670 of file zfs_vnops.c.

static int zfs_freebsd_readdir ( struct vop_readdir_args *  ap) [static]

Definition at line 5831 of file zfs_vnops.c.

static int zfs_freebsd_readlink ( struct vop_readlink_args *  ap) [static]

Definition at line 6053 of file zfs_vnops.c.

static int zfs_freebsd_reclaim ( struct vop_reclaim_args *  ap) [static]

Definition at line 6115 of file zfs_vnops.c.

static int zfs_freebsd_remove ( struct vop_remove_args *  ap) [static]

Definition at line 5782 of file zfs_vnops.c.

static int zfs_freebsd_rename ( struct vop_rename_args *  ap) [static]

Definition at line 5996 of file zfs_vnops.c.

static int zfs_freebsd_rmdir ( struct vop_rmdir_args *  ap) [static]

Definition at line 5816 of file zfs_vnops.c.

int zfs_freebsd_setacl ( struct vop_setacl_args *  ap)

Definition at line 6632 of file zfs_vnops.c.

static int zfs_freebsd_setattr ( struct vop_setattr_args *  ap) [static]

Definition at line 5906 of file zfs_vnops.c.

static int zfs_freebsd_symlink ( struct vop_symlink_args *  ap) [static]

Definition at line 6031 of file zfs_vnops.c.

static int zfs_freebsd_write ( struct vop_write_args *  ap) [static]

Definition at line 5684 of file zfs_vnops.c.

static int zfs_fsync ( vnode_t *  vp,
int  syncflag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 2603 of file zfs_vnops.c.

int zfs_get_data ( void *  arg,
lr_write_t lr,
char *  buf,
zio_t zio 
)

Get data to generate a TX_WRITE intent log record.

Definition at line 1117 of file zfs_vnops.c.

void zfs_get_done ( zgd_t zgd,
int  error 
)

Definition at line 1087 of file zfs_vnops.c.

static int zfs_getattr ( vnode_t *  vp,
vattr_t *  vap,
int  flags,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Get the requested file attributes and place them in the provided vattr structure.

Parameters:
[in]vpvnode of file.
[in,out]vapva_mask identifies requested attributes. If AT_XVATTR set, then optional attrs are requested. Attribute values are returned here
[in]flagsATTR_NOACLCHECK (CIFS server context)
[in]crcredentials of caller.
[in]ctcaller context
Returns:
0 (always succeeds)

Definition at line 2636 of file zfs_vnops.c.

static int zfs_getextattr ( struct vop_getextattr_args *  ap) [static]

Vnode operating to retrieve a named extended attribute.

Definition at line 6282 of file zfs_vnops.c.

static int zfs_getpages ( struct vnode *  vp,
vm_page_t *  m,
int  count,
int  reqpage 
) [static]

Definition at line 5534 of file zfs_vnops.c.

static int zfs_getsecattr ( vnode_t *  vp,
vsecattr_t *  vsecp,
int  flag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 5142 of file zfs_vnops.c.

static int zfs_holey ( vnode_t *  vp,
u_long  cmd,
offset_t *  off 
) [static]

Lseek support for finding holes (cmd == _FIO_SEEK_HOLE) and data (cmd == _FIO_SEEK_DATA).

"off" is an in/out parameter.

Definition at line 236 of file zfs_vnops.c.

void zfs_inactive ( vnode_t *  vp,
cred_t *  cr,
caller_context_t *  ct 
)

Definition at line 4537 of file zfs_vnops.c.

static int zfs_ioctl ( vnode_t *  vp,
u_long  com,
intptr_t  data,
int  flag,
cred_t *  cred,
int *  rvalp,
caller_context_t *  ct 
) [static]

Definition at line 276 of file zfs_vnops.c.

static int zfs_link ( vnode_t *  tdvp,
vnode_t *  svp,
char *  name,
cred_t *  cr,
caller_context_t *  ct,
int  flags 
) [static]

Insert a new entry into directory tdvp referencing svp.

Parameters:
[in,out]tdvpDirectory to contain new entry. On return, ctime and mtime are updated
[in,out]svpvnode of new entry. On return, ctime is updated
[in]namename of new entry.
[in]crcredentials of caller
[in]ctcaller context
Returns:
0 on success, error code on failure

Timestamps:

  • tdvp - ctime|mtime updated
  • svp - ctime updated

Definition at line 4163 of file zfs_vnops.c.

static int zfs_listextattr ( struct vop_listextattr_args *  ap) [static]

Vnode operation to retrieve extended attributes on a vnode.

Definition at line 6485 of file zfs_vnops.c.

static int zfs_lookup ( vnode_t *  dvp,
char *  nm,
vnode_t **  vpp,
struct componentname *  cnp,
int  nameiop,
cred_t *  cr,
kthread_t *  td,
int  flags 
) [static]

Lookup an entry in a directory, or an extended attribute directory.

If it exists, return a held vnode reference for it.

Parameters:
[in]dvpvnode of directory to search
[in]nmname of entry to lookup
[out]vppvnode of located entry, NULL if not found.
[in]crcredentials of caller
[in]flagsLOOKUP_XATTR set if looking for an attribute.
Returns:
0 on success, error code on failure

Timestamps: NA

Definition at line 1292 of file zfs_vnops.c.

static caddr_t zfs_map_page ( vm_page_t  pp,
struct sf_buf **  sfp 
) [static]

Definition at line 368 of file zfs_vnops.c.

static int zfs_mkdir ( vnode_t *  dvp,
char *  dirname,
vattr_t *  vap,
vnode_t **  vpp,
cred_t *  cr,
caller_context_t *  ct,
int  flags,
vsecattr_t *  vsecp 
) [static]

Create a new directory and insert it into dvp using the name provided.

Return a pointer to the inserted directory.

Parameters:
[in,out]dvpvnode of directory to add subdir to. On return, ctime and mtime are updated
[in]dirnamename of new directory.
[in]vapattributes of new directory.
[out]vppstorage for the returned vnode of the created directory. Ctime, mtime, and atime are updated
[in]crcredentials of caller.
[in]ctcaller context
[in]vsecpACL to be set
Returns:
0 on success, error code on failure

Timestamps:

  • dvp - ctime|mtime updated
  • vp - ctime|mtime|atime updated

Definition at line 1976 of file zfs_vnops.c.

static int zfs_open ( vnode_t **  vpp,
int  flag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 170 of file zfs_vnops.c.

static int zfs_pathconf ( vnode_t *  vp,
int  cmd,
ulong_t *  valp,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Definition at line 5059 of file zfs_vnops.c.

static int zfs_read ( vnode_t *  vp,
uio_t *  uio,
int  ioflag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Read bytes from specified file into supplied buffer.

Parameters:
[in,out]vpvnode of file to be read from. On return, atime is updated if byte count > 0
[in,out]uiostructure supplying read location, range info, and return buffer. On return, the range and offset is updated, and the buffer is filled
[in]ioflagSYNC flags; used to provide FRSYNC semantics
[in]crcredentials of caller
[in]ctcaller context
Returns:
0 if success, or an error code on failure Side Effects:
  • vp - atime updated if byte count > 0

Definition at line 571 of file zfs_vnops.c.

static int zfs_readdir ( vnode_t *  vp,
uio_t *  uio,
cred_t *  cr,
int *  eofp,
int *  ncookies,
u_long **  cookies 
) [static]

Read multiple directory entries.

Read as many directory entries as will fit into the provided buffer from the given directory cursor position (specified in the uio structure.

Parameters:
[in,out]vpvnode of directory to read. On return, atime is updated
[in,out]uiostructure supplying read location, range info, and return buffer. On return, offset and range are updated and buffer is filled
[in]crcredentials of caller
[out]eofpset to true if end-of-file detected
[out]ncookiesnumber of returned cookies
[out]cookiesarray of cookies returned by ZAP. Note that the low 4 bits of the cookie returned by zap is always zero. This allows us to use the low range for "special" directory entries: We use 0 for '.', and 1 for '..'. If this is the root of the filesystem, we use the offset 2 for the '.zfs' directory.
Returns:
0 on success, error code on failure

Timestamps:

  • vp - atime updated

Definition at line 2300 of file zfs_vnops.c.

static int zfs_readlink ( vnode_t *  vp,
uio_t *  uio,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Return, in the buffer contained in the provided uio structure, the symbolic path referred to by vp.

Parameters:
[in,out]vpvnode of symbolic link. On return, atime is updated
[in,out]uiostructure to contain the link path.
[in]crcredentials of caller.
[in]ctcaller context
Returns:
0 on success, error code on failure

Timestamps:

  • vp - atime updated

Definition at line 4122 of file zfs_vnops.c.

static void zfs_reclaim_complete ( void *  arg,
int  pending 
) [static]

Definition at line 6093 of file zfs_vnops.c.

static int zfs_remove ( vnode_t *  dvp,
char *  name,
cred_t *  cr,
caller_context_t *  ct,
int  flags 
) [static]

Remove an entry from a directory.

Parameters:
[in,out]dvpvnode of directory to remove entry from. On return, ctime and mtime are updated
[in]namename of entry to remove.
[in]crcredentials of caller.
[in]ctcaller context
[in]flagscase flags
Returns:
0 on success, or error code on failure

Timestamps:

  • dvp - ctime|mtime
  • vp - ctime (if nlink > 0)

Definition at line 1744 of file zfs_vnops.c.

static int zfs_rename ( vnode_t *  sdvp,
char *  snm,
vnode_t *  tdvp,
char *  tnm,
cred_t *  cr,
caller_context_t *  ct,
int  flags 
) [static]

Move an entry from the provided source directory to the target directory.

Change the entry name as indicated.

Parameters:
[in,out]sdvpSource directory containing the "old entry". ctime|mtime are updated on return
[in]snmOld entry name.
[in,out]tdvpTarget directory to contain the "new entry". ctime|mtime are updated on return
[in]tnmNew entry name.
[in]crcredentials of caller.
[in]ctcaller context
[in]flagscase flags
Returns:
0 on success, error code on failure

Timestamps:

  • sdvp,tdvp - ctime|mtime updated

Definition at line 3605 of file zfs_vnops.c.

static int zfs_rename_lock ( znode_t szp,
znode_t tdzp,
znode_t sdzp,
zfs_zlock_t **  zlpp 
) [static]

Search back through the directory tree, using the ".." entries.

Lock each directory in the chain to prevent concurrent renames. Fail any attempt to move a directory into one of its own descendants. XXX - z_parent_lock can overlap with map or grow locks

Definition at line 3517 of file zfs_vnops.c.

static void zfs_rename_unlock ( zfs_zlock_t **  zlpp) [static]

Drop locks and release vnodes that were held by zfs_rename_lock().

Definition at line 3497 of file zfs_vnops.c.

static int zfs_rmdir ( vnode_t *  dvp,
char *  name,
vnode_t *  cwd,
cred_t *  cr,
caller_context_t *  ct,
int  flags 
) [static]

Remove a directory subdir entry.

If the current working directory is the same as the subdir to be removed, the remove will fail.

Parameters:
[in,out]dvpvnode of directory to remove from. On return, ctime and mtime are updated
[in]namename of directory to be removed.
[in]cwdvnode of current working directory.
[in]crcredentials of caller.
[in]ctcaller context
[in]flagscase flags
Returns:
0 on success, error code on failure

Timestamps:

  • dvp - ctime|mtime updated

Definition at line 2156 of file zfs_vnops.c.

static int zfs_setattr ( vnode_t *  vp,
vattr_t *  vap,
int  flags,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Set the file attributes to the values contained in the vattr structure.

Parameters:
[in,out]vpvnode of file to be modified. On return, ctime is updated. mtime is updated if the size changed
[in]vapnew attribute values. If AT_XVATTR set, then optional attrs are being set
[in]flagsflags - ATTR_UTIME set if non-default time values provided - ATTR_NOACLCHECK (CIFS context only)
[in]crcredentials of caller
[in]ctcaller context
Returns:
0 on success, error code on failure

Timestamps:

  • vp - ctime updated, mtime updated if size changed.

Definition at line 2863 of file zfs_vnops.c.

static int zfs_setextattr ( struct vop_setextattr_args *  ap) [static]

Vnode operation to set a named attribute.

Definition at line 6418 of file zfs_vnops.c.

int zfs_setsecattr ( vnode_t *  vp,
vsecattr_t *  vsecp,
int  flag,
cred_t *  cr,
caller_context_t *  ct 
)

Definition at line 5160 of file zfs_vnops.c.

static int zfs_symlink ( vnode_t *  dvp,
vnode_t **  vpp,
char *  name,
vattr_t *  vap,
char *  link,
cred_t *  cr,
kthread_t *  td 
) [static]

Insert the indicated symbolic reference entry into the directory.

Parameters:
[in,out]dvpDirectory to contain new symbolic link. On return, ctime and mtime are updated
[in]nametarget path of new symlink
[in]vapAttributes of new entry
[in]linkName for new symlink entry
[in]crcredentials of caller
Returns:
0 on success, error code on failure

Timestamps:

  • dvp - ctime|mtime updated

Definition at line 3971 of file zfs_vnops.c.

static void zfs_unmap_page ( struct sf_buf *  sf) [static]

Definition at line 376 of file zfs_vnops.c.

static int zfs_write ( vnode_t *  vp,
uio_t *  uio,
int  ioflag,
cred_t *  cr,
caller_context_t *  ct 
) [static]

Write the bytes to a file.

Parameters:
[in,out]vpvnode of file to be written to. On return, ctime and/or mtime is updated if byte count > 0
[in,out]uiostructure supplying write location, range info, and data buffer. On return, offset and range is updated
[in]ioflagFAPPEND, FSYNC, and/or FDSYNC
[in]crcredentials of caller
[in]ctcaller context (NFS/CIFS fem monitor only)
Returns:
0 on success, error code on failure

Timestamps:

  • vp - ctime|mtime updated if byte count > 0

Definition at line 721 of file zfs_vnops.c.


Variable Documentation

uint64_t null_xattr = 0

Definition at line 1724 of file zfs_vnops.c.

struct vop_vector zfs_fifoops
Initial value:
 {
        .vop_default =          &fifo_specops,
        .vop_fsync =            zfs_freebsd_fsync,
        .vop_access =           zfs_freebsd_access,
        .vop_getattr =          zfs_freebsd_getattr,
        .vop_inactive =         zfs_freebsd_inactive,
        .vop_read =             VOP_PANIC,
        .vop_reclaim =          zfs_freebsd_reclaim,
        .vop_setattr =          zfs_freebsd_setattr,
        .vop_write =            VOP_PANIC,
        .vop_pathconf =         zfs_freebsd_fifo_pathconf,
        .vop_fid =              zfs_freebsd_fid,
        .vop_getacl =           zfs_freebsd_getacl,
        .vop_setacl =           zfs_freebsd_setacl,
        .vop_aclcheck =         zfs_freebsd_aclcheck,
}

Definition at line 6693 of file zfs_vnops.c.

ulong_t zfs_fsync_sync_cnt = 4

Definition at line 2600 of file zfs_vnops.c.

offset_t zfs_read_chunk_size = 1024 * 1024

Definition at line 551 of file zfs_vnops.c.

struct vop_vector zfs_shareops
Initial value:
 {
        .vop_default =          &default_vnodeops,
        .vop_access =           zfs_freebsd_access,
        .vop_inactive =         zfs_freebsd_inactive,
        .vop_reclaim =          zfs_freebsd_reclaim,
        .vop_fid =              zfs_freebsd_fid,
        .vop_pathconf =         zfs_freebsd_pathconf,
}

Definition at line 6694 of file zfs_vnops.c.

struct vop_vector zfs_vnodeops

Definition at line 6692 of file zfs_vnops.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines