Commit 75e17b3c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nathan Scott

[XFS] add helper to get xfs_inode from vnode

SGI-PV: 947206
SGI-Modid: xfs-linux-melb:xfs-kern:203960a
Signed-off-by: default avatarChristoph Hellwig <hch@sgi.com>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 204ab25f
...@@ -54,7 +54,6 @@ xfs_page_trace( ...@@ -54,7 +54,6 @@ xfs_page_trace(
int mask) int mask)
{ {
xfs_inode_t *ip; xfs_inode_t *ip;
bhv_desc_t *bdp;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t offset = page_offset(page); loff_t offset = page_offset(page);
...@@ -63,8 +62,7 @@ xfs_page_trace( ...@@ -63,8 +62,7 @@ xfs_page_trace(
if (page_has_buffers(page)) if (page_has_buffers(page))
xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops); ip = xfs_vtoi(vp);
ip = XFS_BHVTOI(bdp);
if (!ip->i_rwtrace) if (!ip->i_rwtrace)
return; return;
......
...@@ -509,16 +509,14 @@ linvfs_open_exec( ...@@ -509,16 +509,14 @@ linvfs_open_exec(
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
int error = 0; int error = 0;
bhv_desc_t *bdp;
xfs_inode_t *ip; xfs_inode_t *ip;
if (vp->v_vfsp->vfs_flag & VFS_DMI) { if (vp->v_vfsp->vfs_flag & VFS_DMI) {
bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops); ip = xfs_vtoi(vp);
if (!bdp) { if (!ip) {
error = -EINVAL; error = -EINVAL;
goto open_exec_out; goto open_exec_out;
} }
ip = XFS_BHVTOI(bdp);
if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ)) { if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ)) {
error = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, error = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp,
0, 0, 0, NULL); 0, 0, 0, NULL);
......
...@@ -145,13 +145,10 @@ xfs_find_handle( ...@@ -145,13 +145,10 @@ xfs_find_handle(
if (cmd != XFS_IOC_PATH_TO_FSHANDLE) { if (cmd != XFS_IOC_PATH_TO_FSHANDLE) {
xfs_inode_t *ip; xfs_inode_t *ip;
bhv_desc_t *bhv;
int lock_mode; int lock_mode;
/* need to get access to the xfs_inode to read the generation */ /* need to get access to the xfs_inode to read the generation */
bhv = vn_bhv_lookup_unlocked(VN_BHV_HEAD(vp), &xfs_vnodeops); ip = xfs_vtoi(vp);
ASSERT(bhv);
ip = XFS_BHVTOI(bhv);
ASSERT(ip); ASSERT(ip);
lock_mode = xfs_ilock_map_shared(ip); lock_mode = xfs_ilock_map_shared(ip);
......
...@@ -58,6 +58,22 @@ ...@@ -58,6 +58,22 @@
#define IS_NOATIME(inode) ((inode->i_sb->s_flags & MS_NOATIME) || \ #define IS_NOATIME(inode) ((inode->i_sb->s_flags & MS_NOATIME) || \
(S_ISDIR(inode->i_mode) && inode->i_sb->s_flags & MS_NODIRATIME)) (S_ISDIR(inode->i_mode) && inode->i_sb->s_flags & MS_NODIRATIME))
/*
* Get a XFS inode from a given vnode.
*/
xfs_inode_t *
xfs_vtoi(
struct vnode *vp)
{
bhv_desc_t *bdp;
bdp = bhv_lookup_range(VN_BHV_HEAD(vp),
VNODE_POSITION_XFS, VNODE_POSITION_XFS);
if (unlikely(bdp == NULL))
return NULL;
return XFS_BHVTOI(bdp);
}
/* /*
* Bring the atime in the XFS inode uptodate. * Bring the atime in the XFS inode uptodate.
* Used before logging the inode to disk or when the Linux inode goes away. * Used before logging the inode to disk or when the Linux inode goes away.
......
...@@ -60,8 +60,6 @@ xfs_swapext( ...@@ -60,8 +60,6 @@ xfs_swapext(
xfs_bstat_t *sbp; xfs_bstat_t *sbp;
struct file *fp = NULL, *tfp = NULL; struct file *fp = NULL, *tfp = NULL;
vnode_t *vp, *tvp; vnode_t *vp, *tvp;
bhv_desc_t *bdp, *tbdp;
vn_bhv_head_t *bhp, *tbhp;
static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
int ilf_fields, tilf_fields; int ilf_fields, tilf_fields;
int error = 0; int error = 0;
...@@ -90,13 +88,10 @@ xfs_swapext( ...@@ -90,13 +88,10 @@ xfs_swapext(
goto error0; goto error0;
} }
bhp = VN_BHV_HEAD(vp); ip = xfs_vtoi(vp);
bdp = vn_bhv_lookup(bhp, &xfs_vnodeops); if (ip == NULL) {
if (bdp == NULL) {
error = XFS_ERROR(EBADF); error = XFS_ERROR(EBADF);
goto error0; goto error0;
} else {
ip = XFS_BHVTOI(bdp);
} }
if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) ||
...@@ -105,13 +100,10 @@ xfs_swapext( ...@@ -105,13 +100,10 @@ xfs_swapext(
goto error0; goto error0;
} }
tbhp = VN_BHV_HEAD(tvp); tip = xfs_vtoi(tvp);
tbdp = vn_bhv_lookup(tbhp, &xfs_vnodeops); if (tip == NULL) {
if (tbdp == NULL) {
error = XFS_ERROR(EBADF); error = XFS_ERROR(EBADF);
goto error0; goto error0;
} else {
tip = XFS_BHVTOI(tbdp);
} }
if (ip->i_mount != tip->i_mount) { if (ip->i_mount != tip->i_mount) {
......
...@@ -493,7 +493,6 @@ xfs_iget( ...@@ -493,7 +493,6 @@ xfs_iget(
retry: retry:
if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) { if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) {
bhv_desc_t *bdp;
xfs_inode_t *ip; xfs_inode_t *ip;
vp = LINVFS_GET_VP(inode); vp = LINVFS_GET_VP(inode);
...@@ -517,14 +516,12 @@ xfs_iget( ...@@ -517,14 +516,12 @@ xfs_iget(
* to wait for the inode to go away. * to wait for the inode to go away.
*/ */
if (is_bad_inode(inode) || if (is_bad_inode(inode) ||
((bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), ((ip = xfs_vtoi(vp)) == NULL)) {
&xfs_vnodeops)) == NULL)) {
iput(inode); iput(inode);
delay(1); delay(1);
goto retry; goto retry;
} }
ip = XFS_BHVTOI(bdp);
if (lock_flags != 0) if (lock_flags != 0)
xfs_ilock(ip, lock_flags); xfs_ilock(ip, lock_flags);
XFS_STATS_INC(xs_ig_found); XFS_STATS_INC(xs_ig_found);
......
...@@ -436,6 +436,8 @@ void xfs_ichgtime(xfs_inode_t *, int); ...@@ -436,6 +436,8 @@ void xfs_ichgtime(xfs_inode_t *, int);
xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); xfs_fsize_t xfs_file_last_byte(xfs_inode_t *);
void xfs_lock_inodes(xfs_inode_t **, int, int, uint); void xfs_lock_inodes(xfs_inode_t **, int, int, uint);
xfs_inode_t *xfs_vtoi(struct vnode *vp);
void xfs_synchronize_atime(xfs_inode_t *); void xfs_synchronize_atime(xfs_inode_t *);
#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
......
...@@ -243,7 +243,6 @@ xfs_rename( ...@@ -243,7 +243,6 @@ xfs_rename(
xfs_inode_t *inodes[4]; xfs_inode_t *inodes[4];
int target_ip_dropped = 0; /* dropped target_ip link? */ int target_ip_dropped = 0; /* dropped target_ip link? */
vnode_t *src_dir_vp; vnode_t *src_dir_vp;
bhv_desc_t *target_dir_bdp;
int spaceres; int spaceres;
int target_link_zero = 0; int target_link_zero = 0;
int num_inodes; int num_inodes;
...@@ -260,14 +259,12 @@ xfs_rename( ...@@ -260,14 +259,12 @@ xfs_rename(
* Find the XFS behavior descriptor for the target directory * Find the XFS behavior descriptor for the target directory
* vnode since it was not handed to us. * vnode since it was not handed to us.
*/ */
target_dir_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(target_dir_vp), target_dp = xfs_vtoi(target_dir_vp);
&xfs_vnodeops); if (target_dp == NULL) {
if (target_dir_bdp == NULL) {
return XFS_ERROR(EXDEV); return XFS_ERROR(EXDEV);
} }
src_dp = XFS_BHVTOI(src_dir_bdp); src_dp = XFS_BHVTOI(src_dir_bdp);
target_dp = XFS_BHVTOI(target_dir_bdp);
mp = src_dp->i_mount; mp = src_dp->i_mount;
if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_RENAME) || if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_RENAME) ||
......
...@@ -55,16 +55,13 @@ xfs_get_dir_entry( ...@@ -55,16 +55,13 @@ xfs_get_dir_entry(
xfs_inode_t **ipp) xfs_inode_t **ipp)
{ {
vnode_t *vp; vnode_t *vp;
bhv_desc_t *bdp;
vp = VNAME_TO_VNODE(dentry); vp = VNAME_TO_VNODE(dentry);
bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(vp), &xfs_vnodeops);
if (!bdp) { *ipp = xfs_vtoi(vp);
*ipp = NULL; if (!*ipp)
return XFS_ERROR(ENOENT); return XFS_ERROR(ENOENT);
}
VN_HOLD(vp); VN_HOLD(vp);
*ipp = XFS_BHVTOI(bdp);
return 0; return 0;
} }
......
...@@ -2578,7 +2578,6 @@ xfs_link( ...@@ -2578,7 +2578,6 @@ xfs_link(
int cancel_flags; int cancel_flags;
int committed; int committed;
vnode_t *target_dir_vp; vnode_t *target_dir_vp;
bhv_desc_t *src_bdp;
int resblks; int resblks;
char *target_name = VNAME(dentry); char *target_name = VNAME(dentry);
int target_namelen; int target_namelen;
...@@ -2591,8 +2590,7 @@ xfs_link( ...@@ -2591,8 +2590,7 @@ xfs_link(
if (VN_ISDIR(src_vp)) if (VN_ISDIR(src_vp))
return XFS_ERROR(EPERM); return XFS_ERROR(EPERM);
src_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(src_vp), &xfs_vnodeops); sip = xfs_vtoi(src_vp);
sip = XFS_BHVTOI(src_bdp);
tdp = XFS_BHVTOI(target_dir_bdp); tdp = XFS_BHVTOI(target_dir_bdp);
mp = tdp->i_mount; mp = tdp->i_mount;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment