📄 xfs_vnode.h
字号:
/* * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like. Any license provided herein, whether implied or * otherwise, applies only to this software file. Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. * * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA 94043, or: * * http://www.sgi.com * * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ * * Portions Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#ifndef __XFS_VNODE_H__#define __XFS_VNODE_H__struct uio;struct file;struct vattr;struct xfs_iomap;struct attrlist_cursor_kern;/* * Vnode types. VNON means no type. */enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };typedef xfs_ino_t vnumber_t;typedef struct dentry vname_t;typedef bhv_head_t vn_bhv_head_t;/* * MP locking protocols: * v_flag, v_vfsp VN_LOCK/VN_UNLOCK * v_type read-only or fs-dependent */typedef struct vnode { __u32 v_flag; /* vnode flags (see below) */ enum vtype v_type; /* vnode type */ struct vfs *v_vfsp; /* ptr to containing VFS */ vnumber_t v_number; /* in-core vnode number */ vn_bhv_head_t v_bh; /* behavior head */ spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */ struct inode v_inode; /* Linux inode */#ifdef XFS_VNODE_TRACE struct ktrace *v_trace; /* trace header structure */#endif} vnode_t;#define v_fbhv v_bh.bh_first /* first behavior */#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */#define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */#define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */#define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */typedef enum { VN_BHV_UNKNOWN, /* not specified */ VN_BHV_XFS, /* xfs */ VN_BHV_DM, /* data migration */ VN_BHV_QM, /* quota manager */ VN_BHV_IO, /* IO path */ VN_BHV_END /* housekeeping end-of-range */} vn_bhv_t;#define VNODE_POSITION_XFS (VNODE_POSITION_BASE)#define VNODE_POSITION_DM (VNODE_POSITION_BASE+10)#define VNODE_POSITION_QM (VNODE_POSITION_BASE+20)#define VNODE_POSITION_IO (VNODE_POSITION_BASE+30)/* * Macros for dealing with the behavior descriptor inside of the vnode. */#define BHV_TO_VNODE(bdp) ((vnode_t *)BHV_VOBJ(bdp))#define BHV_TO_VNODE_NULL(bdp) ((vnode_t *)BHV_VOBJNULL(bdp))#define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh)))#define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name)#define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp)#define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops)#define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)/* * Vnode to Linux inode mapping. */#define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode))#define LINVFS_GET_IP(vp) (&(vp)->v_inode)/* * Convert between vnode types and inode formats (since POSIX.1 * defines mode word of stat structure in terms of inode formats). */extern enum vtype iftovt_tab[];extern u_short vttoif_tab[];#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])#define VTTOIF(indx) (vttoif_tab[(int)(indx)])#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))/* * Vnode flags. */#define VINACT 0x1 /* vnode is being inactivated */#define VRECLM 0x2 /* vnode is being reclaimed */#define VWAIT 0x4 /* waiting for VINACT/VRECLM to end */#define VMODIFIED 0x8 /* XFS inode state possibly differs */ /* to the Linux inode state. *//* * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter. */typedef enum vrwlock { VRWLOCK_NONE, VRWLOCK_READ, VRWLOCK_WRITE, VRWLOCK_WRITE_DIRECT, VRWLOCK_TRY_READ, VRWLOCK_TRY_WRITE} vrwlock_t;/* * Return values for VOP_INACTIVE. A return value of * VN_INACTIVE_NOCACHE implies that the file system behavior * has disassociated its state and bhv_desc_t from the vnode. */#define VN_INACTIVE_CACHE 0#define VN_INACTIVE_NOCACHE 1/* * Values for the cmd code given to VOP_VNODE_CHANGE. */typedef enum vchange { VCHANGE_FLAGS_FRLOCKS = 0, VCHANGE_FLAGS_ENF_LOCKING = 1, VCHANGE_FLAGS_TRUNCATED = 2, VCHANGE_FLAGS_PAGE_DIRTY = 3, VCHANGE_FLAGS_IOEXCL_COUNT = 4} vchange_t;typedef int (*vop_open_t)(bhv_desc_t *, struct cred *);typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct file *, char *, size_t, loff_t *, int, struct cred *);typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct file *, const char *, size_t, loff_t *, int, struct cred *);typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *, int, unsigned int, unsigned long);typedef int (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int, struct cred *);typedef int (*vop_setattr_t)(bhv_desc_t *, struct vattr *, int, struct cred *);typedef int (*vop_access_t)(bhv_desc_t *, int, struct cred *);typedef int (*vop_lookup_t)(bhv_desc_t *, vname_t *, vnode_t **, int, vnode_t *, struct cred *);typedef int (*vop_create_t)(bhv_desc_t *, vname_t *, struct vattr *, vnode_t **, struct cred *);typedef int (*vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);typedef int (*vop_link_t)(bhv_desc_t *, vnode_t *, vname_t *, struct cred *);typedef int (*vop_rename_t)(bhv_desc_t *, vname_t *, vnode_t *, vname_t *, struct cred *);typedef int (*vop_mkdir_t)(bhv_desc_t *, vname_t *, struct vattr *, vnode_t **, struct cred *);typedef int (*vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);typedef int (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *, int *);typedef int (*vop_symlink_t)(bhv_desc_t *, vname_t *, struct vattr *, char *, vnode_t **, struct cred *);typedef int (*vop_readlink_t)(bhv_desc_t *, struct uio *, int, struct cred *);typedef int (*vop_fsync_t)(bhv_desc_t *, int, struct cred *, xfs_off_t, xfs_off_t);typedef int (*vop_inactive_t)(bhv_desc_t *, struct cred *);typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *);typedef int (*vop_release_t)(bhv_desc_t *);typedef int (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);typedef int (*vop_frlock_t)(bhv_desc_t *, int, struct file_lock *,int, xfs_off_t, struct cred *);typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, struct xfs_iomap *, int *);typedef int (*vop_reclaim_t)(bhv_desc_t *);typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int, struct cred *);typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int, struct cred *);typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *);typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, struct attrlist_cursor_kern *, struct cred *);typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);typedef void (*vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);typedef int (*vop_iflush_t)(bhv_desc_t *, int);typedef struct vnodeops { bhv_position_t vn_position; /* position within behavior chain */ vop_open_t vop_open; vop_read_t vop_read; vop_write_t vop_write; vop_ioctl_t vop_ioctl; vop_getattr_t vop_getattr; vop_setattr_t vop_setattr; vop_access_t vop_access; vop_lookup_t vop_lookup; vop_create_t vop_create; vop_remove_t vop_remove; vop_link_t vop_link; vop_rename_t vop_rename; vop_mkdir_t vop_mkdir; vop_rmdir_t vop_rmdir; vop_readdir_t vop_readdir; vop_symlink_t vop_symlink; vop_readlink_t vop_readlink; vop_fsync_t vop_fsync; vop_inactive_t vop_inactive; vop_fid2_t vop_fid2; vop_rwlock_t vop_rwlock; vop_rwunlock_t vop_rwunlock; vop_frlock_t vop_frlock; vop_bmap_t vop_bmap; vop_reclaim_t vop_reclaim; vop_attr_get_t vop_attr_get; vop_attr_set_t vop_attr_set; vop_attr_remove_t vop_attr_remove; vop_attr_list_t vop_attr_list; vop_link_removed_t vop_link_removed; vop_vnode_change_t vop_vnode_change; vop_ptossvp_t vop_tosspages; vop_pflushinvalvp_t vop_flushinval_pages; vop_pflushvp_t vop_flush_pages; vop_release_t vop_release; vop_iflush_t vop_iflush;} vnodeops_t;/* * VOP's. */#define _VOP_(op, vp) (*((vnodeops_t *)(vp)->v_fops)->op)#define VOP_READ(vp,file,buf,size,offset,ioflags,cr,rv) \ rv = _VOP_(vop_read, vp)((vp)->v_fbhv,file,buf,size,offset,ioflags,cr)#define VOP_WRITE(vp,file,buf,size,offset,ioflags,cr,rv) \ rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,buf,size,offset,ioflags,cr)#define VOP_BMAP(vp,of,sz,rw,b,n,rv) \ rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)#define VOP_OPEN(vp, cr, rv) \ rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)#define VOP_GETATTR(vp, vap, f, cr, rv) \ rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)#define VOP_SETATTR(vp, vap, f, cr, rv) \ rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)#define VOP_ACCESS(vp, mode, cr, rv) \ rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)#define VOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \ rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)#define VOP_CREATE(dvp,d,vap,vpp,cr,rv) \ rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)#define VOP_REMOVE(dvp,d,cr,rv) \ rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)#define VOP_LINK(tdvp,fvp,d,cr,rv) \ rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)#define VOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \ rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)#define VOP_MKDIR(dp,d,vap,vpp,cr,rv) \ rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)#define VOP_RMDIR(dp,d,cr,rv) \ rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)#define VOP_READDIR(vp,uiop,cr,eofp,rv) \ rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)#define VOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \ rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)#define VOP_READLINK(vp,uiop,fl,cr,rv) \ rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)#define VOP_FSYNC(vp,f,cr,b,e,rv) \ rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)#define VOP_INACTIVE(vp, cr, rv) \ rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)#define VOP_RELEASE(vp, rv) \ rv = _VOP_(vop_release, vp)((vp)->v_fbhv)#define VOP_FID2(vp, fidp, rv) \ rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)#define VOP_RWLOCK(vp,i) \ (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)#define VOP_RWLOCK_TRY(vp,i) \ _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)#define VOP_RWUNLOCK(vp,i) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -