aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-08-13 01:45:15 -0400
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-08-13 01:45:15 -0400
commit016516462575d28fab3354f762cad16c86c09116 (patch)
treeef644fe09f5eb963df28ad7e7bda3d547cae46d1 /fs
parent3790689fa3c771bba6bafb7dee3e8389dd0b55bc (diff)
[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>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c14
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h6
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c4
-rw-r--r--fs/xfs/xfs_iget.c7
-rw-r--r--fs/xfs/xfs_inode.h22
-rw-r--r--fs/xfs/xfs_utils.c4
9 files changed, 41 insertions, 30 deletions
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index 987fe84f7b13..d3880b7c147d 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -139,7 +139,7 @@ xfs_nfs_get_inode(
139 } 139 }
140 140
141 xfs_iunlock(ip, XFS_ILOCK_SHARED); 141 xfs_iunlock(ip, XFS_ILOCK_SHARED);
142 return ip->i_vnode; 142 return VFS_I(ip);
143} 143}
144 144
145STATIC struct dentry * 145STATIC struct dentry *
@@ -219,9 +219,9 @@ xfs_fs_get_parent(
219 if (unlikely(error)) 219 if (unlikely(error))
220 return ERR_PTR(-error); 220 return ERR_PTR(-error);
221 221
222 parent = d_alloc_anon(cip->i_vnode); 222 parent = d_alloc_anon(VFS_I(cip));
223 if (unlikely(!parent)) { 223 if (unlikely(!parent)) {
224 iput(cip->i_vnode); 224 iput(VFS_I(cip));
225 return ERR_PTR(-ENOMEM); 225 return ERR_PTR(-ENOMEM);
226 } 226 }
227 return parent; 227 return parent;
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 1eefe61f0e10..36caa6d957df 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -31,7 +31,7 @@ xfs_tosspages(
31 xfs_off_t last, 31 xfs_off_t last,
32 int fiopt) 32 int fiopt)
33{ 33{
34 struct address_space *mapping = ip->i_vnode->i_mapping; 34 struct address_space *mapping = VFS_I(ip)->i_mapping;
35 35
36 if (mapping->nrpages) 36 if (mapping->nrpages)
37 truncate_inode_pages(mapping, first); 37 truncate_inode_pages(mapping, first);
@@ -44,7 +44,7 @@ xfs_flushinval_pages(
44 xfs_off_t last, 44 xfs_off_t last,
45 int fiopt) 45 int fiopt)
46{ 46{
47 struct address_space *mapping = ip->i_vnode->i_mapping; 47 struct address_space *mapping = VFS_I(ip)->i_mapping;
48 int ret = 0; 48 int ret = 0;
49 49
50 if (mapping->nrpages) { 50 if (mapping->nrpages) {
@@ -64,7 +64,7 @@ xfs_flush_pages(
64 uint64_t flags, 64 uint64_t flags,
65 int fiopt) 65 int fiopt)
66{ 66{
67 struct address_space *mapping = ip->i_vnode->i_mapping; 67 struct address_space *mapping = VFS_I(ip)->i_mapping;
68 int ret = 0; 68 int ret = 0;
69 int ret2; 69 int ret2;
70 70
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index e88f51028086..fec5ff5a2f17 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -62,7 +62,7 @@ void
62xfs_synchronize_atime( 62xfs_synchronize_atime(
63 xfs_inode_t *ip) 63 xfs_inode_t *ip)
64{ 64{
65 struct inode *inode = ip->i_vnode; 65 struct inode *inode = VFS_I(ip);
66 66
67 if (inode) { 67 if (inode) {
68 ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec; 68 ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
@@ -79,7 +79,7 @@ void
79xfs_mark_inode_dirty_sync( 79xfs_mark_inode_dirty_sync(
80 xfs_inode_t *ip) 80 xfs_inode_t *ip)
81{ 81{
82 struct inode *inode = ip->i_vnode; 82 struct inode *inode = VFS_I(ip);
83 83
84 if (inode) 84 if (inode)
85 mark_inode_dirty_sync(inode); 85 mark_inode_dirty_sync(inode);
@@ -299,7 +299,7 @@ xfs_vn_mknod(
299 if (unlikely(error)) 299 if (unlikely(error))
300 goto out_free_acl; 300 goto out_free_acl;
301 301
302 inode = ip->i_vnode; 302 inode = VFS_I(ip);
303 303
304 error = xfs_init_security(inode, dir); 304 error = xfs_init_security(inode, dir);
305 if (unlikely(error)) 305 if (unlikely(error))
@@ -366,7 +366,7 @@ xfs_vn_lookup(
366 return NULL; 366 return NULL;
367 } 367 }
368 368
369 return d_splice_alias(cip->i_vnode, dentry); 369 return d_splice_alias(VFS_I(cip), dentry);
370} 370}
371 371
372STATIC struct dentry * 372STATIC struct dentry *
@@ -399,12 +399,12 @@ xfs_vn_ci_lookup(
399 399
400 /* if exact match, just splice and exit */ 400 /* if exact match, just splice and exit */
401 if (!ci_name.name) 401 if (!ci_name.name)
402 return d_splice_alias(ip->i_vnode, dentry); 402 return d_splice_alias(VFS_I(ip), dentry);
403 403
404 /* else case-insensitive match... */ 404 /* else case-insensitive match... */
405 dname.name = ci_name.name; 405 dname.name = ci_name.name;
406 dname.len = ci_name.len; 406 dname.len = ci_name.len;
407 dentry = d_add_ci(ip->i_vnode, dentry, &dname); 407 dentry = d_add_ci(VFS_I(ip), dentry, &dname);
408 kmem_free(ci_name.name); 408 kmem_free(ci_name.name);
409 return dentry; 409 return dentry;
410} 410}
@@ -478,7 +478,7 @@ xfs_vn_symlink(
478 if (unlikely(error)) 478 if (unlikely(error))
479 goto out; 479 goto out;
480 480
481 inode = cip->i_vnode; 481 inode = VFS_I(cip);
482 482
483 error = xfs_init_security(inode, dir); 483 error = xfs_init_security(inode, dir);
484 if (unlikely(error)) 484 if (unlikely(error))
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index d97ba934a2ac..fdda404bc343 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -33,10 +33,4 @@ struct xfs_inode;
33extern void xfs_ichgtime(struct xfs_inode *, int); 33extern void xfs_ichgtime(struct xfs_inode *, int);
34extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int); 34extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
35 35
36#define xfs_vtoi(vp) \
37 ((struct xfs_inode *)vn_to_inode(vp)->i_private)
38
39#define XFS_I(inode) \
40 ((struct xfs_inode *)(inode)->i_private)
41
42#endif /* __XFS_IOPS_H__ */ 36#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 82333b3e118e..e03e2c3789b7 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -137,7 +137,7 @@ xfs_iozero(
137 struct address_space *mapping; 137 struct address_space *mapping;
138 int status; 138 int status;
139 139
140 mapping = ip->i_vnode->i_mapping; 140 mapping = VFS_I(ip)->i_mapping;
141 do { 141 do {
142 unsigned offset, bytes; 142 unsigned offset, bytes;
143 void *fsdata; 143 void *fsdata;
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 30ae96397e31..b49722940d6d 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1106,7 +1106,7 @@ void
1106xfs_flush_inode( 1106xfs_flush_inode(
1107 xfs_inode_t *ip) 1107 xfs_inode_t *ip)
1108{ 1108{
1109 struct inode *inode = ip->i_vnode; 1109 struct inode *inode = VFS_I(ip);
1110 1110
1111 igrab(inode); 1111 igrab(inode);
1112 xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work); 1112 xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work);
@@ -1825,7 +1825,7 @@ xfs_fs_fill_super(
1825 sb->s_time_gran = 1; 1825 sb->s_time_gran = 1;
1826 set_posix_acl_flag(sb); 1826 set_posix_acl_flag(sb);
1827 1827
1828 root = igrab(mp->m_rootip->i_vnode); 1828 root = igrab(VFS_I(mp->m_rootip));
1829 if (!root) { 1829 if (!root) {
1830 error = ENOENT; 1830 error = ENOENT;
1831 goto fail_unmount; 1831 goto fail_unmount;
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index b07604b94d9f..d44342640ca3 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -411,10 +411,11 @@ xfs_iput(xfs_inode_t *ip,
411 * Special iput for brand-new inodes that are still locked 411 * Special iput for brand-new inodes that are still locked
412 */ 412 */
413void 413void
414xfs_iput_new(xfs_inode_t *ip, 414xfs_iput_new(
415 uint lock_flags) 415 xfs_inode_t *ip,
416 uint lock_flags)
416{ 417{
417 struct inode *inode = ip->i_vnode; 418 struct inode *inode = VFS_I(ip);
418 419
419 xfs_itrace_entry(ip); 420 xfs_itrace_entry(ip);
420 421
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 17a04b6321ed..4a5e48c8ded2 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -263,6 +263,25 @@ typedef struct xfs_inode {
263#define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \ 263#define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \
264 (ip)->i_size : (ip)->i_d.di_size; 264 (ip)->i_size : (ip)->i_d.di_size;
265 265
266/* Convert from vfs inode to xfs inode */
267static inline struct xfs_inode *XFS_I(struct inode *inode)
268{
269 return (struct xfs_inode *)inode->i_private;
270}
271
272static inline struct xfs_inode *xfs_vtoi(bhv_vnode_t *vp)
273{
274 return XFS_I((struct inode *)vp);
275}
276
277/* convert from xfs inode to vfs inode */
278static inline struct inode *VFS_I(struct xfs_inode *ip)
279{
280 return (struct inode *)ip->i_vnode;
281}
282#define XFS_ITOV(ip) VFS_I(ip)
283#define XFS_ITOV_NULL(ip) VFS_I(ip)
284
266/* 285/*
267 * i_flags helper functions 286 * i_flags helper functions
268 */ 287 */
@@ -439,9 +458,6 @@ xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags)
439#define XFS_ITRUNC_DEFINITE 0x1 458#define XFS_ITRUNC_DEFINITE 0x1
440#define XFS_ITRUNC_MAYBE 0x2 459#define XFS_ITRUNC_MAYBE 0x2
441 460
442#define XFS_ITOV(ip) ((ip)->i_vnode)
443#define XFS_ITOV_NULL(ip) ((ip)->i_vnode)
444
445/* 461/*
446 * For multiple groups support: if S_ISGID bit is set in the parent 462 * For multiple groups support: if S_ISGID bit is set in the parent
447 * directory, group of new file is set to that of the parent, and 463 * directory, group of new file is set to that of the parent, and
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 98e5f110ba5f..35d4d414bcc2 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -237,7 +237,7 @@ xfs_droplink(
237 237
238 ASSERT (ip->i_d.di_nlink > 0); 238 ASSERT (ip->i_d.di_nlink > 0);
239 ip->i_d.di_nlink--; 239 ip->i_d.di_nlink--;
240 drop_nlink(ip->i_vnode); 240 drop_nlink(VFS_I(ip));
241 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 241 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
242 242
243 error = 0; 243 error = 0;
@@ -301,7 +301,7 @@ xfs_bumplink(
301 301
302 ASSERT(ip->i_d.di_nlink > 0); 302 ASSERT(ip->i_d.di_nlink > 0);
303 ip->i_d.di_nlink++; 303 ip->i_d.di_nlink++;
304 inc_nlink(ip->i_vnode); 304 inc_nlink(VFS_I(ip));
305 if ((ip->i_d.di_version == XFS_DINODE_VERSION_1) && 305 if ((ip->i_d.di_version == XFS_DINODE_VERSION_1) &&
306 (ip->i_d.di_nlink > XFS_MAXLINK_1)) { 306 (ip->i_d.di_nlink > XFS_MAXLINK_1)) {
307 /* 307 /*