Skip to content

Commit

Permalink
[XFS] remove struct vnode::v_type
Browse files Browse the repository at this point in the history
SGI-PV: 936236
SGI-Modid: xfs-linux:xfs-kern:195878a

Signed-off-by: Christoph Hellwig <hch@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
  • Loading branch information
Christoph Hellwig authored and Nathan Scott committed Sep 2, 2005
1 parent 155ffd0 commit 0432dab
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 85 deletions.
16 changes: 11 additions & 5 deletions fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,19 @@ xfs_find_handle(
return -XFS_ERROR(EINVAL);
}

/* we need the vnode */
vp = LINVFS_GET_VP(inode);
if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
case S_IFDIR:
case S_IFLNK:
break;
default:
iput(inode);
return -XFS_ERROR(EBADF);
}

/* we need the vnode */
vp = LINVFS_GET_VP(inode);

/* now we can grab the fsid */
memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
hsize = sizeof(xfs_fsid_t);
Expand Down Expand Up @@ -386,7 +392,7 @@ xfs_readlink_by_handle(
return -error;

/* Restrict this handle operation to symlinks only. */
if (vp->v_type != VLNK) {
if (!S_ISLNK(inode->i_mode)) {
VN_RELE(vp);
return -XFS_ERROR(EINVAL);
}
Expand Down Expand Up @@ -985,7 +991,7 @@ xfs_ioc_space(
if (!(filp->f_mode & FMODE_WRITE))
return -XFS_ERROR(EBADF);

if (vp->v_type != VREG)
if (!VN_ISREG(vp))
return -XFS_ERROR(EINVAL);

if (copy_from_user(&bf, arg, sizeof(bf)))
Expand Down
6 changes: 2 additions & 4 deletions fs/xfs/linux-2.6/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ linvfs_mknod(

memset(&va, 0, sizeof(va));
va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
va.va_type = IFTOVT(mode);
va.va_mode = mode;

switch (mode & S_IFMT) {
Expand Down Expand Up @@ -308,14 +307,13 @@ linvfs_symlink(
cvp = NULL;

memset(&va, 0, sizeof(va));
va.va_type = VLNK;
va.va_mode = irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO;
va.va_mode = S_IFLNK |
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;

error = 0;
VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
if (!error && cvp) {
ASSERT(cvp->v_type == VLNK);
ip = LINVFS_GET_IP(cvp);
d_instantiate(dentry, ip);
validate_fields(dir);
Expand Down
35 changes: 21 additions & 14 deletions fs/xfs/linux-2.6/xfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,25 @@ STATIC __inline__ void
xfs_set_inodeops(
struct inode *inode)
{
vnode_t *vp = LINVFS_GET_VP(inode);

if (vp->v_type == VNON) {
vn_mark_bad(vp);
} else if (S_ISREG(inode->i_mode)) {
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
inode->i_op = &linvfs_file_inode_operations;
inode->i_fop = &linvfs_file_operations;
inode->i_mapping->a_ops = &linvfs_aops;
} else if (S_ISDIR(inode->i_mode)) {
break;
case S_IFDIR:
inode->i_op = &linvfs_dir_inode_operations;
inode->i_fop = &linvfs_dir_operations;
} else if (S_ISLNK(inode->i_mode)) {
break;
case S_IFLNK:
inode->i_op = &linvfs_symlink_inode_operations;
if (inode->i_blocks)
inode->i_mapping->a_ops = &linvfs_aops;
} else {
break;
default:
inode->i_op = &linvfs_file_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
break;
}
}

Expand All @@ -167,16 +168,23 @@ xfs_revalidate_inode(
{
struct inode *inode = LINVFS_GET_IP(vp);

inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
inode->i_mode = ip->i_d.di_mode;
inode->i_nlink = ip->i_d.di_nlink;
inode->i_uid = ip->i_d.di_uid;
inode->i_gid = ip->i_d.di_gid;
if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {

switch (inode->i_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
inode->i_rdev =
MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
sysv_minor(ip->i_df.if_u2.if_rdev));
break;
default:
inode->i_rdev = 0;
} else {
xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
inode->i_rdev = MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
break;
}

inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_generation = ip->i_d.di_gen;
i_size_write(inode, ip->i_d.di_size);
Expand Down Expand Up @@ -231,7 +239,6 @@ xfs_initialize_vnode(
* finish our work.
*/
if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
vp->v_type = IFTOVT(ip->i_d.di_mode);
xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
xfs_set_inodeops(inode);

Expand Down
16 changes: 1 addition & 15 deletions fs/xfs/linux-2.6/xfs_vnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@ DEFINE_SPINLOCK(vnumber_lock);
#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
sv_t vsync[NVSYNC];

/*
* Translate stat(2) file types to vnode types and vice versa.
* Aware of numeric order of S_IFMT and vnode type values.
*/
enum vtype iftovt_tab[] = {
VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VNON
};

u_short vttoif_tab[] = {
0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFIFO, 0, S_IFSOCK
};


void
vn_init(void)
Expand Down Expand Up @@ -95,7 +82,6 @@ vn_reclaim(
vp->v_flag &= (VRECLM|VWAIT);
VN_UNLOCK(vp, 0);

vp->v_type = VNON;
vp->v_fbhv = NULL;

#ifdef XFS_VNODE_TRACE
Expand Down Expand Up @@ -174,7 +160,7 @@ vn_revalidate_core(
{
struct inode *inode = LINVFS_GET_IP(vp);

inode->i_mode = VTTOIF(vap->va_type) | vap->va_mode;
inode->i_mode = vap->va_mode;
inode->i_nlink = vap->va_nlink;
inode->i_uid = vap->va_uid;
inode->i_gid = vap->va_gid;
Expand Down
26 changes: 7 additions & 19 deletions fs/xfs/linux-2.6/xfs_vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ 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;
Expand All @@ -77,11 +73,9 @@ 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 */
Expand All @@ -93,6 +87,12 @@ typedef struct vnode {
/* inode MUST be last */
} vnode_t;

#define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode)
#define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode)
#define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode)
#define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode)
#define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode)

#define v_fbhv v_bh.bh_first /* first behavior */
#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */

Expand Down Expand Up @@ -132,17 +132,6 @@ typedef enum {
#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.
*/
Expand Down Expand Up @@ -408,7 +397,6 @@ typedef struct vnodeops {
*/
typedef struct vattr {
int va_mask; /* bit-mask of attributes present */
enum vtype va_type; /* vnode type (for create) */
mode_t va_mode; /* file access mode and type */
xfs_nlink_t va_nlink; /* number of references to file */
uid_t va_uid; /* owner user id */
Expand Down Expand Up @@ -498,7 +486,7 @@ typedef struct vattr {
* Check whether mandatory file locking is enabled.
*/
#define MANDLOCK(vp, mode) \
((vp)->v_type == VREG && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
(VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)

extern void vn_init(void);
extern int vn_wait(struct vnode *);
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ xfs_acl_vhasacl_default(
{
int error;

if (vp->v_type != VDIR)
if (!VN_ISDIR(vp))
return 0;
xfs_acl_get_attr(vp, NULL, _ACL_TYPE_DEFAULT, ATTR_KERNOVAL, &error);
return (error == 0);
Expand Down Expand Up @@ -389,7 +389,7 @@ xfs_acl_allow_set(

if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
return EPERM;
if (kind == _ACL_TYPE_DEFAULT && vp->v_type != VDIR)
if (kind == _ACL_TYPE_DEFAULT && !VN_ISDIR(vp))
return ENOTDIR;
if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
return EROFS;
Expand Down Expand Up @@ -750,7 +750,7 @@ xfs_acl_inherit(
* If the new file is a directory, its default ACL is a copy of
* the containing directory's default ACL.
*/
if (vp->v_type == VDIR)
if (VN_ISDIR(vp))
xfs_acl_set_attr(vp, pdaclp, _ACL_TYPE_DEFAULT, &error);
if (!error && !basicperms)
xfs_acl_set_attr(vp, cacl, _ACL_TYPE_ACCESS, &error);
Expand Down
3 changes: 1 addition & 2 deletions fs/xfs/xfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,6 @@ xfs_ialloc(
ASSERT(ip != NULL);

vp = XFS_ITOV(ip);
vp->v_type = IFTOVT(mode);
ip->i_d.di_mode = (__uint16_t)mode;
ip->i_d.di_onlink = 0;
ip->i_d.di_nlink = nlink;
Expand Down Expand Up @@ -1250,7 +1249,7 @@ xfs_ialloc(
*/
xfs_trans_log_inode(tp, ip, flags);

/* now that we have a v_type we can set Linux inode ops (& unlock) */
/* now that we have an i_mode we can set Linux inode ops (& unlock) */
VFS_INIT_VNODE(XFS_MTOVFS(tp->t_mountp), vp, XFS_ITOBHV(ip), 1);

*ipp = ip;
Expand Down
Loading

0 comments on commit 0432dab

Please sign in to comment.