aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-03-31 15:34:58 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-03-31 15:34:58 -0500
commit86579dd06deecfa6ac88d5e84e4d63c397cd6f6d (patch)
treeb4475d3ccde53015ad84a06e4e55e64591171b75 /fs/xfs/linux-2.6
parent7ea9ea832212c4a755650f7c7cc1ff0b63292a41 (diff)
parenta0f067802576d4eb4c65d40b8ee7d6ea3c81dd61 (diff)
Merge branch 'master'
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/mrlock.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c540
-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_export.h2
-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.c26
-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.c53
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c9
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c214
-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.h5
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c35
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h33
24 files changed, 911 insertions, 851 deletions
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index c64a29cdfff3..2cfd33d4d8aa 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 SLAB_MEM_SPREAD
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/mrlock.h b/fs/xfs/linux-2.6/mrlock.h
index 16b44c3c2362..1b262b790d9c 100644
--- a/fs/xfs/linux-2.6/mrlock.h
+++ b/fs/xfs/linux-2.6/mrlock.h
@@ -79,7 +79,7 @@ static inline void mrdemote(mrlock_t *mrp)
79 * Debug-only routine, without some platform-specific asm code, we can 79 * Debug-only routine, without some platform-specific asm code, we can
80 * now only answer requests regarding whether we hold the lock for write 80 * now only answer requests regarding whether we hold the lock for write
81 * (reader state is outside our visibility, we only track writer state). 81 * (reader state is outside our visibility, we only track writer state).
82 * Note: means !ismrlocked would give false positivies, so don't do that. 82 * Note: means !ismrlocked would give false positives, so don't do that.
83 */ 83 */
84static inline int ismrlocked(mrlock_t *mrp, int type) 84static inline int ismrlocked(mrlock_t *mrp, int type)
85{ 85{
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 74d8be87f983..6cbbd165c60d 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);
@@ -350,7 +372,7 @@ static inline int bio_add_buffer(struct bio *bio, struct buffer_head *bh)
350 * assumes that all buffers on the page are started at the same time. 372 * assumes that all buffers on the page are started at the same time.
351 * 373 *
352 * The fix is two passes across the ioend list - one to start writeback on the 374 * The fix is two passes across the ioend list - one to start writeback on the
353 * bufferheads, and then the second one submit them for I/O. 375 * buffer_heads, and then submit them for I/O on the second pass.
354 */ 376 */
355STATIC void 377STATIC void
356xfs_submit_ioend( 378xfs_submit_ioend(
@@ -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;
@@ -668,7 +699,7 @@ xfs_convert_page(
668 699
669 /* 700 /*
670 * page_dirty is initially a count of buffers on the page before 701 * page_dirty is initially a count of buffers on the page before
671 * EOF and is decrememted as we move each into a cleanable state. 702 * EOF and is decremented as we move each into a cleanable state.
672 * 703 *
673 * Derivation: 704 * Derivation:
674 * 705 *
@@ -811,7 +842,7 @@ xfs_cluster_write(
811 * page if possible. 842 * page if possible.
812 * The bh->b_state's cannot know if any of the blocks or which block for 843 * The bh->b_state's cannot know if any of the blocks or which block for
813 * that matter are dirty due to mmap writes, and therefore bh uptodate is 844 * that matter are dirty due to mmap writes, and therefore bh uptodate is
814 * only vaild if the page itself isn't completely uptodate. Some layers 845 * only valid if the page itself isn't completely uptodate. Some layers
815 * may clear the page dirty flag prior to calling write page, under the 846 * may clear the page dirty flag prior to calling write page, under the
816 * assumption the entire page will be written out; by not writing out the 847 * assumption the entire page will be written out; by not writing out the
817 * whole page the page can be reused before all valid dirty data is 848 * whole page the page can be reused before all valid dirty data is
@@ -861,7 +892,7 @@ xfs_page_state_convert(
861 892
862 /* 893 /*
863 * page_dirty is initially a count of buffers on the page before 894 * page_dirty is initially a count of buffers on the page before
864 * EOF and is decrememted as we move each into a cleanable state. 895 * EOF and is decremented as we move each into a cleanable state.
865 * 896 *
866 * Derivation: 897 * Derivation:
867 * 898 *
@@ -1040,54 +1071,191 @@ 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
1043STATIC int 1094STATIC int
1044__linvfs_get_block( 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 */
1180STATIC int
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_blocks(
1045 struct inode *inode, 1227 struct inode *inode,
1046 sector_t iblock, 1228 sector_t iblock,
1047 unsigned long blocks,
1048 struct buffer_head *bh_result, 1229 struct buffer_head *bh_result,
1049 int create, 1230 int create,
1050 int direct, 1231 int direct,
1051 bmapi_flags_t flags) 1232 bmapi_flags_t flags)
1052{ 1233{
1053 vnode_t *vp = LINVFS_GET_VP(inode); 1234 vnode_t *vp = vn_from_inode(inode);
1054 xfs_iomap_t iomap; 1235 xfs_iomap_t iomap;
1055 xfs_off_t offset; 1236 xfs_off_t offset;
1056 ssize_t size; 1237 ssize_t size;
1057 int retpbbm = 1; 1238 int niomap = 1;
1058 int error; 1239 int error;
1059 1240
1060 offset = (xfs_off_t)iblock << inode->i_blkbits; 1241 offset = (xfs_off_t)iblock << inode->i_blkbits;
1061 if (blocks) 1242 ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
1062 size = (ssize_t) min_t(xfs_off_t, LONG_MAX, 1243 size = bh_result->b_size;
1063 (xfs_off_t)blocks << inode->i_blkbits);
1064 else
1065 size = 1 << inode->i_blkbits;
1066
1067 VOP_BMAP(vp, offset, size, 1244 VOP_BMAP(vp, offset, size,
1068 create ? flags : BMAPI_READ, &iomap, &retpbbm, error); 1245 create ? flags : BMAPI_READ, &iomap, &niomap, error);
1069 if (error) 1246 if (error)
1070 return -error; 1247 return -error;
1071 1248 if (niomap == 0)
1072 if (retpbbm == 0)
1073 return 0; 1249 return 0;
1074 1250
1075 if (iomap.iomap_bn != IOMAP_DADDR_NULL) { 1251 if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
1076 xfs_daddr_t bn; 1252 /*
1077 xfs_off_t delta; 1253 * 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). 1254 * the read case (treat as if we're reading into a hole).
1081 */ 1255 */
1082 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1256 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1083 delta = offset - iomap.iomap_offset; 1257 xfs_map_buffer(bh_result, &iomap, offset,
1084 delta >>= inode->i_blkbits; 1258 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 } 1259 }
1092 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1260 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1093 if (direct) 1261 if (direct)
@@ -1097,12 +1265,16 @@ __linvfs_get_block(
1097 } 1265 }
1098 } 1266 }
1099 1267
1100 /* If this is a realtime file, data might be on a new device */ 1268 /*
1269 * If this is a realtime file, data may be on a different device.
1270 * to that pointed to from the buffer_head b_bdev currently.
1271 */
1101 bh_result->b_bdev = iomap.iomap_target->bt_bdev; 1272 bh_result->b_bdev = iomap.iomap_target->bt_bdev;
1102 1273
1103 /* If we previously allocated a block out beyond eof and 1274 /*
1104 * we are now coming back to use it then we will need to 1275 * If we previously allocated a block out beyond eof and we are
1105 * flag it as new even if it has a disk address. 1276 * now coming back to use it then we will need to flag it as new
1277 * even if it has a disk address.
1106 */ 1278 */
1107 if (create && 1279 if (create &&
1108 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || 1280 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
@@ -1118,42 +1290,40 @@ __linvfs_get_block(
1118 } 1290 }
1119 } 1291 }
1120 1292
1121 if (blocks) { 1293 if (direct || size > (1 << inode->i_blkbits)) {
1122 ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0); 1294 ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0);
1123 offset = min_t(xfs_off_t, 1295 offset = min_t(xfs_off_t,
1124 iomap.iomap_bsize - iomap.iomap_delta, 1296 iomap.iomap_bsize - iomap.iomap_delta, size);
1125 (xfs_off_t)blocks << inode->i_blkbits); 1297 bh_result->b_size = (ssize_t)min_t(xfs_off_t, LONG_MAX, offset);
1126 bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset);
1127 } 1298 }
1128 1299
1129 return 0; 1300 return 0;
1130} 1301}
1131 1302
1132int 1303int
1133linvfs_get_block( 1304xfs_get_blocks(
1134 struct inode *inode, 1305 struct inode *inode,
1135 sector_t iblock, 1306 sector_t iblock,
1136 struct buffer_head *bh_result, 1307 struct buffer_head *bh_result,
1137 int create) 1308 int create)
1138{ 1309{
1139 return __linvfs_get_block(inode, iblock, 0, bh_result, 1310 return __xfs_get_blocks(inode, iblock,
1140 create, 0, BMAPI_WRITE); 1311 bh_result, create, 0, BMAPI_WRITE);
1141} 1312}
1142 1313
1143STATIC int 1314STATIC int
1144linvfs_get_blocks_direct( 1315xfs_get_blocks_direct(
1145 struct inode *inode, 1316 struct inode *inode,
1146 sector_t iblock, 1317 sector_t iblock,
1147 unsigned long max_blocks,
1148 struct buffer_head *bh_result, 1318 struct buffer_head *bh_result,
1149 int create) 1319 int create)
1150{ 1320{
1151 return __linvfs_get_block(inode, iblock, max_blocks, bh_result, 1321 return __xfs_get_blocks(inode, iblock,
1152 create, 1, BMAPI_WRITE|BMAPI_DIRECT); 1322 bh_result, create, 1, BMAPI_WRITE|BMAPI_DIRECT);
1153} 1323}
1154 1324
1155STATIC void 1325STATIC void
1156linvfs_end_io_direct( 1326xfs_end_io_direct(
1157 struct kiocb *iocb, 1327 struct kiocb *iocb,
1158 loff_t offset, 1328 loff_t offset,
1159 ssize_t size, 1329 ssize_t size,
@@ -1164,9 +1334,9 @@ linvfs_end_io_direct(
1164 /* 1334 /*
1165 * Non-NULL private data means we need to issue a transaction to 1335 * Non-NULL private data means we need to issue a transaction to
1166 * convert a range from unwritten to written extents. This needs 1336 * convert a range from unwritten to written extents. This needs
1167 * to happen from process contect but aio+dio I/O completion 1337 * to happen from process context but aio+dio I/O completion
1168 * happens from irq context so we need to defer it to a workqueue. 1338 * happens from irq context so we need to defer it to a workqueue.
1169 * This is not nessecary for synchronous direct I/O, but we do 1339 * This is not necessary for synchronous direct I/O, but we do
1170 * it anyway to keep the code uniform and simpler. 1340 * it anyway to keep the code uniform and simpler.
1171 * 1341 *
1172 * The core direct I/O code might be changed to always call the 1342 * The core direct I/O code might be changed to always call the
@@ -1183,7 +1353,7 @@ linvfs_end_io_direct(
1183 } 1353 }
1184 1354
1185 /* 1355 /*
1186 * blockdev_direct_IO can return an error even afer the I/O 1356 * blockdev_direct_IO can return an error even after the I/O
1187 * completion handler was called. Thus we need to protect 1357 * completion handler was called. Thus we need to protect
1188 * against double-freeing. 1358 * against double-freeing.
1189 */ 1359 */
@@ -1191,7 +1361,7 @@ linvfs_end_io_direct(
1191} 1361}
1192 1362
1193STATIC ssize_t 1363STATIC ssize_t
1194linvfs_direct_IO( 1364xfs_vm_direct_IO(
1195 int rw, 1365 int rw,
1196 struct kiocb *iocb, 1366 struct kiocb *iocb,
1197 const struct iovec *iov, 1367 const struct iovec *iov,
@@ -1200,7 +1370,7 @@ linvfs_direct_IO(
1200{ 1370{
1201 struct file *file = iocb->ki_filp; 1371 struct file *file = iocb->ki_filp;
1202 struct inode *inode = file->f_mapping->host; 1372 struct inode *inode = file->f_mapping->host;
1203 vnode_t *vp = LINVFS_GET_VP(inode); 1373 vnode_t *vp = vn_from_inode(inode);
1204 xfs_iomap_t iomap; 1374 xfs_iomap_t iomap;
1205 int maps = 1; 1375 int maps = 1;
1206 int error; 1376 int error;
@@ -1215,253 +1385,79 @@ linvfs_direct_IO(
1215 ret = blockdev_direct_IO_own_locking(rw, iocb, inode, 1385 ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
1216 iomap.iomap_target->bt_bdev, 1386 iomap.iomap_target->bt_bdev,
1217 iov, offset, nr_segs, 1387 iov, offset, nr_segs,
1218 linvfs_get_blocks_direct, 1388 xfs_get_blocks_direct,
1219 linvfs_end_io_direct); 1389 xfs_end_io_direct);
1220 1390
1221 if (unlikely(ret <= 0 && iocb->private)) 1391 if (unlikely(ret <= 0 && iocb->private))
1222 xfs_destroy_ioend(iocb->private); 1392 xfs_destroy_ioend(iocb->private);
1223 return ret; 1393 return ret;
1224} 1394}
1225 1395
1396STATIC int
1397xfs_vm_prepare_write(
1398 struct file *file,
1399 struct page *page,
1400 unsigned int from,
1401 unsigned int to)
1402{
1403 return block_prepare_write(page, from, to, xfs_get_blocks);
1404}
1226 1405
1227STATIC sector_t 1406STATIC sector_t
1228linvfs_bmap( 1407xfs_vm_bmap(
1229 struct address_space *mapping, 1408 struct address_space *mapping,
1230 sector_t block) 1409 sector_t block)
1231{ 1410{
1232 struct inode *inode = (struct inode *)mapping->host; 1411 struct inode *inode = (struct inode *)mapping->host;
1233 vnode_t *vp = LINVFS_GET_VP(inode); 1412 vnode_t *vp = vn_from_inode(inode);
1234 int error; 1413 int error;
1235 1414
1236 vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address); 1415 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
1237 1416
1238 VOP_RWLOCK(vp, VRWLOCK_READ); 1417 VOP_RWLOCK(vp, VRWLOCK_READ);
1239 VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error); 1418 VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
1240 VOP_RWUNLOCK(vp, VRWLOCK_READ); 1419 VOP_RWUNLOCK(vp, VRWLOCK_READ);
1241 return generic_block_bmap(mapping, block, linvfs_get_block); 1420 return generic_block_bmap(mapping, block, xfs_get_blocks);
1242} 1421}
1243 1422
1244STATIC int 1423STATIC int
1245linvfs_readpage( 1424xfs_vm_readpage(
1246 struct file *unused, 1425 struct file *unused,
1247 struct page *page) 1426 struct page *page)
1248{ 1427{
1249 return mpage_readpage(page, linvfs_get_block); 1428 return mpage_readpage(page, xfs_get_blocks);
1250} 1429}
1251 1430
1252STATIC int 1431STATIC int
1253linvfs_readpages( 1432xfs_vm_readpages(
1254 struct file *unused, 1433 struct file *unused,
1255 struct address_space *mapping, 1434 struct address_space *mapping,
1256 struct list_head *pages, 1435 struct list_head *pages,
1257 unsigned nr_pages) 1436 unsigned nr_pages)
1258{ 1437{
1259 return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block); 1438 return mpage_readpages(mapping, pages, nr_pages, xfs_get_blocks);
1260} 1439}
1261 1440
1262STATIC void 1441STATIC void
1263xfs_count_page_state( 1442xfs_vm_invalidatepage(
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}
1285
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
1308linvfs_writepage(
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, 1443 struct page *page,
1377 unsigned long offset) 1444 unsigned long offset)
1378{ 1445{
1379 xfs_page_trace(XFS_INVALIDPAGE_ENTER, 1446 xfs_page_trace(XFS_INVALIDPAGE_ENTER,
1380 page->mapping->host, page, offset); 1447 page->mapping->host, page, offset);
1381 return block_invalidatepage(page, offset); 1448 block_invalidatepage(page, offset);
1382}
1383
1384/*
1385 * Called to move a page into cleanable state - and from there
1386 * to be released. Possibly the page is already clean. We always
1387 * have buffer heads in this call.
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} 1449}
1454 1450
1455struct address_space_operations linvfs_aops = { 1451struct address_space_operations xfs_address_space_operations = {
1456 .readpage = linvfs_readpage, 1452 .readpage = xfs_vm_readpage,
1457 .readpages = linvfs_readpages, 1453 .readpages = xfs_vm_readpages,
1458 .writepage = linvfs_writepage, 1454 .writepage = xfs_vm_writepage,
1459 .sync_page = block_sync_page, 1455 .sync_page = block_sync_page,
1460 .releasepage = linvfs_release_page, 1456 .releasepage = xfs_vm_releasepage,
1461 .invalidatepage = linvfs_invalidate_page, 1457 .invalidatepage = xfs_vm_invalidatepage,
1462 .prepare_write = linvfs_prepare_write, 1458 .prepare_write = xfs_vm_prepare_write,
1463 .commit_write = generic_commit_write, 1459 .commit_write = generic_commit_write,
1464 .bmap = linvfs_bmap, 1460 .bmap = xfs_vm_bmap,
1465 .direct_IO = linvfs_direct_IO, 1461 .direct_IO = xfs_vm_direct_IO,
1466 .migratepage = buffer_migrate_page, 1462 .migratepage = buffer_migrate_page,
1467}; 1463};
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 55339dd5a30d..60716543c68b 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_blocks(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_export.h b/fs/xfs/linux-2.6/xfs_export.h
index e5b0559700a4..e794ca4efc76 100644
--- a/fs/xfs/linux-2.6/xfs_export.h
+++ b/fs/xfs/linux-2.6/xfs_export.h
@@ -54,7 +54,7 @@
54 * Note, the NFS filehandle also includes an fsid portion which 54 * Note, the NFS filehandle also includes an fsid portion which
55 * may have an inode number in it. That number is hardcoded to 55 * may have an inode number in it. That number is hardcoded to
56 * 32bits and there is no way for XFS to intercept it. In 56 * 32bits and there is no way for XFS to intercept it. In
57 * practice this means when exporting an XFS filesytem with 64bit 57 * practice this means when exporting an XFS filesystem with 64bit
58 * inodes you should either export the mountpoint (rather than 58 * inodes you should either export the mountpoint (rather than
59 * a subdirectory) or use the "fsid" export option. 59 * a subdirectory) or use the "fsid" export option.
60 */ 60 */
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index ced4404339c7..85997b1205f5 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 = { 531const struct 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 = { 553const struct 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 = { 573const struct 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..251bfe451a3f 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -72,7 +72,7 @@ xfs_ioctl32_flock(
72 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) || 72 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
73 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32))) 73 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
74 return -EFAULT; 74 return -EFAULT;
75 75
76 return (unsigned long)p; 76 return (unsigned long)p;
77} 77}
78 78
@@ -107,11 +107,15 @@ 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(
111 int mode,
112 struct file *file,
113 unsigned cmd,
114 unsigned long arg)
111{ 115{
116 struct inode *inode = file->f_dentry->d_inode;
117 vnode_t *vp = vn_from_inode(inode);
112 int error; 118 int error;
113 struct inode *inode = f->f_dentry->d_inode;
114 vnode_t *vp = LINVFS_GET_VP(inode);
115 119
116 switch (cmd) { 120 switch (cmd) {
117 case XFS_IOC_DIOINFO: 121 case XFS_IOC_DIOINFO:
@@ -189,26 +193,26 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
189 return -ENOIOCTLCMD; 193 return -ENOIOCTLCMD;
190 } 194 }
191 195
192 VOP_IOCTL(vp, inode, f, mode, cmd, (void __user *)arg, error); 196 VOP_IOCTL(vp, inode, file, mode, cmd, (void __user *)arg, error);
193 VMODIFY(vp); 197 VMODIFY(vp);
194 198
195 return error; 199 return error;
196} 200}
197 201
198long 202long
199linvfs_compat_ioctl( 203xfs_file_compat_ioctl(
200 struct file *f, 204 struct file *file,
201 unsigned cmd, 205 unsigned cmd,
202 unsigned long arg) 206 unsigned long arg)
203{ 207{
204 return __linvfs_compat_ioctl(0, f, cmd, arg); 208 return xfs_compat_ioctl(0, file, cmd, arg);
205} 209}
206 210
207long 211long
208linvfs_compat_invis_ioctl( 212xfs_file_compat_invis_ioctl(
209 struct file *f, 213 struct file *file,
210 unsigned cmd, 214 unsigned cmd,
211 unsigned long arg) 215 unsigned long arg)
212{ 216{
213 return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg); 217 return xfs_compat_ioctl(IO_INVIS, file, cmd, arg);
214} 218}
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..149237304fb6 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_blocks);
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..ad6173da5678 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 const struct file_operations xfs_file_operations;
26extern struct file_operations linvfs_invis_file_operations; 26extern const struct file_operations xfs_dir_file_operations;
27extern struct file_operations linvfs_dir_operations; 27extern const 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..84ddf1893894 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,13 +675,13 @@ 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;
679 682
680 /* 683 /*
681 * The iolock was dropped and reaquired in XFS_SEND_DATA 684 * The iolock was dropped and reacquired in XFS_SEND_DATA
682 * so we have to recheck the size when appending. 685 * so we have to recheck the size when appending.
683 * We will only "goto start;" once, since having sent the 686 * We will only "goto start;" once, since having sent the
684 * event prevents another call to XFS_SEND_DATA, which is 687 * event prevents another call to XFS_SEND_DATA, which is
@@ -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..1f0589a05eca 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -56,24 +56,21 @@ xfs_read_xfsstats(
56 }; 56 };
57 57
58 /* Loop over all stats groups */ 58 /* Loop over all stats groups */
59 for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) { 59 for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
60 len += sprintf(buffer + len, xstats[i].desc); 60 len += sprintf(buffer + len, xstats[i].desc);
61 /* inner loop does each group */ 61 /* inner loop does each group */
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..1884300417e3 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
@@ -378,15 +375,12 @@ linvfs_init_zones(void)
378 if (!xfs_ioend_zone) 375 if (!xfs_ioend_zone)
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_slab_pool(4 * MAX_BUF_PER_PAGE,
382 mempool_alloc_slab, mempool_free_slab, 379 xfs_ioend_zone);
383 xfs_ioend_zone);
384 if (!xfs_ioend_pool) 380 if (!xfs_ioend_pool)
385 goto out_free_ioend_zone; 381 goto out_free_ioend_zone;
386
387 return 0; 382 return 0;
388 383
389
390 out_free_ioend_zone: 384 out_free_ioend_zone:
391 kmem_zone_destroy(xfs_ioend_zone); 385 kmem_zone_destroy(xfs_ioend_zone);
392 out_destroy_vnode_zone: 386 out_destroy_vnode_zone:
@@ -396,7 +390,7 @@ linvfs_init_zones(void)
396} 390}
397 391
398STATIC void 392STATIC void
399linvfs_destroy_zones(void) 393xfs_destroy_zones(void)
400{ 394{
401 mempool_destroy(xfs_ioend_pool); 395 mempool_destroy(xfs_ioend_pool);
402 kmem_zone_destroy(xfs_vnode_zone); 396 kmem_zone_destroy(xfs_vnode_zone);
@@ -407,14 +401,14 @@ linvfs_destroy_zones(void)
407 * Attempt to flush the inode, this will actually fail 401 * Attempt to flush the inode, this will actually fail
408 * if the inode is pinned, but we dirty the inode again 402 * if the inode is pinned, but we dirty the inode again
409 * at the point when it is unpinned after a log write, 403 * at the point when it is unpinned after a log write,
410 * since this is when the inode itself becomes flushable. 404 * since this is when the inode itself becomes flushable.
411 */ 405 */
412STATIC int 406STATIC int
413linvfs_write_inode( 407xfs_fs_write_inode(
414 struct inode *inode, 408 struct inode *inode,
415 int sync) 409 int sync)
416{ 410{
417 vnode_t *vp = LINVFS_GET_VP(inode); 411 vnode_t *vp = vn_from_inode(inode);
418 int error = 0, flags = FLUSH_INODE; 412 int error = 0, flags = FLUSH_INODE;
419 413
420 if (vp) { 414 if (vp) {
@@ -434,13 +428,13 @@ linvfs_write_inode(
434} 428}
435 429
436STATIC void 430STATIC void
437linvfs_clear_inode( 431xfs_fs_clear_inode(
438 struct inode *inode) 432 struct inode *inode)
439{ 433{
440 vnode_t *vp = LINVFS_GET_VP(inode); 434 vnode_t *vp = vn_from_inode(inode);
441 int error, cache; 435 int error, cache;
442 436
443 vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address); 437 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
444 438
445 XFS_STATS_INC(vn_rele); 439 XFS_STATS_INC(vn_rele);
446 XFS_STATS_INC(vn_remove); 440 XFS_STATS_INC(vn_remove);
@@ -516,7 +510,7 @@ void
516xfs_flush_inode( 510xfs_flush_inode(
517 xfs_inode_t *ip) 511 xfs_inode_t *ip)
518{ 512{
519 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); 513 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
520 struct vfs *vfs = XFS_MTOVFS(ip->i_mount); 514 struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
521 515
522 igrab(inode); 516 igrab(inode);
@@ -541,7 +535,7 @@ void
541xfs_flush_device( 535xfs_flush_device(
542 xfs_inode_t *ip) 536 xfs_inode_t *ip)
543{ 537{
544 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); 538 struct inode *inode = vn_to_inode(XFS_ITOV(ip));
545 struct vfs *vfs = XFS_MTOVFS(ip->i_mount); 539 struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
546 540
547 igrab(inode); 541 igrab(inode);
@@ -550,7 +544,7 @@ xfs_flush_device(
550 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); 544 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
551} 545}
552 546
553#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR) 547#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR|SYNC_REFCACHE)
554STATIC void 548STATIC void
555vfs_sync_worker( 549vfs_sync_worker(
556 vfs_t *vfsp, 550 vfs_t *vfsp,
@@ -613,7 +607,7 @@ xfssyncd(
613} 607}
614 608
615STATIC int 609STATIC int
616linvfs_start_syncd( 610xfs_fs_start_syncd(
617 vfs_t *vfsp) 611 vfs_t *vfsp)
618{ 612{
619 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker; 613 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
@@ -625,20 +619,20 @@ linvfs_start_syncd(
625} 619}
626 620
627STATIC void 621STATIC void
628linvfs_stop_syncd( 622xfs_fs_stop_syncd(
629 vfs_t *vfsp) 623 vfs_t *vfsp)
630{ 624{
631 kthread_stop(vfsp->vfs_sync_task); 625 kthread_stop(vfsp->vfs_sync_task);
632} 626}
633 627
634STATIC void 628STATIC void
635linvfs_put_super( 629xfs_fs_put_super(
636 struct super_block *sb) 630 struct super_block *sb)
637{ 631{
638 vfs_t *vfsp = LINVFS_GET_VFS(sb); 632 vfs_t *vfsp = vfs_from_sb(sb);
639 int error; 633 int error;
640 634
641 linvfs_stop_syncd(vfsp); 635 xfs_fs_stop_syncd(vfsp);
642 VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error); 636 VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
643 if (!error) 637 if (!error)
644 VFS_UNMOUNT(vfsp, 0, NULL, error); 638 VFS_UNMOUNT(vfsp, 0, NULL, error);
@@ -652,10 +646,10 @@ linvfs_put_super(
652} 646}
653 647
654STATIC void 648STATIC void
655linvfs_write_super( 649xfs_fs_write_super(
656 struct super_block *sb) 650 struct super_block *sb)
657{ 651{
658 vfs_t *vfsp = LINVFS_GET_VFS(sb); 652 vfs_t *vfsp = vfs_from_sb(sb);
659 int error; 653 int error;
660 654
661 if (sb->s_flags & MS_RDONLY) { 655 if (sb->s_flags & MS_RDONLY) {
@@ -668,11 +662,11 @@ linvfs_write_super(
668} 662}
669 663
670STATIC int 664STATIC int
671linvfs_sync_super( 665xfs_fs_sync_super(
672 struct super_block *sb, 666 struct super_block *sb,
673 int wait) 667 int wait)
674{ 668{
675 vfs_t *vfsp = LINVFS_GET_VFS(sb); 669 vfs_t *vfsp = vfs_from_sb(sb);
676 int error; 670 int error;
677 int flags = SYNC_FSDATA; 671 int flags = SYNC_FSDATA;
678 672
@@ -707,11 +701,11 @@ linvfs_sync_super(
707} 701}
708 702
709STATIC int 703STATIC int
710linvfs_statfs( 704xfs_fs_statfs(
711 struct super_block *sb, 705 struct super_block *sb,
712 struct kstatfs *statp) 706 struct kstatfs *statp)
713{ 707{
714 vfs_t *vfsp = LINVFS_GET_VFS(sb); 708 vfs_t *vfsp = vfs_from_sb(sb);
715 int error; 709 int error;
716 710
717 VFS_STATVFS(vfsp, statp, NULL, error); 711 VFS_STATVFS(vfsp, statp, NULL, error);
@@ -719,12 +713,12 @@ linvfs_statfs(
719} 713}
720 714
721STATIC int 715STATIC int
722linvfs_remount( 716xfs_fs_remount(
723 struct super_block *sb, 717 struct super_block *sb,
724 int *flags, 718 int *flags,
725 char *options) 719 char *options)
726{ 720{
727 vfs_t *vfsp = LINVFS_GET_VFS(sb); 721 vfs_t *vfsp = vfs_from_sb(sb);
728 struct xfs_mount_args *args = xfs_args_allocate(sb); 722 struct xfs_mount_args *args = xfs_args_allocate(sb);
729 int error; 723 int error;
730 724
@@ -736,18 +730,18 @@ linvfs_remount(
736} 730}
737 731
738STATIC void 732STATIC void
739linvfs_freeze_fs( 733xfs_fs_lockfs(
740 struct super_block *sb) 734 struct super_block *sb)
741{ 735{
742 VFS_FREEZE(LINVFS_GET_VFS(sb)); 736 VFS_FREEZE(vfs_from_sb(sb));
743} 737}
744 738
745STATIC int 739STATIC int
746linvfs_show_options( 740xfs_fs_show_options(
747 struct seq_file *m, 741 struct seq_file *m,
748 struct vfsmount *mnt) 742 struct vfsmount *mnt)
749{ 743{
750 struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb); 744 struct vfs *vfsp = vfs_from_sb(mnt->mnt_sb);
751 int error; 745 int error;
752 746
753 VFS_SHOWARGS(vfsp, m, error); 747 VFS_SHOWARGS(vfsp, m, error);
@@ -755,11 +749,11 @@ linvfs_show_options(
755} 749}
756 750
757STATIC int 751STATIC int
758linvfs_quotasync( 752xfs_fs_quotasync(
759 struct super_block *sb, 753 struct super_block *sb,
760 int type) 754 int type)
761{ 755{
762 struct vfs *vfsp = LINVFS_GET_VFS(sb); 756 struct vfs *vfsp = vfs_from_sb(sb);
763 int error; 757 int error;
764 758
765 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error); 759 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
@@ -767,11 +761,11 @@ linvfs_quotasync(
767} 761}
768 762
769STATIC int 763STATIC int
770linvfs_getxstate( 764xfs_fs_getxstate(
771 struct super_block *sb, 765 struct super_block *sb,
772 struct fs_quota_stat *fqs) 766 struct fs_quota_stat *fqs)
773{ 767{
774 struct vfs *vfsp = LINVFS_GET_VFS(sb); 768 struct vfs *vfsp = vfs_from_sb(sb);
775 int error; 769 int error;
776 770
777 VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error); 771 VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
@@ -779,12 +773,12 @@ linvfs_getxstate(
779} 773}
780 774
781STATIC int 775STATIC int
782linvfs_setxstate( 776xfs_fs_setxstate(
783 struct super_block *sb, 777 struct super_block *sb,
784 unsigned int flags, 778 unsigned int flags,
785 int op) 779 int op)
786{ 780{
787 struct vfs *vfsp = LINVFS_GET_VFS(sb); 781 struct vfs *vfsp = vfs_from_sb(sb);
788 int error; 782 int error;
789 783
790 VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error); 784 VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
@@ -792,13 +786,13 @@ linvfs_setxstate(
792} 786}
793 787
794STATIC int 788STATIC int
795linvfs_getxquota( 789xfs_fs_getxquota(
796 struct super_block *sb, 790 struct super_block *sb,
797 int type, 791 int type,
798 qid_t id, 792 qid_t id,
799 struct fs_disk_quota *fdq) 793 struct fs_disk_quota *fdq)
800{ 794{
801 struct vfs *vfsp = LINVFS_GET_VFS(sb); 795 struct vfs *vfsp = vfs_from_sb(sb);
802 int error, getmode; 796 int error, getmode;
803 797
804 getmode = (type == USRQUOTA) ? Q_XGETQUOTA : 798 getmode = (type == USRQUOTA) ? Q_XGETQUOTA :
@@ -808,13 +802,13 @@ linvfs_getxquota(
808} 802}
809 803
810STATIC int 804STATIC int
811linvfs_setxquota( 805xfs_fs_setxquota(
812 struct super_block *sb, 806 struct super_block *sb,
813 int type, 807 int type,
814 qid_t id, 808 qid_t id,
815 struct fs_disk_quota *fdq) 809 struct fs_disk_quota *fdq)
816{ 810{
817 struct vfs *vfsp = LINVFS_GET_VFS(sb); 811 struct vfs *vfsp = vfs_from_sb(sb);
818 int error, setmode; 812 int error, setmode;
819 813
820 setmode = (type == USRQUOTA) ? Q_XSETQLIM : 814 setmode = (type == USRQUOTA) ? Q_XSETQLIM :
@@ -824,21 +818,17 @@ linvfs_setxquota(
824} 818}
825 819
826STATIC int 820STATIC int
827linvfs_fill_super( 821xfs_fs_fill_super(
828 struct super_block *sb, 822 struct super_block *sb,
829 void *data, 823 void *data,
830 int silent) 824 int silent)
831{ 825{
832 vnode_t *rootvp; 826 vnode_t *rootvp;
833 struct vfs *vfsp = vfs_allocate(); 827 struct vfs *vfsp = vfs_allocate(sb);
834 struct xfs_mount_args *args = xfs_args_allocate(sb); 828 struct xfs_mount_args *args = xfs_args_allocate(sb);
835 struct kstatfs statvfs; 829 struct kstatfs statvfs;
836 int error, error2; 830 int error, error2;
837 831
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); 832 bhv_insert_all_vfsops(vfsp);
843 833
844 VFS_PARSEARGS(vfsp, (char *)data, args, 0, error); 834 VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
@@ -849,10 +839,10 @@ linvfs_fill_super(
849 839
850 sb_min_blocksize(sb, BBSIZE); 840 sb_min_blocksize(sb, BBSIZE);
851#ifdef CONFIG_XFS_EXPORT 841#ifdef CONFIG_XFS_EXPORT
852 sb->s_export_op = &linvfs_export_ops; 842 sb->s_export_op = &xfs_export_operations;
853#endif 843#endif
854 sb->s_qcop = &linvfs_qops; 844 sb->s_qcop = &xfs_quotactl_operations;
855 sb->s_op = &linvfs_sops; 845 sb->s_op = &xfs_super_operations;
856 846
857 VFS_MOUNT(vfsp, args, NULL, error); 847 VFS_MOUNT(vfsp, args, NULL, error);
858 if (error) { 848 if (error) {
@@ -876,7 +866,7 @@ linvfs_fill_super(
876 if (error) 866 if (error)
877 goto fail_unmount; 867 goto fail_unmount;
878 868
879 sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp)); 869 sb->s_root = d_alloc_root(vn_to_inode(rootvp));
880 if (!sb->s_root) { 870 if (!sb->s_root) {
881 error = ENOMEM; 871 error = ENOMEM;
882 goto fail_vnrele; 872 goto fail_vnrele;
@@ -885,7 +875,7 @@ linvfs_fill_super(
885 error = EINVAL; 875 error = EINVAL;
886 goto fail_vnrele; 876 goto fail_vnrele;
887 } 877 }
888 if ((error = linvfs_start_syncd(vfsp))) 878 if ((error = xfs_fs_start_syncd(vfsp)))
889 goto fail_vnrele; 879 goto fail_vnrele;
890 vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address); 880 vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
891 881
@@ -910,41 +900,41 @@ fail_vfsop:
910} 900}
911 901
912STATIC struct super_block * 902STATIC struct super_block *
913linvfs_get_sb( 903xfs_fs_get_sb(
914 struct file_system_type *fs_type, 904 struct file_system_type *fs_type,
915 int flags, 905 int flags,
916 const char *dev_name, 906 const char *dev_name,
917 void *data) 907 void *data)
918{ 908{
919 return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super); 909 return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
920} 910}
921 911
922STATIC struct super_operations linvfs_sops = { 912STATIC struct super_operations xfs_super_operations = {
923 .alloc_inode = linvfs_alloc_inode, 913 .alloc_inode = xfs_fs_alloc_inode,
924 .destroy_inode = linvfs_destroy_inode, 914 .destroy_inode = xfs_fs_destroy_inode,
925 .write_inode = linvfs_write_inode, 915 .write_inode = xfs_fs_write_inode,
926 .clear_inode = linvfs_clear_inode, 916 .clear_inode = xfs_fs_clear_inode,
927 .put_super = linvfs_put_super, 917 .put_super = xfs_fs_put_super,
928 .write_super = linvfs_write_super, 918 .write_super = xfs_fs_write_super,
929 .sync_fs = linvfs_sync_super, 919 .sync_fs = xfs_fs_sync_super,
930 .write_super_lockfs = linvfs_freeze_fs, 920 .write_super_lockfs = xfs_fs_lockfs,
931 .statfs = linvfs_statfs, 921 .statfs = xfs_fs_statfs,
932 .remount_fs = linvfs_remount, 922 .remount_fs = xfs_fs_remount,
933 .show_options = linvfs_show_options, 923 .show_options = xfs_fs_show_options,
934}; 924};
935 925
936STATIC struct quotactl_ops linvfs_qops = { 926STATIC struct quotactl_ops xfs_quotactl_operations = {
937 .quota_sync = linvfs_quotasync, 927 .quota_sync = xfs_fs_quotasync,
938 .get_xstate = linvfs_getxstate, 928 .get_xstate = xfs_fs_getxstate,
939 .set_xstate = linvfs_setxstate, 929 .set_xstate = xfs_fs_setxstate,
940 .get_xquota = linvfs_getxquota, 930 .get_xquota = xfs_fs_getxquota,
941 .set_xquota = linvfs_setxquota, 931 .set_xquota = xfs_fs_setxquota,
942}; 932};
943 933
944STATIC struct file_system_type xfs_fs_type = { 934STATIC struct file_system_type xfs_fs_type = {
945 .owner = THIS_MODULE, 935 .owner = THIS_MODULE,
946 .name = "xfs", 936 .name = "xfs",
947 .get_sb = linvfs_get_sb, 937 .get_sb = xfs_fs_get_sb,
948 .kill_sb = kill_block_super, 938 .kill_sb = kill_block_super,
949 .fs_flags = FS_REQUIRES_DEV, 939 .fs_flags = FS_REQUIRES_DEV,
950}; 940};
@@ -965,7 +955,7 @@ init_xfs_fs( void )
965 955
966 ktrace_init(64); 956 ktrace_init(64);
967 957
968 error = linvfs_init_zones(); 958 error = xfs_init_zones();
969 if (error < 0) 959 if (error < 0)
970 goto undo_zones; 960 goto undo_zones;
971 961
@@ -981,14 +971,13 @@ init_xfs_fs( void )
981 error = register_filesystem(&xfs_fs_type); 971 error = register_filesystem(&xfs_fs_type);
982 if (error) 972 if (error)
983 goto undo_register; 973 goto undo_register;
984 XFS_DM_INIT(&xfs_fs_type);
985 return 0; 974 return 0;
986 975
987undo_register: 976undo_register:
988 xfs_buf_terminate(); 977 xfs_buf_terminate();
989 978
990undo_buffers: 979undo_buffers:
991 linvfs_destroy_zones(); 980 xfs_destroy_zones();
992 981
993undo_zones: 982undo_zones:
994 return error; 983 return error;
@@ -998,11 +987,10 @@ STATIC void __exit
998exit_xfs_fs( void ) 987exit_xfs_fs( void )
999{ 988{
1000 vfs_exitquota(); 989 vfs_exitquota();
1001 XFS_DM_EXIT(&xfs_fs_type);
1002 unregister_filesystem(&xfs_fs_type); 990 unregister_filesystem(&xfs_fs_type);
1003 xfs_cleanup(); 991 xfs_cleanup();
1004 xfs_buf_terminate(); 992 xfs_buf_terminate();
1005 linvfs_destroy_zones(); 993 xfs_destroy_zones();
1006 ktrace_uninit(); 994 ktrace_uninit();
1007} 995}
1008 996
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..841200c03092 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -92,7 +92,7 @@ typedef enum {
92#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */ 92#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
93#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ 93#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
94#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ 94#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
95#define SYNC_QUIESCE 0x0100 /* quiesce fileystem for a snapshot */ 95#define SYNC_QUIESCE 0x0100 /* quiesce filesystem for a snapshot */
96 96
97typedef int (*vfs_mount_t)(bhv_desc_t *, 97typedef int (*vfs_mount_t)(bhv_desc_t *,
98 struct xfs_mount_args *, struct cred *); 98 struct xfs_mount_args *, struct cred *);
@@ -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)