[XFS] Avoid directly referencing the VFS inode.
In several places we directly convert from the XFS inode to the linux (VFS) inode by a simple deference of ip->i_vnode. We should not do this - a helper function should be used to extract the VFS inode from the XFS inode. Introduce the function VFS_I() to extract the VFS inode from the XFS inode. The name was chosen to match XFS_I() which is used to extract the XFS inode from the VFS inode. SGI-PV: 981498 SGI-Modid: xfs-linux-melb:xfs-kern:31720a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Niv Sardi <xaiki@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
parent
3790689fa3
commit
0165164625
|
@ -139,7 +139,7 @@ xfs_nfs_get_inode(
|
|||
}
|
||||
|
||||
xfs_iunlock(ip, XFS_ILOCK_SHARED);
|
||||
return ip->i_vnode;
|
||||
return VFS_I(ip);
|
||||
}
|
||||
|
||||
STATIC struct dentry *
|
||||
|
@ -219,9 +219,9 @@ xfs_fs_get_parent(
|
|||
if (unlikely(error))
|
||||
return ERR_PTR(-error);
|
||||
|
||||
parent = d_alloc_anon(cip->i_vnode);
|
||||
parent = d_alloc_anon(VFS_I(cip));
|
||||
if (unlikely(!parent)) {
|
||||
iput(cip->i_vnode);
|
||||
iput(VFS_I(cip));
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
return parent;
|
||||
|
|
|
@ -31,7 +31,7 @@ xfs_tosspages(
|
|||
xfs_off_t last,
|
||||
int fiopt)
|
||||
{
|
||||
struct address_space *mapping = ip->i_vnode->i_mapping;
|
||||
struct address_space *mapping = VFS_I(ip)->i_mapping;
|
||||
|
||||
if (mapping->nrpages)
|
||||
truncate_inode_pages(mapping, first);
|
||||
|
@ -44,7 +44,7 @@ xfs_flushinval_pages(
|
|||
xfs_off_t last,
|
||||
int fiopt)
|
||||
{
|
||||
struct address_space *mapping = ip->i_vnode->i_mapping;
|
||||
struct address_space *mapping = VFS_I(ip)->i_mapping;
|
||||
int ret = 0;
|
||||
|
||||
if (mapping->nrpages) {
|
||||
|
@ -64,7 +64,7 @@ xfs_flush_pages(
|
|||
uint64_t flags,
|
||||
int fiopt)
|
||||
{
|
||||
struct address_space *mapping = ip->i_vnode->i_mapping;
|
||||
struct address_space *mapping = VFS_I(ip)->i_mapping;
|
||||
int ret = 0;
|
||||
int ret2;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void
|
|||
xfs_synchronize_atime(
|
||||
xfs_inode_t *ip)
|
||||
{
|
||||
struct inode *inode = ip->i_vnode;
|
||||
struct inode *inode = VFS_I(ip);
|
||||
|
||||
if (inode) {
|
||||
ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
|
||||
|
@ -79,7 +79,7 @@ void
|
|||
xfs_mark_inode_dirty_sync(
|
||||
xfs_inode_t *ip)
|
||||
{
|
||||
struct inode *inode = ip->i_vnode;
|
||||
struct inode *inode = VFS_I(ip);
|
||||
|
||||
if (inode)
|
||||
mark_inode_dirty_sync(inode);
|
||||
|
@ -299,7 +299,7 @@ xfs_vn_mknod(
|
|||
if (unlikely(error))
|
||||
goto out_free_acl;
|
||||
|
||||
inode = ip->i_vnode;
|
||||
inode = VFS_I(ip);
|
||||
|
||||
error = xfs_init_security(inode, dir);
|
||||
if (unlikely(error))
|
||||
|
@ -366,7 +366,7 @@ xfs_vn_lookup(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return d_splice_alias(cip->i_vnode, dentry);
|
||||
return d_splice_alias(VFS_I(cip), dentry);
|
||||
}
|
||||
|
||||
STATIC struct dentry *
|
||||
|
@ -399,12 +399,12 @@ xfs_vn_ci_lookup(
|
|||
|
||||
/* if exact match, just splice and exit */
|
||||
if (!ci_name.name)
|
||||
return d_splice_alias(ip->i_vnode, dentry);
|
||||
return d_splice_alias(VFS_I(ip), dentry);
|
||||
|
||||
/* else case-insensitive match... */
|
||||
dname.name = ci_name.name;
|
||||
dname.len = ci_name.len;
|
||||
dentry = d_add_ci(ip->i_vnode, dentry, &dname);
|
||||
dentry = d_add_ci(VFS_I(ip), dentry, &dname);
|
||||
kmem_free(ci_name.name);
|
||||
return dentry;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ xfs_vn_symlink(
|
|||
if (unlikely(error))
|
||||
goto out;
|
||||
|
||||
inode = cip->i_vnode;
|
||||
inode = VFS_I(cip);
|
||||
|
||||
error = xfs_init_security(inode, dir);
|
||||
if (unlikely(error))
|
||||
|
|
|
@ -33,10 +33,4 @@ struct xfs_inode;
|
|||
extern void xfs_ichgtime(struct xfs_inode *, int);
|
||||
extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
|
||||
|
||||
#define xfs_vtoi(vp) \
|
||||
((struct xfs_inode *)vn_to_inode(vp)->i_private)
|
||||
|
||||
#define XFS_I(inode) \
|
||||
((struct xfs_inode *)(inode)->i_private)
|
||||
|
||||
#endif /* __XFS_IOPS_H__ */
|
||||
|
|
|
@ -137,7 +137,7 @@ xfs_iozero(
|
|||
struct address_space *mapping;
|
||||
int status;
|
||||
|
||||
mapping = ip->i_vnode->i_mapping;
|
||||
mapping = VFS_I(ip)->i_mapping;
|
||||
do {
|
||||
unsigned offset, bytes;
|
||||
void *fsdata;
|
||||
|
|
|
@ -1106,7 +1106,7 @@ void
|
|||
xfs_flush_inode(
|
||||
xfs_inode_t *ip)
|
||||
{
|
||||
struct inode *inode = ip->i_vnode;
|
||||
struct inode *inode = VFS_I(ip);
|
||||
|
||||
igrab(inode);
|
||||
xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work);
|
||||
|
@ -1825,7 +1825,7 @@ xfs_fs_fill_super(
|
|||
sb->s_time_gran = 1;
|
||||
set_posix_acl_flag(sb);
|
||||
|
||||
root = igrab(mp->m_rootip->i_vnode);
|
||||
root = igrab(VFS_I(mp->m_rootip));
|
||||
if (!root) {
|
||||
error = ENOENT;
|
||||
goto fail_unmount;
|
||||
|
|
|
@ -411,10 +411,11 @@ xfs_iput(xfs_inode_t *ip,
|
|||
* Special iput for brand-new inodes that are still locked
|
||||
*/
|
||||
void
|
||||
xfs_iput_new(xfs_inode_t *ip,
|
||||
uint lock_flags)
|
||||
xfs_iput_new(
|
||||
xfs_inode_t *ip,
|
||||
uint lock_flags)
|
||||
{
|
||||
struct inode *inode = ip->i_vnode;
|
||||
struct inode *inode = VFS_I(ip);
|
||||
|
||||
xfs_itrace_entry(ip);
|
||||
|
||||
|
|
|
@ -263,6 +263,25 @@ typedef struct xfs_inode {
|
|||
#define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \
|
||||
(ip)->i_size : (ip)->i_d.di_size;
|
||||
|
||||
/* Convert from vfs inode to xfs inode */
|
||||
static inline struct xfs_inode *XFS_I(struct inode *inode)
|
||||
{
|
||||
return (struct xfs_inode *)inode->i_private;
|
||||
}
|
||||
|
||||
static inline struct xfs_inode *xfs_vtoi(bhv_vnode_t *vp)
|
||||
{
|
||||
return XFS_I((struct inode *)vp);
|
||||
}
|
||||
|
||||
/* convert from xfs inode to vfs inode */
|
||||
static inline struct inode *VFS_I(struct xfs_inode *ip)
|
||||
{
|
||||
return (struct inode *)ip->i_vnode;
|
||||
}
|
||||
#define XFS_ITOV(ip) VFS_I(ip)
|
||||
#define XFS_ITOV_NULL(ip) VFS_I(ip)
|
||||
|
||||
/*
|
||||
* i_flags helper functions
|
||||
*/
|
||||
|
@ -439,9 +458,6 @@ xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags)
|
|||
#define XFS_ITRUNC_DEFINITE 0x1
|
||||
#define XFS_ITRUNC_MAYBE 0x2
|
||||
|
||||
#define XFS_ITOV(ip) ((ip)->i_vnode)
|
||||
#define XFS_ITOV_NULL(ip) ((ip)->i_vnode)
|
||||
|
||||
/*
|
||||
* For multiple groups support: if S_ISGID bit is set in the parent
|
||||
* directory, group of new file is set to that of the parent, and
|
||||
|
|
|
@ -237,7 +237,7 @@ xfs_droplink(
|
|||
|
||||
ASSERT (ip->i_d.di_nlink > 0);
|
||||
ip->i_d.di_nlink--;
|
||||
drop_nlink(ip->i_vnode);
|
||||
drop_nlink(VFS_I(ip));
|
||||
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
|
||||
|
||||
error = 0;
|
||||
|
@ -301,7 +301,7 @@ xfs_bumplink(
|
|||
|
||||
ASSERT(ip->i_d.di_nlink > 0);
|
||||
ip->i_d.di_nlink++;
|
||||
inc_nlink(ip->i_vnode);
|
||||
inc_nlink(VFS_I(ip));
|
||||
if ((ip->i_d.di_version == XFS_DINODE_VERSION_1) &&
|
||||
(ip->i_d.di_nlink > XFS_MAXLINK_1)) {
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue