aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r--fs/xfs/linux-2.6/kmem.h91
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c484
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c8
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c37
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c187
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c138
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c12
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c317
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h12
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h10
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c51
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c7
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c213
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h7
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.c19
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h3
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c35
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h33
22 files changed, 871 insertions, 810 deletions
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index c64a29cdfff3..f0268a84e6fd 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -23,17 +23,8 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24 24
25/* 25/*
26 * memory management routines 26 * Process flags handling
27 */ 27 */
28#define KM_SLEEP 0x0001u
29#define KM_NOSLEEP 0x0002u
30#define KM_NOFS 0x0004u
31#define KM_MAYFAIL 0x0008u
32
33#define kmem_zone kmem_cache
34#define kmem_zone_t struct kmem_cache
35
36typedef unsigned long xfs_pflags_t;
37 28
38#define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO) 29#define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO)
39#define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS) 30#define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS)
@@ -67,74 +58,102 @@ typedef unsigned long xfs_pflags_t;
67 *(NSTATEP) = *(OSTATEP); \ 58 *(NSTATEP) = *(OSTATEP); \
68} while (0) 59} while (0)
69 60
70static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) 61/*
62 * General memory allocation interfaces
63 */
64
65#define KM_SLEEP 0x0001u
66#define KM_NOSLEEP 0x0002u
67#define KM_NOFS 0x0004u
68#define KM_MAYFAIL 0x0008u
69
70/*
71 * We use a special process flag to avoid recursive callbacks into
72 * the filesystem during transactions. We will also issue our own
73 * warnings, so we explicitly skip any generic ones (silly of us).
74 */
75static inline gfp_t
76kmem_flags_convert(unsigned int __nocast flags)
71{ 77{
72 gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ 78 gfp_t lflags;
73 79
74#ifdef DEBUG 80 BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL));
75 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
76 printk(KERN_WARNING
77 "XFS: memory allocation with wrong flags (%x)\n", flags);
78 BUG();
79 }
80#endif
81 81
82 if (flags & KM_NOSLEEP) { 82 if (flags & KM_NOSLEEP) {
83 lflags |= GFP_ATOMIC; 83 lflags = GFP_ATOMIC | __GFP_NOWARN;
84 } else { 84 } else {
85 lflags |= GFP_KERNEL; 85 lflags = GFP_KERNEL | __GFP_NOWARN;
86
87 /* avoid recusive callbacks to filesystem during transactions */
88 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) 86 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
89 lflags &= ~__GFP_FS; 87 lflags &= ~__GFP_FS;
90 } 88 }
91 89 return lflags;
92 return lflags;
93} 90}
94 91
95static __inline kmem_zone_t * 92extern void *kmem_alloc(size_t, unsigned int __nocast);
93extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
94extern void *kmem_zalloc(size_t, unsigned int __nocast);
95extern void kmem_free(void *, size_t);
96
97/*
98 * Zone interfaces
99 */
100
101#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN
102#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT
103#define KM_ZONE_SPREAD 0
104
105#define kmem_zone kmem_cache
106#define kmem_zone_t struct kmem_cache
107
108static inline kmem_zone_t *
96kmem_zone_init(int size, char *zone_name) 109kmem_zone_init(int size, char *zone_name)
97{ 110{
98 return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL); 111 return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
99} 112}
100 113
101static __inline void 114static inline kmem_zone_t *
115kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
116 void (*construct)(void *, kmem_zone_t *, unsigned long))
117{
118 return kmem_cache_create(zone_name, size, 0, flags, construct, NULL);
119}
120
121static inline void
102kmem_zone_free(kmem_zone_t *zone, void *ptr) 122kmem_zone_free(kmem_zone_t *zone, void *ptr)
103{ 123{
104 kmem_cache_free(zone, ptr); 124 kmem_cache_free(zone, ptr);
105} 125}
106 126
107static __inline void 127static inline void
108kmem_zone_destroy(kmem_zone_t *zone) 128kmem_zone_destroy(kmem_zone_t *zone)
109{ 129{
110 if (zone && kmem_cache_destroy(zone)) 130 if (zone && kmem_cache_destroy(zone))
111 BUG(); 131 BUG();
112} 132}
113 133
114extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
115extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); 134extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
135extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
116 136
117extern void *kmem_alloc(size_t, unsigned int __nocast); 137/*
118extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); 138 * Low memory cache shrinkers
119extern void *kmem_zalloc(size_t, unsigned int __nocast); 139 */
120extern void kmem_free(void *, size_t);
121 140
122typedef struct shrinker *kmem_shaker_t; 141typedef struct shrinker *kmem_shaker_t;
123typedef int (*kmem_shake_func_t)(int, gfp_t); 142typedef int (*kmem_shake_func_t)(int, gfp_t);
124 143
125static __inline kmem_shaker_t 144static inline kmem_shaker_t
126kmem_shake_register(kmem_shake_func_t sfunc) 145kmem_shake_register(kmem_shake_func_t sfunc)
127{ 146{
128 return set_shrinker(DEFAULT_SEEKS, sfunc); 147 return set_shrinker(DEFAULT_SEEKS, sfunc);
129} 148}
130 149
131static __inline void 150static inline void
132kmem_shake_deregister(kmem_shaker_t shrinker) 151kmem_shake_deregister(kmem_shaker_t shrinker)
133{ 152{
134 remove_shrinker(shrinker); 153 remove_shrinker(shrinker);
135} 154}
136 155
137static __inline int 156static inline int
138kmem_shake_allow(gfp_t gfp_mask) 157kmem_shake_allow(gfp_t gfp_mask)
139{ 158{
140 return (gfp_mask & __GFP_WAIT); 159 return (gfp_mask & __GFP_WAIT);
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 74d8be87f983..97fc056130eb 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -43,7 +43,29 @@
43#include <linux/pagevec.h> 43#include <linux/pagevec.h>
44#include <linux/writeback.h> 44#include <linux/writeback.h>
45 45
46STATIC void xfs_count_page_state(struct page *, int *, int *, int *); 46STATIC void
47xfs_count_page_state(
48 struct page *page,
49 int *delalloc,
50 int *unmapped,
51 int *unwritten)
52{
53 struct buffer_head *bh, *head;
54
55 *delalloc = *unmapped = *unwritten = 0;
56
57 bh = head = page_buffers(page);
58 do {
59 if (buffer_uptodate(bh) && !buffer_mapped(bh))
60 (*unmapped) = 1;
61 else if (buffer_unwritten(bh) && !buffer_delay(bh))
62 clear_buffer_unwritten(bh);
63 else if (buffer_unwritten(bh))
64 (*unwritten) = 1;
65 else if (buffer_delay(bh))
66 (*delalloc) = 1;
67 } while ((bh = bh->b_this_page) != head);
68}
47 69
48#if defined(XFS_RW_TRACE) 70#if defined(XFS_RW_TRACE)
49void 71void
@@ -54,7 +76,7 @@ xfs_page_trace(
54 int mask) 76 int mask)
55{ 77{
56 xfs_inode_t *ip; 78 xfs_inode_t *ip;
57 vnode_t *vp = LINVFS_GET_VP(inode); 79 vnode_t *vp = vn_from_inode(inode);
58 loff_t isize = i_size_read(inode); 80 loff_t isize = i_size_read(inode);
59 loff_t offset = page_offset(page); 81 loff_t offset = page_offset(page);
60 int delalloc = -1, unmapped = -1, unwritten = -1; 82 int delalloc = -1, unmapped = -1, unwritten = -1;
@@ -81,7 +103,7 @@ xfs_page_trace(
81 (void *)((unsigned long)delalloc), 103 (void *)((unsigned long)delalloc),
82 (void *)((unsigned long)unmapped), 104 (void *)((unsigned long)unmapped),
83 (void *)((unsigned long)unwritten), 105 (void *)((unsigned long)unwritten),
84 (void *)NULL, 106 (void *)((unsigned long)current_pid()),
85 (void *)NULL); 107 (void *)NULL);
86} 108}
87#else 109#else
@@ -192,7 +214,7 @@ xfs_alloc_ioend(
192 ioend->io_uptodate = 1; /* cleared if any I/O fails */ 214 ioend->io_uptodate = 1; /* cleared if any I/O fails */
193 ioend->io_list = NULL; 215 ioend->io_list = NULL;
194 ioend->io_type = type; 216 ioend->io_type = type;
195 ioend->io_vnode = LINVFS_GET_VP(inode); 217 ioend->io_vnode = vn_from_inode(inode);
196 ioend->io_buffer_head = NULL; 218 ioend->io_buffer_head = NULL;
197 ioend->io_buffer_tail = NULL; 219 ioend->io_buffer_tail = NULL;
198 atomic_inc(&ioend->io_vnode->v_iocount); 220 atomic_inc(&ioend->io_vnode->v_iocount);
@@ -217,7 +239,7 @@ xfs_map_blocks(
217 xfs_iomap_t *mapp, 239 xfs_iomap_t *mapp,
218 int flags) 240 int flags)
219{ 241{
220 vnode_t *vp = LINVFS_GET_VP(inode); 242 vnode_t *vp = vn_from_inode(inode);
221 int error, nmaps = 1; 243 int error, nmaps = 1;
222 244
223 VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error); 245 VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error);
@@ -462,28 +484,37 @@ xfs_add_to_ioend(
462} 484}
463 485
464STATIC void 486STATIC void
487xfs_map_buffer(
488 struct buffer_head *bh,
489 xfs_iomap_t *mp,
490 xfs_off_t offset,
491 uint block_bits)
492{
493 sector_t bn;
494
495 ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
496
497 bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) +
498 ((offset - mp->iomap_offset) >> block_bits);
499
500 ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME));
501
502 bh->b_blocknr = bn;
503 set_buffer_mapped(bh);
504}
505
506STATIC void
465xfs_map_at_offset( 507xfs_map_at_offset(
466 struct buffer_head *bh, 508 struct buffer_head *bh,
467 loff_t offset, 509 loff_t offset,
468 int block_bits, 510 int block_bits,
469 xfs_iomap_t *iomapp) 511 xfs_iomap_t *iomapp)
470{ 512{
471 xfs_daddr_t bn;
472 int sector_shift;
473
474 ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); 513 ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
475 ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); 514 ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
476 ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
477
478 sector_shift = block_bits - BBSHIFT;
479 bn = (iomapp->iomap_bn >> sector_shift) +
480 ((offset - iomapp->iomap_offset) >> block_bits);
481
482 ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME));
483 ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
484 515
485 lock_buffer(bh); 516 lock_buffer(bh);
486 bh->b_blocknr = bn; 517 xfs_map_buffer(bh, iomapp, offset, block_bits);
487 bh->b_bdev = iomapp->iomap_target->bt_bdev; 518 bh->b_bdev = iomapp->iomap_target->bt_bdev;
488 set_buffer_mapped(bh); 519 set_buffer_mapped(bh);
489 clear_buffer_delay(bh); 520 clear_buffer_delay(bh);
@@ -616,7 +647,7 @@ xfs_is_delayed_page(
616 acceptable = (type == IOMAP_UNWRITTEN); 647 acceptable = (type == IOMAP_UNWRITTEN);
617 else if (buffer_delay(bh)) 648 else if (buffer_delay(bh))
618 acceptable = (type == IOMAP_DELAY); 649 acceptable = (type == IOMAP_DELAY);
619 else if (buffer_mapped(bh)) 650 else if (buffer_dirty(bh) && buffer_mapped(bh))
620 acceptable = (type == 0); 651 acceptable = (type == 0);
621 else 652 else
622 break; 653 break;
@@ -1040,8 +1071,159 @@ error:
1040 return err; 1071 return err;
1041} 1072}
1042 1073
1074/*
1075 * writepage: Called from one of two places:
1076 *
1077 * 1. we are flushing a delalloc buffer head.
1078 *
1079 * 2. we are writing out a dirty page. Typically the page dirty
1080 * state is cleared before we get here. In this case is it
1081 * conceivable we have no buffer heads.
1082 *
1083 * For delalloc space on the page we need to allocate space and
1084 * flush it. For unmapped buffer heads on the page we should
1085 * allocate space if the page is uptodate. For any other dirty
1086 * buffer heads on the page we should flush them.
1087 *
1088 * If we detect that a transaction would be required to flush
1089 * the page, we have to check the process flags first, if we
1090 * are already in a transaction or disk I/O during allocations
1091 * is off, we need to fail the writepage and redirty the page.
1092 */
1093
1094STATIC int
1095xfs_vm_writepage(
1096 struct page *page,
1097 struct writeback_control *wbc)
1098{
1099 int error;
1100 int need_trans;
1101 int delalloc, unmapped, unwritten;
1102 struct inode *inode = page->mapping->host;
1103
1104 xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
1105
1106 /*
1107 * We need a transaction if:
1108 * 1. There are delalloc buffers on the page
1109 * 2. The page is uptodate and we have unmapped buffers
1110 * 3. The page is uptodate and we have no buffers
1111 * 4. There are unwritten buffers on the page
1112 */
1113
1114 if (!page_has_buffers(page)) {
1115 unmapped = 1;
1116 need_trans = 1;
1117 } else {
1118 xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
1119 if (!PageUptodate(page))
1120 unmapped = 0;
1121 need_trans = delalloc + unmapped + unwritten;
1122 }
1123
1124 /*
1125 * If we need a transaction and the process flags say
1126 * we are already in a transaction, or no IO is allowed
1127 * then mark the page dirty again and leave the page
1128 * as is.
1129 */
1130 if (PFLAGS_TEST_FSTRANS() && need_trans)
1131 goto out_fail;
1132
1133 /*
1134 * Delay hooking up buffer heads until we have
1135 * made our go/no-go decision.
1136 */
1137 if (!page_has_buffers(page))
1138 create_empty_buffers(page, 1 << inode->i_blkbits, 0);
1139
1140 /*
1141 * Convert delayed allocate, unwritten or unmapped space
1142 * to real space and flush out to disk.
1143 */
1144 error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
1145 if (error == -EAGAIN)
1146 goto out_fail;
1147 if (unlikely(error < 0))
1148 goto out_unlock;
1149
1150 return 0;
1151
1152out_fail:
1153 redirty_page_for_writepage(wbc, page);
1154 unlock_page(page);
1155 return 0;
1156out_unlock:
1157 unlock_page(page);
1158 return error;
1159}
1160
1161/*
1162 * Called to move a page into cleanable state - and from there
1163 * to be released. Possibly the page is already clean. We always
1164 * have buffer heads in this call.
1165 *
1166 * Returns 0 if the page is ok to release, 1 otherwise.
1167 *
1168 * Possible scenarios are:
1169 *
1170 * 1. We are being called to release a page which has been written
1171 * to via regular I/O. buffer heads will be dirty and possibly
1172 * delalloc. If no delalloc buffer heads in this case then we
1173 * can just return zero.
1174 *
1175 * 2. We are called to release a page which has been written via
1176 * mmap, all we need to do is ensure there is no delalloc
1177 * state in the buffer heads, if not we can let the caller
1178 * free them and we should come back later via writepage.
1179 */
1043STATIC int 1180STATIC int
1044__linvfs_get_block( 1181xfs_vm_releasepage(
1182 struct page *page,
1183 gfp_t gfp_mask)
1184{
1185 struct inode *inode = page->mapping->host;
1186 int dirty, delalloc, unmapped, unwritten;
1187 struct writeback_control wbc = {
1188 .sync_mode = WB_SYNC_ALL,
1189 .nr_to_write = 1,
1190 };
1191
1192 xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
1193
1194 if (!page_has_buffers(page))
1195 return 0;
1196
1197 xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
1198 if (!delalloc && !unwritten)
1199 goto free_buffers;
1200
1201 if (!(gfp_mask & __GFP_FS))
1202 return 0;
1203
1204 /* If we are already inside a transaction or the thread cannot
1205 * do I/O, we cannot release this page.
1206 */
1207 if (PFLAGS_TEST_FSTRANS())
1208 return 0;
1209
1210 /*
1211 * Convert delalloc space to real space, do not flush the
1212 * data out to disk, that will be done by the caller.
1213 * Never need to allocate space here - we will always
1214 * come back to writepage in that case.
1215 */
1216 dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
1217 if (dirty == 0 && !unwritten)
1218 goto free_buffers;
1219 return 0;
1220
1221free_buffers:
1222 return try_to_free_buffers(page);
1223}
1224
1225STATIC int
1226__xfs_get_block(
1045 struct inode *inode, 1227 struct inode *inode,
1046 sector_t iblock, 1228 sector_t iblock,
1047 unsigned long blocks, 1229 unsigned long blocks,
@@ -1050,7 +1232,7 @@ __linvfs_get_block(
1050 int direct, 1232 int direct,
1051 bmapi_flags_t flags) 1233 bmapi_flags_t flags)
1052{ 1234{
1053 vnode_t *vp = LINVFS_GET_VP(inode); 1235 vnode_t *vp = vn_from_inode(inode);
1054 xfs_iomap_t iomap; 1236 xfs_iomap_t iomap;
1055 xfs_off_t offset; 1237 xfs_off_t offset;
1056 ssize_t size; 1238 ssize_t size;
@@ -1073,21 +1255,13 @@ __linvfs_get_block(
1073 return 0; 1255 return 0;
1074 1256
1075 if (iomap.iomap_bn != IOMAP_DADDR_NULL) { 1257 if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
1076 xfs_daddr_t bn; 1258 /*
1077 xfs_off_t delta; 1259 * For unwritten extents do not report a disk address on
1078
1079 /* For unwritten extents do not report a disk address on
1080 * the read case (treat as if we're reading into a hole). 1260 * the read case (treat as if we're reading into a hole).
1081 */ 1261 */
1082 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1262 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1083 delta = offset - iomap.iomap_offset; 1263 xfs_map_buffer(bh_result, &iomap, offset,
1084 delta >>= inode->i_blkbits; 1264 inode->i_blkbits);
1085
1086 bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
1087 bn += delta;
1088 BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
1089 bh_result->b_blocknr = bn;
1090 set_buffer_mapped(bh_result);
1091 } 1265 }
1092 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1266 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1093 if (direct) 1267 if (direct)
@@ -1130,30 +1304,30 @@ __linvfs_get_block(
1130} 1304}
1131 1305
1132int 1306int
1133linvfs_get_block( 1307xfs_get_block(
1134 struct inode *inode, 1308 struct inode *inode,
1135 sector_t iblock, 1309 sector_t iblock,
1136 struct buffer_head *bh_result, 1310 struct buffer_head *bh_result,
1137 int create) 1311 int create)
1138{ 1312{
1139 return __linvfs_get_block(inode, iblock, 0, bh_result, 1313 return __xfs_get_block(inode, iblock, 0, bh_result,
1140 create, 0, BMAPI_WRITE); 1314 create, 0, BMAPI_WRITE);
1141} 1315}
1142 1316
1143STATIC int 1317STATIC int
1144linvfs_get_blocks_direct( 1318xfs_get_blocks_direct(
1145 struct inode *inode, 1319 struct inode *inode,
1146 sector_t iblock, 1320 sector_t iblock,
1147 unsigned long max_blocks, 1321 unsigned long max_blocks,
1148 struct buffer_head *bh_result, 1322 struct buffer_head *bh_result,
1149 int create) 1323 int create)
1150{ 1324{
1151 return __linvfs_get_block(inode, iblock, max_blocks, bh_result, 1325 return __xfs_get_block(inode, iblock, max_blocks, bh_result,
1152 create, 1, BMAPI_WRITE|BMAPI_DIRECT); 1326 create, 1, BMAPI_WRITE|BMAPI_DIRECT);
1153} 1327}
1154 1328
1155STATIC void 1329STATIC void
1156linvfs_end_io_direct( 1330xfs_end_io_direct(
1157 struct kiocb *iocb, 1331 struct kiocb *iocb,
1158 loff_t offset, 1332 loff_t offset,
1159 ssize_t size, 1333 ssize_t size,
@@ -1191,7 +1365,7 @@ linvfs_end_io_direct(
1191} 1365}
1192 1366
1193STATIC ssize_t 1367STATIC ssize_t
1194linvfs_direct_IO( 1368xfs_vm_direct_IO(
1195 int rw, 1369 int rw,
1196 struct kiocb *iocb, 1370 struct kiocb *iocb,
1197 const struct iovec *iov, 1371 const struct iovec *iov,
@@ -1200,7 +1374,7 @@ linvfs_direct_IO(
1200{ 1374{
1201 struct file *file = iocb->ki_filp; 1375 struct file *file = iocb->ki_filp;
1202 struct inode *inode = file->f_mapping->host; 1376 struct inode *inode = file->f_mapping->host;
1203 vnode_t *vp = LINVFS_GET_VP(inode); 1377 vnode_t *vp = vn_from_inode(inode);
1204 xfs_iomap_t iomap; 1378 xfs_iomap_t iomap;
1205 int maps = 1; 1379 int maps = 1;
1206 int error; 1380 int error;
@@ -1215,164 +1389,61 @@ linvfs_direct_IO(
1215 ret = blockdev_direct_IO_own_locking(rw, iocb, inode, 1389 ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
1216 iomap.iomap_target->bt_bdev, 1390 iomap.iomap_target->bt_bdev,
1217 iov, offset, nr_segs, 1391 iov, offset, nr_segs,
1218 linvfs_get_blocks_direct, 1392 xfs_get_blocks_direct,
1219 linvfs_end_io_direct); 1393 xfs_end_io_direct);
1220 1394
1221 if (unlikely(ret <= 0 && iocb->private)) 1395 if (unlikely(ret <= 0 && iocb->private))
1222 xfs_destroy_ioend(iocb->private); 1396 xfs_destroy_ioend(iocb->private);
1223 return ret; 1397 return ret;
1224} 1398}
1225 1399
1400STATIC int
1401xfs_vm_prepare_write(
1402 struct file *file,
1403 struct page *page,
1404 unsigned int from,
1405 unsigned int to)
1406{
1407 return block_prepare_write(page, from, to, xfs_get_block);
1408}
1226 1409
1227STATIC sector_t 1410STATIC sector_t
1228linvfs_bmap( 1411xfs_vm_bmap(
1229 struct address_space *mapping, 1412 struct address_space *mapping,
1230 sector_t block) 1413 sector_t block)
1231{ 1414{
1232 struct inode *inode = (struct inode *)mapping->host; 1415 struct inode *inode = (struct inode *)mapping->host;
1233 vnode_t *vp = LINVFS_GET_VP(inode); 1416 vnode_t *vp = vn_from_inode(inode);
1234 int error; 1417 int error;
1235 1418
1236 vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address); 1419 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
1237 1420
1238 VOP_RWLOCK(vp, VRWLOCK_READ); 1421 VOP_RWLOCK(vp, VRWLOCK_READ);
1239 VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error); 1422 VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
1240 VOP_RWUNLOCK(vp, VRWLOCK_READ); 1423 VOP_RWUNLOCK(vp, VRWLOCK_READ);
1241 return generic_block_bmap(mapping, block, linvfs_get_block); 1424 return generic_block_bmap(mapping, block, xfs_get_block);
1242} 1425}
1243 1426
1244STATIC int 1427STATIC int
1245linvfs_readpage( 1428xfs_vm_readpage(
1246 struct file *unused, 1429 struct file *unused,
1247 struct page *page) 1430 struct page *page)
1248{ 1431{
1249 return mpage_readpage(page, linvfs_get_block); 1432 return mpage_readpage(page, xfs_get_block);
1250} 1433}
1251 1434
1252STATIC int 1435STATIC int
1253linvfs_readpages( 1436xfs_vm_readpages(
1254 struct file *unused, 1437 struct file *unused,
1255 struct address_space *mapping, 1438 struct address_space *mapping,
1256 struct list_head *pages, 1439 struct list_head *pages,
1257 unsigned nr_pages) 1440 unsigned nr_pages)
1258{ 1441{
1259 return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block); 1442 return mpage_readpages(mapping, pages, nr_pages, xfs_get_block);
1260}
1261
1262STATIC void
1263xfs_count_page_state(
1264 struct page *page,
1265 int *delalloc,
1266 int *unmapped,
1267 int *unwritten)
1268{
1269 struct buffer_head *bh, *head;
1270
1271 *delalloc = *unmapped = *unwritten = 0;
1272
1273 bh = head = page_buffers(page);
1274 do {
1275 if (buffer_uptodate(bh) && !buffer_mapped(bh))
1276 (*unmapped) = 1;
1277 else if (buffer_unwritten(bh) && !buffer_delay(bh))
1278 clear_buffer_unwritten(bh);
1279 else if (buffer_unwritten(bh))
1280 (*unwritten) = 1;
1281 else if (buffer_delay(bh))
1282 (*delalloc) = 1;
1283 } while ((bh = bh->b_this_page) != head);
1284} 1443}
1285 1444
1286
1287/*
1288 * writepage: Called from one of two places:
1289 *
1290 * 1. we are flushing a delalloc buffer head.
1291 *
1292 * 2. we are writing out a dirty page. Typically the page dirty
1293 * state is cleared before we get here. In this case is it
1294 * conceivable we have no buffer heads.
1295 *
1296 * For delalloc space on the page we need to allocate space and
1297 * flush it. For unmapped buffer heads on the page we should
1298 * allocate space if the page is uptodate. For any other dirty
1299 * buffer heads on the page we should flush them.
1300 *
1301 * If we detect that a transaction would be required to flush
1302 * the page, we have to check the process flags first, if we
1303 * are already in a transaction or disk I/O during allocations
1304 * is off, we need to fail the writepage and redirty the page.
1305 */
1306
1307STATIC int 1445STATIC int
1308linvfs_writepage( 1446xfs_vm_invalidatepage(
1309 struct page *page,
1310 struct writeback_control *wbc)
1311{
1312 int error;
1313 int need_trans;
1314 int delalloc, unmapped, unwritten;
1315 struct inode *inode = page->mapping->host;
1316
1317 xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
1318
1319 /*
1320 * We need a transaction if:
1321 * 1. There are delalloc buffers on the page
1322 * 2. The page is uptodate and we have unmapped buffers
1323 * 3. The page is uptodate and we have no buffers
1324 * 4. There are unwritten buffers on the page
1325 */
1326
1327 if (!page_has_buffers(page)) {
1328 unmapped = 1;
1329 need_trans = 1;
1330 } else {
1331 xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
1332 if (!PageUptodate(page))
1333 unmapped = 0;
1334 need_trans = delalloc + unmapped + unwritten;
1335 }
1336
1337 /*
1338 * If we need a transaction and the process flags say
1339 * we are already in a transaction, or no IO is allowed
1340 * then mark the page dirty again and leave the page
1341 * as is.
1342 */
1343 if (PFLAGS_TEST_FSTRANS() && need_trans)
1344 goto out_fail;
1345
1346 /*
1347 * Delay hooking up buffer heads until we have
1348 * made our go/no-go decision.
1349 */
1350 if (!page_has_buffers(page))
1351 create_empty_buffers(page, 1 << inode->i_blkbits, 0);
1352
1353 /*
1354 * Convert delayed allocate, unwritten or unmapped space
1355 * to real space and flush out to disk.
1356 */
1357 error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
1358 if (error == -EAGAIN)
1359 goto out_fail;
1360 if (unlikely(error < 0))
1361 goto out_unlock;
1362
1363 return 0;
1364
1365out_fail:
1366 redirty_page_for_writepage(wbc, page);
1367 unlock_page(page);
1368 return 0;
1369out_unlock:
1370 unlock_page(page);
1371 return error;
1372}
1373
1374STATIC int
1375linvfs_invalidate_page(
1376 struct page *page, 1447 struct page *page,
1377 unsigned long offset) 1448 unsigned long offset)
1378{ 1449{
@@ -1381,87 +1452,16 @@ linvfs_invalidate_page(
1381 return block_invalidatepage(page, offset); 1452 return block_invalidatepage(page, offset);
1382} 1453}
1383 1454
1384/* 1455struct address_space_operations xfs_address_space_operations = {
1385 * Called to move a page into cleanable state - and from there 1456 .readpage = xfs_vm_readpage,
1386 * to be released. Possibly the page is already clean. We always 1457 .readpages = xfs_vm_readpages,
1387 * have buffer heads in this call. 1458 .writepage = xfs_vm_writepage,
1388 *
1389 * Returns 0 if the page is ok to release, 1 otherwise.
1390 *
1391 * Possible scenarios are:
1392 *
1393 * 1. We are being called to release a page which has been written
1394 * to via regular I/O. buffer heads will be dirty and possibly
1395 * delalloc. If no delalloc buffer heads in this case then we
1396 * can just return zero.
1397 *
1398 * 2. We are called to release a page which has been written via
1399 * mmap, all we need to do is ensure there is no delalloc
1400 * state in the buffer heads, if not we can let the caller
1401 * free them and we should come back later via writepage.
1402 */
1403STATIC int
1404linvfs_release_page(
1405 struct page *page,
1406 gfp_t gfp_mask)
1407{
1408 struct inode *inode = page->mapping->host;
1409 int dirty, delalloc, unmapped, unwritten;
1410 struct writeback_control wbc = {
1411 .sync_mode = WB_SYNC_ALL,
1412 .nr_to_write = 1,
1413 };
1414
1415 xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
1416
1417 xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
1418 if (!delalloc && !unwritten)
1419 goto free_buffers;
1420
1421 if (!(gfp_mask & __GFP_FS))
1422 return 0;
1423
1424 /* If we are already inside a transaction or the thread cannot
1425 * do I/O, we cannot release this page.
1426 */
1427 if (PFLAGS_TEST_FSTRANS())
1428 return 0;
1429
1430 /*
1431 * Convert delalloc space to real space, do not flush the
1432 * data out to disk, that will be done by the caller.
1433 * Never need to allocate space here - we will always
1434 * come back to writepage in that case.
1435 */
1436 dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
1437 if (dirty == 0 && !unwritten)
1438 goto free_buffers;
1439 return 0;
1440
1441free_buffers:
1442 return try_to_free_buffers(page);
1443}
1444
1445STATIC int
1446linvfs_prepare_write(
1447 struct file *file,
1448 struct page *page,
1449 unsigned int from,
1450 unsigned int to)
1451{
1452 return block_prepare_write(page, from, to, linvfs_get_block);
1453}
1454
1455struct address_space_operations linvfs_aops = {
1456 .readpage = linvfs_readpage,
1457 .readpages = linvfs_readpages,
1458 .writepage = linvfs_writepage,
1459 .sync_page = block_sync_page, 1459 .sync_page = block_sync_page,
1460 .releasepage = linvfs_release_page, 1460 .releasepage = xfs_vm_releasepage,
1461 .invalidatepage = linvfs_invalidate_page, 1461 .invalidatepage = xfs_vm_invalidatepage,
1462 .prepare_write = linvfs_prepare_write, 1462 .prepare_write = xfs_vm_prepare_write,
1463 .commit_write = generic_commit_write, 1463 .commit_write = generic_commit_write,
1464 .bmap = linvfs_bmap, 1464 .bmap = xfs_vm_bmap,
1465 .direct_IO = linvfs_direct_IO, 1465 .direct_IO = xfs_vm_direct_IO,
1466 .migratepage = buffer_migrate_page, 1466 .migratepage = buffer_migrate_page,
1467}; 1467};
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 55339dd5a30d..795699f121d2 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -40,7 +40,7 @@ typedef struct xfs_ioend {
40 struct work_struct io_work; /* xfsdatad work queue */ 40 struct work_struct io_work; /* xfsdatad work queue */
41} xfs_ioend_t; 41} xfs_ioend_t;
42 42
43extern struct address_space_operations linvfs_aops; 43extern struct address_space_operations xfs_address_space_operations;
44extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int); 44extern int xfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
45 45
46#endif /* __XFS_IOPS_H__ */ 46#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index bfb4f2917bb6..9fb0312665ca 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -29,6 +29,7 @@
29#include <linux/blkdev.h> 29#include <linux/blkdev.h>
30#include <linux/hash.h> 30#include <linux/hash.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/migrate.h>
32#include "xfs_linux.h" 33#include "xfs_linux.h"
33 34
34STATIC kmem_zone_t *xfs_buf_zone; 35STATIC kmem_zone_t *xfs_buf_zone;
@@ -1805,13 +1806,12 @@ xfs_flush_buftarg(
1805int __init 1806int __init
1806xfs_buf_init(void) 1807xfs_buf_init(void)
1807{ 1808{
1808 int error = -ENOMEM;
1809
1810#ifdef XFS_BUF_TRACE 1809#ifdef XFS_BUF_TRACE
1811 xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP); 1810 xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP);
1812#endif 1811#endif
1813 1812
1814 xfs_buf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf"); 1813 xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
1814 KM_ZONE_HWALIGN, NULL);
1815 if (!xfs_buf_zone) 1815 if (!xfs_buf_zone)
1816 goto out_free_trace_buf; 1816 goto out_free_trace_buf;
1817 1817
@@ -1839,7 +1839,7 @@ xfs_buf_init(void)
1839#ifdef XFS_BUF_TRACE 1839#ifdef XFS_BUF_TRACE
1840 ktrace_free(xfs_buf_trace_buf); 1840 ktrace_free(xfs_buf_trace_buf);
1841#endif 1841#endif
1842 return error; 1842 return -ENOMEM;
1843} 1843}
1844 1844
1845void 1845void
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index 80eb249f2fa0..b768ea910bbe 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -25,6 +25,8 @@
25#include "xfs_mount.h" 25#include "xfs_mount.h"
26#include "xfs_export.h" 26#include "xfs_export.h"
27 27
28STATIC struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
29
28/* 30/*
29 * XFS encodes and decodes the fileid portion of NFS filehandles 31 * XFS encodes and decodes the fileid portion of NFS filehandles
30 * itself instead of letting the generic NFS code do it. This 32 * itself instead of letting the generic NFS code do it. This
@@ -37,7 +39,7 @@
37 */ 39 */
38 40
39STATIC struct dentry * 41STATIC struct dentry *
40linvfs_decode_fh( 42xfs_fs_decode_fh(
41 struct super_block *sb, 43 struct super_block *sb,
42 __u32 *fh, 44 __u32 *fh,
43 int fh_len, 45 int fh_len,
@@ -78,12 +80,12 @@ linvfs_decode_fh(
78 } 80 }
79 81
80 fh = (__u32 *)&ifid; 82 fh = (__u32 *)&ifid;
81 return find_exported_dentry(sb, fh, parent, acceptable, context); 83 return sb->s_export_op->find_exported_dentry(sb, fh, parent, acceptable, context);
82} 84}
83 85
84 86
85STATIC int 87STATIC int
86linvfs_encode_fh( 88xfs_fs_encode_fh(
87 struct dentry *dentry, 89 struct dentry *dentry,
88 __u32 *fh, 90 __u32 *fh,
89 int *max_len, 91 int *max_len,
@@ -95,7 +97,7 @@ linvfs_encode_fh(
95 int len; 97 int len;
96 int is64 = 0; 98 int is64 = 0;
97#if XFS_BIG_INUMS 99#if XFS_BIG_INUMS
98 vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); 100 vfs_t *vfs = vfs_from_sb(inode->i_sb);
99 101
100 if (!(vfs->vfs_flag & VFS_32BITINODES)) { 102 if (!(vfs->vfs_flag & VFS_32BITINODES)) {
101 /* filesystem may contain 64bit inode numbers */ 103 /* filesystem may contain 64bit inode numbers */
@@ -130,21 +132,21 @@ linvfs_encode_fh(
130} 132}
131 133
132STATIC struct dentry * 134STATIC struct dentry *
133linvfs_get_dentry( 135xfs_fs_get_dentry(
134 struct super_block *sb, 136 struct super_block *sb,
135 void *data) 137 void *data)
136{ 138{
137 vnode_t *vp; 139 vnode_t *vp;
138 struct inode *inode; 140 struct inode *inode;
139 struct dentry *result; 141 struct dentry *result;
140 vfs_t *vfsp = LINVFS_GET_VFS(sb); 142 vfs_t *vfsp = vfs_from_sb(sb);
141 int error; 143 int error;
142 144
143 VFS_VGET(vfsp, &vp, (fid_t *)data, error); 145 VFS_VGET(vfsp, &vp, (fid_t *)data, error);
144 if (error || vp == NULL) 146 if (error || vp == NULL)
145 return ERR_PTR(-ESTALE) ; 147 return ERR_PTR(-ESTALE) ;
146 148
147 inode = LINVFS_GET_IP(vp); 149 inode = vn_to_inode(vp);
148 result = d_alloc_anon(inode); 150 result = d_alloc_anon(inode);
149 if (!result) { 151 if (!result) {
150 iput(inode); 152 iput(inode);
@@ -154,25 +156,20 @@ linvfs_get_dentry(
154} 156}
155 157
156STATIC struct dentry * 158STATIC struct dentry *
157linvfs_get_parent( 159xfs_fs_get_parent(
158 struct dentry *child) 160 struct dentry *child)
159{ 161{
160 int error; 162 int error;
161 vnode_t *vp, *cvp; 163 vnode_t *vp, *cvp;
162 struct dentry *parent; 164 struct dentry *parent;
163 struct dentry dotdot;
164
165 dotdot.d_name.name = "..";
166 dotdot.d_name.len = 2;
167 dotdot.d_inode = NULL;
168 165
169 cvp = NULL; 166 cvp = NULL;
170 vp = LINVFS_GET_VP(child->d_inode); 167 vp = vn_from_inode(child->d_inode);
171 VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error); 168 VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
172 if (unlikely(error)) 169 if (unlikely(error))
173 return ERR_PTR(-error); 170 return ERR_PTR(-error);
174 171
175 parent = d_alloc_anon(LINVFS_GET_IP(cvp)); 172 parent = d_alloc_anon(vn_to_inode(cvp));
176 if (unlikely(!parent)) { 173 if (unlikely(!parent)) {
177 VN_RELE(cvp); 174 VN_RELE(cvp);
178 return ERR_PTR(-ENOMEM); 175 return ERR_PTR(-ENOMEM);
@@ -180,9 +177,9 @@ linvfs_get_parent(
180 return parent; 177 return parent;
181} 178}
182 179
183struct export_operations linvfs_export_ops = { 180struct export_operations xfs_export_operations = {
184 .decode_fh = linvfs_decode_fh, 181 .decode_fh = xfs_fs_decode_fh,
185 .encode_fh = linvfs_encode_fh, 182 .encode_fh = xfs_fs_encode_fh,
186 .get_parent = linvfs_get_parent, 183 .get_parent = xfs_fs_get_parent,
187 .get_dentry = linvfs_get_dentry, 184 .get_dentry = xfs_fs_get_dentry,
188}; 185};
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index ced4404339c7..185567a6a561 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -43,13 +43,13 @@
43#include <linux/dcache.h> 43#include <linux/dcache.h>
44#include <linux/smp_lock.h> 44#include <linux/smp_lock.h>
45 45
46static struct vm_operations_struct linvfs_file_vm_ops; 46static struct vm_operations_struct xfs_file_vm_ops;
47#ifdef CONFIG_XFS_DMAPI 47#ifdef CONFIG_XFS_DMAPI
48static struct vm_operations_struct linvfs_dmapi_file_vm_ops; 48static struct vm_operations_struct xfs_dmapi_file_vm_ops;
49#endif 49#endif
50 50
51STATIC inline ssize_t 51STATIC inline ssize_t
52__linvfs_read( 52__xfs_file_read(
53 struct kiocb *iocb, 53 struct kiocb *iocb,
54 char __user *buf, 54 char __user *buf,
55 int ioflags, 55 int ioflags,
@@ -58,7 +58,7 @@ __linvfs_read(
58{ 58{
59 struct iovec iov = {buf, count}; 59 struct iovec iov = {buf, count};
60 struct file *file = iocb->ki_filp; 60 struct file *file = iocb->ki_filp;
61 vnode_t *vp = LINVFS_GET_VP(file->f_dentry->d_inode); 61 vnode_t *vp = vn_from_inode(file->f_dentry->d_inode);
62 ssize_t rval; 62 ssize_t rval;
63 63
64 BUG_ON(iocb->ki_pos != pos); 64 BUG_ON(iocb->ki_pos != pos);
@@ -71,28 +71,28 @@ __linvfs_read(
71 71
72 72
73STATIC ssize_t 73STATIC ssize_t
74linvfs_aio_read( 74xfs_file_aio_read(
75 struct kiocb *iocb, 75 struct kiocb *iocb,
76 char __user *buf, 76 char __user *buf,
77 size_t count, 77 size_t count,
78 loff_t pos) 78 loff_t pos)
79{ 79{
80 return __linvfs_read(iocb, buf, IO_ISAIO, count, pos); 80 return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos);
81} 81}
82 82
83STATIC ssize_t 83STATIC ssize_t
84linvfs_aio_read_invis( 84xfs_file_aio_read_invis(
85 struct kiocb *iocb, 85 struct kiocb *iocb,
86 char __user *buf, 86 char __user *buf,
87 size_t count, 87 size_t count,
88 loff_t pos) 88 loff_t pos)
89{ 89{
90 return __linvfs_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); 90 return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
91} 91}
92 92
93 93
94STATIC inline ssize_t 94STATIC inline ssize_t
95__linvfs_write( 95__xfs_file_write(
96 struct kiocb *iocb, 96 struct kiocb *iocb,
97 const char __user *buf, 97 const char __user *buf,
98 int ioflags, 98 int ioflags,
@@ -102,7 +102,7 @@ __linvfs_write(
102 struct iovec iov = {(void __user *)buf, count}; 102 struct iovec iov = {(void __user *)buf, count};
103 struct file *file = iocb->ki_filp; 103 struct file *file = iocb->ki_filp;
104 struct inode *inode = file->f_mapping->host; 104 struct inode *inode = file->f_mapping->host;
105 vnode_t *vp = LINVFS_GET_VP(inode); 105 vnode_t *vp = vn_from_inode(inode);
106 ssize_t rval; 106 ssize_t rval;
107 107
108 BUG_ON(iocb->ki_pos != pos); 108 BUG_ON(iocb->ki_pos != pos);
@@ -115,28 +115,28 @@ __linvfs_write(
115 115
116 116
117STATIC ssize_t 117STATIC ssize_t
118linvfs_aio_write( 118xfs_file_aio_write(
119 struct kiocb *iocb, 119 struct kiocb *iocb,
120 const char __user *buf, 120 const char __user *buf,
121 size_t count, 121 size_t count,
122 loff_t pos) 122 loff_t pos)
123{ 123{
124 return __linvfs_write(iocb, buf, IO_ISAIO, count, pos); 124 return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos);
125} 125}
126 126
127STATIC ssize_t 127STATIC ssize_t
128linvfs_aio_write_invis( 128xfs_file_aio_write_invis(
129 struct kiocb *iocb, 129 struct kiocb *iocb,
130 const char __user *buf, 130 const char __user *buf,
131 size_t count, 131 size_t count,
132 loff_t pos) 132 loff_t pos)
133{ 133{
134 return __linvfs_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); 134 return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
135} 135}
136 136
137 137
138STATIC inline ssize_t 138STATIC inline ssize_t
139__linvfs_readv( 139__xfs_file_readv(
140 struct file *file, 140 struct file *file,
141 const struct iovec *iov, 141 const struct iovec *iov,
142 int ioflags, 142 int ioflags,
@@ -144,8 +144,8 @@ __linvfs_readv(
144 loff_t *ppos) 144 loff_t *ppos)
145{ 145{
146 struct inode *inode = file->f_mapping->host; 146 struct inode *inode = file->f_mapping->host;
147 vnode_t *vp = LINVFS_GET_VP(inode); 147 vnode_t *vp = vn_from_inode(inode);
148 struct kiocb kiocb; 148 struct kiocb kiocb;
149 ssize_t rval; 149 ssize_t rval;
150 150
151 init_sync_kiocb(&kiocb, file); 151 init_sync_kiocb(&kiocb, file);
@@ -160,28 +160,28 @@ __linvfs_readv(
160} 160}
161 161
162STATIC ssize_t 162STATIC ssize_t
163linvfs_readv( 163xfs_file_readv(
164 struct file *file, 164 struct file *file,
165 const struct iovec *iov, 165 const struct iovec *iov,
166 unsigned long nr_segs, 166 unsigned long nr_segs,
167 loff_t *ppos) 167 loff_t *ppos)
168{ 168{
169 return __linvfs_readv(file, iov, 0, nr_segs, ppos); 169 return __xfs_file_readv(file, iov, 0, nr_segs, ppos);
170} 170}
171 171
172STATIC ssize_t 172STATIC ssize_t
173linvfs_readv_invis( 173xfs_file_readv_invis(
174 struct file *file, 174 struct file *file,
175 const struct iovec *iov, 175 const struct iovec *iov,
176 unsigned long nr_segs, 176 unsigned long nr_segs,
177 loff_t *ppos) 177 loff_t *ppos)
178{ 178{
179 return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos); 179 return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos);
180} 180}
181 181
182 182
183STATIC inline ssize_t 183STATIC inline ssize_t
184__linvfs_writev( 184__xfs_file_writev(
185 struct file *file, 185 struct file *file,
186 const struct iovec *iov, 186 const struct iovec *iov,
187 int ioflags, 187 int ioflags,
@@ -189,8 +189,8 @@ __linvfs_writev(
189 loff_t *ppos) 189 loff_t *ppos)
190{ 190{
191 struct inode *inode = file->f_mapping->host; 191 struct inode *inode = file->f_mapping->host;
192 vnode_t *vp = LINVFS_GET_VP(inode); 192 vnode_t *vp = vn_from_inode(inode);
193 struct kiocb kiocb; 193 struct kiocb kiocb;
194 ssize_t rval; 194 ssize_t rval;
195 195
196 init_sync_kiocb(&kiocb, file); 196 init_sync_kiocb(&kiocb, file);
@@ -206,34 +206,34 @@ __linvfs_writev(
206 206
207 207
208STATIC ssize_t 208STATIC ssize_t
209linvfs_writev( 209xfs_file_writev(
210 struct file *file, 210 struct file *file,
211 const struct iovec *iov, 211 const struct iovec *iov,
212 unsigned long nr_segs, 212 unsigned long nr_segs,
213 loff_t *ppos) 213 loff_t *ppos)
214{ 214{
215 return __linvfs_writev(file, iov, 0, nr_segs, ppos); 215 return __xfs_file_writev(file, iov, 0, nr_segs, ppos);
216} 216}
217 217
218STATIC ssize_t 218STATIC ssize_t
219linvfs_writev_invis( 219xfs_file_writev_invis(
220 struct file *file, 220 struct file *file,
221 const struct iovec *iov, 221 const struct iovec *iov,
222 unsigned long nr_segs, 222 unsigned long nr_segs,
223 loff_t *ppos) 223 loff_t *ppos)
224{ 224{
225 return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos); 225 return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos);
226} 226}
227 227
228STATIC ssize_t 228STATIC ssize_t
229linvfs_sendfile( 229xfs_file_sendfile(
230 struct file *filp, 230 struct file *filp,
231 loff_t *ppos, 231 loff_t *ppos,
232 size_t count, 232 size_t count,
233 read_actor_t actor, 233 read_actor_t actor,
234 void *target) 234 void *target)
235{ 235{
236 vnode_t *vp = LINVFS_GET_VP(filp->f_dentry->d_inode); 236 vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode);
237 ssize_t rval; 237 ssize_t rval;
238 238
239 VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval); 239 VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval);
@@ -242,11 +242,11 @@ linvfs_sendfile(
242 242
243 243
244STATIC int 244STATIC int
245linvfs_open( 245xfs_file_open(
246 struct inode *inode, 246 struct inode *inode,
247 struct file *filp) 247 struct file *filp)
248{ 248{
249 vnode_t *vp = LINVFS_GET_VP(inode); 249 vnode_t *vp = vn_from_inode(inode);
250 int error; 250 int error;
251 251
252 if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) 252 if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
@@ -259,11 +259,11 @@ linvfs_open(
259 259
260 260
261STATIC int 261STATIC int
262linvfs_release( 262xfs_file_release(
263 struct inode *inode, 263 struct inode *inode,
264 struct file *filp) 264 struct file *filp)
265{ 265{
266 vnode_t *vp = LINVFS_GET_VP(inode); 266 vnode_t *vp = vn_from_inode(inode);
267 int error = 0; 267 int error = 0;
268 268
269 if (vp) 269 if (vp)
@@ -273,13 +273,13 @@ linvfs_release(
273 273
274 274
275STATIC int 275STATIC int
276linvfs_fsync( 276xfs_file_fsync(
277 struct file *filp, 277 struct file *filp,
278 struct dentry *dentry, 278 struct dentry *dentry,
279 int datasync) 279 int datasync)
280{ 280{
281 struct inode *inode = dentry->d_inode; 281 struct inode *inode = dentry->d_inode;
282 vnode_t *vp = LINVFS_GET_VP(inode); 282 vnode_t *vp = vn_from_inode(inode);
283 int error; 283 int error;
284 int flags = FSYNC_WAIT; 284 int flags = FSYNC_WAIT;
285 285
@@ -292,7 +292,7 @@ linvfs_fsync(
292} 292}
293 293
294/* 294/*
295 * linvfs_readdir maps to VOP_READDIR(). 295 * xfs_file_readdir maps to VOP_READDIR().
296 * We need to build a uio, cred, ... 296 * We need to build a uio, cred, ...
297 */ 297 */
298 298
@@ -301,13 +301,13 @@ linvfs_fsync(
301#ifdef CONFIG_XFS_DMAPI 301#ifdef CONFIG_XFS_DMAPI
302 302
303STATIC struct page * 303STATIC struct page *
304linvfs_filemap_nopage( 304xfs_vm_nopage(
305 struct vm_area_struct *area, 305 struct vm_area_struct *area,
306 unsigned long address, 306 unsigned long address,
307 int *type) 307 int *type)
308{ 308{
309 struct inode *inode = area->vm_file->f_dentry->d_inode; 309 struct inode *inode = area->vm_file->f_dentry->d_inode;
310 vnode_t *vp = LINVFS_GET_VP(inode); 310 vnode_t *vp = vn_from_inode(inode);
311 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); 311 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
312 int error; 312 int error;
313 313
@@ -324,7 +324,7 @@ linvfs_filemap_nopage(
324 324
325 325
326STATIC int 326STATIC int
327linvfs_readdir( 327xfs_file_readdir(
328 struct file *filp, 328 struct file *filp,
329 void *dirent, 329 void *dirent,
330 filldir_t filldir) 330 filldir_t filldir)
@@ -340,7 +340,7 @@ linvfs_readdir(
340 xfs_off_t start_offset, curr_offset; 340 xfs_off_t start_offset, curr_offset;
341 xfs_dirent_t *dbp = NULL; 341 xfs_dirent_t *dbp = NULL;
342 342
343 vp = LINVFS_GET_VP(filp->f_dentry->d_inode); 343 vp = vn_from_inode(filp->f_dentry->d_inode);
344 ASSERT(vp); 344 ASSERT(vp);
345 345
346 /* Try fairly hard to get memory */ 346 /* Try fairly hard to get memory */
@@ -404,39 +404,40 @@ done:
404 404
405 405
406STATIC int 406STATIC int
407linvfs_file_mmap( 407xfs_file_mmap(
408 struct file *filp, 408 struct file *filp,
409 struct vm_area_struct *vma) 409 struct vm_area_struct *vma)
410{ 410{
411 struct inode *ip = filp->f_dentry->d_inode; 411 struct inode *ip = filp->f_dentry->d_inode;
412 vnode_t *vp = LINVFS_GET_VP(ip); 412 vnode_t *vp = vn_from_inode(ip);
413 vattr_t va = { .va_mask = XFS_AT_UPDATIME }; 413 vattr_t vattr;
414 int error; 414 int error;
415 415
416 vma->vm_ops = &linvfs_file_vm_ops; 416 vma->vm_ops = &xfs_file_vm_ops;
417 417
418#ifdef CONFIG_XFS_DMAPI 418#ifdef CONFIG_XFS_DMAPI
419 if (vp->v_vfsp->vfs_flag & VFS_DMI) { 419 if (vp->v_vfsp->vfs_flag & VFS_DMI) {
420 vma->vm_ops = &linvfs_dmapi_file_vm_ops; 420 vma->vm_ops = &xfs_dmapi_file_vm_ops;
421 } 421 }
422#endif /* CONFIG_XFS_DMAPI */ 422#endif /* CONFIG_XFS_DMAPI */
423 423
424 VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error); 424 vattr.va_mask = XFS_AT_UPDATIME;
425 if (!error) 425 VOP_SETATTR(vp, &vattr, XFS_AT_UPDATIME, NULL, error);
426 vn_revalidate(vp); /* update Linux inode flags */ 426 if (likely(!error))
427 __vn_revalidate(vp, &vattr); /* update flags */
427 return 0; 428 return 0;
428} 429}
429 430
430 431
431STATIC long 432STATIC long
432linvfs_ioctl( 433xfs_file_ioctl(
433 struct file *filp, 434 struct file *filp,
434 unsigned int cmd, 435 unsigned int cmd,
435 unsigned long arg) 436 unsigned long arg)
436{ 437{
437 int error; 438 int error;
438 struct inode *inode = filp->f_dentry->d_inode; 439 struct inode *inode = filp->f_dentry->d_inode;
439 vnode_t *vp = LINVFS_GET_VP(inode); 440 vnode_t *vp = vn_from_inode(inode);
440 441
441 VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error); 442 VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error);
442 VMODIFY(vp); 443 VMODIFY(vp);
@@ -451,14 +452,14 @@ linvfs_ioctl(
451} 452}
452 453
453STATIC long 454STATIC long
454linvfs_ioctl_invis( 455xfs_file_ioctl_invis(
455 struct file *filp, 456 struct file *filp,
456 unsigned int cmd, 457 unsigned int cmd,
457 unsigned long arg) 458 unsigned long arg)
458{ 459{
459 int error; 460 int error;
460 struct inode *inode = filp->f_dentry->d_inode; 461 struct inode *inode = filp->f_dentry->d_inode;
461 vnode_t *vp = LINVFS_GET_VP(inode); 462 vnode_t *vp = vn_from_inode(inode);
462 463
463 ASSERT(vp); 464 ASSERT(vp);
464 VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error); 465 VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
@@ -476,11 +477,11 @@ linvfs_ioctl_invis(
476#ifdef CONFIG_XFS_DMAPI 477#ifdef CONFIG_XFS_DMAPI
477#ifdef HAVE_VMOP_MPROTECT 478#ifdef HAVE_VMOP_MPROTECT
478STATIC int 479STATIC int
479linvfs_mprotect( 480xfs_vm_mprotect(
480 struct vm_area_struct *vma, 481 struct vm_area_struct *vma,
481 unsigned int newflags) 482 unsigned int newflags)
482{ 483{
483 vnode_t *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode); 484 vnode_t *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode);
484 int error = 0; 485 int error = 0;
485 486
486 if (vp->v_vfsp->vfs_flag & VFS_DMI) { 487 if (vp->v_vfsp->vfs_flag & VFS_DMI) {
@@ -503,10 +504,10 @@ linvfs_mprotect(
503 * it back online. 504 * it back online.
504 */ 505 */
505STATIC int 506STATIC int
506linvfs_open_exec( 507xfs_file_open_exec(
507 struct inode *inode) 508 struct inode *inode)
508{ 509{
509 vnode_t *vp = LINVFS_GET_VP(inode); 510 vnode_t *vp = vn_from_inode(inode);
510 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); 511 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
511 int error = 0; 512 int error = 0;
512 xfs_inode_t *ip; 513 xfs_inode_t *ip;
@@ -527,69 +528,69 @@ open_exec_out:
527} 528}
528#endif /* HAVE_FOP_OPEN_EXEC */ 529#endif /* HAVE_FOP_OPEN_EXEC */
529 530
530struct file_operations linvfs_file_operations = { 531struct file_operations xfs_file_operations = {
531 .llseek = generic_file_llseek, 532 .llseek = generic_file_llseek,
532 .read = do_sync_read, 533 .read = do_sync_read,
533 .write = do_sync_write, 534 .write = do_sync_write,
534 .readv = linvfs_readv, 535 .readv = xfs_file_readv,
535 .writev = linvfs_writev, 536 .writev = xfs_file_writev,
536 .aio_read = linvfs_aio_read, 537 .aio_read = xfs_file_aio_read,
537 .aio_write = linvfs_aio_write, 538 .aio_write = xfs_file_aio_write,
538 .sendfile = linvfs_sendfile, 539 .sendfile = xfs_file_sendfile,
539 .unlocked_ioctl = linvfs_ioctl, 540 .unlocked_ioctl = xfs_file_ioctl,
540#ifdef CONFIG_COMPAT 541#ifdef CONFIG_COMPAT
541 .compat_ioctl = linvfs_compat_ioctl, 542 .compat_ioctl = xfs_file_compat_ioctl,
542#endif 543#endif
543 .mmap = linvfs_file_mmap, 544 .mmap = xfs_file_mmap,
544 .open = linvfs_open, 545 .open = xfs_file_open,
545 .release = linvfs_release, 546 .release = xfs_file_release,
546 .fsync = linvfs_fsync, 547 .fsync = xfs_file_fsync,
547#ifdef HAVE_FOP_OPEN_EXEC 548#ifdef HAVE_FOP_OPEN_EXEC
548 .open_exec = linvfs_open_exec, 549 .open_exec = xfs_file_open_exec,
549#endif 550#endif
550}; 551};
551 552
552struct file_operations linvfs_invis_file_operations = { 553struct file_operations xfs_invis_file_operations = {
553 .llseek = generic_file_llseek, 554 .llseek = generic_file_llseek,
554 .read = do_sync_read, 555 .read = do_sync_read,
555 .write = do_sync_write, 556 .write = do_sync_write,
556 .readv = linvfs_readv_invis, 557 .readv = xfs_file_readv_invis,
557 .writev = linvfs_writev_invis, 558 .writev = xfs_file_writev_invis,
558 .aio_read = linvfs_aio_read_invis, 559 .aio_read = xfs_file_aio_read_invis,
559 .aio_write = linvfs_aio_write_invis, 560 .aio_write = xfs_file_aio_write_invis,
560 .sendfile = linvfs_sendfile, 561 .sendfile = xfs_file_sendfile,
561 .unlocked_ioctl = linvfs_ioctl_invis, 562 .unlocked_ioctl = xfs_file_ioctl_invis,
562#ifdef CONFIG_COMPAT 563#ifdef CONFIG_COMPAT
563 .compat_ioctl = linvfs_compat_invis_ioctl, 564 .compat_ioctl = xfs_file_compat_invis_ioctl,
564#endif 565#endif
565 .mmap = linvfs_file_mmap, 566 .mmap = xfs_file_mmap,
566 .open = linvfs_open, 567 .open = xfs_file_open,
567 .release = linvfs_release, 568 .release = xfs_file_release,
568 .fsync = linvfs_fsync, 569 .fsync = xfs_file_fsync,
569}; 570};
570 571
571 572
572struct file_operations linvfs_dir_operations = { 573struct file_operations xfs_dir_file_operations = {
573 .read = generic_read_dir, 574 .read = generic_read_dir,
574 .readdir = linvfs_readdir, 575 .readdir = xfs_file_readdir,
575 .unlocked_ioctl = linvfs_ioctl, 576 .unlocked_ioctl = xfs_file_ioctl,
576#ifdef CONFIG_COMPAT 577#ifdef CONFIG_COMPAT
577 .compat_ioctl = linvfs_compat_ioctl, 578 .compat_ioctl = xfs_file_compat_ioctl,
578#endif 579#endif
579 .fsync = linvfs_fsync, 580 .fsync = xfs_file_fsync,
580}; 581};
581 582
582static struct vm_operations_struct linvfs_file_vm_ops = { 583static struct vm_operations_struct xfs_file_vm_ops = {
583 .nopage = filemap_nopage, 584 .nopage = filemap_nopage,
584 .populate = filemap_populate, 585 .populate = filemap_populate,
585}; 586};
586 587
587#ifdef CONFIG_XFS_DMAPI 588#ifdef CONFIG_XFS_DMAPI
588static struct vm_operations_struct linvfs_dmapi_file_vm_ops = { 589static struct vm_operations_struct xfs_dmapi_file_vm_ops = {
589 .nopage = linvfs_filemap_nopage, 590 .nopage = xfs_vm_nopage,
590 .populate = filemap_populate, 591 .populate = filemap_populate,
591#ifdef HAVE_VMOP_MPROTECT 592#ifdef HAVE_VMOP_MPROTECT
592 .mprotect = linvfs_mprotect, 593 .mprotect = xfs_vm_mprotect,
593#endif 594#endif
594}; 595};
595#endif /* CONFIG_XFS_DMAPI */ 596#endif /* CONFIG_XFS_DMAPI */
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 4fa4b1a5187e..575f2a790f31 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -57,7 +57,7 @@ fs_tosspages(
57 int fiopt) 57 int fiopt)
58{ 58{
59 vnode_t *vp = BHV_TO_VNODE(bdp); 59 vnode_t *vp = BHV_TO_VNODE(bdp);
60 struct inode *ip = LINVFS_GET_IP(vp); 60 struct inode *ip = vn_to_inode(vp);
61 61
62 if (VN_CACHED(vp)) 62 if (VN_CACHED(vp))
63 truncate_inode_pages(ip->i_mapping, first); 63 truncate_inode_pages(ip->i_mapping, first);
@@ -76,7 +76,7 @@ fs_flushinval_pages(
76 int fiopt) 76 int fiopt)
77{ 77{
78 vnode_t *vp = BHV_TO_VNODE(bdp); 78 vnode_t *vp = BHV_TO_VNODE(bdp);
79 struct inode *ip = LINVFS_GET_IP(vp); 79 struct inode *ip = vn_to_inode(vp);
80 80
81 if (VN_CACHED(vp)) { 81 if (VN_CACHED(vp)) {
82 filemap_write_and_wait(ip->i_mapping); 82 filemap_write_and_wait(ip->i_mapping);
@@ -98,7 +98,7 @@ fs_flush_pages(
98 int fiopt) 98 int fiopt)
99{ 99{
100 vnode_t *vp = BHV_TO_VNODE(bdp); 100 vnode_t *vp = BHV_TO_VNODE(bdp);
101 struct inode *ip = LINVFS_GET_IP(vp); 101 struct inode *ip = vn_to_inode(vp);
102 102
103 if (VN_CACHED(vp)) { 103 if (VN_CACHED(vp)) {
104 filemap_fdatawrite(ip->i_mapping); 104 filemap_fdatawrite(ip->i_mapping);
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 4db47790415c..84478491609b 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -138,7 +138,7 @@ xfs_find_handle(
138 } 138 }
139 139
140 /* we need the vnode */ 140 /* we need the vnode */
141 vp = LINVFS_GET_VP(inode); 141 vp = vn_from_inode(inode);
142 142
143 /* now we can grab the fsid */ 143 /* now we can grab the fsid */
144 memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t)); 144 memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
@@ -256,7 +256,7 @@ xfs_vget_fsop_handlereq(
256 } 256 }
257 257
258 vpp = XFS_ITOV(ip); 258 vpp = XFS_ITOV(ip);
259 inodep = LINVFS_GET_IP(vpp); 259 inodep = vn_to_inode(vpp);
260 xfs_iunlock(ip, XFS_ILOCK_SHARED); 260 xfs_iunlock(ip, XFS_ILOCK_SHARED);
261 261
262 *vp = vpp; 262 *vp = vpp;
@@ -344,7 +344,7 @@ xfs_open_by_handle(
344 return -XFS_ERROR(-PTR_ERR(filp)); 344 return -XFS_ERROR(-PTR_ERR(filp));
345 } 345 }
346 if (inode->i_mode & S_IFREG) 346 if (inode->i_mode & S_IFREG)
347 filp->f_op = &linvfs_invis_file_operations; 347 filp->f_op = &xfs_invis_file_operations;
348 348
349 fd_install(new_fd, filp); 349 fd_install(new_fd, filp);
350 return new_fd; 350 return new_fd;
@@ -715,7 +715,7 @@ xfs_ioctl(
715 xfs_inode_t *ip; 715 xfs_inode_t *ip;
716 xfs_mount_t *mp; 716 xfs_mount_t *mp;
717 717
718 vp = LINVFS_GET_VP(inode); 718 vp = vn_from_inode(inode);
719 719
720 vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address); 720 vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
721 721
@@ -1160,105 +1160,129 @@ xfs_ioc_xattr(
1160 void __user *arg) 1160 void __user *arg)
1161{ 1161{
1162 struct fsxattr fa; 1162 struct fsxattr fa;
1163 vattr_t va; 1163 struct vattr *vattr;
1164 int error; 1164 int error = 0;
1165 int attr_flags; 1165 int attr_flags;
1166 unsigned int flags; 1166 unsigned int flags;
1167 1167
1168 vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
1169 if (unlikely(!vattr))
1170 return -ENOMEM;
1171
1168 switch (cmd) { 1172 switch (cmd) {
1169 case XFS_IOC_FSGETXATTR: { 1173 case XFS_IOC_FSGETXATTR: {
1170 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ 1174 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1171 XFS_AT_NEXTENTS | XFS_AT_PROJID; 1175 XFS_AT_NEXTENTS | XFS_AT_PROJID;
1172 VOP_GETATTR(vp, &va, 0, NULL, error); 1176 VOP_GETATTR(vp, vattr, 0, NULL, error);
1173 if (error) 1177 if (unlikely(error)) {
1174 return -error; 1178 error = -error;
1179 break;
1180 }
1175 1181
1176 fa.fsx_xflags = va.va_xflags; 1182 fa.fsx_xflags = vattr->va_xflags;
1177 fa.fsx_extsize = va.va_extsize; 1183 fa.fsx_extsize = vattr->va_extsize;
1178 fa.fsx_nextents = va.va_nextents; 1184 fa.fsx_nextents = vattr->va_nextents;
1179 fa.fsx_projid = va.va_projid; 1185 fa.fsx_projid = vattr->va_projid;
1180 1186
1181 if (copy_to_user(arg, &fa, sizeof(fa))) 1187 if (copy_to_user(arg, &fa, sizeof(fa))) {
1182 return -XFS_ERROR(EFAULT); 1188 error = -EFAULT;
1183 return 0; 1189 break;
1190 }
1191 break;
1184 } 1192 }
1185 1193
1186 case XFS_IOC_FSSETXATTR: { 1194 case XFS_IOC_FSSETXATTR: {
1187 if (copy_from_user(&fa, arg, sizeof(fa))) 1195 if (copy_from_user(&fa, arg, sizeof(fa))) {
1188 return -XFS_ERROR(EFAULT); 1196 error = -EFAULT;
1197 break;
1198 }
1189 1199
1190 attr_flags = 0; 1200 attr_flags = 0;
1191 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 1201 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
1192 attr_flags |= ATTR_NONBLOCK; 1202 attr_flags |= ATTR_NONBLOCK;
1193 1203
1194 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID; 1204 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
1195 va.va_xflags = fa.fsx_xflags; 1205 vattr->va_xflags = fa.fsx_xflags;
1196 va.va_extsize = fa.fsx_extsize; 1206 vattr->va_extsize = fa.fsx_extsize;
1197 va.va_projid = fa.fsx_projid; 1207 vattr->va_projid = fa.fsx_projid;
1198 1208
1199 VOP_SETATTR(vp, &va, attr_flags, NULL, error); 1209 VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
1200 if (!error) 1210 if (likely(!error))
1201 vn_revalidate(vp); /* update Linux inode flags */ 1211 __vn_revalidate(vp, vattr); /* update flags */
1202 return -error; 1212 error = -error;
1213 break;
1203 } 1214 }
1204 1215
1205 case XFS_IOC_FSGETXATTRA: { 1216 case XFS_IOC_FSGETXATTRA: {
1206 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \ 1217 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1207 XFS_AT_ANEXTENTS | XFS_AT_PROJID; 1218 XFS_AT_ANEXTENTS | XFS_AT_PROJID;
1208 VOP_GETATTR(vp, &va, 0, NULL, error); 1219 VOP_GETATTR(vp, vattr, 0, NULL, error);
1209 if (error) 1220 if (unlikely(error)) {
1210 return -error; 1221 error = -error;
1222 break;
1223 }
1211 1224
1212 fa.fsx_xflags = va.va_xflags; 1225 fa.fsx_xflags = vattr->va_xflags;
1213 fa.fsx_extsize = va.va_extsize; 1226 fa.fsx_extsize = vattr->va_extsize;
1214 fa.fsx_nextents = va.va_anextents; 1227 fa.fsx_nextents = vattr->va_anextents;
1215 fa.fsx_projid = va.va_projid; 1228 fa.fsx_projid = vattr->va_projid;
1216 1229
1217 if (copy_to_user(arg, &fa, sizeof(fa))) 1230 if (copy_to_user(arg, &fa, sizeof(fa))) {
1218 return -XFS_ERROR(EFAULT); 1231 error = -EFAULT;
1219 return 0; 1232 break;
1233 }
1234 break;
1220 } 1235 }
1221 1236
1222 case XFS_IOC_GETXFLAGS: { 1237 case XFS_IOC_GETXFLAGS: {
1223 flags = xfs_di2lxflags(ip->i_d.di_flags); 1238 flags = xfs_di2lxflags(ip->i_d.di_flags);
1224 if (copy_to_user(arg, &flags, sizeof(flags))) 1239 if (copy_to_user(arg, &flags, sizeof(flags)))
1225 return -XFS_ERROR(EFAULT); 1240 error = -EFAULT;
1226 return 0; 1241 break;
1227 } 1242 }
1228 1243
1229 case XFS_IOC_SETXFLAGS: { 1244 case XFS_IOC_SETXFLAGS: {
1230 if (copy_from_user(&flags, arg, sizeof(flags))) 1245 if (copy_from_user(&flags, arg, sizeof(flags))) {
1231 return -XFS_ERROR(EFAULT); 1246 error = -EFAULT;
1247 break;
1248 }
1232 1249
1233 if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \ 1250 if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
1234 LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \ 1251 LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \
1235 LINUX_XFLAG_SYNC)) 1252 LINUX_XFLAG_SYNC)) {
1236 return -XFS_ERROR(EOPNOTSUPP); 1253 error = -EOPNOTSUPP;
1254 break;
1255 }
1237 1256
1238 attr_flags = 0; 1257 attr_flags = 0;
1239 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 1258 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
1240 attr_flags |= ATTR_NONBLOCK; 1259 attr_flags |= ATTR_NONBLOCK;
1241 1260
1242 va.va_mask = XFS_AT_XFLAGS; 1261 vattr->va_mask = XFS_AT_XFLAGS;
1243 va.va_xflags = xfs_merge_ioc_xflags(flags, 1262 vattr->va_xflags = xfs_merge_ioc_xflags(flags,
1244 xfs_ip2xflags(ip)); 1263 xfs_ip2xflags(ip));
1245 1264
1246 VOP_SETATTR(vp, &va, attr_flags, NULL, error); 1265 VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
1247 if (!error) 1266 if (likely(!error))
1248 vn_revalidate(vp); /* update Linux inode flags */ 1267 __vn_revalidate(vp, vattr); /* update flags */
1249 return -error; 1268 error = -error;
1269 break;
1250 } 1270 }
1251 1271
1252 case XFS_IOC_GETVERSION: { 1272 case XFS_IOC_GETVERSION: {
1253 flags = LINVFS_GET_IP(vp)->i_generation; 1273 flags = vn_to_inode(vp)->i_generation;
1254 if (copy_to_user(arg, &flags, sizeof(flags))) 1274 if (copy_to_user(arg, &flags, sizeof(flags)))
1255 return -XFS_ERROR(EFAULT); 1275 error = -EFAULT;
1256 return 0; 1276 break;
1257 } 1277 }
1258 1278
1259 default: 1279 default:
1260 return -ENOTTY; 1280 error = -ENOTTY;
1281 break;
1261 } 1282 }
1283
1284 kfree(vattr);
1285 return error;
1262} 1286}
1263 1287
1264STATIC int 1288STATIC int
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index a7c9ba1a9f7b..b6321abd9a81 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -107,11 +107,11 @@ xfs_ioctl32_bulkstat(
107#endif 107#endif
108 108
109STATIC long 109STATIC long
110__linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) 110xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
111{ 111{
112 int error; 112 int error;
113 struct inode *inode = f->f_dentry->d_inode; 113 struct inode *inode = f->f_dentry->d_inode;
114 vnode_t *vp = LINVFS_GET_VP(inode); 114 vnode_t *vp = vn_to_inode(inode);
115 115
116 switch (cmd) { 116 switch (cmd) {
117 case XFS_IOC_DIOINFO: 117 case XFS_IOC_DIOINFO:
@@ -196,19 +196,19 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
196} 196}
197 197
198long 198long
199linvfs_compat_ioctl( 199xfs_file_compat_ioctl(
200 struct file *f, 200 struct file *f,
201 unsigned cmd, 201 unsigned cmd,
202 unsigned long arg) 202 unsigned long arg)
203{ 203{
204 return __linvfs_compat_ioctl(0, f, cmd, arg); 204 return xfs_compat_ioctl(0, f, cmd, arg);
205} 205}
206 206
207long 207long
208linvfs_compat_invis_ioctl( 208xfs_file_compat_invis_ioctl(
209 struct file *f, 209 struct file *f,
210 unsigned cmd, 210 unsigned cmd,
211 unsigned long arg) 211 unsigned long arg)
212{ 212{
213 return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg); 213 return xfs_compat_ioctl(IO_INVIS, f, cmd, arg);
214} 214}
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h
index 011c273bec50..02de6e62ee37 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.h
@@ -18,7 +18,7 @@
18#ifndef __XFS_IOCTL32_H__ 18#ifndef __XFS_IOCTL32_H__
19#define __XFS_IOCTL32_H__ 19#define __XFS_IOCTL32_H__
20 20
21extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long); 21extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long);
22extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long); 22extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long);
23 23
24#endif /* __XFS_IOCTL32_H__ */ 24#endif /* __XFS_IOCTL32_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index d7f6f2d8ac8e..af487437bd7e 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -106,7 +106,7 @@ xfs_ichgtime(
106 xfs_inode_t *ip, 106 xfs_inode_t *ip,
107 int flags) 107 int flags)
108{ 108{
109 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); 109 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
110 timespec_t tv; 110 timespec_t tv;
111 111
112 nanotime(&tv); 112 nanotime(&tv);
@@ -198,22 +198,22 @@ xfs_ichgtime_fast(
198 * Pull the link count and size up from the xfs inode to the linux inode 198 * Pull the link count and size up from the xfs inode to the linux inode
199 */ 199 */
200STATIC void 200STATIC void
201validate_fields( 201xfs_validate_fields(
202 struct inode *ip) 202 struct inode *ip,
203 struct vattr *vattr)
203{ 204{
204 vnode_t *vp = LINVFS_GET_VP(ip); 205 vnode_t *vp = vn_from_inode(ip);
205 vattr_t va;
206 int error; 206 int error;
207 207
208 va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS; 208 vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
209 VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error); 209 VOP_GETATTR(vp, vattr, ATTR_LAZY, NULL, error);
210 if (likely(!error)) { 210 if (likely(!error)) {
211 ip->i_nlink = va.va_nlink; 211 ip->i_nlink = vattr->va_nlink;
212 ip->i_blocks = va.va_nblocks; 212 ip->i_blocks = vattr->va_nblocks;
213 213
214 /* we're under i_mutex so i_size can't change under us */ 214 /* we're under i_sem so i_size can't change under us */
215 if (i_size_read(ip) != va.va_size) 215 if (i_size_read(ip) != vattr->va_size)
216 i_size_write(ip, va.va_size); 216 i_size_write(ip, vattr->va_size);
217 } 217 }
218} 218}
219 219
@@ -224,11 +224,11 @@ validate_fields(
224 * inode, of course, such that log replay can't cause these to be lost). 224 * inode, of course, such that log replay can't cause these to be lost).
225 */ 225 */
226STATIC int 226STATIC int
227linvfs_init_security( 227xfs_init_security(
228 struct vnode *vp, 228 struct vnode *vp,
229 struct inode *dir) 229 struct inode *dir)
230{ 230{
231 struct inode *ip = LINVFS_GET_IP(vp); 231 struct inode *ip = vn_to_inode(vp);
232 size_t length; 232 size_t length;
233 void *value; 233 void *value;
234 char *name; 234 char *name;
@@ -257,46 +257,46 @@ linvfs_init_security(
257 * XXX(hch): nfsd is broken, better fix it instead. 257 * XXX(hch): nfsd is broken, better fix it instead.
258 */ 258 */
259STATIC inline int 259STATIC inline int
260has_fs_struct(struct task_struct *task) 260xfs_has_fs_struct(struct task_struct *task)
261{ 261{
262 return (task->fs != init_task.fs); 262 return (task->fs != init_task.fs);
263} 263}
264 264
265STATIC inline void 265STATIC inline void
266cleanup_inode( 266xfs_cleanup_inode(
267 vnode_t *dvp, 267 vnode_t *dvp,
268 vnode_t *vp, 268 vnode_t *vp,
269 struct dentry *dentry, 269 struct dentry *dentry,
270 int mode) 270 int mode)
271{ 271{
272 struct dentry teardown = {}; 272 struct dentry teardown = {};
273 int err2; 273 int error;
274 274
275 /* Oh, the horror. 275 /* Oh, the horror.
276 * If we can't add the ACL or we fail in 276 * If we can't add the ACL or we fail in
277 * linvfs_init_security we must back out. 277 * xfs_init_security we must back out.
278 * ENOSPC can hit here, among other things. 278 * ENOSPC can hit here, among other things.
279 */ 279 */
280 teardown.d_inode = LINVFS_GET_IP(vp); 280 teardown.d_inode = vn_to_inode(vp);
281 teardown.d_name = dentry->d_name; 281 teardown.d_name = dentry->d_name;
282 282
283 if (S_ISDIR(mode)) 283 if (S_ISDIR(mode))
284 VOP_RMDIR(dvp, &teardown, NULL, err2); 284 VOP_RMDIR(dvp, &teardown, NULL, error);
285 else 285 else
286 VOP_REMOVE(dvp, &teardown, NULL, err2); 286 VOP_REMOVE(dvp, &teardown, NULL, error);
287 VN_RELE(vp); 287 VN_RELE(vp);
288} 288}
289 289
290STATIC int 290STATIC int
291linvfs_mknod( 291xfs_vn_mknod(
292 struct inode *dir, 292 struct inode *dir,
293 struct dentry *dentry, 293 struct dentry *dentry,
294 int mode, 294 int mode,
295 dev_t rdev) 295 dev_t rdev)
296{ 296{
297 struct inode *ip; 297 struct inode *ip;
298 vattr_t va; 298 vattr_t vattr = { 0 };
299 vnode_t *vp = NULL, *dvp = LINVFS_GET_VP(dir); 299 vnode_t *vp = NULL, *dvp = vn_from_inode(dir);
300 xfs_acl_t *default_acl = NULL; 300 xfs_acl_t *default_acl = NULL;
301 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; 301 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
302 int error; 302 int error;
@@ -305,99 +305,98 @@ linvfs_mknod(
305 * Irix uses Missed'em'V split, but doesn't want to see 305 * Irix uses Missed'em'V split, but doesn't want to see
306 * the upper 5 bits of (14bit) major. 306 * the upper 5 bits of (14bit) major.
307 */ 307 */
308 if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff) 308 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
309 return -EINVAL; 309 return -EINVAL;
310 310
311 if (test_default_acl && test_default_acl(dvp)) { 311 if (unlikely(test_default_acl && test_default_acl(dvp))) {
312 if (!_ACL_ALLOC(default_acl)) 312 if (!_ACL_ALLOC(default_acl)) {
313 return -ENOMEM; 313 return -ENOMEM;
314 }
314 if (!_ACL_GET_DEFAULT(dvp, default_acl)) { 315 if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
315 _ACL_FREE(default_acl); 316 _ACL_FREE(default_acl);
316 default_acl = NULL; 317 default_acl = NULL;
317 } 318 }
318 } 319 }
319 320
320 if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current)) 321 if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
321 mode &= ~current->fs->umask; 322 mode &= ~current->fs->umask;
322 323
323 memset(&va, 0, sizeof(va)); 324 vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
324 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; 325 vattr.va_mode = mode;
325 va.va_mode = mode;
326 326
327 switch (mode & S_IFMT) { 327 switch (mode & S_IFMT) {
328 case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: 328 case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
329 va.va_rdev = sysv_encode_dev(rdev); 329 vattr.va_rdev = sysv_encode_dev(rdev);
330 va.va_mask |= XFS_AT_RDEV; 330 vattr.va_mask |= XFS_AT_RDEV;
331 /*FALLTHROUGH*/ 331 /*FALLTHROUGH*/
332 case S_IFREG: 332 case S_IFREG:
333 VOP_CREATE(dvp, dentry, &va, &vp, NULL, error); 333 VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error);
334 break; 334 break;
335 case S_IFDIR: 335 case S_IFDIR:
336 VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error); 336 VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error);
337 break; 337 break;
338 default: 338 default:
339 error = EINVAL; 339 error = EINVAL;
340 break; 340 break;
341 } 341 }
342 342
343 if (!error) 343 if (unlikely(!error)) {
344 { 344 error = xfs_init_security(vp, dir);
345 error = linvfs_init_security(vp, dir);
346 if (error) 345 if (error)
347 cleanup_inode(dvp, vp, dentry, mode); 346 xfs_cleanup_inode(dvp, vp, dentry, mode);
348 } 347 }
349 348
350 if (default_acl) { 349 if (unlikely(default_acl)) {
351 if (!error) { 350 if (!error) {
352 error = _ACL_INHERIT(vp, &va, default_acl); 351 error = _ACL_INHERIT(vp, &vattr, default_acl);
353 if (!error) 352 if (!error)
354 VMODIFY(vp); 353 VMODIFY(vp);
355 else 354 else
356 cleanup_inode(dvp, vp, dentry, mode); 355 xfs_cleanup_inode(dvp, vp, dentry, mode);
357 } 356 }
358 _ACL_FREE(default_acl); 357 _ACL_FREE(default_acl);
359 } 358 }
360 359
361 if (!error) { 360 if (likely(!error)) {
362 ASSERT(vp); 361 ASSERT(vp);
363 ip = LINVFS_GET_IP(vp); 362 ip = vn_to_inode(vp);
364 363
365 if (S_ISCHR(mode) || S_ISBLK(mode)) 364 if (S_ISCHR(mode) || S_ISBLK(mode))
366 ip->i_rdev = rdev; 365 ip->i_rdev = rdev;
367 else if (S_ISDIR(mode)) 366 else if (S_ISDIR(mode))
368 validate_fields(ip); 367 xfs_validate_fields(ip, &vattr);
369 d_instantiate(dentry, ip); 368 d_instantiate(dentry, ip);
370 validate_fields(dir); 369 xfs_validate_fields(dir, &vattr);
371 } 370 }
372 return -error; 371 return -error;
373} 372}
374 373
375STATIC int 374STATIC int
376linvfs_create( 375xfs_vn_create(
377 struct inode *dir, 376 struct inode *dir,
378 struct dentry *dentry, 377 struct dentry *dentry,
379 int mode, 378 int mode,
380 struct nameidata *nd) 379 struct nameidata *nd)
381{ 380{
382 return linvfs_mknod(dir, dentry, mode, 0); 381 return xfs_vn_mknod(dir, dentry, mode, 0);
383} 382}
384 383
385STATIC int 384STATIC int
386linvfs_mkdir( 385xfs_vn_mkdir(
387 struct inode *dir, 386 struct inode *dir,
388 struct dentry *dentry, 387 struct dentry *dentry,
389 int mode) 388 int mode)
390{ 389{
391 return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0); 390 return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
392} 391}
393 392
394STATIC struct dentry * 393STATIC struct dentry *
395linvfs_lookup( 394xfs_vn_lookup(
396 struct inode *dir, 395 struct inode *dir,
397 struct dentry *dentry, 396 struct dentry *dentry,
398 struct nameidata *nd) 397 struct nameidata *nd)
399{ 398{
400 struct vnode *vp = LINVFS_GET_VP(dir), *cvp; 399 struct vnode *vp = vn_from_inode(dir), *cvp;
401 int error; 400 int error;
402 401
403 if (dentry->d_name.len >= MAXNAMELEN) 402 if (dentry->d_name.len >= MAXNAMELEN)
@@ -411,11 +410,11 @@ linvfs_lookup(
411 return NULL; 410 return NULL;
412 } 411 }
413 412
414 return d_splice_alias(LINVFS_GET_IP(cvp), dentry); 413 return d_splice_alias(vn_to_inode(cvp), dentry);
415} 414}
416 415
417STATIC int 416STATIC int
418linvfs_link( 417xfs_vn_link(
419 struct dentry *old_dentry, 418 struct dentry *old_dentry,
420 struct inode *dir, 419 struct inode *dir,
421 struct dentry *dentry) 420 struct dentry *dentry)
@@ -423,99 +422,102 @@ linvfs_link(
423 struct inode *ip; /* inode of guy being linked to */ 422 struct inode *ip; /* inode of guy being linked to */
424 vnode_t *tdvp; /* target directory for new name/link */ 423 vnode_t *tdvp; /* target directory for new name/link */
425 vnode_t *vp; /* vp of name being linked */ 424 vnode_t *vp; /* vp of name being linked */
425 vattr_t vattr;
426 int error; 426 int error;
427 427
428 ip = old_dentry->d_inode; /* inode being linked to */ 428 ip = old_dentry->d_inode; /* inode being linked to */
429 if (S_ISDIR(ip->i_mode)) 429 if (S_ISDIR(ip->i_mode))
430 return -EPERM; 430 return -EPERM;
431 431
432 tdvp = LINVFS_GET_VP(dir); 432 tdvp = vn_from_inode(dir);
433 vp = LINVFS_GET_VP(ip); 433 vp = vn_from_inode(ip);
434 434
435 VOP_LINK(tdvp, vp, dentry, NULL, error); 435 VOP_LINK(tdvp, vp, dentry, NULL, error);
436 if (!error) { 436 if (likely(!error)) {
437 VMODIFY(tdvp); 437 VMODIFY(tdvp);
438 VN_HOLD(vp); 438 VN_HOLD(vp);
439 validate_fields(ip); 439 xfs_validate_fields(ip, &vattr);
440 d_instantiate(dentry, ip); 440 d_instantiate(dentry, ip);
441 } 441 }
442 return -error; 442 return -error;
443} 443}
444 444
445STATIC int 445STATIC int
446linvfs_unlink( 446xfs_vn_unlink(
447 struct inode *dir, 447 struct inode *dir,
448 struct dentry *dentry) 448 struct dentry *dentry)
449{ 449{
450 struct inode *inode; 450 struct inode *inode;
451 vnode_t *dvp; /* directory containing name to remove */ 451 vnode_t *dvp; /* directory containing name to remove */
452 vattr_t vattr;
452 int error; 453 int error;
453 454
454 inode = dentry->d_inode; 455 inode = dentry->d_inode;
455 dvp = LINVFS_GET_VP(dir); 456 dvp = vn_from_inode(dir);
456 457
457 VOP_REMOVE(dvp, dentry, NULL, error); 458 VOP_REMOVE(dvp, dentry, NULL, error);
458 if (!error) { 459 if (likely(!error)) {
459 validate_fields(dir); /* For size only */ 460 xfs_validate_fields(dir, &vattr); /* size needs update */
460 validate_fields(inode); 461 xfs_validate_fields(inode, &vattr);
461 } 462 }
462
463 return -error; 463 return -error;
464} 464}
465 465
466STATIC int 466STATIC int
467linvfs_symlink( 467xfs_vn_symlink(
468 struct inode *dir, 468 struct inode *dir,
469 struct dentry *dentry, 469 struct dentry *dentry,
470 const char *symname) 470 const char *symname)
471{ 471{
472 struct inode *ip; 472 struct inode *ip;
473 vattr_t va; 473 vattr_t vattr = { 0 };
474 vnode_t *dvp; /* directory containing name of symlink */ 474 vnode_t *dvp; /* directory containing name of symlink */
475 vnode_t *cvp; /* used to lookup symlink to put in dentry */ 475 vnode_t *cvp; /* used to lookup symlink to put in dentry */
476 int error; 476 int error;
477 477
478 dvp = LINVFS_GET_VP(dir); 478 dvp = vn_from_inode(dir);
479 cvp = NULL; 479 cvp = NULL;
480 480
481 memset(&va, 0, sizeof(va)); 481 vattr.va_mode = S_IFLNK |
482 va.va_mode = S_IFLNK |
483 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); 482 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
484 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; 483 vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
485 484
486 error = 0; 485 error = 0;
487 VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); 486 VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error);
488 if (likely(!error && cvp)) { 487 if (likely(!error && cvp)) {
489 error = linvfs_init_security(cvp, dir); 488 error = xfs_init_security(cvp, dir);
490 if (likely(!error)) { 489 if (likely(!error)) {
491 ip = LINVFS_GET_IP(cvp); 490 ip = vn_to_inode(cvp);
492 d_instantiate(dentry, ip); 491 d_instantiate(dentry, ip);
493 validate_fields(dir); 492 xfs_validate_fields(dir, &vattr);
494 validate_fields(ip); 493 xfs_validate_fields(ip, &vattr);
494 } else {
495 xfs_cleanup_inode(dvp, cvp, dentry, 0);
495 } 496 }
496 } 497 }
497 return -error; 498 return -error;
498} 499}
499 500
500STATIC int 501STATIC int
501linvfs_rmdir( 502xfs_vn_rmdir(
502 struct inode *dir, 503 struct inode *dir,
503 struct dentry *dentry) 504 struct dentry *dentry)
504{ 505{
505 struct inode *inode = dentry->d_inode; 506 struct inode *inode = dentry->d_inode;
506 vnode_t *dvp = LINVFS_GET_VP(dir); 507 vnode_t *dvp = vn_from_inode(dir);
508 vattr_t vattr;
507 int error; 509 int error;
508 510
509 VOP_RMDIR(dvp, dentry, NULL, error); 511 VOP_RMDIR(dvp, dentry, NULL, error);
510 if (!error) { 512 if (likely(!error)) {
511 validate_fields(inode); 513 xfs_validate_fields(inode, &vattr);
512 validate_fields(dir); 514 xfs_validate_fields(dir, &vattr);
513 } 515 }
514 return -error; 516 return -error;
515} 517}
516 518
517STATIC int 519STATIC int
518linvfs_rename( 520xfs_vn_rename(
519 struct inode *odir, 521 struct inode *odir,
520 struct dentry *odentry, 522 struct dentry *odentry,
521 struct inode *ndir, 523 struct inode *ndir,
@@ -524,22 +526,21 @@ linvfs_rename(
524 struct inode *new_inode = ndentry->d_inode; 526 struct inode *new_inode = ndentry->d_inode;
525 vnode_t *fvp; /* from directory */ 527 vnode_t *fvp; /* from directory */
526 vnode_t *tvp; /* target directory */ 528 vnode_t *tvp; /* target directory */
529 vattr_t vattr;
527 int error; 530 int error;
528 531
529 fvp = LINVFS_GET_VP(odir); 532 fvp = vn_from_inode(odir);
530 tvp = LINVFS_GET_VP(ndir); 533 tvp = vn_from_inode(ndir);
531 534
532 VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error); 535 VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
533 if (error) 536 if (likely(!error)) {
534 return -error; 537 if (new_inode)
535 538 xfs_validate_fields(new_inode, &vattr);
536 if (new_inode) 539 xfs_validate_fields(odir, &vattr);
537 validate_fields(new_inode); 540 if (ndir != odir)
538 541 xfs_validate_fields(ndir, &vattr);
539 validate_fields(odir); 542 }
540 if (ndir != odir) 543 return -error;
541 validate_fields(ndir);
542 return 0;
543} 544}
544 545
545/* 546/*
@@ -548,7 +549,7 @@ linvfs_rename(
548 * uio is kmalloced for this reason... 549 * uio is kmalloced for this reason...
549 */ 550 */
550STATIC void * 551STATIC void *
551linvfs_follow_link( 552xfs_vn_follow_link(
552 struct dentry *dentry, 553 struct dentry *dentry,
553 struct nameidata *nd) 554 struct nameidata *nd)
554{ 555{
@@ -574,7 +575,7 @@ linvfs_follow_link(
574 return NULL; 575 return NULL;
575 } 576 }
576 577
577 vp = LINVFS_GET_VP(dentry->d_inode); 578 vp = vn_from_inode(dentry->d_inode);
578 579
579 iov.iov_base = link; 580 iov.iov_base = link;
580 iov.iov_len = MAXPATHLEN; 581 iov.iov_len = MAXPATHLEN;
@@ -599,7 +600,7 @@ linvfs_follow_link(
599} 600}
600 601
601STATIC void 602STATIC void
602linvfs_put_link( 603xfs_vn_put_link(
603 struct dentry *dentry, 604 struct dentry *dentry,
604 struct nameidata *nd, 605 struct nameidata *nd,
605 void *p) 606 void *p)
@@ -612,12 +613,12 @@ linvfs_put_link(
612 613
613#ifdef CONFIG_XFS_POSIX_ACL 614#ifdef CONFIG_XFS_POSIX_ACL
614STATIC int 615STATIC int
615linvfs_permission( 616xfs_vn_permission(
616 struct inode *inode, 617 struct inode *inode,
617 int mode, 618 int mode,
618 struct nameidata *nd) 619 struct nameidata *nd)
619{ 620{
620 vnode_t *vp = LINVFS_GET_VP(inode); 621 vnode_t *vp = vn_from_inode(inode);
621 int error; 622 int error;
622 623
623 mode <<= 6; /* convert from linux to vnode access bits */ 624 mode <<= 6; /* convert from linux to vnode access bits */
@@ -625,17 +626,17 @@ linvfs_permission(
625 return -error; 626 return -error;
626} 627}
627#else 628#else
628#define linvfs_permission NULL 629#define xfs_vn_permission NULL
629#endif 630#endif
630 631
631STATIC int 632STATIC int
632linvfs_getattr( 633xfs_vn_getattr(
633 struct vfsmount *mnt, 634 struct vfsmount *mnt,
634 struct dentry *dentry, 635 struct dentry *dentry,
635 struct kstat *stat) 636 struct kstat *stat)
636{ 637{
637 struct inode *inode = dentry->d_inode; 638 struct inode *inode = dentry->d_inode;
638 vnode_t *vp = LINVFS_GET_VP(inode); 639 vnode_t *vp = vn_from_inode(inode);
639 int error = 0; 640 int error = 0;
640 641
641 if (unlikely(vp->v_flag & VMODIFIED)) 642 if (unlikely(vp->v_flag & VMODIFIED))
@@ -646,18 +647,17 @@ linvfs_getattr(
646} 647}
647 648
648STATIC int 649STATIC int
649linvfs_setattr( 650xfs_vn_setattr(
650 struct dentry *dentry, 651 struct dentry *dentry,
651 struct iattr *attr) 652 struct iattr *attr)
652{ 653{
653 struct inode *inode = dentry->d_inode; 654 struct inode *inode = dentry->d_inode;
654 unsigned int ia_valid = attr->ia_valid; 655 unsigned int ia_valid = attr->ia_valid;
655 vnode_t *vp = LINVFS_GET_VP(inode); 656 vnode_t *vp = vn_from_inode(inode);
656 vattr_t vattr; 657 vattr_t vattr = { 0 };
657 int flags = 0; 658 int flags = 0;
658 int error; 659 int error;
659 660
660 memset(&vattr, 0, sizeof(vattr_t));
661 if (ia_valid & ATTR_UID) { 661 if (ia_valid & ATTR_UID) {
662 vattr.va_mask |= XFS_AT_UID; 662 vattr.va_mask |= XFS_AT_UID;
663 vattr.va_uid = attr->ia_uid; 663 vattr.va_uid = attr->ia_uid;
@@ -699,28 +699,27 @@ linvfs_setattr(
699#endif 699#endif
700 700
701 VOP_SETATTR(vp, &vattr, flags, NULL, error); 701 VOP_SETATTR(vp, &vattr, flags, NULL, error);
702 if (error) 702 if (likely(!error))
703 return -error; 703 __vn_revalidate(vp, &vattr);
704 vn_revalidate(vp); 704 return -error;
705 return error;
706} 705}
707 706
708STATIC void 707STATIC void
709linvfs_truncate( 708xfs_vn_truncate(
710 struct inode *inode) 709 struct inode *inode)
711{ 710{
712 block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block); 711 block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_block);
713} 712}
714 713
715STATIC int 714STATIC int
716linvfs_setxattr( 715xfs_vn_setxattr(
717 struct dentry *dentry, 716 struct dentry *dentry,
718 const char *name, 717 const char *name,
719 const void *data, 718 const void *data,
720 size_t size, 719 size_t size,
721 int flags) 720 int flags)
722{ 721{
723 vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); 722 vnode_t *vp = vn_from_inode(dentry->d_inode);
724 char *attr = (char *)name; 723 char *attr = (char *)name;
725 attrnames_t *namesp; 724 attrnames_t *namesp;
726 int xflags = 0; 725 int xflags = 0;
@@ -744,13 +743,13 @@ linvfs_setxattr(
744} 743}
745 744
746STATIC ssize_t 745STATIC ssize_t
747linvfs_getxattr( 746xfs_vn_getxattr(
748 struct dentry *dentry, 747 struct dentry *dentry,
749 const char *name, 748 const char *name,
750 void *data, 749 void *data,
751 size_t size) 750 size_t size)
752{ 751{
753 vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); 752 vnode_t *vp = vn_from_inode(dentry->d_inode);
754 char *attr = (char *)name; 753 char *attr = (char *)name;
755 attrnames_t *namesp; 754 attrnames_t *namesp;
756 int xflags = 0; 755 int xflags = 0;
@@ -774,12 +773,12 @@ linvfs_getxattr(
774} 773}
775 774
776STATIC ssize_t 775STATIC ssize_t
777linvfs_listxattr( 776xfs_vn_listxattr(
778 struct dentry *dentry, 777 struct dentry *dentry,
779 char *data, 778 char *data,
780 size_t size) 779 size_t size)
781{ 780{
782 vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); 781 vnode_t *vp = vn_from_inode(dentry->d_inode);
783 int error, xflags = ATTR_KERNAMELS; 782 int error, xflags = ATTR_KERNAMELS;
784 ssize_t result; 783 ssize_t result;
785 784
@@ -794,11 +793,11 @@ linvfs_listxattr(
794} 793}
795 794
796STATIC int 795STATIC int
797linvfs_removexattr( 796xfs_vn_removexattr(
798 struct dentry *dentry, 797 struct dentry *dentry,
799 const char *name) 798 const char *name)
800{ 799{
801 vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); 800 vnode_t *vp = vn_from_inode(dentry->d_inode);
802 char *attr = (char *)name; 801 char *attr = (char *)name;
803 attrnames_t *namesp; 802 attrnames_t *namesp;
804 int xflags = 0; 803 int xflags = 0;
@@ -816,45 +815,45 @@ linvfs_removexattr(
816} 815}
817 816
818 817
819struct inode_operations linvfs_file_inode_operations = { 818struct inode_operations xfs_inode_operations = {
820 .permission = linvfs_permission, 819 .permission = xfs_vn_permission,
821 .truncate = linvfs_truncate, 820 .truncate = xfs_vn_truncate,
822 .getattr = linvfs_getattr, 821 .getattr = xfs_vn_getattr,
823 .setattr = linvfs_setattr, 822 .setattr = xfs_vn_setattr,
824 .setxattr = linvfs_setxattr, 823 .setxattr = xfs_vn_setxattr,
825 .getxattr = linvfs_getxattr, 824 .getxattr = xfs_vn_getxattr,
826 .listxattr = linvfs_listxattr, 825 .listxattr = xfs_vn_listxattr,
827 .removexattr = linvfs_removexattr, 826 .removexattr = xfs_vn_removexattr,
828}; 827};
829 828
830struct inode_operations linvfs_dir_inode_operations = { 829struct inode_operations xfs_dir_inode_operations = {
831 .create = linvfs_create, 830 .create = xfs_vn_create,
832 .lookup = linvfs_lookup, 831 .lookup = xfs_vn_lookup,
833 .link = linvfs_link, 832 .link = xfs_vn_link,
834 .unlink = linvfs_unlink, 833 .unlink = xfs_vn_unlink,
835 .symlink = linvfs_symlink, 834 .symlink = xfs_vn_symlink,
836 .mkdir = linvfs_mkdir, 835 .mkdir = xfs_vn_mkdir,
837 .rmdir = linvfs_rmdir, 836 .rmdir = xfs_vn_rmdir,
838 .mknod = linvfs_mknod, 837 .mknod = xfs_vn_mknod,
839 .rename = linvfs_rename, 838 .rename = xfs_vn_rename,
840 .permission = linvfs_permission, 839 .permission = xfs_vn_permission,
841 .getattr = linvfs_getattr, 840 .getattr = xfs_vn_getattr,
842 .setattr = linvfs_setattr, 841 .setattr = xfs_vn_setattr,
843 .setxattr = linvfs_setxattr, 842 .setxattr = xfs_vn_setxattr,
844 .getxattr = linvfs_getxattr, 843 .getxattr = xfs_vn_getxattr,
845 .listxattr = linvfs_listxattr, 844 .listxattr = xfs_vn_listxattr,
846 .removexattr = linvfs_removexattr, 845 .removexattr = xfs_vn_removexattr,
847}; 846};
848 847
849struct inode_operations linvfs_symlink_inode_operations = { 848struct inode_operations xfs_symlink_inode_operations = {
850 .readlink = generic_readlink, 849 .readlink = generic_readlink,
851 .follow_link = linvfs_follow_link, 850 .follow_link = xfs_vn_follow_link,
852 .put_link = linvfs_put_link, 851 .put_link = xfs_vn_put_link,
853 .permission = linvfs_permission, 852 .permission = xfs_vn_permission,
854 .getattr = linvfs_getattr, 853 .getattr = xfs_vn_getattr,
855 .setattr = linvfs_setattr, 854 .setattr = xfs_vn_setattr,
856 .setxattr = linvfs_setxattr, 855 .setxattr = xfs_vn_setxattr,
857 .getxattr = linvfs_getxattr, 856 .getxattr = xfs_vn_getxattr,
858 .listxattr = linvfs_listxattr, 857 .listxattr = xfs_vn_listxattr,
859 .removexattr = linvfs_removexattr, 858 .removexattr = xfs_vn_removexattr,
860}; 859};
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index 6899a6b4a50a..a8417d7af5f9 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -18,13 +18,13 @@
18#ifndef __XFS_IOPS_H__ 18#ifndef __XFS_IOPS_H__
19#define __XFS_IOPS_H__ 19#define __XFS_IOPS_H__
20 20
21extern struct inode_operations linvfs_file_inode_operations; 21extern struct inode_operations xfs_inode_operations;
22extern struct inode_operations linvfs_dir_inode_operations; 22extern struct inode_operations xfs_dir_inode_operations;
23extern struct inode_operations linvfs_symlink_inode_operations; 23extern struct inode_operations xfs_symlink_inode_operations;
24 24
25extern struct file_operations linvfs_file_operations; 25extern struct file_operations xfs_file_operations;
26extern struct file_operations linvfs_invis_file_operations; 26extern struct file_operations xfs_dir_file_operations;
27extern struct file_operations linvfs_dir_operations; 27extern struct file_operations xfs_invis_file_operations;
28 28
29extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, 29extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
30 int, unsigned int, void __user *); 30 int, unsigned int, void __user *);
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 67389b745526..1fe09f2d6519 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -73,6 +73,9 @@
73#include <linux/list.h> 73#include <linux/list.h>
74#include <linux/proc_fs.h> 74#include <linux/proc_fs.h>
75#include <linux/sort.h> 75#include <linux/sort.h>
76#include <linux/cpu.h>
77#include <linux/notifier.h>
78#include <linux/delay.h>
76 79
77#include <asm/page.h> 80#include <asm/page.h>
78#include <asm/div64.h> 81#include <asm/div64.h>
@@ -100,6 +103,11 @@
100 */ 103 */
101#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */ 104#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */
102#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */ 105#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */
106#ifdef CONFIG_SMP
107#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
108#else
109#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
110#endif
103 111
104/* 112/*
105 * State flag for unwritten extent buffers. 113 * State flag for unwritten extent buffers.
@@ -226,7 +234,7 @@ BUFFER_FNS(PrivateStart, unwritten);
226#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL) 234#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
227#define xfs_stack_trace() dump_stack() 235#define xfs_stack_trace() dump_stack()
228#define xfs_itruncate_data(ip, off) \ 236#define xfs_itruncate_data(ip, off) \
229 (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) 237 (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off)))
230#define xfs_statvfs_fsid(statp, mp) \ 238#define xfs_statvfs_fsid(statp, mp) \
231 ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \ 239 ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \
232 __kernel_fsid_t *fsid = &(statp)->f_fsid; \ 240 __kernel_fsid_t *fsid = &(statp)->f_fsid; \
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index e0ab45fbfebd..0169360475c4 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -83,7 +83,7 @@ xfs_rw_enter_trace(
83 (void *)((unsigned long)ioflags), 83 (void *)((unsigned long)ioflags),
84 (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)), 84 (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
85 (void *)((unsigned long)(io->io_new_size & 0xffffffff)), 85 (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
86 (void *)NULL, 86 (void *)((unsigned long)current_pid()),
87 (void *)NULL, 87 (void *)NULL,
88 (void *)NULL, 88 (void *)NULL,
89 (void *)NULL, 89 (void *)NULL,
@@ -113,7 +113,7 @@ xfs_inval_cached_trace(
113 (void *)((unsigned long)(first & 0xffffffff)), 113 (void *)((unsigned long)(first & 0xffffffff)),
114 (void *)((unsigned long)((last >> 32) & 0xffffffff)), 114 (void *)((unsigned long)((last >> 32) & 0xffffffff)),
115 (void *)((unsigned long)(last & 0xffffffff)), 115 (void *)((unsigned long)(last & 0xffffffff)),
116 (void *)NULL, 116 (void *)((unsigned long)current_pid()),
117 (void *)NULL, 117 (void *)NULL,
118 (void *)NULL, 118 (void *)NULL,
119 (void *)NULL, 119 (void *)NULL,
@@ -249,9 +249,8 @@ xfs_read(
249 if (n < size) 249 if (n < size)
250 size = n; 250 size = n;
251 251
252 if (XFS_FORCED_SHUTDOWN(mp)) { 252 if (XFS_FORCED_SHUTDOWN(mp))
253 return -EIO; 253 return -EIO;
254 }
255 254
256 if (unlikely(ioflags & IO_ISDIRECT)) 255 if (unlikely(ioflags & IO_ISDIRECT))
257 mutex_lock(&inode->i_mutex); 256 mutex_lock(&inode->i_mutex);
@@ -267,10 +266,14 @@ xfs_read(
267 dmflags, &locktype); 266 dmflags, &locktype);
268 if (ret) { 267 if (ret) {
269 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 268 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
270 goto unlock_isem; 269 goto unlock_mutex;
271 } 270 }
272 } 271 }
273 272
273 if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp)))
274 VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(*offset)),
275 -1, FI_REMAPF_LOCKED);
276
274 xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, 277 xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
275 (void *)iovp, segs, *offset, ioflags); 278 (void *)iovp, segs, *offset, ioflags);
276 ret = __generic_file_aio_read(iocb, iovp, segs, offset); 279 ret = __generic_file_aio_read(iocb, iovp, segs, offset);
@@ -281,7 +284,7 @@ xfs_read(
281 284
282 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 285 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
283 286
284unlock_isem: 287unlock_mutex:
285 if (unlikely(ioflags & IO_ISDIRECT)) 288 if (unlikely(ioflags & IO_ISDIRECT))
286 mutex_unlock(&inode->i_mutex); 289 mutex_unlock(&inode->i_mutex);
287 return ret; 290 return ret;
@@ -432,7 +435,7 @@ xfs_zero_eof(
432 xfs_fsize_t isize, /* current inode size */ 435 xfs_fsize_t isize, /* current inode size */
433 xfs_fsize_t end_size) /* terminal inode size */ 436 xfs_fsize_t end_size) /* terminal inode size */
434{ 437{
435 struct inode *ip = LINVFS_GET_IP(vp); 438 struct inode *ip = vn_to_inode(vp);
436 xfs_fileoff_t start_zero_fsb; 439 xfs_fileoff_t start_zero_fsb;
437 xfs_fileoff_t end_zero_fsb; 440 xfs_fileoff_t end_zero_fsb;
438 xfs_fileoff_t zero_count_fsb; 441 xfs_fileoff_t zero_count_fsb;
@@ -573,7 +576,7 @@ xfs_write(
573 vrwlock_t locktype; 576 vrwlock_t locktype;
574 size_t ocount = 0, count; 577 size_t ocount = 0, count;
575 loff_t pos; 578 loff_t pos;
576 int need_isem = 1, need_flush = 0; 579 int need_i_mutex = 1, need_flush = 0;
577 580
578 XFS_STATS_INC(xs_write_calls); 581 XFS_STATS_INC(xs_write_calls);
579 582
@@ -622,14 +625,14 @@ xfs_write(
622 return XFS_ERROR(-EINVAL); 625 return XFS_ERROR(-EINVAL);
623 626
624 if (!VN_CACHED(vp) && pos < i_size_read(inode)) 627 if (!VN_CACHED(vp) && pos < i_size_read(inode))
625 need_isem = 0; 628 need_i_mutex = 0;
626 629
627 if (VN_CACHED(vp)) 630 if (VN_CACHED(vp))
628 need_flush = 1; 631 need_flush = 1;
629 } 632 }
630 633
631relock: 634relock:
632 if (need_isem) { 635 if (need_i_mutex) {
633 iolock = XFS_IOLOCK_EXCL; 636 iolock = XFS_IOLOCK_EXCL;
634 locktype = VRWLOCK_WRITE; 637 locktype = VRWLOCK_WRITE;
635 638
@@ -651,7 +654,7 @@ start:
651 S_ISBLK(inode->i_mode)); 654 S_ISBLK(inode->i_mode));
652 if (error) { 655 if (error) {
653 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 656 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
654 goto out_unlock_isem; 657 goto out_unlock_mutex;
655 } 658 }
656 659
657 new_size = pos + count; 660 new_size = pos + count;
@@ -663,7 +666,7 @@ start:
663 loff_t savedsize = pos; 666 loff_t savedsize = pos;
664 int dmflags = FILP_DELAY_FLAG(file); 667 int dmflags = FILP_DELAY_FLAG(file);
665 668
666 if (need_isem) 669 if (need_i_mutex)
667 dmflags |= DM_FLAGS_IMUX; 670 dmflags |= DM_FLAGS_IMUX;
668 671
669 xfs_iunlock(xip, XFS_ILOCK_EXCL); 672 xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -672,7 +675,7 @@ start:
672 dmflags, &locktype); 675 dmflags, &locktype);
673 if (error) { 676 if (error) {
674 xfs_iunlock(xip, iolock); 677 xfs_iunlock(xip, iolock);
675 goto out_unlock_isem; 678 goto out_unlock_mutex;
676 } 679 }
677 xfs_ilock(xip, XFS_ILOCK_EXCL); 680 xfs_ilock(xip, XFS_ILOCK_EXCL);
678 eventsent = 1; 681 eventsent = 1;
@@ -710,7 +713,7 @@ start:
710 isize, pos + count); 713 isize, pos + count);
711 if (error) { 714 if (error) {
712 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 715 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
713 goto out_unlock_isem; 716 goto out_unlock_mutex;
714 } 717 }
715 } 718 }
716 xfs_iunlock(xip, XFS_ILOCK_EXCL); 719 xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -731,7 +734,7 @@ start:
731 error = -remove_suid(file->f_dentry); 734 error = -remove_suid(file->f_dentry);
732 if (unlikely(error)) { 735 if (unlikely(error)) {
733 xfs_iunlock(xip, iolock); 736 xfs_iunlock(xip, iolock);
734 goto out_unlock_isem; 737 goto out_unlock_mutex;
735 } 738 }
736 } 739 }
737 740
@@ -747,14 +750,14 @@ retry:
747 -1, FI_REMAPF_LOCKED); 750 -1, FI_REMAPF_LOCKED);
748 } 751 }
749 752
750 if (need_isem) { 753 if (need_i_mutex) {
751 /* demote the lock now the cached pages are gone */ 754 /* demote the lock now the cached pages are gone */
752 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL); 755 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
753 mutex_unlock(&inode->i_mutex); 756 mutex_unlock(&inode->i_mutex);
754 757
755 iolock = XFS_IOLOCK_SHARED; 758 iolock = XFS_IOLOCK_SHARED;
756 locktype = VRWLOCK_WRITE_DIRECT; 759 locktype = VRWLOCK_WRITE_DIRECT;
757 need_isem = 0; 760 need_i_mutex = 0;
758 } 761 }
759 762
760 xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs, 763 xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
@@ -772,7 +775,7 @@ retry:
772 pos += ret; 775 pos += ret;
773 count -= ret; 776 count -= ret;
774 777
775 need_isem = 1; 778 need_i_mutex = 1;
776 ioflags &= ~IO_ISDIRECT; 779 ioflags &= ~IO_ISDIRECT;
777 xfs_iunlock(xip, iolock); 780 xfs_iunlock(xip, iolock);
778 goto relock; 781 goto relock;
@@ -794,14 +797,14 @@ retry:
794 !(ioflags & IO_INVIS)) { 797 !(ioflags & IO_INVIS)) {
795 798
796 xfs_rwunlock(bdp, locktype); 799 xfs_rwunlock(bdp, locktype);
797 if (need_isem) 800 if (need_i_mutex)
798 mutex_unlock(&inode->i_mutex); 801 mutex_unlock(&inode->i_mutex);
799 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, 802 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
800 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, 803 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
801 0, 0, 0); /* Delay flag intentionally unused */ 804 0, 0, 0); /* Delay flag intentionally unused */
802 if (error) 805 if (error)
803 goto out_nounlocks; 806 goto out_nounlocks;
804 if (need_isem) 807 if (need_i_mutex)
805 mutex_lock(&inode->i_mutex); 808 mutex_lock(&inode->i_mutex);
806 xfs_rwlock(bdp, locktype); 809 xfs_rwlock(bdp, locktype);
807 pos = xip->i_d.di_size; 810 pos = xip->i_d.di_size;
@@ -905,9 +908,9 @@ retry:
905 if (error) 908 if (error)
906 goto out_unlock_internal; 909 goto out_unlock_internal;
907 } 910 }
908 911
909 xfs_rwunlock(bdp, locktype); 912 xfs_rwunlock(bdp, locktype);
910 if (need_isem) 913 if (need_i_mutex)
911 mutex_unlock(&inode->i_mutex); 914 mutex_unlock(&inode->i_mutex);
912 915
913 error = sync_page_range(inode, mapping, pos, ret); 916 error = sync_page_range(inode, mapping, pos, ret);
@@ -918,8 +921,8 @@ retry:
918 921
919 out_unlock_internal: 922 out_unlock_internal:
920 xfs_rwunlock(bdp, locktype); 923 xfs_rwunlock(bdp, locktype);
921 out_unlock_isem: 924 out_unlock_mutex:
922 if (need_isem) 925 if (need_i_mutex)
923 mutex_unlock(&inode->i_mutex); 926 mutex_unlock(&inode->i_mutex);
924 out_nounlocks: 927 out_nounlocks:
925 return -error; 928 return -error;
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index 8955720a2c6b..713e6a7505d0 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -62,18 +62,15 @@ xfs_read_xfsstats(
62 while (j < xstats[i].endpoint) { 62 while (j < xstats[i].endpoint) {
63 val = 0; 63 val = 0;
64 /* sum over all cpus */ 64 /* sum over all cpus */
65 for (c = 0; c < NR_CPUS; c++) { 65 for_each_cpu(c)
66 if (!cpu_possible(c)) continue;
67 val += *(((__u32*)&per_cpu(xfsstats, c) + j)); 66 val += *(((__u32*)&per_cpu(xfsstats, c) + j));
68 }
69 len += sprintf(buffer + len, " %u", val); 67 len += sprintf(buffer + len, " %u", val);
70 j++; 68 j++;
71 } 69 }
72 buffer[len++] = '\n'; 70 buffer[len++] = '\n';
73 } 71 }
74 /* extra precision counters */ 72 /* extra precision counters */
75 for (i = 0; i < NR_CPUS; i++) { 73 for_each_cpu(i) {
76 if (!cpu_possible(i)) continue;
77 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes; 74 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
78 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes; 75 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
79 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes; 76 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index f22e426d9e42..8355faf8ffde 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -59,8 +59,8 @@
59#include <linux/writeback.h> 59#include <linux/writeback.h>
60#include <linux/kthread.h> 60#include <linux/kthread.h>
61 61
62STATIC struct quotactl_ops linvfs_qops; 62STATIC struct quotactl_ops xfs_quotactl_operations;
63STATIC struct super_operations linvfs_sops; 63STATIC struct super_operations xfs_super_operations;
64STATIC kmem_zone_t *xfs_vnode_zone; 64STATIC kmem_zone_t *xfs_vnode_zone;
65STATIC kmem_zone_t *xfs_ioend_zone; 65STATIC kmem_zone_t *xfs_ioend_zone;
66mempool_t *xfs_ioend_pool; 66mempool_t *xfs_ioend_pool;
@@ -76,8 +76,6 @@ xfs_args_allocate(
76 strncpy(args->fsname, sb->s_id, MAXNAMELEN); 76 strncpy(args->fsname, sb->s_id, MAXNAMELEN);
77 77
78 /* Copy the already-parsed mount(2) flags we're interested in */ 78 /* Copy the already-parsed mount(2) flags we're interested in */
79 if (sb->s_flags & MS_NOATIME)
80 args->flags |= XFSMNT_NOATIME;
81 if (sb->s_flags & MS_DIRSYNC) 79 if (sb->s_flags & MS_DIRSYNC)
82 args->flags |= XFSMNT_DIRSYNC; 80 args->flags |= XFSMNT_DIRSYNC;
83 if (sb->s_flags & MS_SYNCHRONOUS) 81 if (sb->s_flags & MS_SYNCHRONOUS)
@@ -129,21 +127,21 @@ xfs_set_inodeops(
129{ 127{
130 switch (inode->i_mode & S_IFMT) { 128 switch (inode->i_mode & S_IFMT) {
131 case S_IFREG: 129 case S_IFREG:
132 inode->i_op = &linvfs_file_inode_operations; 130 inode->i_op = &xfs_inode_operations;
133 inode->i_fop = &linvfs_file_operations; 131 inode->i_fop = &xfs_file_operations;
134 inode->i_mapping->a_ops = &linvfs_aops; 132 inode->i_mapping->a_ops = &xfs_address_space_operations;
135 break; 133 break;
136 case S_IFDIR: 134 case S_IFDIR:
137 inode->i_op = &linvfs_dir_inode_operations; 135 inode->i_op = &xfs_dir_inode_operations;
138 inode->i_fop = &linvfs_dir_operations; 136 inode->i_fop = &xfs_dir_file_operations;
139 break; 137 break;
140 case S_IFLNK: 138 case S_IFLNK:
141 inode->i_op = &linvfs_symlink_inode_operations; 139 inode->i_op = &xfs_symlink_inode_operations;
142 if (inode->i_blocks) 140 if (inode->i_blocks)
143 inode->i_mapping->a_ops = &linvfs_aops; 141 inode->i_mapping->a_ops = &xfs_address_space_operations;
144 break; 142 break;
145 default: 143 default:
146 inode->i_op = &linvfs_file_inode_operations; 144 inode->i_op = &xfs_inode_operations;
147 init_special_inode(inode, inode->i_mode, inode->i_rdev); 145 init_special_inode(inode, inode->i_mode, inode->i_rdev);
148 break; 146 break;
149 } 147 }
@@ -155,7 +153,7 @@ xfs_revalidate_inode(
155 vnode_t *vp, 153 vnode_t *vp,
156 xfs_inode_t *ip) 154 xfs_inode_t *ip)
157{ 155{
158 struct inode *inode = LINVFS_GET_IP(vp); 156 struct inode *inode = vn_to_inode(vp);
159 157
160 inode->i_mode = ip->i_d.di_mode; 158 inode->i_mode = ip->i_d.di_mode;
161 inode->i_nlink = ip->i_d.di_nlink; 159 inode->i_nlink = ip->i_d.di_nlink;
@@ -212,7 +210,7 @@ xfs_initialize_vnode(
212 int unlock) 210 int unlock)
213{ 211{
214 xfs_inode_t *ip = XFS_BHVTOI(inode_bhv); 212 xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
215 struct inode *inode = LINVFS_GET_IP(vp); 213 struct inode *inode = vn_to_inode(vp);
216 214
217 if (!inode_bhv->bd_vobj) { 215 if (!inode_bhv->bd_vobj) {
218 vp->v_vfsp = bhvtovfs(bdp); 216 vp->v_vfsp = bhvtovfs(bdp);
@@ -230,7 +228,7 @@ xfs_initialize_vnode(
230 if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) { 228 if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
231 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 229 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
232 xfs_set_inodeops(inode); 230 xfs_set_inodeops(inode);
233 231
234 ip->i_flags &= ~XFS_INEW; 232 ip->i_flags &= ~XFS_INEW;
235 barrier(); 233 barrier();
236 234
@@ -334,43 +332,42 @@ xfs_blkdev_issue_flush(
334} 332}
335 333
336STATIC struct inode * 334STATIC struct inode *
337linvfs_alloc_inode( 335xfs_fs_alloc_inode(
338 struct super_block *sb) 336 struct super_block *sb)
339{ 337{
340 vnode_t *vp; 338 vnode_t *vp;
341 339
342 vp = kmem_cache_alloc(xfs_vnode_zone, kmem_flags_convert(KM_SLEEP)); 340 vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP);
343 if (!vp) 341 if (unlikely(!vp))
344 return NULL; 342 return NULL;
345 return LINVFS_GET_IP(vp); 343 return vn_to_inode(vp);
346} 344}
347 345
348STATIC void 346STATIC void
349linvfs_destroy_inode( 347xfs_fs_destroy_inode(
350 struct inode *inode) 348 struct inode *inode)
351{ 349{
352 kmem_zone_free(xfs_vnode_zone, LINVFS_GET_VP(inode)); 350 kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode));
353} 351}
354 352
355STATIC void 353STATIC void
356linvfs_inode_init_once( 354xfs_fs_inode_init_once(
357 void *data, 355 void *vnode,
358 kmem_cache_t *cachep, 356 kmem_zone_t *zonep,
359 unsigned long flags) 357 unsigned long flags)
360{ 358{
361 vnode_t *vp = (vnode_t *)data;
362
363 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 359 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
364 SLAB_CTOR_CONSTRUCTOR) 360 SLAB_CTOR_CONSTRUCTOR)
365 inode_init_once(LINVFS_GET_IP(vp)); 361 inode_init_once(vn_to_inode((vnode_t *)vnode));
366} 362}
367 363
368STATIC int 364STATIC int
369linvfs_init_zones(void) 365xfs_init_zones(void)
370{ 366{
371 xfs_vnode_zone = kmem_cache_create("xfs_vnode", 367 xfs_vnode_zone = kmem_zone_init_flags(sizeof(vnode_t), "xfs_vnode_t",
372 sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT, 368 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
373 linvfs_inode_init_once, NULL); 369 KM_ZONE_SPREAD,
370 xfs_fs_inode_init_once);
374 if (!xfs_vnode_zone) 371 if (!xfs_vnode_zone)
375 goto out; 372 goto out;
376 373
@@ -379,14 +376,12 @@ linvfs_init_zones(void)
379 goto out_destroy_vnode_zone; 376 goto out_destroy_vnode_zone;
380 377
381 xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE, 378 xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE,
382 mempool_alloc_slab, mempool_free_slab, 379 mempool_alloc_slab, mempool_free_slab,
383 xfs_ioend_zone); 380 xfs_ioend_zone);
384 if (!xfs_ioend_pool) 381 if (!xfs_ioend_pool)
385 goto out_free_ioend_zone; 382 goto out_free_ioend_zone;
386
387 return 0; 383 return 0;
388 384
389
390 out_free_ioend_zone: 385 out_free_ioend_zone:
391 kmem_zone_destroy(xfs_ioend_zone); 386 kmem_zone_destroy(xfs_ioend_zone);
392 out_destroy_vnode_zone: 387 out_destroy_vnode_zone:
@@ -396,7 +391,7 @@ linvfs_init_zones(void)
396} 391}
397 392
398STATIC void 393STATIC void
399linvfs_destroy_zones(void) 394xfs_destroy_zones(void)
400{ 395{
401 mempool_destroy(xfs_ioend_pool); 396 mempool_destroy(xfs_ioend_pool);
402 kmem_zone_destroy(xfs_vnode_zone); 397 kmem_zone_destroy(xfs_vnode_zone);
@@ -407,14 +402,14 @@ linvfs_destroy_zones(void)
407 * Attempt to flush the inode, this will actually fail 402 * Attempt to flush the inode, this will actually fail
408 * if the inode is pinned, but we dirty the inode again 403 * if the inode is pinned, but we dirty the inode again
409 * at the point when it is unpinned after a log write, 404 * at the point when it is unpinned after a log write,
410 * since this is when the inode itself becomes flushable. 405 * since this is when the inode itself becomes flushable.
411 */ 406 */
412STATIC int 407STATIC int
413linvfs_write_inode( 408xfs_fs_write_inode(
414 struct inode *inode, 409 struct inode *inode,
415 int sync) 410 int sync)
416{ 411{
417 vnode_t *vp = LINVFS_GET_VP(inode); 412 vnode_t *vp = vn_from_inode(inode);
418 int error = 0, flags = FLUSH_INODE; 413 int error = 0, flags = FLUSH_INODE;
419 414
420 if (vp) { 415 if (vp) {
@@ -434,13 +429,13 @@ linvfs_write_inode(
434} 429}
435 430
436STATIC void 431STATIC void
437linvfs_clear_inode( 432xfs_fs_clear_inode(
438 struct inode *inode) 433 struct inode *inode)
439{ 434{
440 vnode_t *vp = LINVFS_GET_VP(inode); 435 vnode_t *vp = vn_from_inode(inode);
441 int error, cache; 436 int error, cache;
442 437
443 vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address); 438 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
444 439
445 XFS_STATS_INC(vn_rele); 440 XFS_STATS_INC(vn_rele);
446 XFS_STATS_INC(vn_remove); 441 XFS_STATS_INC(vn_remove);
@@ -516,7 +511,7 @@ void
516xfs_flush_inode( 511xfs_flush_inode(
517 xfs_inode_t *ip) 512 xfs_inode_t *ip)
518{ 513{
519 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); 514 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
520 struct vfs *vfs = XFS_MTOVFS(ip->i_mount); 515 struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
521 516
522 igrab(inode); 517 igrab(inode);
@@ -541,7 +536,7 @@ void
541xfs_flush_device( 536xfs_flush_device(
542 xfs_inode_t *ip) 537 xfs_inode_t *ip)
543{ 538{
544 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); 539 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
545 struct vfs *vfs = XFS_MTOVFS(ip->i_mount); 540 struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
546 541
547 igrab(inode); 542 igrab(inode);
@@ -550,7 +545,7 @@ xfs_flush_device(
550 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); 545 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
551} 546}
552 547
553#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR) 548#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR|SYNC_REFCACHE)
554STATIC void 549STATIC void
555vfs_sync_worker( 550vfs_sync_worker(
556 vfs_t *vfsp, 551 vfs_t *vfsp,
@@ -613,7 +608,7 @@ xfssyncd(
613} 608}
614 609
615STATIC int 610STATIC int
616linvfs_start_syncd( 611xfs_fs_start_syncd(
617 vfs_t *vfsp) 612 vfs_t *vfsp)
618{ 613{
619 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker; 614 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
@@ -625,20 +620,20 @@ linvfs_start_syncd(
625} 620}
626 621
627STATIC void 622STATIC void
628linvfs_stop_syncd( 623xfs_fs_stop_syncd(
629 vfs_t *vfsp) 624 vfs_t *vfsp)
630{ 625{
631 kthread_stop(vfsp->vfs_sync_task); 626 kthread_stop(vfsp->vfs_sync_task);
632} 627}
633 628
634STATIC void 629STATIC void
635linvfs_put_super( 630xfs_fs_put_super(
636 struct super_block *sb) 631 struct super_block *sb)
637{ 632{
638 vfs_t *vfsp = LINVFS_GET_VFS(sb); 633 vfs_t *vfsp = vfs_from_sb(sb);
639 int error; 634 int error;
640 635
641 linvfs_stop_syncd(vfsp); 636 xfs_fs_stop_syncd(vfsp);
642 VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error); 637 VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
643 if (!error) 638 if (!error)
644 VFS_UNMOUNT(vfsp, 0, NULL, error); 639 VFS_UNMOUNT(vfsp, 0, NULL, error);
@@ -652,10 +647,10 @@ linvfs_put_super(
652} 647}
653 648
654STATIC void 649STATIC void
655linvfs_write_super( 650xfs_fs_write_super(
656 struct super_block *sb) 651 struct super_block *sb)
657{ 652{
658 vfs_t *vfsp = LINVFS_GET_VFS(sb); 653 vfs_t *vfsp = vfs_from_sb(sb);
659 int error; 654 int error;
660 655
661 if (sb->s_flags & MS_RDONLY) { 656 if (sb->s_flags & MS_RDONLY) {
@@ -668,11 +663,11 @@ linvfs_write_super(
668} 663}
669 664
670STATIC int 665STATIC int
671linvfs_sync_super( 666xfs_fs_sync_super(
672 struct super_block *sb, 667 struct super_block *sb,
673 int wait) 668 int wait)
674{ 669{
675 vfs_t *vfsp = LINVFS_GET_VFS(sb); 670 vfs_t *vfsp = vfs_from_sb(sb);
676 int error; 671 int error;
677 int flags = SYNC_FSDATA; 672 int flags = SYNC_FSDATA;
678 673
@@ -707,11 +702,11 @@ linvfs_sync_super(
707} 702}
708 703
709STATIC int 704STATIC int
710linvfs_statfs( 705xfs_fs_statfs(
711 struct super_block *sb, 706 struct super_block *sb,
712 struct kstatfs *statp) 707 struct kstatfs *statp)
713{ 708{
714 vfs_t *vfsp = LINVFS_GET_VFS(sb); 709 vfs_t *vfsp = vfs_from_sb(sb);
715 int error; 710 int error;
716 711
717 VFS_STATVFS(vfsp, statp, NULL, error); 712 VFS_STATVFS(vfsp, statp, NULL, error);
@@ -719,12 +714,12 @@ linvfs_statfs(
719} 714}
720 715
721STATIC int 716STATIC int
722linvfs_remount( 717xfs_fs_remount(
723 struct super_block *sb, 718 struct super_block *sb,
724 int *flags, 719 int *flags,
725 char *options) 720 char *options)
726{ 721{
727 vfs_t *vfsp = LINVFS_GET_VFS(sb); 722 vfs_t *vfsp = vfs_from_sb(sb);
728 struct xfs_mount_args *args = xfs_args_allocate(sb); 723 struct xfs_mount_args *args = xfs_args_allocate(sb);
729 int error; 724 int error;
730 725
@@ -736,18 +731,18 @@ linvfs_remount(
736} 731}
737 732
738STATIC void 733STATIC void
739linvfs_freeze_fs( 734xfs_fs_lockfs(
740 struct super_block *sb) 735 struct super_block *sb)
741{ 736{
742 VFS_FREEZE(LINVFS_GET_VFS(sb)); 737 VFS_FREEZE(vfs_from_sb(sb));
743} 738}
744 739
745STATIC int 740STATIC int
746linvfs_show_options( 741xfs_fs_show_options(
747 struct seq_file *m, 742 struct seq_file *m,
748 struct vfsmount *mnt) 743 struct vfsmount *mnt)
749{ 744{
750 struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb); 745 struct vfs *vfsp = vfs_from_sb(mnt->mnt_sb);
751 int error; 746 int error;
752 747
753 VFS_SHOWARGS(vfsp, m, error); 748 VFS_SHOWARGS(vfsp, m, error);
@@ -755,11 +750,11 @@ linvfs_show_options(
755} 750}
756 751
757STATIC int 752STATIC int
758linvfs_quotasync( 753xfs_fs_quotasync(
759 struct super_block *sb, 754 struct super_block *sb,
760 int type) 755 int type)
761{ 756{
762 struct vfs *vfsp = LINVFS_GET_VFS(sb); 757 struct vfs *vfsp = vfs_from_sb(sb);
763 int error; 758 int error;
764 759
765 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error); 760 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
@@ -767,11 +762,11 @@ linvfs_quotasync(
767} 762}
768 763
769STATIC int 764STATIC int
770linvfs_getxstate( 765xfs_fs_getxstate(
771 struct super_block *sb, 766 struct super_block *sb,
772 struct fs_quota_stat *fqs) 767 struct fs_quota_stat *fqs)
773{ 768{
774 struct vfs *vfsp = LINVFS_GET_VFS(sb); 769 struct vfs *vfsp = vfs_from_sb(sb);
775 int error; 770 int error;
776 771
777 VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error); 772 VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
@@ -779,12 +774,12 @@ linvfs_getxstate(
779} 774}
780 775
781STATIC int 776STATIC int
782linvfs_setxstate( 777xfs_fs_setxstate(
783 struct super_block *sb, 778 struct super_block *sb,
784 unsigned int flags, 779 unsigned int flags,
785 int op) 780 int op)
786{ 781{
787 struct vfs *vfsp = LINVFS_GET_VFS(sb); 782 struct vfs *vfsp = vfs_from_sb(sb);
788 int error; 783 int error;
789 784
790 VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error); 785 VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
@@ -792,13 +787,13 @@ linvfs_setxstate(
792} 787}
793 788
794STATIC int 789STATIC int
795linvfs_getxquota( 790xfs_fs_getxquota(
796 struct super_block *sb, 791 struct super_block *sb,
797 int type, 792 int type,
798 qid_t id, 793 qid_t id,
799 struct fs_disk_quota *fdq) 794 struct fs_disk_quota *fdq)
800{ 795{
801 struct vfs *vfsp = LINVFS_GET_VFS(sb); 796 struct vfs *vfsp = vfs_from_sb(sb);
802 int error, getmode; 797 int error, getmode;
803 798
804 getmode = (type == USRQUOTA) ? Q_XGETQUOTA : 799 getmode = (type == USRQUOTA) ? Q_XGETQUOTA :
@@ -808,13 +803,13 @@ linvfs_getxquota(
808} 803}
809 804
810STATIC int 805STATIC int
811linvfs_setxquota( 806xfs_fs_setxquota(
812 struct super_block *sb, 807 struct super_block *sb,
813 int type, 808 int type,
814 qid_t id, 809 qid_t id,
815 struct fs_disk_quota *fdq) 810 struct fs_disk_quota *fdq)
816{ 811{
817 struct vfs *vfsp = LINVFS_GET_VFS(sb); 812 struct vfs *vfsp = vfs_from_sb(sb);
818 int error, setmode; 813 int error, setmode;
819 814
820 setmode = (type == USRQUOTA) ? Q_XSETQLIM : 815 setmode = (type == USRQUOTA) ? Q_XSETQLIM :
@@ -824,21 +819,17 @@ linvfs_setxquota(
824} 819}
825 820
826STATIC int 821STATIC int
827linvfs_fill_super( 822xfs_fs_fill_super(
828 struct super_block *sb, 823 struct super_block *sb,
829 void *data, 824 void *data,
830 int silent) 825 int silent)
831{ 826{
832 vnode_t *rootvp; 827 vnode_t *rootvp;
833 struct vfs *vfsp = vfs_allocate(); 828 struct vfs *vfsp = vfs_allocate(sb);
834 struct xfs_mount_args *args = xfs_args_allocate(sb); 829 struct xfs_mount_args *args = xfs_args_allocate(sb);
835 struct kstatfs statvfs; 830 struct kstatfs statvfs;
836 int error, error2; 831 int error, error2;
837 832
838 vfsp->vfs_super = sb;
839 LINVFS_SET_VFS(sb, vfsp);
840 if (sb->s_flags & MS_RDONLY)
841 vfsp->vfs_flag |= VFS_RDONLY;
842 bhv_insert_all_vfsops(vfsp); 833 bhv_insert_all_vfsops(vfsp);
843 834
844 VFS_PARSEARGS(vfsp, (char *)data, args, 0, error); 835 VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
@@ -849,10 +840,10 @@ linvfs_fill_super(
849 840
850 sb_min_blocksize(sb, BBSIZE); 841 sb_min_blocksize(sb, BBSIZE);
851#ifdef CONFIG_XFS_EXPORT 842#ifdef CONFIG_XFS_EXPORT
852 sb->s_export_op = &linvfs_export_ops; 843 sb->s_export_op = &xfs_export_operations;
853#endif 844#endif
854 sb->s_qcop = &linvfs_qops; 845 sb->s_qcop = &xfs_quotactl_operations;
855 sb->s_op = &linvfs_sops; 846 sb->s_op = &xfs_super_operations;
856 847
857 VFS_MOUNT(vfsp, args, NULL, error); 848 VFS_MOUNT(vfsp, args, NULL, error);
858 if (error) { 849 if (error) {
@@ -876,7 +867,7 @@ linvfs_fill_super(
876 if (error) 867 if (error)
877 goto fail_unmount; 868 goto fail_unmount;
878 869
879 sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp)); 870 sb->s_root = d_alloc_root(vn_to_inode(rootvp));
880 if (!sb->s_root) { 871 if (!sb->s_root) {
881 error = ENOMEM; 872 error = ENOMEM;
882 goto fail_vnrele; 873 goto fail_vnrele;
@@ -885,7 +876,7 @@ linvfs_fill_super(
885 error = EINVAL; 876 error = EINVAL;
886 goto fail_vnrele; 877 goto fail_vnrele;
887 } 878 }
888 if ((error = linvfs_start_syncd(vfsp))) 879 if ((error = xfs_fs_start_syncd(vfsp)))
889 goto fail_vnrele; 880 goto fail_vnrele;
890 vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address); 881 vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
891 882
@@ -910,41 +901,41 @@ fail_vfsop:
910} 901}
911 902
912STATIC struct super_block * 903STATIC struct super_block *
913linvfs_get_sb( 904xfs_fs_get_sb(
914 struct file_system_type *fs_type, 905 struct file_system_type *fs_type,
915 int flags, 906 int flags,
916 const char *dev_name, 907 const char *dev_name,
917 void *data) 908 void *data)
918{ 909{
919 return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super); 910 return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
920} 911}
921 912
922STATIC struct super_operations linvfs_sops = { 913STATIC struct super_operations xfs_super_operations = {
923 .alloc_inode = linvfs_alloc_inode, 914 .alloc_inode = xfs_fs_alloc_inode,
924 .destroy_inode = linvfs_destroy_inode, 915 .destroy_inode = xfs_fs_destroy_inode,
925 .write_inode = linvfs_write_inode, 916 .write_inode = xfs_fs_write_inode,
926 .clear_inode = linvfs_clear_inode, 917 .clear_inode = xfs_fs_clear_inode,
927 .put_super = linvfs_put_super, 918 .put_super = xfs_fs_put_super,
928 .write_super = linvfs_write_super, 919 .write_super = xfs_fs_write_super,
929 .sync_fs = linvfs_sync_super, 920 .sync_fs = xfs_fs_sync_super,
930 .write_super_lockfs = linvfs_freeze_fs, 921 .write_super_lockfs = xfs_fs_lockfs,
931 .statfs = linvfs_statfs, 922 .statfs = xfs_fs_statfs,
932 .remount_fs = linvfs_remount, 923 .remount_fs = xfs_fs_remount,
933 .show_options = linvfs_show_options, 924 .show_options = xfs_fs_show_options,
934}; 925};
935 926
936STATIC struct quotactl_ops linvfs_qops = { 927STATIC struct quotactl_ops xfs_quotactl_operations = {
937 .quota_sync = linvfs_quotasync, 928 .quota_sync = xfs_fs_quotasync,
938 .get_xstate = linvfs_getxstate, 929 .get_xstate = xfs_fs_getxstate,
939 .set_xstate = linvfs_setxstate, 930 .set_xstate = xfs_fs_setxstate,
940 .get_xquota = linvfs_getxquota, 931 .get_xquota = xfs_fs_getxquota,
941 .set_xquota = linvfs_setxquota, 932 .set_xquota = xfs_fs_setxquota,
942}; 933};
943 934
944STATIC struct file_system_type xfs_fs_type = { 935STATIC struct file_system_type xfs_fs_type = {
945 .owner = THIS_MODULE, 936 .owner = THIS_MODULE,
946 .name = "xfs", 937 .name = "xfs",
947 .get_sb = linvfs_get_sb, 938 .get_sb = xfs_fs_get_sb,
948 .kill_sb = kill_block_super, 939 .kill_sb = kill_block_super,
949 .fs_flags = FS_REQUIRES_DEV, 940 .fs_flags = FS_REQUIRES_DEV,
950}; 941};
@@ -965,7 +956,7 @@ init_xfs_fs( void )
965 956
966 ktrace_init(64); 957 ktrace_init(64);
967 958
968 error = linvfs_init_zones(); 959 error = xfs_init_zones();
969 if (error < 0) 960 if (error < 0)
970 goto undo_zones; 961 goto undo_zones;
971 962
@@ -981,14 +972,13 @@ init_xfs_fs( void )
981 error = register_filesystem(&xfs_fs_type); 972 error = register_filesystem(&xfs_fs_type);
982 if (error) 973 if (error)
983 goto undo_register; 974 goto undo_register;
984 XFS_DM_INIT(&xfs_fs_type);
985 return 0; 975 return 0;
986 976
987undo_register: 977undo_register:
988 xfs_buf_terminate(); 978 xfs_buf_terminate();
989 979
990undo_buffers: 980undo_buffers:
991 linvfs_destroy_zones(); 981 xfs_destroy_zones();
992 982
993undo_zones: 983undo_zones:
994 return error; 984 return error;
@@ -998,11 +988,10 @@ STATIC void __exit
998exit_xfs_fs( void ) 988exit_xfs_fs( void )
999{ 989{
1000 vfs_exitquota(); 990 vfs_exitquota();
1001 XFS_DM_EXIT(&xfs_fs_type);
1002 unregister_filesystem(&xfs_fs_type); 991 unregister_filesystem(&xfs_fs_type);
1003 xfs_cleanup(); 992 xfs_cleanup();
1004 xfs_buf_terminate(); 993 xfs_buf_terminate();
1005 linvfs_destroy_zones(); 994 xfs_destroy_zones();
1006 ktrace_uninit(); 995 ktrace_uninit();
1007} 996}
1008 997
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index df59408dca06..376b96cb513a 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -98,11 +98,6 @@ extern void xfs_qm_exit(void);
98 XFS_DMAPI_STRING \ 98 XFS_DMAPI_STRING \
99 XFS_DBG_STRING /* DBG must be last */ 99 XFS_DBG_STRING /* DBG must be last */
100 100
101#define LINVFS_GET_VFS(s) \
102 (vfs_t *)((s)->s_fs_info)
103#define LINVFS_SET_VFS(s, vfsp) \
104 ((s)->s_fs_info = vfsp)
105
106struct xfs_inode; 101struct xfs_inode;
107struct xfs_mount; 102struct xfs_mount;
108struct xfs_buftarg; 103struct xfs_buftarg;
@@ -120,6 +115,6 @@ extern int xfs_blkdev_get(struct xfs_mount *, const char *,
120extern void xfs_blkdev_put(struct block_device *); 115extern void xfs_blkdev_put(struct block_device *);
121extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); 116extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
122 117
123extern struct export_operations linvfs_export_ops; 118extern struct export_operations xfs_export_operations;
124 119
125#endif /* __XFS_SUPER_H__ */ 120#endif /* __XFS_SUPER_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index a02564972420..7079cc837210 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -38,8 +38,7 @@ xfs_stats_clear_proc_handler(
38 38
39 if (!ret && write && *valp) { 39 if (!ret && write && *valp) {
40 printk("XFS Clearing xfsstats\n"); 40 printk("XFS Clearing xfsstats\n");
41 for (c = 0; c < NR_CPUS; c++) { 41 for_each_cpu(c) {
42 if (!cpu_possible(c)) continue;
43 preempt_disable(); 42 preempt_disable();
44 /* save vn_active, it's a universal truth! */ 43 /* save vn_active, it's a universal truth! */
45 vn_active = per_cpu(xfsstats, c).vn_active; 44 vn_active = per_cpu(xfsstats, c).vn_active;
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c
index c855d62e5344..6f7c9f7a8624 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.c
+++ b/fs/xfs/linux-2.6/xfs_vfs.c
@@ -227,7 +227,8 @@ vfs_freeze(
227} 227}
228 228
229vfs_t * 229vfs_t *
230vfs_allocate( void ) 230vfs_allocate(
231 struct super_block *sb)
231{ 232{
232 struct vfs *vfsp; 233 struct vfs *vfsp;
233 234
@@ -236,9 +237,23 @@ vfs_allocate( void )
236 INIT_LIST_HEAD(&vfsp->vfs_sync_list); 237 INIT_LIST_HEAD(&vfsp->vfs_sync_list);
237 spin_lock_init(&vfsp->vfs_sync_lock); 238 spin_lock_init(&vfsp->vfs_sync_lock);
238 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); 239 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
240
241 vfsp->vfs_super = sb;
242 sb->s_fs_info = vfsp;
243
244 if (sb->s_flags & MS_RDONLY)
245 vfsp->vfs_flag |= VFS_RDONLY;
246
239 return vfsp; 247 return vfsp;
240} 248}
241 249
250vfs_t *
251vfs_from_sb(
252 struct super_block *sb)
253{
254 return (vfs_t *)sb->s_fs_info;
255}
256
242void 257void
243vfs_deallocate( 258vfs_deallocate(
244 struct vfs *vfsp) 259 struct vfs *vfsp)
@@ -295,7 +310,7 @@ bhv_remove_all_vfsops(
295 bhv_remove_vfsops(vfsp, VFS_POSITION_DM); 310 bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
296 if (!freebase) 311 if (!freebase)
297 return; 312 return;
298 mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops)); 313 mp = XFS_VFSTOM(vfsp);
299 VFS_REMOVEBHV(vfsp, &mp->m_bhv); 314 VFS_REMOVEBHV(vfsp, &mp->m_bhv);
300 xfs_mount_free(mp, 0); 315 xfs_mount_free(mp, 0);
301} 316}
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 57caf9eddee0..8fed356db055 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -193,7 +193,8 @@ typedef struct bhv_vfsops {
193#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o)) 193#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o))
194#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL ) 194#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL )
195 195
196extern vfs_t *vfs_allocate(void); 196extern vfs_t *vfs_allocate(struct super_block *);
197extern vfs_t *vfs_from_sb(struct super_block *);
197extern void vfs_deallocate(vfs_t *); 198extern void vfs_deallocate(vfs_t *);
198extern void vfs_insertops(vfs_t *, bhv_vfsops_t *); 199extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
199extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *); 200extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 260dd8415dd7..d27c25b27ccd 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -58,7 +58,7 @@ struct vnode *
58vn_initialize( 58vn_initialize(
59 struct inode *inode) 59 struct inode *inode)
60{ 60{
61 struct vnode *vp = LINVFS_GET_VP(inode); 61 struct vnode *vp = vn_from_inode(inode);
62 62
63 XFS_STATS_INC(vn_active); 63 XFS_STATS_INC(vn_active);
64 XFS_STATS_INC(vn_alloc); 64 XFS_STATS_INC(vn_alloc);
@@ -83,7 +83,7 @@ vn_initialize(
83 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); 83 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
84#endif /* XFS_VNODE_TRACE */ 84#endif /* XFS_VNODE_TRACE */
85 85
86 vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address); 86 vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address);
87 return vp; 87 return vp;
88} 88}
89 89
@@ -97,7 +97,7 @@ vn_revalidate_core(
97 struct vnode *vp, 97 struct vnode *vp,
98 vattr_t *vap) 98 vattr_t *vap)
99{ 99{
100 struct inode *inode = LINVFS_GET_IP(vp); 100 struct inode *inode = vn_to_inode(vp);
101 101
102 inode->i_mode = vap->va_mode; 102 inode->i_mode = vap->va_mode;
103 inode->i_nlink = vap->va_nlink; 103 inode->i_nlink = vap->va_nlink;
@@ -129,24 +129,31 @@ vn_revalidate_core(
129 * Revalidate the Linux inode from the vnode. 129 * Revalidate the Linux inode from the vnode.
130 */ 130 */
131int 131int
132vn_revalidate( 132__vn_revalidate(
133 struct vnode *vp) 133 struct vnode *vp,
134 struct vattr *vattr)
134{ 135{
135 vattr_t va;
136 int error; 136 int error;
137 137
138 vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address); 138 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
139 ASSERT(vp->v_fbhv != NULL); 139 vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
140 140 VOP_GETATTR(vp, vattr, 0, NULL, error);
141 va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS; 141 if (likely(!error)) {
142 VOP_GETATTR(vp, &va, 0, NULL, error); 142 vn_revalidate_core(vp, vattr);
143 if (!error) {
144 vn_revalidate_core(vp, &va);
145 VUNMODIFY(vp); 143 VUNMODIFY(vp);
146 } 144 }
147 return -error; 145 return -error;
148} 146}
149 147
148int
149vn_revalidate(
150 struct vnode *vp)
151{
152 vattr_t vattr;
153
154 return __vn_revalidate(vp, &vattr);
155}
156
150/* 157/*
151 * Add a reference to a referenced vnode. 158 * Add a reference to a referenced vnode.
152 */ 159 */
@@ -159,7 +166,7 @@ vn_hold(
159 XFS_STATS_INC(vn_hold); 166 XFS_STATS_INC(vn_hold);
160 167
161 VN_LOCK(vp); 168 VN_LOCK(vp);
162 inode = igrab(LINVFS_GET_IP(vp)); 169 inode = igrab(vn_to_inode(vp));
163 ASSERT(inode); 170 ASSERT(inode);
164 VN_UNLOCK(vp, 0); 171 VN_UNLOCK(vp, 0);
165 172
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 0fe2419461d6..06f5845e9568 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -116,8 +116,14 @@ typedef enum {
116/* 116/*
117 * Vnode to Linux inode mapping. 117 * Vnode to Linux inode mapping.
118 */ 118 */
119#define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode)) 119static inline struct vnode *vn_from_inode(struct inode *inode)
120#define LINVFS_GET_IP(vp) (&(vp)->v_inode) 120{
121 return (vnode_t *)list_entry(inode, vnode_t, v_inode);
122}
123static inline struct inode *vn_to_inode(struct vnode *vnode)
124{
125 return &vnode->v_inode;
126}
121 127
122/* 128/*
123 * Vnode flags. 129 * Vnode flags.
@@ -490,6 +496,7 @@ typedef struct vnode_map {
490 (vmap).v_ino = (vp)->v_inode.i_ino; } 496 (vmap).v_ino = (vp)->v_inode.i_ino; }
491 497
492extern int vn_revalidate(struct vnode *); 498extern int vn_revalidate(struct vnode *);
499extern int __vn_revalidate(struct vnode *, vattr_t *);
493extern void vn_revalidate_core(struct vnode *, vattr_t *); 500extern void vn_revalidate_core(struct vnode *, vattr_t *);
494 501
495extern void vn_iowait(struct vnode *vp); 502extern void vn_iowait(struct vnode *vp);
@@ -497,7 +504,7 @@ extern void vn_iowake(struct vnode *vp);
497 504
498static inline int vn_count(struct vnode *vp) 505static inline int vn_count(struct vnode *vp)
499{ 506{
500 return atomic_read(&LINVFS_GET_IP(vp)->i_count); 507 return atomic_read(&vn_to_inode(vp)->i_count);
501} 508}
502 509
503/* 510/*
@@ -511,16 +518,16 @@ extern vnode_t *vn_hold(struct vnode *);
511 vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) 518 vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
512#define VN_RELE(vp) \ 519#define VN_RELE(vp) \
513 (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ 520 (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
514 iput(LINVFS_GET_IP(vp))) 521 iput(vn_to_inode(vp)))
515#else 522#else
516#define VN_HOLD(vp) ((void)vn_hold(vp)) 523#define VN_HOLD(vp) ((void)vn_hold(vp))
517#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp))) 524#define VN_RELE(vp) (iput(vn_to_inode(vp)))
518#endif 525#endif
519 526
520static inline struct vnode *vn_grab(struct vnode *vp) 527static inline struct vnode *vn_grab(struct vnode *vp)
521{ 528{
522 struct inode *inode = igrab(LINVFS_GET_IP(vp)); 529 struct inode *inode = igrab(vn_to_inode(vp));
523 return inode ? LINVFS_GET_VP(inode) : NULL; 530 return inode ? vn_from_inode(inode) : NULL;
524} 531}
525 532
526/* 533/*
@@ -528,7 +535,7 @@ static inline struct vnode *vn_grab(struct vnode *vp)
528 */ 535 */
529#define VNAME(dentry) ((char *) (dentry)->d_name.name) 536#define VNAME(dentry) ((char *) (dentry)->d_name.name)
530#define VNAMELEN(dentry) ((dentry)->d_name.len) 537#define VNAMELEN(dentry) ((dentry)->d_name.len)
531#define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode)) 538#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
532 539
533/* 540/*
534 * Vnode spinlock manipulation. 541 * Vnode spinlock manipulation.
@@ -557,12 +564,12 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
557 */ 564 */
558static inline void vn_mark_bad(struct vnode *vp) 565static inline void vn_mark_bad(struct vnode *vp)
559{ 566{
560 make_bad_inode(LINVFS_GET_IP(vp)); 567 make_bad_inode(vn_to_inode(vp));
561} 568}
562 569
563static inline int VN_BAD(struct vnode *vp) 570static inline int VN_BAD(struct vnode *vp)
564{ 571{
565 return is_bad_inode(LINVFS_GET_IP(vp)); 572 return is_bad_inode(vn_to_inode(vp));
566} 573}
567 574
568/* 575/*
@@ -587,9 +594,9 @@ static inline void vn_atime_to_time_t(struct vnode *vp, time_t *tt)
587/* 594/*
588 * Some useful predicates. 595 * Some useful predicates.
589 */ 596 */
590#define VN_MAPPED(vp) mapping_mapped(LINVFS_GET_IP(vp)->i_mapping) 597#define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping)
591#define VN_CACHED(vp) (LINVFS_GET_IP(vp)->i_mapping->nrpages) 598#define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages)
592#define VN_DIRTY(vp) mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \ 599#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
593 PAGECACHE_TAG_DIRTY) 600 PAGECACHE_TAG_DIRTY)
594#define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED) 601#define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED)
595#define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED) 602#define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED)