aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r--fs/xfs/linux-2.6/kmem.c54
-rw-r--r--fs/xfs/linux-2.6/kmem.h66
-rw-r--r--fs/xfs/linux-2.6/mrlock.h36
-rw-r--r--fs/xfs/linux-2.6/mutex.h36
-rw-r--r--fs/xfs/linux-2.6/sema.h36
-rw-r--r--fs/xfs/linux-2.6/spin.h39
-rw-r--r--fs/xfs/linux-2.6/sv.h36
-rw-r--r--fs/xfs/linux-2.6/time.h39
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c341
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c336
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h85
-rw-r--r--fs/xfs/linux-2.6/xfs_cred.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c47
-rw-r--r--fs/xfs/linux-2.6/xfs_export.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c131
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c38
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.h57
-rw-r--r--fs/xfs/linux-2.6/xfs_globals.c42
-rw-r--r--fs/xfs/linux-2.6/xfs_globals.h41
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c73
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c103
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.h44
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c203
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h40
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h67
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c72
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h48
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c37
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c310
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h37
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c56
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.h37
-rw-r--r--fs/xfs/linux-2.6/xfs_version.h41
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.c39
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h39
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c291
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h113
39 files changed, 1354 insertions, 1900 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index 364ea8c386b1..aba7fcf881a2 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -1,54 +1,37 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <linux/sched.h> 18#include <linux/sched.h>
34#include <linux/mm.h> 19#include <linux/mm.h>
35#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
36#include <linux/highmem.h> 21#include <linux/highmem.h>
37#include <linux/swap.h> 22#include <linux/swap.h>
38#include <linux/blkdev.h> 23#include <linux/blkdev.h>
39
40#include "time.h" 24#include "time.h"
41#include "kmem.h" 25#include "kmem.h"
42 26
43#define MAX_VMALLOCS 6 27#define MAX_VMALLOCS 6
44#define MAX_SLAB_SIZE 0x20000 28#define MAX_SLAB_SIZE 0x20000
45 29
46
47void * 30void *
48kmem_alloc(size_t size, int flags) 31kmem_alloc(size_t size, unsigned int __nocast flags)
49{ 32{
50 int retries = 0; 33 int retries = 0;
51 int lflags = kmem_flags_convert(flags); 34 gfp_t lflags = kmem_flags_convert(flags);
52 void *ptr; 35 void *ptr;
53 36
54 do { 37 do {
@@ -67,7 +50,7 @@ kmem_alloc(size_t size, int flags)
67} 50}
68 51
69void * 52void *
70kmem_zalloc(size_t size, int flags) 53kmem_zalloc(size_t size, unsigned int __nocast flags)
71{ 54{
72 void *ptr; 55 void *ptr;
73 56
@@ -89,7 +72,8 @@ kmem_free(void *ptr, size_t size)
89} 72}
90 73
91void * 74void *
92kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags) 75kmem_realloc(void *ptr, size_t newsize, size_t oldsize,
76 unsigned int __nocast flags)
93{ 77{
94 void *new; 78 void *new;
95 79
@@ -104,10 +88,10 @@ kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
104} 88}
105 89
106void * 90void *
107kmem_zone_alloc(kmem_zone_t *zone, int flags) 91kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
108{ 92{
109 int retries = 0; 93 int retries = 0;
110 int lflags = kmem_flags_convert(flags); 94 gfp_t lflags = kmem_flags_convert(flags);
111 void *ptr; 95 void *ptr;
112 96
113 do { 97 do {
@@ -123,7 +107,7 @@ kmem_zone_alloc(kmem_zone_t *zone, int flags)
123} 107}
124 108
125void * 109void *
126kmem_zone_zalloc(kmem_zone_t *zone, int flags) 110kmem_zone_zalloc(kmem_zone_t *zone, unsigned int __nocast flags)
127{ 111{
128 void *ptr; 112 void *ptr;
129 113
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 1397b669b059..8f82c1a20dc5 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_KMEM_H__ 18#ifndef __XFS_SUPPORT_KMEM_H__
33#define __XFS_SUPPORT_KMEM_H__ 19#define __XFS_SUPPORT_KMEM_H__
@@ -39,10 +25,10 @@
39/* 25/*
40 * memory management routines 26 * memory management routines
41 */ 27 */
42#define KM_SLEEP 0x0001 28#define KM_SLEEP 0x0001u
43#define KM_NOSLEEP 0x0002 29#define KM_NOSLEEP 0x0002u
44#define KM_NOFS 0x0004 30#define KM_NOFS 0x0004u
45#define KM_MAYFAIL 0x0008 31#define KM_MAYFAIL 0x0008u
46 32
47#define kmem_zone kmem_cache_s 33#define kmem_zone kmem_cache_s
48#define kmem_zone_t kmem_cache_t 34#define kmem_zone_t kmem_cache_t
@@ -81,9 +67,9 @@ typedef unsigned long xfs_pflags_t;
81 *(NSTATEP) = *(OSTATEP); \ 67 *(NSTATEP) = *(OSTATEP); \
82} while (0) 68} while (0)
83 69
84static __inline unsigned int kmem_flags_convert(int flags) 70static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
85{ 71{
86 int lflags = __GFP_NOWARN; /* we'll report problems, if need be */ 72 gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */
87 73
88#ifdef DEBUG 74#ifdef DEBUG
89 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { 75 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
@@ -102,7 +88,7 @@ static __inline unsigned int kmem_flags_convert(int flags)
102 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) 88 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
103 lflags &= ~__GFP_FS; 89 lflags &= ~__GFP_FS;
104 } 90 }
105 91
106 return lflags; 92 return lflags;
107} 93}
108 94
@@ -125,16 +111,16 @@ kmem_zone_destroy(kmem_zone_t *zone)
125 BUG(); 111 BUG();
126} 112}
127 113
128extern void *kmem_zone_zalloc(kmem_zone_t *, int); 114extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
129extern void *kmem_zone_alloc(kmem_zone_t *, int); 115extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
130 116
131extern void *kmem_alloc(size_t, int); 117extern void *kmem_alloc(size_t, unsigned int __nocast);
132extern void *kmem_realloc(void *, size_t, size_t, int); 118extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
133extern void *kmem_zalloc(size_t, int); 119extern void *kmem_zalloc(size_t, unsigned int __nocast);
134extern void kmem_free(void *, size_t); 120extern void kmem_free(void *, size_t);
135 121
136typedef struct shrinker *kmem_shaker_t; 122typedef struct shrinker *kmem_shaker_t;
137typedef int (*kmem_shake_func_t)(int, unsigned int); 123typedef int (*kmem_shake_func_t)(int, gfp_t);
138 124
139static __inline kmem_shaker_t 125static __inline kmem_shaker_t
140kmem_shake_register(kmem_shake_func_t sfunc) 126kmem_shake_register(kmem_shake_func_t sfunc)
@@ -149,7 +135,7 @@ kmem_shake_deregister(kmem_shaker_t shrinker)
149} 135}
150 136
151static __inline int 137static __inline int
152kmem_shake_allow(unsigned int gfp_mask) 138kmem_shake_allow(gfp_t gfp_mask)
153{ 139{
154 return (gfp_mask & __GFP_WAIT); 140 return (gfp_mask & __GFP_WAIT);
155} 141}
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/linux-2.6/mrlock.h
index d2c11a098ff2..16b44c3c2362 100644
--- a/fs/xfs/linux-2.6/mrlock.h
+++ b/fs/xfs/linux-2.6/mrlock.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_MRLOCK_H__ 18#ifndef __XFS_SUPPORT_MRLOCK_H__
33#define __XFS_SUPPORT_MRLOCK_H__ 19#define __XFS_SUPPORT_MRLOCK_H__
diff --git a/fs/xfs/linux-2.6/mutex.h b/fs/xfs/linux-2.6/mutex.h
index 0b296bb944cb..ce773d89a923 100644
--- a/fs/xfs/linux-2.6/mutex.h
+++ b/fs/xfs/linux-2.6/mutex.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_MUTEX_H__ 18#ifndef __XFS_SUPPORT_MUTEX_H__
33#define __XFS_SUPPORT_MUTEX_H__ 19#define __XFS_SUPPORT_MUTEX_H__
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h
index 30b67b4e1cbf..194a84490bd1 100644
--- a/fs/xfs/linux-2.6/sema.h
+++ b/fs/xfs/linux-2.6/sema.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SEMA_H__ 18#ifndef __XFS_SUPPORT_SEMA_H__
33#define __XFS_SUPPORT_SEMA_H__ 19#define __XFS_SUPPORT_SEMA_H__
diff --git a/fs/xfs/linux-2.6/spin.h b/fs/xfs/linux-2.6/spin.h
index bcf60a0b8df0..50a6191178f4 100644
--- a/fs/xfs/linux-2.6/spin.h
+++ b/fs/xfs/linux-2.6/spin.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SPIN_H__ 18#ifndef __XFS_SUPPORT_SPIN_H__
33#define __XFS_SUPPORT_SPIN_H__ 19#define __XFS_SUPPORT_SPIN_H__
@@ -45,6 +31,9 @@
45typedef spinlock_t lock_t; 31typedef spinlock_t lock_t;
46 32
47#define SPLDECL(s) unsigned long s 33#define SPLDECL(s) unsigned long s
34#ifndef DEFINE_SPINLOCK
35#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED
36#endif
48 37
49#define spinlock_init(lock, name) spin_lock_init(lock) 38#define spinlock_init(lock, name) spin_lock_init(lock)
50#define spinlock_destroy(lock) 39#define spinlock_destroy(lock)
diff --git a/fs/xfs/linux-2.6/sv.h b/fs/xfs/linux-2.6/sv.h
index 821d3167e05b..9a8ad481b008 100644
--- a/fs/xfs/linux-2.6/sv.h
+++ b/fs/xfs/linux-2.6/sv.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SV_H__ 18#ifndef __XFS_SUPPORT_SV_H__
33#define __XFS_SUPPORT_SV_H__ 19#define __XFS_SUPPORT_SV_H__
diff --git a/fs/xfs/linux-2.6/time.h b/fs/xfs/linux-2.6/time.h
index 6c6fd0faa8e1..387e695a184c 100644
--- a/fs/xfs/linux-2.6/time.h
+++ b/fs/xfs/linux-2.6/time.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_TIME_H__ 18#ifndef __XFS_SUPPORT_TIME_H__
33#define __XFS_SUPPORT_TIME_H__ 19#define __XFS_SUPPORT_TIME_H__
@@ -39,8 +25,7 @@ typedef struct timespec timespec_t;
39 25
40static inline void delay(long ticks) 26static inline void delay(long ticks)
41{ 27{
42 set_current_state(TASK_UNINTERRUPTIBLE); 28 schedule_timeout_uninterruptible(ticks);
43 schedule_timeout(ticks);
44} 29}
45 30
46static inline void nanotime(struct timespec *tvp) 31static inline void nanotime(struct timespec *tvp)
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index a3a4b5aaf5d9..c6108971b4e6 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1,39 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_inum.h" 19#include "xfs_bit.h"
35#include "xfs_log.h" 20#include "xfs_log.h"
21#include "xfs_inum.h"
36#include "xfs_sb.h" 22#include "xfs_sb.h"
23#include "xfs_ag.h"
37#include "xfs_dir.h" 24#include "xfs_dir.h"
38#include "xfs_dir2.h" 25#include "xfs_dir2.h"
39#include "xfs_trans.h" 26#include "xfs_trans.h"
@@ -42,13 +29,13 @@
42#include "xfs_bmap_btree.h" 29#include "xfs_bmap_btree.h"
43#include "xfs_alloc_btree.h" 30#include "xfs_alloc_btree.h"
44#include "xfs_ialloc_btree.h" 31#include "xfs_ialloc_btree.h"
45#include "xfs_alloc.h"
46#include "xfs_btree.h"
47#include "xfs_attr_sf.h"
48#include "xfs_dir_sf.h" 32#include "xfs_dir_sf.h"
49#include "xfs_dir2_sf.h" 33#include "xfs_dir2_sf.h"
34#include "xfs_attr_sf.h"
50#include "xfs_dinode.h" 35#include "xfs_dinode.h"
51#include "xfs_inode.h" 36#include "xfs_inode.h"
37#include "xfs_alloc.h"
38#include "xfs_btree.h"
52#include "xfs_error.h" 39#include "xfs_error.h"
53#include "xfs_rw.h" 40#include "xfs_rw.h"
54#include "xfs_iomap.h" 41#include "xfs_iomap.h"
@@ -104,66 +91,114 @@ xfs_page_trace(
104#define xfs_page_trace(tag, inode, page, mask) 91#define xfs_page_trace(tag, inode, page, mask)
105#endif 92#endif
106 93
107void 94/*
108linvfs_unwritten_done( 95 * Schedule IO completion handling on a xfsdatad if this was
109 struct buffer_head *bh, 96 * the final hold on this ioend.
110 int uptodate) 97 */
98STATIC void
99xfs_finish_ioend(
100 xfs_ioend_t *ioend)
111{ 101{
112 xfs_buf_t *pb = (xfs_buf_t *)bh->b_private; 102 if (atomic_dec_and_test(&ioend->io_remaining))
103 queue_work(xfsdatad_workqueue, &ioend->io_work);
104}
113 105
114 ASSERT(buffer_unwritten(bh)); 106STATIC void
115 bh->b_end_io = NULL; 107xfs_destroy_ioend(
116 clear_buffer_unwritten(bh); 108 xfs_ioend_t *ioend)
117 if (!uptodate) 109{
118 pagebuf_ioerror(pb, EIO); 110 vn_iowake(ioend->io_vnode);
119 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { 111 mempool_free(ioend, xfs_ioend_pool);
120 pagebuf_iodone(pb, 1, 1);
121 }
122 end_buffer_async_write(bh, uptodate);
123} 112}
124 113
125/* 114/*
126 * Issue transactions to convert a buffer range from unwritten 115 * Issue transactions to convert a buffer range from unwritten
127 * to written extents (buffered IO). 116 * to written extents.
128 */ 117 */
129STATIC void 118STATIC void
130linvfs_unwritten_convert( 119xfs_end_bio_unwritten(
131 xfs_buf_t *bp) 120 void *data)
132{ 121{
133 vnode_t *vp = XFS_BUF_FSPRIVATE(bp, vnode_t *); 122 xfs_ioend_t *ioend = data;
134 int error; 123 vnode_t *vp = ioend->io_vnode;
124 xfs_off_t offset = ioend->io_offset;
125 size_t size = ioend->io_size;
126 struct buffer_head *bh, *next;
127 int error;
128
129 if (ioend->io_uptodate)
130 VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
131
132 /* ioend->io_buffer_head is only non-NULL for buffered I/O */
133 for (bh = ioend->io_buffer_head; bh; bh = next) {
134 next = bh->b_private;
135 135
136 BUG_ON(atomic_read(&bp->pb_hold) < 1); 136 bh->b_end_io = NULL;
137 VOP_BMAP(vp, XFS_BUF_OFFSET(bp), XFS_BUF_SIZE(bp), 137 clear_buffer_unwritten(bh);
138 BMAPI_UNWRITTEN, NULL, NULL, error); 138 end_buffer_async_write(bh, ioend->io_uptodate);
139 XFS_BUF_SET_FSPRIVATE(bp, NULL); 139 }
140 XFS_BUF_CLR_IODONE_FUNC(bp); 140
141 XFS_BUF_UNDATAIO(bp); 141 xfs_destroy_ioend(ioend);
142 iput(LINVFS_GET_IP(vp));
143 pagebuf_iodone(bp, 0, 0);
144} 142}
145 143
146/* 144/*
147 * Issue transactions to convert a buffer range from unwritten 145 * Allocate and initialise an IO completion structure.
148 * to written extents (direct IO). 146 * We need to track unwritten extent write completion here initially.
147 * We'll need to extend this for updating the ondisk inode size later
148 * (vs. incore size).
149 */ 149 */
150STATIC void 150STATIC xfs_ioend_t *
151linvfs_unwritten_convert_direct( 151xfs_alloc_ioend(
152 struct kiocb *iocb, 152 struct inode *inode)
153 loff_t offset,
154 ssize_t size,
155 void *private)
156{ 153{
157 struct inode *inode = iocb->ki_filp->f_dentry->d_inode; 154 xfs_ioend_t *ioend;
158 ASSERT(!private || inode == (struct inode *)private);
159 155
160 /* private indicates an unwritten extent lay beneath this IO */ 156 ioend = mempool_alloc(xfs_ioend_pool, GFP_NOFS);
161 if (private && size > 0) {
162 vnode_t *vp = LINVFS_GET_VP(inode);
163 int error;
164 157
165 VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error); 158 /*
166 } 159 * Set the count to 1 initially, which will prevent an I/O
160 * completion callback from happening before we have started
161 * all the I/O from calling the completion routine too early.
162 */
163 atomic_set(&ioend->io_remaining, 1);
164 ioend->io_uptodate = 1; /* cleared if any I/O fails */
165 ioend->io_vnode = LINVFS_GET_VP(inode);
166 ioend->io_buffer_head = NULL;
167 atomic_inc(&ioend->io_vnode->v_iocount);
168 ioend->io_offset = 0;
169 ioend->io_size = 0;
170
171 INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten, ioend);
172
173 return ioend;
174}
175
176void
177linvfs_unwritten_done(
178 struct buffer_head *bh,
179 int uptodate)
180{
181 xfs_ioend_t *ioend = bh->b_private;
182 static spinlock_t unwritten_done_lock = SPIN_LOCK_UNLOCKED;
183 unsigned long flags;
184
185 ASSERT(buffer_unwritten(bh));
186 bh->b_end_io = NULL;
187
188 if (!uptodate)
189 ioend->io_uptodate = 0;
190
191 /*
192 * Deep magic here. We reuse b_private in the buffer_heads to build
193 * a chain for completing the I/O from user context after we've issued
194 * a transaction to convert the unwritten extent.
195 */
196 spin_lock_irqsave(&unwritten_done_lock, flags);
197 bh->b_private = ioend->io_buffer_head;
198 ioend->io_buffer_head = bh;
199 spin_unlock_irqrestore(&unwritten_done_lock, flags);
200
201 xfs_finish_ioend(ioend);
167} 202}
168 203
169STATIC int 204STATIC int
@@ -255,7 +290,7 @@ xfs_probe_unwritten_page(
255 struct address_space *mapping, 290 struct address_space *mapping,
256 pgoff_t index, 291 pgoff_t index,
257 xfs_iomap_t *iomapp, 292 xfs_iomap_t *iomapp,
258 xfs_buf_t *pb, 293 xfs_ioend_t *ioend,
259 unsigned long max_offset, 294 unsigned long max_offset,
260 unsigned long *fsbs, 295 unsigned long *fsbs,
261 unsigned int bbits) 296 unsigned int bbits)
@@ -283,7 +318,7 @@ xfs_probe_unwritten_page(
283 break; 318 break;
284 xfs_map_at_offset(page, bh, p_offset, bbits, iomapp); 319 xfs_map_at_offset(page, bh, p_offset, bbits, iomapp);
285 set_buffer_unwritten_io(bh); 320 set_buffer_unwritten_io(bh);
286 bh->b_private = pb; 321 bh->b_private = ioend;
287 p_offset += bh->b_size; 322 p_offset += bh->b_size;
288 (*fsbs)++; 323 (*fsbs)++;
289 } while ((bh = bh->b_this_page) != head); 324 } while ((bh = bh->b_this_page) != head);
@@ -434,34 +469,15 @@ xfs_map_unwritten(
434{ 469{
435 struct buffer_head *bh = curr; 470 struct buffer_head *bh = curr;
436 xfs_iomap_t *tmp; 471 xfs_iomap_t *tmp;
437 xfs_buf_t *pb; 472 xfs_ioend_t *ioend;
438 loff_t offset, size; 473 loff_t offset;
439 unsigned long nblocks = 0; 474 unsigned long nblocks = 0;
440 475
441 offset = start_page->index; 476 offset = start_page->index;
442 offset <<= PAGE_CACHE_SHIFT; 477 offset <<= PAGE_CACHE_SHIFT;
443 offset += p_offset; 478 offset += p_offset;
444 479
445 /* get an "empty" pagebuf to manage IO completion 480 ioend = xfs_alloc_ioend(inode);
446 * Proper values will be set before returning */
447 pb = pagebuf_lookup(iomapp->iomap_target, 0, 0, 0);
448 if (!pb)
449 return -EAGAIN;
450
451 /* Take a reference to the inode to prevent it from
452 * being reclaimed while we have outstanding unwritten
453 * extent IO on it.
454 */
455 if ((igrab(inode)) != inode) {
456 pagebuf_free(pb);
457 return -EAGAIN;
458 }
459
460 /* Set the count to 1 initially, this will stop an I/O
461 * completion callout which happens before we have started
462 * all the I/O from calling pagebuf_iodone too early.
463 */
464 atomic_set(&pb->pb_io_remaining, 1);
465 481
466 /* First map forwards in the page consecutive buffers 482 /* First map forwards in the page consecutive buffers
467 * covering this unwritten extent 483 * covering this unwritten extent
@@ -474,12 +490,12 @@ xfs_map_unwritten(
474 break; 490 break;
475 xfs_map_at_offset(start_page, bh, p_offset, block_bits, iomapp); 491 xfs_map_at_offset(start_page, bh, p_offset, block_bits, iomapp);
476 set_buffer_unwritten_io(bh); 492 set_buffer_unwritten_io(bh);
477 bh->b_private = pb; 493 bh->b_private = ioend;
478 p_offset += bh->b_size; 494 p_offset += bh->b_size;
479 nblocks++; 495 nblocks++;
480 } while ((bh = bh->b_this_page) != head); 496 } while ((bh = bh->b_this_page) != head);
481 497
482 atomic_add(nblocks, &pb->pb_io_remaining); 498 atomic_add(nblocks, &ioend->io_remaining);
483 499
484 /* If we reached the end of the page, map forwards in any 500 /* If we reached the end of the page, map forwards in any
485 * following pages which are also covered by this extent. 501 * following pages which are also covered by this extent.
@@ -496,13 +512,13 @@ xfs_map_unwritten(
496 tloff = min(tlast, tloff); 512 tloff = min(tlast, tloff);
497 for (tindex = start_page->index + 1; tindex < tloff; tindex++) { 513 for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
498 page = xfs_probe_unwritten_page(mapping, 514 page = xfs_probe_unwritten_page(mapping,
499 tindex, iomapp, pb, 515 tindex, iomapp, ioend,
500 PAGE_CACHE_SIZE, &bs, bbits); 516 PAGE_CACHE_SIZE, &bs, bbits);
501 if (!page) 517 if (!page)
502 break; 518 break;
503 nblocks += bs; 519 nblocks += bs;
504 atomic_add(bs, &pb->pb_io_remaining); 520 atomic_add(bs, &ioend->io_remaining);
505 xfs_convert_page(inode, page, iomapp, wbc, pb, 521 xfs_convert_page(inode, page, iomapp, wbc, ioend,
506 startio, all_bh); 522 startio, all_bh);
507 /* stop if converting the next page might add 523 /* stop if converting the next page might add
508 * enough blocks that the corresponding byte 524 * enough blocks that the corresponding byte
@@ -514,12 +530,12 @@ xfs_map_unwritten(
514 if (tindex == tlast && 530 if (tindex == tlast &&
515 (pg_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) { 531 (pg_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
516 page = xfs_probe_unwritten_page(mapping, 532 page = xfs_probe_unwritten_page(mapping,
517 tindex, iomapp, pb, 533 tindex, iomapp, ioend,
518 pg_offset, &bs, bbits); 534 pg_offset, &bs, bbits);
519 if (page) { 535 if (page) {
520 nblocks += bs; 536 nblocks += bs;
521 atomic_add(bs, &pb->pb_io_remaining); 537 atomic_add(bs, &ioend->io_remaining);
522 xfs_convert_page(inode, page, iomapp, wbc, pb, 538 xfs_convert_page(inode, page, iomapp, wbc, ioend,
523 startio, all_bh); 539 startio, all_bh);
524 if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits)) 540 if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
525 goto enough; 541 goto enough;
@@ -528,21 +544,9 @@ xfs_map_unwritten(
528 } 544 }
529 545
530enough: 546enough:
531 size = nblocks; /* NB: using 64bit number here */ 547 ioend->io_size = (xfs_off_t)nblocks << block_bits;
532 size <<= block_bits; /* convert fsb's to byte range */ 548 ioend->io_offset = offset;
533 549 xfs_finish_ioend(ioend);
534 XFS_BUF_DATAIO(pb);
535 XFS_BUF_ASYNC(pb);
536 XFS_BUF_SET_SIZE(pb, size);
537 XFS_BUF_SET_COUNT(pb, size);
538 XFS_BUF_SET_OFFSET(pb, offset);
539 XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode));
540 XFS_BUF_SET_IODONE_FUNC(pb, linvfs_unwritten_convert);
541
542 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
543 pagebuf_iodone(pb, 1, 1);
544 }
545
546 return 0; 550 return 0;
547} 551}
548 552
@@ -744,8 +748,9 @@ xfs_page_state_convert(
744 if (page->index >= end_index) { 748 if (page->index >= end_index) {
745 if ((page->index >= end_index + 1) || 749 if ((page->index >= end_index + 1) ||
746 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { 750 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
747 err = -EIO; 751 if (startio)
748 goto error; 752 unlock_page(page);
753 return 0;
749 } 754 }
750 } 755 }
751 756
@@ -787,7 +792,7 @@ xfs_page_state_convert(
787 continue; 792 continue;
788 if (!iomp) { 793 if (!iomp) {
789 err = xfs_map_blocks(inode, offset, len, &iomap, 794 err = xfs_map_blocks(inode, offset, len, &iomap,
790 BMAPI_READ|BMAPI_IGNSTATE); 795 BMAPI_WRITE|BMAPI_IGNSTATE);
791 if (err) { 796 if (err) {
792 goto error; 797 goto error;
793 } 798 }
@@ -931,15 +936,18 @@ __linvfs_get_block(
931{ 936{
932 vnode_t *vp = LINVFS_GET_VP(inode); 937 vnode_t *vp = LINVFS_GET_VP(inode);
933 xfs_iomap_t iomap; 938 xfs_iomap_t iomap;
939 xfs_off_t offset;
940 ssize_t size;
934 int retpbbm = 1; 941 int retpbbm = 1;
935 int error; 942 int error;
936 ssize_t size;
937 loff_t offset = (loff_t)iblock << inode->i_blkbits;
938 943
939 if (blocks) 944 if (blocks) {
940 size = blocks << inode->i_blkbits; 945 offset = blocks << inode->i_blkbits; /* 64 bit goodness */
941 else 946 size = (ssize_t) min_t(xfs_off_t, offset, LONG_MAX);
947 } else {
942 size = 1 << inode->i_blkbits; 948 size = 1 << inode->i_blkbits;
949 }
950 offset = (xfs_off_t)iblock << inode->i_blkbits;
943 951
944 VOP_BMAP(vp, offset, size, 952 VOP_BMAP(vp, offset, size,
945 create ? flags : BMAPI_READ, &iomap, &retpbbm, error); 953 create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
@@ -950,8 +958,8 @@ __linvfs_get_block(
950 return 0; 958 return 0;
951 959
952 if (iomap.iomap_bn != IOMAP_DADDR_NULL) { 960 if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
953 xfs_daddr_t bn; 961 xfs_daddr_t bn;
954 loff_t delta; 962 xfs_off_t delta;
955 963
956 /* For unwritten extents do not report a disk address on 964 /* For unwritten extents do not report a disk address on
957 * the read case (treat as if we're reading into a hole). 965 * the read case (treat as if we're reading into a hole).
@@ -983,9 +991,8 @@ __linvfs_get_block(
983 */ 991 */
984 if (create && 992 if (create &&
985 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || 993 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
986 (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) { 994 (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW)))
987 set_buffer_new(bh_result); 995 set_buffer_new(bh_result);
988 }
989 996
990 if (iomap.iomap_flags & IOMAP_DELAY) { 997 if (iomap.iomap_flags & IOMAP_DELAY) {
991 BUG_ON(direct); 998 BUG_ON(direct);
@@ -997,9 +1004,11 @@ __linvfs_get_block(
997 } 1004 }
998 1005
999 if (blocks) { 1006 if (blocks) {
1000 bh_result->b_size = (ssize_t)min( 1007 ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0);
1001 (loff_t)(iomap.iomap_bsize - iomap.iomap_delta), 1008 offset = min_t(xfs_off_t,
1002 (loff_t)(blocks << inode->i_blkbits)); 1009 iomap.iomap_bsize - iomap.iomap_delta,
1010 blocks << inode->i_blkbits);
1011 bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset);
1003 } 1012 }
1004 1013
1005 return 0; 1014 return 0;
@@ -1028,6 +1037,44 @@ linvfs_get_blocks_direct(
1028 create, 1, BMAPI_WRITE|BMAPI_DIRECT); 1037 create, 1, BMAPI_WRITE|BMAPI_DIRECT);
1029} 1038}
1030 1039
1040STATIC void
1041linvfs_end_io_direct(
1042 struct kiocb *iocb,
1043 loff_t offset,
1044 ssize_t size,
1045 void *private)
1046{
1047 xfs_ioend_t *ioend = iocb->private;
1048
1049 /*
1050 * Non-NULL private data means we need to issue a transaction to
1051 * convert a range from unwritten to written extents. This needs
1052 * to happen from process contect but aio+dio I/O completion
1053 * happens from irq context so we need to defer it to a workqueue.
1054 * This is not nessecary for synchronous direct I/O, but we do
1055 * it anyway to keep the code uniform and simpler.
1056 *
1057 * The core direct I/O code might be changed to always call the
1058 * completion handler in the future, in which case all this can
1059 * go away.
1060 */
1061 if (private && size > 0) {
1062 ioend->io_offset = offset;
1063 ioend->io_size = size;
1064 xfs_finish_ioend(ioend);
1065 } else {
1066 ASSERT(size >= 0);
1067 xfs_destroy_ioend(ioend);
1068 }
1069
1070 /*
1071 * blockdev_direct_IO can return an error even afer the I/O
1072 * completion handler was called. Thus we need to protect
1073 * against double-freeing.
1074 */
1075 iocb->private = NULL;
1076}
1077
1031STATIC ssize_t 1078STATIC ssize_t
1032linvfs_direct_IO( 1079linvfs_direct_IO(
1033 int rw, 1080 int rw,
@@ -1042,16 +1089,23 @@ linvfs_direct_IO(
1042 xfs_iomap_t iomap; 1089 xfs_iomap_t iomap;
1043 int maps = 1; 1090 int maps = 1;
1044 int error; 1091 int error;
1092 ssize_t ret;
1045 1093
1046 VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error); 1094 VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
1047 if (error) 1095 if (error)
1048 return -error; 1096 return -error;
1049 1097
1050 return blockdev_direct_IO_own_locking(rw, iocb, inode, 1098 iocb->private = xfs_alloc_ioend(inode);
1099
1100 ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
1051 iomap.iomap_target->pbr_bdev, 1101 iomap.iomap_target->pbr_bdev,
1052 iov, offset, nr_segs, 1102 iov, offset, nr_segs,
1053 linvfs_get_blocks_direct, 1103 linvfs_get_blocks_direct,
1054 linvfs_unwritten_convert_direct); 1104 linvfs_end_io_direct);
1105
1106 if (unlikely(ret <= 0 && iocb->private))
1107 xfs_destroy_ioend(iocb->private);
1108 return ret;
1055} 1109}
1056 1110
1057 1111
@@ -1202,6 +1256,16 @@ out_unlock:
1202 return error; 1256 return error;
1203} 1257}
1204 1258
1259STATIC int
1260linvfs_invalidate_page(
1261 struct page *page,
1262 unsigned long offset)
1263{
1264 xfs_page_trace(XFS_INVALIDPAGE_ENTER,
1265 page->mapping->host, page, offset);
1266 return block_invalidatepage(page, offset);
1267}
1268
1205/* 1269/*
1206 * Called to move a page into cleanable state - and from there 1270 * Called to move a page into cleanable state - and from there
1207 * to be released. Possibly the page is already clean. We always 1271 * to be released. Possibly the page is already clean. We always
@@ -1224,7 +1288,7 @@ out_unlock:
1224STATIC int 1288STATIC int
1225linvfs_release_page( 1289linvfs_release_page(
1226 struct page *page, 1290 struct page *page,
1227 int gfp_mask) 1291 gfp_t gfp_mask)
1228{ 1292{
1229 struct inode *inode = page->mapping->host; 1293 struct inode *inode = page->mapping->host;
1230 int dirty, delalloc, unmapped, unwritten; 1294 int dirty, delalloc, unmapped, unwritten;
@@ -1279,6 +1343,7 @@ struct address_space_operations linvfs_aops = {
1279 .writepage = linvfs_writepage, 1343 .writepage = linvfs_writepage,
1280 .sync_page = block_sync_page, 1344 .sync_page = block_sync_page,
1281 .releasepage = linvfs_release_page, 1345 .releasepage = linvfs_release_page,
1346 .invalidatepage = linvfs_invalidate_page,
1282 .prepare_write = linvfs_prepare_write, 1347 .prepare_write = linvfs_prepare_write,
1283 .commit_write = generic_commit_write, 1348 .commit_write = generic_commit_write,
1284 .bmap = linvfs_bmap, 1349 .bmap = linvfs_bmap,
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
new file mode 100644
index 000000000000..4720758a9ade
--- /dev/null
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) 2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_AOPS_H__
19#define __XFS_AOPS_H__
20
21extern struct workqueue_struct *xfsdatad_workqueue;
22extern mempool_t *xfs_ioend_pool;
23
24typedef void (*xfs_ioend_func_t)(void *);
25
26typedef struct xfs_ioend {
27 unsigned int io_uptodate; /* I/O status register */
28 atomic_t io_remaining; /* hold count */
29 struct vnode *io_vnode; /* file being written to */
30 struct buffer_head *io_buffer_head;/* buffer linked list head */
31 size_t io_size; /* size of the extent */
32 xfs_off_t io_offset; /* offset in the file */
33 struct work_struct io_work; /* xfsdatad work queue */
34} xfs_ioend_t;
35
36#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 df0cba239dd5..6fe21d2b8847 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1,46 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * 12 * GNU General Public License for more details.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * The xfs_buf.c code provides an abstract buffer cache model on top
35 * of the Linux page cache. Cached metadata blocks for a file system
36 * are hashed to the inode for the block device. xfs_buf.c assembles
37 * buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O.
38 *
39 * Written by Steve Lord, Jim Mostek, Russell Cattelan
40 * and Rajagopal Ananthanarayanan ("ananth") at SGI.
41 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
42 */ 17 */
43
44#include <linux/stddef.h> 18#include <linux/stddef.h>
45#include <linux/errno.h> 19#include <linux/errno.h>
46#include <linux/slab.h> 20#include <linux/slab.h>
@@ -54,24 +28,16 @@
54#include <linux/percpu.h> 28#include <linux/percpu.h>
55#include <linux/blkdev.h> 29#include <linux/blkdev.h>
56#include <linux/hash.h> 30#include <linux/hash.h>
57 31#include <linux/kthread.h>
58#include "xfs_linux.h" 32#include "xfs_linux.h"
59 33
60/*
61 * File wide globals
62 */
63
64STATIC kmem_cache_t *pagebuf_zone; 34STATIC kmem_cache_t *pagebuf_zone;
65STATIC kmem_shaker_t pagebuf_shake; 35STATIC kmem_shaker_t pagebuf_shake;
66STATIC int xfsbufd_wakeup(int, unsigned int); 36STATIC int xfsbufd_wakeup(int, gfp_t);
67STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); 37STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
68 38
69STATIC struct workqueue_struct *xfslogd_workqueue; 39STATIC struct workqueue_struct *xfslogd_workqueue;
70STATIC struct workqueue_struct *xfsdatad_workqueue; 40struct workqueue_struct *xfsdatad_workqueue;
71
72/*
73 * Pagebuf debugging
74 */
75 41
76#ifdef PAGEBUF_TRACE 42#ifdef PAGEBUF_TRACE
77void 43void
@@ -111,10 +77,6 @@ ktrace_t *pagebuf_trace_buf;
111# define PB_GET_OWNER(pb) do { } while (0) 77# define PB_GET_OWNER(pb) do { } while (0)
112#endif 78#endif
113 79
114/*
115 * Pagebuf allocation / freeing.
116 */
117
118#define pb_to_gfp(flags) \ 80#define pb_to_gfp(flags) \
119 ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \ 81 ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \
120 ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) 82 ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
@@ -122,7 +84,6 @@ ktrace_t *pagebuf_trace_buf;
122#define pb_to_km(flags) \ 84#define pb_to_km(flags) \
123 (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) 85 (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
124 86
125
126#define pagebuf_allocate(flags) \ 87#define pagebuf_allocate(flags) \
127 kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) 88 kmem_zone_alloc(pagebuf_zone, pb_to_km(flags))
128#define pagebuf_deallocate(pb) \ 89#define pagebuf_deallocate(pb) \
@@ -180,8 +141,9 @@ set_page_region(
180 size_t offset, 141 size_t offset,
181 size_t length) 142 size_t length)
182{ 143{
183 page->private |= page_region_mask(offset, length); 144 set_page_private(page,
184 if (page->private == ~0UL) 145 page_private(page) | page_region_mask(offset, length));
146 if (page_private(page) == ~0UL)
185 SetPageUptodate(page); 147 SetPageUptodate(page);
186} 148}
187 149
@@ -193,7 +155,7 @@ test_page_region(
193{ 155{
194 unsigned long mask = page_region_mask(offset, length); 156 unsigned long mask = page_region_mask(offset, length);
195 157
196 return (mask && (page->private & mask) == mask); 158 return (mask && (page_private(page) & mask) == mask);
197} 159}
198 160
199/* 161/*
@@ -284,7 +246,7 @@ _pagebuf_initialize(
284 * most cases but may be reset (e.g. XFS recovery). 246 * most cases but may be reset (e.g. XFS recovery).
285 */ 247 */
286 pb->pb_buffer_length = pb->pb_count_desired = range_length; 248 pb->pb_buffer_length = pb->pb_count_desired = range_length;
287 pb->pb_flags = flags | PBF_NONE; 249 pb->pb_flags = flags;
288 pb->pb_bn = XFS_BUF_DADDR_NULL; 250 pb->pb_bn = XFS_BUF_DADDR_NULL;
289 atomic_set(&pb->pb_pin_count, 0); 251 atomic_set(&pb->pb_pin_count, 0);
290 init_waitqueue_head(&pb->pb_waiters); 252 init_waitqueue_head(&pb->pb_waiters);
@@ -382,7 +344,7 @@ _pagebuf_lookup_pages(
382 size_t blocksize = bp->pb_target->pbr_bsize; 344 size_t blocksize = bp->pb_target->pbr_bsize;
383 size_t size = bp->pb_count_desired; 345 size_t size = bp->pb_count_desired;
384 size_t nbytes, offset; 346 size_t nbytes, offset;
385 int gfp_mask = pb_to_gfp(flags); 347 gfp_t gfp_mask = pb_to_gfp(flags);
386 unsigned short page_count, i; 348 unsigned short page_count, i;
387 pgoff_t first; 349 pgoff_t first;
388 loff_t end; 350 loff_t end;
@@ -456,14 +418,8 @@ _pagebuf_lookup_pages(
456 unlock_page(bp->pb_pages[i]); 418 unlock_page(bp->pb_pages[i]);
457 } 419 }
458 420
459 if (page_count) { 421 if (page_count == bp->pb_page_count)
460 /* if we have any uptodate pages, mark that in the buffer */ 422 bp->pb_flags |= PBF_DONE;
461 bp->pb_flags &= ~PBF_NONE;
462
463 /* if some pages aren't uptodate, mark that in the buffer */
464 if (page_count != bp->pb_page_count)
465 bp->pb_flags |= PBF_PARTIAL;
466 }
467 423
468 PB_TRACE(bp, "lookup_pages", (long)page_count); 424 PB_TRACE(bp, "lookup_pages", (long)page_count);
469 return error; 425 return error;
@@ -590,8 +546,10 @@ found:
590 PB_SET_OWNER(pb); 546 PB_SET_OWNER(pb);
591 } 547 }
592 548
593 if (pb->pb_flags & PBF_STALE) 549 if (pb->pb_flags & PBF_STALE) {
550 ASSERT((pb->pb_flags & _PBF_DELWRI_Q) == 0);
594 pb->pb_flags &= PBF_MAPPED; 551 pb->pb_flags &= PBF_MAPPED;
552 }
595 PB_TRACE(pb, "got_lock", 0); 553 PB_TRACE(pb, "got_lock", 0);
596 XFS_STATS_INC(pb_get_locked); 554 XFS_STATS_INC(pb_get_locked);
597 return (pb); 555 return (pb);
@@ -672,7 +630,7 @@ xfs_buf_read_flags(
672 630
673 pb = xfs_buf_get_flags(target, ioff, isize, flags); 631 pb = xfs_buf_get_flags(target, ioff, isize, flags);
674 if (pb) { 632 if (pb) {
675 if (PBF_NOT_DONE(pb)) { 633 if (!XFS_BUF_ISDONE(pb)) {
676 PB_TRACE(pb, "read", (unsigned long)flags); 634 PB_TRACE(pb, "read", (unsigned long)flags);
677 XFS_STATS_INC(pb_get_read); 635 XFS_STATS_INC(pb_get_read);
678 pagebuf_iostart(pb, flags); 636 pagebuf_iostart(pb, flags);
@@ -700,25 +658,6 @@ xfs_buf_read_flags(
700} 658}
701 659
702/* 660/*
703 * Create a skeletal pagebuf (no pages associated with it).
704 */
705xfs_buf_t *
706pagebuf_lookup(
707 xfs_buftarg_t *target,
708 loff_t ioff,
709 size_t isize,
710 page_buf_flags_t flags)
711{
712 xfs_buf_t *pb;
713
714 pb = pagebuf_allocate(flags);
715 if (pb) {
716 _pagebuf_initialize(pb, target, ioff, isize, flags);
717 }
718 return pb;
719}
720
721/*
722 * If we are not low on memory then do the readahead in a deadlock 661 * If we are not low on memory then do the readahead in a deadlock
723 * safe manner. 662 * safe manner.
724 */ 663 */
@@ -828,7 +767,7 @@ pagebuf_get_no_daddr(
828 bp = pagebuf_allocate(0); 767 bp = pagebuf_allocate(0);
829 if (unlikely(bp == NULL)) 768 if (unlikely(bp == NULL))
830 goto fail; 769 goto fail;
831 _pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO); 770 _pagebuf_initialize(bp, target, 0, len, 0);
832 771
833 try_again: 772 try_again:
834 data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); 773 data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL);
@@ -891,44 +830,24 @@ pagebuf_rele(
891 830
892 PB_TRACE(pb, "rele", pb->pb_relse); 831 PB_TRACE(pb, "rele", pb->pb_relse);
893 832
894 /*
895 * pagebuf_lookup buffers are not hashed, not delayed write,
896 * and don't have their own release routines. Special case.
897 */
898 if (unlikely(!hash)) {
899 ASSERT(!pb->pb_relse);
900 if (atomic_dec_and_test(&pb->pb_hold))
901 xfs_buf_free(pb);
902 return;
903 }
904
905 if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) { 833 if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) {
906 int do_free = 1;
907
908 if (pb->pb_relse) { 834 if (pb->pb_relse) {
909 atomic_inc(&pb->pb_hold); 835 atomic_inc(&pb->pb_hold);
910 spin_unlock(&hash->bh_lock); 836 spin_unlock(&hash->bh_lock);
911 (*(pb->pb_relse)) (pb); 837 (*(pb->pb_relse)) (pb);
912 spin_lock(&hash->bh_lock);
913 do_free = 0;
914 }
915
916 if (pb->pb_flags & PBF_DELWRI) {
917 pb->pb_flags |= PBF_ASYNC;
918 atomic_inc(&pb->pb_hold);
919 pagebuf_delwri_queue(pb, 0);
920 do_free = 0;
921 } else if (pb->pb_flags & PBF_FS_MANAGED) { 838 } else if (pb->pb_flags & PBF_FS_MANAGED) {
922 do_free = 0;
923 }
924
925 if (do_free) {
926 list_del_init(&pb->pb_hash_list);
927 spin_unlock(&hash->bh_lock); 839 spin_unlock(&hash->bh_lock);
928 pagebuf_free(pb);
929 } else { 840 } else {
841 ASSERT(!(pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)));
842 list_del_init(&pb->pb_hash_list);
930 spin_unlock(&hash->bh_lock); 843 spin_unlock(&hash->bh_lock);
844 pagebuf_free(pb);
931 } 845 }
846 } else {
847 /*
848 * Catch reference count leaks
849 */
850 ASSERT(atomic_read(&pb->pb_hold) >= 0);
932 } 851 }
933} 852}
934 853
@@ -1006,13 +925,24 @@ pagebuf_lock(
1006 * pagebuf_unlock 925 * pagebuf_unlock
1007 * 926 *
1008 * pagebuf_unlock releases the lock on the buffer object created by 927 * pagebuf_unlock releases the lock on the buffer object created by
1009 * pagebuf_lock or pagebuf_cond_lock (not any 928 * pagebuf_lock or pagebuf_cond_lock (not any pinning of underlying pages
1010 * pinning of underlying pages created by pagebuf_pin). 929 * created by pagebuf_pin).
930 *
931 * If the buffer is marked delwri but is not queued, do so before we
932 * unlock the buffer as we need to set flags correctly. We also need to
933 * take a reference for the delwri queue because the unlocker is going to
934 * drop their's and they don't know we just queued it.
1011 */ 935 */
1012void 936void
1013pagebuf_unlock( /* unlock buffer */ 937pagebuf_unlock( /* unlock buffer */
1014 xfs_buf_t *pb) /* buffer to unlock */ 938 xfs_buf_t *pb) /* buffer to unlock */
1015{ 939{
940 if ((pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)) == PBF_DELWRI) {
941 atomic_inc(&pb->pb_hold);
942 pb->pb_flags |= PBF_ASYNC;
943 pagebuf_delwri_queue(pb, 0);
944 }
945
1016 PB_CLEAR_OWNER(pb); 946 PB_CLEAR_OWNER(pb);
1017 up(&pb->pb_sema); 947 up(&pb->pb_sema);
1018 PB_TRACE(pb, "unlock", 0); 948 PB_TRACE(pb, "unlock", 0);
@@ -1124,21 +1054,18 @@ pagebuf_iodone_work(
1124void 1054void
1125pagebuf_iodone( 1055pagebuf_iodone(
1126 xfs_buf_t *pb, 1056 xfs_buf_t *pb,
1127 int dataio,
1128 int schedule) 1057 int schedule)
1129{ 1058{
1130 pb->pb_flags &= ~(PBF_READ | PBF_WRITE); 1059 pb->pb_flags &= ~(PBF_READ | PBF_WRITE);
1131 if (pb->pb_error == 0) { 1060 if (pb->pb_error == 0)
1132 pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE); 1061 pb->pb_flags |= PBF_DONE;
1133 }
1134 1062
1135 PB_TRACE(pb, "iodone", pb->pb_iodone); 1063 PB_TRACE(pb, "iodone", pb->pb_iodone);
1136 1064
1137 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { 1065 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
1138 if (schedule) { 1066 if (schedule) {
1139 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); 1067 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
1140 queue_work(dataio ? xfsdatad_workqueue : 1068 queue_work(xfslogd_workqueue, &pb->pb_iodone_work);
1141 xfslogd_workqueue, &pb->pb_iodone_work);
1142 } else { 1069 } else {
1143 pagebuf_iodone_work(pb); 1070 pagebuf_iodone_work(pb);
1144 } 1071 }
@@ -1238,7 +1165,7 @@ _pagebuf_iodone(
1238{ 1165{
1239 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { 1166 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
1240 pb->pb_locked = 0; 1167 pb->pb_locked = 0;
1241 pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule); 1168 pagebuf_iodone(pb, schedule);
1242 } 1169 }
1243} 1170}
1244 1171
@@ -1249,8 +1176,8 @@ bio_end_io_pagebuf(
1249 int error) 1176 int error)
1250{ 1177{
1251 xfs_buf_t *pb = (xfs_buf_t *)bio->bi_private; 1178 xfs_buf_t *pb = (xfs_buf_t *)bio->bi_private;
1252 unsigned int i, blocksize = pb->pb_target->pbr_bsize; 1179 unsigned int blocksize = pb->pb_target->pbr_bsize;
1253 struct bio_vec *bvec = bio->bi_io_vec; 1180 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
1254 1181
1255 if (bio->bi_size) 1182 if (bio->bi_size)
1256 return 1; 1183 return 1;
@@ -1258,10 +1185,12 @@ bio_end_io_pagebuf(
1258 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 1185 if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
1259 pb->pb_error = EIO; 1186 pb->pb_error = EIO;
1260 1187
1261 for (i = 0; i < bio->bi_vcnt; i++, bvec++) { 1188 do {
1262 struct page *page = bvec->bv_page; 1189 struct page *page = bvec->bv_page;
1263 1190
1264 if (pb->pb_error) { 1191 if (unlikely(pb->pb_error)) {
1192 if (pb->pb_flags & PBF_READ)
1193 ClearPageUptodate(page);
1265 SetPageError(page); 1194 SetPageError(page);
1266 } else if (blocksize == PAGE_CACHE_SIZE) { 1195 } else if (blocksize == PAGE_CACHE_SIZE) {
1267 SetPageUptodate(page); 1196 SetPageUptodate(page);
@@ -1270,10 +1199,13 @@ bio_end_io_pagebuf(
1270 set_page_region(page, bvec->bv_offset, bvec->bv_len); 1199 set_page_region(page, bvec->bv_offset, bvec->bv_len);
1271 } 1200 }
1272 1201
1202 if (--bvec >= bio->bi_io_vec)
1203 prefetchw(&bvec->bv_page->flags);
1204
1273 if (_pagebuf_iolocked(pb)) { 1205 if (_pagebuf_iolocked(pb)) {
1274 unlock_page(page); 1206 unlock_page(page);
1275 } 1207 }
1276 } 1208 } while (bvec >= bio->bi_io_vec);
1277 1209
1278 _pagebuf_iodone(pb, 1); 1210 _pagebuf_iodone(pb, 1);
1279 bio_put(bio); 1211 bio_put(bio);
@@ -1302,6 +1234,11 @@ _pagebuf_ioapply(
1302 rw = (pb->pb_flags & PBF_READ) ? READ : WRITE; 1234 rw = (pb->pb_flags & PBF_READ) ? READ : WRITE;
1303 } 1235 }
1304 1236
1237 if (pb->pb_flags & PBF_ORDERED) {
1238 ASSERT(!(pb->pb_flags & PBF_READ));
1239 rw = WRITE_BARRIER;
1240 }
1241
1305 /* Special code path for reading a sub page size pagebuf in -- 1242 /* Special code path for reading a sub page size pagebuf in --
1306 * we populate up the whole page, and hence the other metadata 1243 * we populate up the whole page, and hence the other metadata
1307 * in the same page. This optimization is only valid when the 1244 * in the same page. This optimization is only valid when the
@@ -1511,6 +1448,11 @@ again:
1511 ASSERT(btp == bp->pb_target); 1448 ASSERT(btp == bp->pb_target);
1512 if (!(bp->pb_flags & PBF_FS_MANAGED)) { 1449 if (!(bp->pb_flags & PBF_FS_MANAGED)) {
1513 spin_unlock(&hash->bh_lock); 1450 spin_unlock(&hash->bh_lock);
1451 /*
1452 * Catch superblock reference count leaks
1453 * immediately
1454 */
1455 BUG_ON(bp->pb_bn == 0);
1514 delay(100); 1456 delay(100);
1515 goto again; 1457 goto again;
1516 } 1458 }
@@ -1686,17 +1628,20 @@ pagebuf_delwri_queue(
1686 int unlock) 1628 int unlock)
1687{ 1629{
1688 PB_TRACE(pb, "delwri_q", (long)unlock); 1630 PB_TRACE(pb, "delwri_q", (long)unlock);
1689 ASSERT(pb->pb_flags & PBF_DELWRI); 1631 ASSERT((pb->pb_flags & (PBF_DELWRI|PBF_ASYNC)) ==
1632 (PBF_DELWRI|PBF_ASYNC));
1690 1633
1691 spin_lock(&pbd_delwrite_lock); 1634 spin_lock(&pbd_delwrite_lock);
1692 /* If already in the queue, dequeue and place at tail */ 1635 /* If already in the queue, dequeue and place at tail */
1693 if (!list_empty(&pb->pb_list)) { 1636 if (!list_empty(&pb->pb_list)) {
1637 ASSERT(pb->pb_flags & _PBF_DELWRI_Q);
1694 if (unlock) { 1638 if (unlock) {
1695 atomic_dec(&pb->pb_hold); 1639 atomic_dec(&pb->pb_hold);
1696 } 1640 }
1697 list_del(&pb->pb_list); 1641 list_del(&pb->pb_list);
1698 } 1642 }
1699 1643
1644 pb->pb_flags |= _PBF_DELWRI_Q;
1700 list_add_tail(&pb->pb_list, &pbd_delwrite_queue); 1645 list_add_tail(&pb->pb_list, &pbd_delwrite_queue);
1701 pb->pb_queuetime = jiffies; 1646 pb->pb_queuetime = jiffies;
1702 spin_unlock(&pbd_delwrite_lock); 1647 spin_unlock(&pbd_delwrite_lock);
@@ -1713,10 +1658,11 @@ pagebuf_delwri_dequeue(
1713 1658
1714 spin_lock(&pbd_delwrite_lock); 1659 spin_lock(&pbd_delwrite_lock);
1715 if ((pb->pb_flags & PBF_DELWRI) && !list_empty(&pb->pb_list)) { 1660 if ((pb->pb_flags & PBF_DELWRI) && !list_empty(&pb->pb_list)) {
1661 ASSERT(pb->pb_flags & _PBF_DELWRI_Q);
1716 list_del_init(&pb->pb_list); 1662 list_del_init(&pb->pb_list);
1717 dequeued = 1; 1663 dequeued = 1;
1718 } 1664 }
1719 pb->pb_flags &= ~PBF_DELWRI; 1665 pb->pb_flags &= ~(PBF_DELWRI|_PBF_DELWRI_Q);
1720 spin_unlock(&pbd_delwrite_lock); 1666 spin_unlock(&pbd_delwrite_lock);
1721 1667
1722 if (dequeued) 1668 if (dequeued)
@@ -1733,16 +1679,14 @@ pagebuf_runall_queues(
1733} 1679}
1734 1680
1735/* Defines for pagebuf daemon */ 1681/* Defines for pagebuf daemon */
1736STATIC DECLARE_COMPLETION(xfsbufd_done);
1737STATIC struct task_struct *xfsbufd_task; 1682STATIC struct task_struct *xfsbufd_task;
1738STATIC int xfsbufd_active;
1739STATIC int xfsbufd_force_flush; 1683STATIC int xfsbufd_force_flush;
1740STATIC int xfsbufd_force_sleep; 1684STATIC int xfsbufd_force_sleep;
1741 1685
1742STATIC int 1686STATIC int
1743xfsbufd_wakeup( 1687xfsbufd_wakeup(
1744 int priority, 1688 int priority,
1745 unsigned int mask) 1689 gfp_t mask)
1746{ 1690{
1747 if (xfsbufd_force_sleep) 1691 if (xfsbufd_force_sleep)
1748 return 0; 1692 return 0;
@@ -1761,14 +1705,8 @@ xfsbufd(
1761 xfs_buftarg_t *target; 1705 xfs_buftarg_t *target;
1762 xfs_buf_t *pb, *n; 1706 xfs_buf_t *pb, *n;
1763 1707
1764 /* Set up the thread */
1765 daemonize("xfsbufd");
1766 current->flags |= PF_MEMALLOC; 1708 current->flags |= PF_MEMALLOC;
1767 1709
1768 xfsbufd_task = current;
1769 xfsbufd_active = 1;
1770 barrier();
1771
1772 INIT_LIST_HEAD(&tmp); 1710 INIT_LIST_HEAD(&tmp);
1773 do { 1711 do {
1774 if (unlikely(freezing(current))) { 1712 if (unlikely(freezing(current))) {
@@ -1778,10 +1716,10 @@ xfsbufd(
1778 xfsbufd_force_sleep = 0; 1716 xfsbufd_force_sleep = 0;
1779 } 1717 }
1780 1718
1781 set_current_state(TASK_INTERRUPTIBLE); 1719 schedule_timeout_interruptible(
1782 schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100); 1720 xfs_buf_timer_centisecs * msecs_to_jiffies(10));
1783 1721
1784 age = (xfs_buf_age_centisecs * HZ) / 100; 1722 age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
1785 spin_lock(&pbd_delwrite_lock); 1723 spin_lock(&pbd_delwrite_lock);
1786 list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) { 1724 list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
1787 PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb)); 1725 PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
@@ -1795,7 +1733,7 @@ xfsbufd(
1795 break; 1733 break;
1796 } 1734 }
1797 1735
1798 pb->pb_flags &= ~PBF_DELWRI; 1736 pb->pb_flags &= ~(PBF_DELWRI|_PBF_DELWRI_Q);
1799 pb->pb_flags |= PBF_WRITE; 1737 pb->pb_flags |= PBF_WRITE;
1800 list_move(&pb->pb_list, &tmp); 1738 list_move(&pb->pb_list, &tmp);
1801 } 1739 }
@@ -1816,9 +1754,9 @@ xfsbufd(
1816 purge_addresses(); 1754 purge_addresses();
1817 1755
1818 xfsbufd_force_flush = 0; 1756 xfsbufd_force_flush = 0;
1819 } while (xfsbufd_active); 1757 } while (!kthread_should_stop());
1820 1758
1821 complete_and_exit(&xfsbufd_done, 0); 1759 return 0;
1822} 1760}
1823 1761
1824/* 1762/*
@@ -1845,15 +1783,13 @@ xfs_flush_buftarg(
1845 if (pb->pb_target != target) 1783 if (pb->pb_target != target)
1846 continue; 1784 continue;
1847 1785
1848 ASSERT(pb->pb_flags & PBF_DELWRI); 1786 ASSERT(pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q));
1849 PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb)); 1787 PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
1850 if (pagebuf_ispin(pb)) { 1788 if (pagebuf_ispin(pb)) {
1851 pincount++; 1789 pincount++;
1852 continue; 1790 continue;
1853 } 1791 }
1854 1792
1855 pb->pb_flags &= ~PBF_DELWRI;
1856 pb->pb_flags |= PBF_WRITE;
1857 list_move(&pb->pb_list, &tmp); 1793 list_move(&pb->pb_list, &tmp);
1858 } 1794 }
1859 spin_unlock(&pbd_delwrite_lock); 1795 spin_unlock(&pbd_delwrite_lock);
@@ -1862,12 +1798,14 @@ xfs_flush_buftarg(
1862 * Dropped the delayed write list lock, now walk the temporary list 1798 * Dropped the delayed write list lock, now walk the temporary list
1863 */ 1799 */
1864 list_for_each_entry_safe(pb, n, &tmp, pb_list) { 1800 list_for_each_entry_safe(pb, n, &tmp, pb_list) {
1801 pagebuf_lock(pb);
1802 pb->pb_flags &= ~(PBF_DELWRI|_PBF_DELWRI_Q);
1803 pb->pb_flags |= PBF_WRITE;
1865 if (wait) 1804 if (wait)
1866 pb->pb_flags &= ~PBF_ASYNC; 1805 pb->pb_flags &= ~PBF_ASYNC;
1867 else 1806 else
1868 list_del_init(&pb->pb_list); 1807 list_del_init(&pb->pb_list);
1869 1808
1870 pagebuf_lock(pb);
1871 pagebuf_iostrategy(pb); 1809 pagebuf_iostrategy(pb);
1872 } 1810 }
1873 1811
@@ -1888,101 +1826,63 @@ xfs_flush_buftarg(
1888 return pincount; 1826 return pincount;
1889} 1827}
1890 1828
1891STATIC int 1829int __init
1892xfs_buf_daemons_start(void) 1830pagebuf_init(void)
1893{ 1831{
1894 int error = -ENOMEM; 1832 int error = -ENOMEM;
1895 1833
1834#ifdef PAGEBUF_TRACE
1835 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
1836#endif
1837
1838 pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
1839 if (!pagebuf_zone)
1840 goto out_free_trace_buf;
1841
1896 xfslogd_workqueue = create_workqueue("xfslogd"); 1842 xfslogd_workqueue = create_workqueue("xfslogd");
1897 if (!xfslogd_workqueue) 1843 if (!xfslogd_workqueue)
1898 goto out; 1844 goto out_free_buf_zone;
1899 1845
1900 xfsdatad_workqueue = create_workqueue("xfsdatad"); 1846 xfsdatad_workqueue = create_workqueue("xfsdatad");
1901 if (!xfsdatad_workqueue) 1847 if (!xfsdatad_workqueue)
1902 goto out_destroy_xfslogd_workqueue; 1848 goto out_destroy_xfslogd_workqueue;
1903 1849
1904 error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES); 1850 xfsbufd_task = kthread_run(xfsbufd, NULL, "xfsbufd");
1905 if (error < 0) 1851 if (IS_ERR(xfsbufd_task)) {
1852 error = PTR_ERR(xfsbufd_task);
1906 goto out_destroy_xfsdatad_workqueue; 1853 goto out_destroy_xfsdatad_workqueue;
1854 }
1855
1856 pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
1857 if (!pagebuf_shake)
1858 goto out_stop_xfsbufd;
1859
1907 return 0; 1860 return 0;
1908 1861
1862 out_stop_xfsbufd:
1863 kthread_stop(xfsbufd_task);
1909 out_destroy_xfsdatad_workqueue: 1864 out_destroy_xfsdatad_workqueue:
1910 destroy_workqueue(xfsdatad_workqueue); 1865 destroy_workqueue(xfsdatad_workqueue);
1911 out_destroy_xfslogd_workqueue: 1866 out_destroy_xfslogd_workqueue:
1912 destroy_workqueue(xfslogd_workqueue); 1867 destroy_workqueue(xfslogd_workqueue);
1913 out:
1914 return error;
1915}
1916
1917/*
1918 * Note: do not mark as __exit, it is called from pagebuf_terminate.
1919 */
1920STATIC void
1921xfs_buf_daemons_stop(void)
1922{
1923 xfsbufd_active = 0;
1924 barrier();
1925 wait_for_completion(&xfsbufd_done);
1926
1927 destroy_workqueue(xfslogd_workqueue);
1928 destroy_workqueue(xfsdatad_workqueue);
1929}
1930
1931/*
1932 * Initialization and Termination
1933 */
1934
1935int __init
1936pagebuf_init(void)
1937{
1938 int error = -ENOMEM;
1939
1940 pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
1941 if (!pagebuf_zone)
1942 goto out;
1943
1944#ifdef PAGEBUF_TRACE
1945 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
1946#endif
1947
1948 error = xfs_buf_daemons_start();
1949 if (error)
1950 goto out_free_buf_zone;
1951
1952 pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
1953 if (!pagebuf_shake) {
1954 error = -ENOMEM;
1955 goto out_stop_daemons;
1956 }
1957
1958 return 0;
1959
1960 out_stop_daemons:
1961 xfs_buf_daemons_stop();
1962 out_free_buf_zone: 1868 out_free_buf_zone:
1869 kmem_zone_destroy(pagebuf_zone);
1870 out_free_trace_buf:
1963#ifdef PAGEBUF_TRACE 1871#ifdef PAGEBUF_TRACE
1964 ktrace_free(pagebuf_trace_buf); 1872 ktrace_free(pagebuf_trace_buf);
1965#endif 1873#endif
1966 kmem_zone_destroy(pagebuf_zone);
1967 out:
1968 return error; 1874 return error;
1969} 1875}
1970 1876
1971
1972/*
1973 * pagebuf_terminate.
1974 *
1975 * Note: do not mark as __exit, this is also called from the __init code.
1976 */
1977void 1877void
1978pagebuf_terminate(void) 1878pagebuf_terminate(void)
1979{ 1879{
1980 xfs_buf_daemons_stop(); 1880 kmem_shake_deregister(pagebuf_shake);
1981 1881 kthread_stop(xfsbufd_task);
1882 destroy_workqueue(xfsdatad_workqueue);
1883 destroy_workqueue(xfslogd_workqueue);
1884 kmem_zone_destroy(pagebuf_zone);
1982#ifdef PAGEBUF_TRACE 1885#ifdef PAGEBUF_TRACE
1983 ktrace_free(pagebuf_trace_buf); 1886 ktrace_free(pagebuf_trace_buf);
1984#endif 1887#endif
1985
1986 kmem_zone_destroy(pagebuf_zone);
1987 kmem_shake_deregister(pagebuf_shake);
1988} 1888}
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 3f8f69a66aea..237a35b915d1 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -1,39 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI
35 */ 17 */
36
37#ifndef __XFS_BUF_H__ 18#ifndef __XFS_BUF_H__
38#define __XFS_BUF_H__ 19#define __XFS_BUF_H__
39 20
@@ -69,15 +50,12 @@ typedef enum page_buf_flags_e { /* pb_flags values */
69 PBF_READ = (1 << 0), /* buffer intended for reading from device */ 50 PBF_READ = (1 << 0), /* buffer intended for reading from device */
70 PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ 51 PBF_WRITE = (1 << 1), /* buffer intended for writing to device */
71 PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ 52 PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */
72 PBF_PARTIAL = (1 << 3), /* buffer partially read */
73 PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ 53 PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */
74 PBF_NONE = (1 << 5), /* buffer not read at all */ 54 PBF_DONE = (1 << 5), /* all pages in the buffer uptodate */
75 PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ 55 PBF_DELWRI = (1 << 6), /* buffer has dirty pages */
76 PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ 56 PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */
77 PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ 57 PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */
78 PBF_FS_DATAIOD = (1 << 9), /* schedule IO completion on fs datad */ 58 PBF_ORDERED = (1 << 11), /* use ordered writes */
79 PBF_FORCEIO = (1 << 10), /* ignore any cache state */
80 PBF_FLUSH = (1 << 11), /* flush disk write cache */
81 PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ 59 PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
82 60
83 /* flags used only as arguments to access routines */ 61 /* flags used only as arguments to access routines */
@@ -89,11 +67,9 @@ typedef enum page_buf_flags_e { /* pb_flags values */
89 _PBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */ 67 _PBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */
90 _PBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */ 68 _PBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */
91 _PBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ 69 _PBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
70 _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
92} page_buf_flags_t; 71} page_buf_flags_t;
93 72
94#define PBF_UPDATE (PBF_READ | PBF_WRITE)
95#define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
96#define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
97 73
98typedef struct xfs_bufhash { 74typedef struct xfs_bufhash {
99 struct list_head bh_list; 75 struct list_head bh_list;
@@ -206,13 +182,6 @@ extern xfs_buf_t *xfs_buf_read_flags( /* allocate and read a buffer */
206#define xfs_buf_read(target, blkno, len, flags) \ 182#define xfs_buf_read(target, blkno, len, flags) \
207 xfs_buf_read_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED) 183 xfs_buf_read_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED)
208 184
209extern xfs_buf_t *pagebuf_lookup(
210 xfs_buftarg_t *,
211 loff_t, /* starting offset of range */
212 size_t, /* length of range */
213 page_buf_flags_t); /* PBF_READ, PBF_WRITE, */
214 /* PBF_FORCEIO, */
215
216extern xfs_buf_t *pagebuf_get_empty( /* allocate pagebuf struct with */ 185extern xfs_buf_t *pagebuf_get_empty( /* allocate pagebuf struct with */
217 /* no memory or disk address */ 186 /* no memory or disk address */
218 size_t len, 187 size_t len,
@@ -264,7 +233,6 @@ extern void pagebuf_unlock( /* unlock buffer */
264 233
265extern void pagebuf_iodone( /* mark buffer I/O complete */ 234extern void pagebuf_iodone( /* mark buffer I/O complete */
266 xfs_buf_t *, /* buffer to mark */ 235 xfs_buf_t *, /* buffer to mark */
267 int, /* use data/log helper thread. */
268 int); /* run completion locally, or in 236 int); /* run completion locally, or in
269 * a helper thread. */ 237 * a helper thread. */
270 238
@@ -344,8 +312,6 @@ extern void pagebuf_trace(
344 312
345 313
346 314
347
348
349/* These are just for xfs_syncsub... it sets an internal variable 315/* These are just for xfs_syncsub... it sets an internal variable
350 * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t 316 * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t
351 */ 317 */
@@ -386,21 +352,21 @@ extern void pagebuf_trace(
386#define XFS_BUF_GETERROR(x) pagebuf_geterror(x) 352#define XFS_BUF_GETERROR(x) pagebuf_geterror(x)
387#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) 353#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0)
388 354
389#define XFS_BUF_DONE(x) ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE)) 355#define XFS_BUF_DONE(x) ((x)->pb_flags |= PBF_DONE)
390#define XFS_BUF_UNDONE(x) ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE) 356#define XFS_BUF_UNDONE(x) ((x)->pb_flags &= ~PBF_DONE)
391#define XFS_BUF_ISDONE(x) (!(PBF_NOT_DONE(x))) 357#define XFS_BUF_ISDONE(x) ((x)->pb_flags & PBF_DONE)
392 358
393#define XFS_BUF_BUSY(x) ((x)->pb_flags |= PBF_FORCEIO) 359#define XFS_BUF_BUSY(x) do { } while (0)
394#define XFS_BUF_UNBUSY(x) ((x)->pb_flags &= ~PBF_FORCEIO) 360#define XFS_BUF_UNBUSY(x) do { } while (0)
395#define XFS_BUF_ISBUSY(x) (1) 361#define XFS_BUF_ISBUSY(x) (1)
396 362
397#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC) 363#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC)
398#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC) 364#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC)
399#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC) 365#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC)
400 366
401#define XFS_BUF_FLUSH(x) ((x)->pb_flags |= PBF_FLUSH) 367#define XFS_BUF_ORDERED(x) ((x)->pb_flags |= PBF_ORDERED)
402#define XFS_BUF_UNFLUSH(x) ((x)->pb_flags &= ~PBF_FLUSH) 368#define XFS_BUF_UNORDERED(x) ((x)->pb_flags &= ~PBF_ORDERED)
403#define XFS_BUF_ISFLUSH(x) ((x)->pb_flags & PBF_FLUSH) 369#define XFS_BUF_ISORDERED(x) ((x)->pb_flags & PBF_ORDERED)
404 370
405#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n") 371#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n")
406#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n") 372#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n")
@@ -420,9 +386,6 @@ extern void pagebuf_trace(
420 386
421#define XFS_BUF_BP_ISMAPPED(bp) 1 387#define XFS_BUF_BP_ISMAPPED(bp) 1
422 388
423#define XFS_BUF_DATAIO(x) ((x)->pb_flags |= PBF_FS_DATAIOD)
424#define XFS_BUF_UNDATAIO(x) ((x)->pb_flags &= ~PBF_FS_DATAIOD)
425
426#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone 389#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone
427#define XFS_BUF_SET_IODONE_FUNC(buf, func) \ 390#define XFS_BUF_SET_IODONE_FUNC(buf, func) \
428 (buf)->pb_iodone = (func) 391 (buf)->pb_iodone = (func)
@@ -452,7 +415,7 @@ extern void pagebuf_trace(
452 415
453#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->pb_addr) 416#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->pb_addr)
454 417
455extern inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset) 418static inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset)
456{ 419{
457 if (bp->pb_flags & PBF_MAPPED) 420 if (bp->pb_flags & PBF_MAPPED)
458 return XFS_BUF_PTR(bp) + offset; 421 return XFS_BUF_PTR(bp) + offset;
@@ -518,7 +481,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
518 pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) 481 pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
519 482
520#define xfs_biodone(pb) \ 483#define xfs_biodone(pb) \
521 pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0) 484 pagebuf_iodone(pb, 0)
522 485
523#define xfs_biomove(pb, off, len, data, rw) \ 486#define xfs_biomove(pb, off, len, data, rw) \
524 pagebuf_iomove((pb), (off), (len), (data), \ 487 pagebuf_iomove((pb), (off), (len), (data), \
diff --git a/fs/xfs/linux-2.6/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h
index 00c45849d41a..4af491024727 100644
--- a/fs/xfs/linux-2.6/xfs_cred.h
+++ b/fs/xfs/linux-2.6/xfs_cred.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_CRED_H__ 18#ifndef __XFS_CRED_H__
33#define __XFS_CRED_H__ 19#define __XFS_CRED_H__
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index f372a1a5e168..80eb249f2fa0 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_types.h" 19#include "xfs_types.h"
35#include "xfs_dmapi.h" 20#include "xfs_dmapi.h"
@@ -41,7 +26,7 @@
41#include "xfs_export.h" 26#include "xfs_export.h"
42 27
43/* 28/*
44 * XFS encode and decodes the fileid portion of NFS filehandles 29 * XFS encodes and decodes the fileid portion of NFS filehandles
45 * itself instead of letting the generic NFS code do it. This 30 * itself instead of letting the generic NFS code do it. This
46 * allows filesystems with 64 bit inode numbers to be exported. 31 * allows filesystems with 64 bit inode numbers to be exported.
47 * 32 *
@@ -51,7 +36,6 @@
51 * remains in that code. 36 * remains in that code.
52 */ 37 */
53 38
54
55STATIC struct dentry * 39STATIC struct dentry *
56linvfs_decode_fh( 40linvfs_decode_fh(
57 struct super_block *sb, 41 struct super_block *sb,
@@ -92,7 +76,7 @@ linvfs_decode_fh(
92 p = xfs_fileid_decode_fid2(p, &pfid, is64); 76 p = xfs_fileid_decode_fid2(p, &pfid, is64);
93 parent = &pfid; 77 parent = &pfid;
94 } 78 }
95 79
96 fh = (__u32 *)&ifid; 80 fh = (__u32 *)&ifid;
97 return find_exported_dentry(sb, fh, parent, acceptable, context); 81 return find_exported_dentry(sb, fh, parent, acceptable, context);
98} 82}
@@ -112,9 +96,8 @@ linvfs_encode_fh(
112 int is64 = 0; 96 int is64 = 0;
113#if XFS_BIG_INUMS 97#if XFS_BIG_INUMS
114 vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); 98 vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb);
115 xfs_mount_t *mp = XFS_VFSTOM(vfs); 99
116 100 if (!(vfs->vfs_flag & VFS_32BITINODES)) {
117 if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) {
118 /* filesystem may contain 64bit inode numbers */ 101 /* filesystem may contain 64bit inode numbers */
119 is64 = XFS_FILEID_TYPE_64FLAG; 102 is64 = XFS_FILEID_TYPE_64FLAG;
120 } 103 }
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/linux-2.6/xfs_export.h
index 60b2abac1c18..e5b0559700a4 100644
--- a/fs/xfs/linux-2.6/xfs_export.h
+++ b/fs/xfs/linux-2.6/xfs_export.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_EXPORT_H__ 18#ifndef __XFS_EXPORT_H__
33#define __XFS_EXPORT_H__ 19#define __XFS_EXPORT_H__
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index f1ce4323f56e..06111d0bbae4 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -1,39 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_inum.h" 19#include "xfs_bit.h"
35#include "xfs_log.h" 20#include "xfs_log.h"
21#include "xfs_inum.h"
36#include "xfs_sb.h" 22#include "xfs_sb.h"
23#include "xfs_ag.h"
37#include "xfs_dir.h" 24#include "xfs_dir.h"
38#include "xfs_dir2.h" 25#include "xfs_dir2.h"
39#include "xfs_trans.h" 26#include "xfs_trans.h"
@@ -311,6 +298,31 @@ linvfs_fsync(
311 298
312#define nextdp(dp) ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen)) 299#define nextdp(dp) ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen))
313 300
301#ifdef CONFIG_XFS_DMAPI
302
303STATIC struct page *
304linvfs_filemap_nopage(
305 struct vm_area_struct *area,
306 unsigned long address,
307 int *type)
308{
309 struct inode *inode = area->vm_file->f_dentry->d_inode;
310 vnode_t *vp = LINVFS_GET_VP(inode);
311 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
312 int error;
313
314 ASSERT_ALWAYS(vp->v_vfsp->vfs_flag & VFS_DMI);
315
316 error = XFS_SEND_MMAP(mp, area, 0);
317 if (error)
318 return NULL;
319
320 return filemap_nopage(area, address, type);
321}
322
323#endif /* CONFIG_XFS_DMAPI */
324
325
314STATIC int 326STATIC int
315linvfs_readdir( 327linvfs_readdir(
316 struct file *filp, 328 struct file *filp,
@@ -390,14 +402,6 @@ done:
390 return -error; 402 return -error;
391} 403}
392 404
393#ifdef CONFIG_XFS_DMAPI
394STATIC void
395linvfs_mmap_close(
396 struct vm_area_struct *vma)
397{
398 xfs_dm_mm_put(vma);
399}
400#endif /* CONFIG_XFS_DMAPI */
401 405
402STATIC int 406STATIC int
403linvfs_file_mmap( 407linvfs_file_mmap(
@@ -411,16 +415,11 @@ linvfs_file_mmap(
411 415
412 vma->vm_ops = &linvfs_file_vm_ops; 416 vma->vm_ops = &linvfs_file_vm_ops;
413 417
414 if (vp->v_vfsp->vfs_flag & VFS_DMI) {
415 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
416
417 error = -XFS_SEND_MMAP(mp, vma, 0);
418 if (error)
419 return error;
420#ifdef CONFIG_XFS_DMAPI 418#ifdef CONFIG_XFS_DMAPI
419 if (vp->v_vfsp->vfs_flag & VFS_DMI) {
421 vma->vm_ops = &linvfs_dmapi_file_vm_ops; 420 vma->vm_ops = &linvfs_dmapi_file_vm_ops;
422#endif
423 } 421 }
422#endif /* CONFIG_XFS_DMAPI */
424 423
425 VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error); 424 VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
426 if (!error) 425 if (!error)
@@ -474,6 +473,7 @@ linvfs_ioctl_invis(
474 return error; 473 return error;
475} 474}
476 475
476#ifdef CONFIG_XFS_DMAPI
477#ifdef HAVE_VMOP_MPROTECT 477#ifdef HAVE_VMOP_MPROTECT
478STATIC int 478STATIC int
479linvfs_mprotect( 479linvfs_mprotect(
@@ -494,6 +494,7 @@ linvfs_mprotect(
494 return error; 494 return error;
495} 495}
496#endif /* HAVE_VMOP_MPROTECT */ 496#endif /* HAVE_VMOP_MPROTECT */
497#endif /* CONFIG_XFS_DMAPI */
497 498
498#ifdef HAVE_FOP_OPEN_EXEC 499#ifdef HAVE_FOP_OPEN_EXEC
499/* If the user is attempting to execute a file that is offline then 500/* If the user is attempting to execute a file that is offline then
@@ -528,49 +529,10 @@ open_exec_out:
528} 529}
529#endif /* HAVE_FOP_OPEN_EXEC */ 530#endif /* HAVE_FOP_OPEN_EXEC */
530 531
531/*
532 * Temporary workaround to the AIO direct IO write problem.
533 * This code can go and we can revert to do_sync_write once
534 * the writepage(s) rework is merged.
535 */
536STATIC ssize_t
537linvfs_write(
538 struct file *filp,
539 const char __user *buf,
540 size_t len,
541 loff_t *ppos)
542{
543 struct kiocb kiocb;
544 ssize_t ret;
545
546 init_sync_kiocb(&kiocb, filp);
547 kiocb.ki_pos = *ppos;
548 ret = __linvfs_write(&kiocb, buf, 0, len, kiocb.ki_pos);
549 *ppos = kiocb.ki_pos;
550 return ret;
551}
552STATIC ssize_t
553linvfs_write_invis(
554 struct file *filp,
555 const char __user *buf,
556 size_t len,
557 loff_t *ppos)
558{
559 struct kiocb kiocb;
560 ssize_t ret;
561
562 init_sync_kiocb(&kiocb, filp);
563 kiocb.ki_pos = *ppos;
564 ret = __linvfs_write(&kiocb, buf, IO_INVIS, len, kiocb.ki_pos);
565 *ppos = kiocb.ki_pos;
566 return ret;
567}
568
569
570struct file_operations linvfs_file_operations = { 532struct file_operations linvfs_file_operations = {
571 .llseek = generic_file_llseek, 533 .llseek = generic_file_llseek,
572 .read = do_sync_read, 534 .read = do_sync_read,
573 .write = linvfs_write, 535 .write = do_sync_write,
574 .readv = linvfs_readv, 536 .readv = linvfs_readv,
575 .writev = linvfs_writev, 537 .writev = linvfs_writev,
576 .aio_read = linvfs_aio_read, 538 .aio_read = linvfs_aio_read,
@@ -592,7 +554,7 @@ struct file_operations linvfs_file_operations = {
592struct file_operations linvfs_invis_file_operations = { 554struct file_operations linvfs_invis_file_operations = {
593 .llseek = generic_file_llseek, 555 .llseek = generic_file_llseek,
594 .read = do_sync_read, 556 .read = do_sync_read,
595 .write = linvfs_write_invis, 557 .write = do_sync_write,
596 .readv = linvfs_readv_invis, 558 .readv = linvfs_readv_invis,
597 .writev = linvfs_writev_invis, 559 .writev = linvfs_writev_invis,
598 .aio_read = linvfs_aio_read_invis, 560 .aio_read = linvfs_aio_read_invis,
@@ -626,8 +588,7 @@ static struct vm_operations_struct linvfs_file_vm_ops = {
626 588
627#ifdef CONFIG_XFS_DMAPI 589#ifdef CONFIG_XFS_DMAPI
628static struct vm_operations_struct linvfs_dmapi_file_vm_ops = { 590static struct vm_operations_struct linvfs_dmapi_file_vm_ops = {
629 .close = linvfs_mmap_close, 591 .nopage = linvfs_filemap_nopage,
630 .nopage = filemap_nopage,
631 .populate = filemap_populate, 592 .populate = filemap_populate,
632#ifdef HAVE_VMOP_MPROTECT 593#ifdef HAVE_VMOP_MPROTECT
633 .mprotect = linvfs_mprotect, 594 .mprotect = linvfs_mprotect,
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 05ebd30ec96f..f89340c61bf2 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32 18
33#include "xfs.h" 19#include "xfs.h"
@@ -117,6 +103,8 @@ fs_flush_pages(
117 103
118 if (VN_CACHED(vp)) { 104 if (VN_CACHED(vp)) {
119 filemap_fdatawrite(ip->i_mapping); 105 filemap_fdatawrite(ip->i_mapping);
106 if (flags & XFS_B_ASYNC)
107 return 0;
120 filemap_fdatawait(ip->i_mapping); 108 filemap_fdatawait(ip->i_mapping);
121 } 109 }
122 110
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.h b/fs/xfs/linux-2.6/xfs_fs_subr.h
index 2db9ddbd4567..aee9ccdd18f7 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.h
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.h
@@ -1,48 +1,29 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_SUBR_H__
33#define __XFS_SUBR_H__
34
35/*
36 * Utilities shared among file system implementations.
37 */ 17 */
18#ifndef __XFS_FS_SUBR_H__
19#define __XFS_FS_SUBR_H__
38 20
39struct cred; 21struct cred;
40 22extern int fs_noerr(void);
41extern int fs_noerr(void); 23extern int fs_nosys(void);
42extern int fs_nosys(void); 24extern void fs_noval(void);
43extern void fs_noval(void); 25extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
44extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); 26extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
45extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); 27extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
46extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
47 28
48#endif /* __XFS_FS_SUBR_H__ */ 29#endif /* __XFS_FS_SUBR_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/linux-2.6/xfs_globals.c
index a6da5b4fd240..6e8085f34635 100644
--- a/fs/xfs/linux-2.6/xfs_globals.c
+++ b/fs/xfs/linux-2.6/xfs_globals.c
@@ -1,40 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * This file contains globals needed by XFS that were normally defined
35 * somewhere else in IRIX.
36 */
37
38#include "xfs.h" 18#include "xfs.h"
39#include "xfs_cred.h" 19#include "xfs_cred.h"
40#include "xfs_sysctl.h" 20#include "xfs_sysctl.h"
diff --git a/fs/xfs/linux-2.6/xfs_globals.h b/fs/xfs/linux-2.6/xfs_globals.h
index e81e2f38a853..e1a22bfcf865 100644
--- a/fs/xfs/linux-2.6/xfs_globals.h
+++ b/fs/xfs/linux-2.6/xfs_globals.h
@@ -1,42 +1,23 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_GLOBALS_H__ 18#ifndef __XFS_GLOBALS_H__
33#define __XFS_GLOBALS_H__ 19#define __XFS_GLOBALS_H__
34 20
35/*
36 * This file declares globals needed by XFS that were normally defined
37 * somewhere else in IRIX.
38 */
39
40extern uint64_t xfs_panic_mask; /* set to cause more panics */ 21extern uint64_t xfs_panic_mask; /* set to cause more panics */
41extern unsigned long xfs_physmem; 22extern unsigned long xfs_physmem;
42extern struct cred *sys_cred; 23extern struct cred *sys_cred;
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 05a447e51cc0..b78b5eb9e96c 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -1,67 +1,52 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34
35#include "xfs_fs.h" 19#include "xfs_fs.h"
36#include "xfs_inum.h" 20#include "xfs_bit.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
40#include "xfs_dir.h" 26#include "xfs_dir.h"
41#include "xfs_dir2.h" 27#include "xfs_dir2.h"
42#include "xfs_alloc.h" 28#include "xfs_alloc.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_ialloc.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
35#include "xfs_attr_sf.h"
52#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
53#include "xfs_dinode.h" 37#include "xfs_dinode.h"
54#include "xfs_inode.h" 38#include "xfs_inode.h"
55#include "xfs_bmap.h" 39#include "xfs_btree.h"
56#include "xfs_bit.h" 40#include "xfs_ialloc.h"
57#include "xfs_rtalloc.h" 41#include "xfs_rtalloc.h"
58#include "xfs_error.h"
59#include "xfs_itable.h" 42#include "xfs_itable.h"
43#include "xfs_error.h"
60#include "xfs_rw.h" 44#include "xfs_rw.h"
61#include "xfs_acl.h" 45#include "xfs_acl.h"
62#include "xfs_cap.h" 46#include "xfs_cap.h"
63#include "xfs_mac.h" 47#include "xfs_mac.h"
64#include "xfs_attr.h" 48#include "xfs_attr.h"
49#include "xfs_bmap.h"
65#include "xfs_buf_item.h" 50#include "xfs_buf_item.h"
66#include "xfs_utils.h" 51#include "xfs_utils.h"
67#include "xfs_dfrag.h" 52#include "xfs_dfrag.h"
@@ -141,13 +126,19 @@ xfs_find_handle(
141 return -XFS_ERROR(EINVAL); 126 return -XFS_ERROR(EINVAL);
142 } 127 }
143 128
144 /* we need the vnode */ 129 switch (inode->i_mode & S_IFMT) {
145 vp = LINVFS_GET_VP(inode); 130 case S_IFREG:
146 if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) { 131 case S_IFDIR:
132 case S_IFLNK:
133 break;
134 default:
147 iput(inode); 135 iput(inode);
148 return -XFS_ERROR(EBADF); 136 return -XFS_ERROR(EBADF);
149 } 137 }
150 138
139 /* we need the vnode */
140 vp = LINVFS_GET_VP(inode);
141
151 /* now we can grab the fsid */ 142 /* now we can grab the fsid */
152 memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t)); 143 memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
153 hsize = sizeof(xfs_fsid_t); 144 hsize = sizeof(xfs_fsid_t);
@@ -386,7 +377,7 @@ xfs_readlink_by_handle(
386 return -error; 377 return -error;
387 378
388 /* Restrict this handle operation to symlinks only. */ 379 /* Restrict this handle operation to symlinks only. */
389 if (vp->v_type != VLNK) { 380 if (!S_ISLNK(inode->i_mode)) {
390 VN_RELE(vp); 381 VN_RELE(vp);
391 return -XFS_ERROR(EINVAL); 382 return -XFS_ERROR(EINVAL);
392 } 383 }
@@ -982,10 +973,10 @@ xfs_ioc_space(
982 if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND)) 973 if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
983 return -XFS_ERROR(EPERM); 974 return -XFS_ERROR(EPERM);
984 975
985 if (!(filp->f_flags & FMODE_WRITE)) 976 if (!(filp->f_mode & FMODE_WRITE))
986 return -XFS_ERROR(EBADF); 977 return -XFS_ERROR(EBADF);
987 978
988 if (vp->v_type != VREG) 979 if (!VN_ISREG(vp))
989 return -XFS_ERROR(EINVAL); 980 return -XFS_ERROR(EINVAL);
990 981
991 if (copy_from_user(&bf, arg, sizeof(bf))) 982 if (copy_from_user(&bf, arg, sizeof(bf)))
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 0f8f1384eb36..c83ae15bb0e6 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <linux/config.h> 18#include <linux/config.h>
34#include <linux/compat.h> 19#include <linux/compat.h>
35#include <linux/init.h> 20#include <linux/init.h>
@@ -39,7 +24,6 @@
39#include <linux/types.h> 24#include <linux/types.h>
40#include <linux/fs.h> 25#include <linux/fs.h>
41#include <asm/uaccess.h> 26#include <asm/uaccess.h>
42
43#include "xfs.h" 27#include "xfs.h"
44#include "xfs_types.h" 28#include "xfs_types.h"
45#include "xfs_fs.h" 29#include "xfs_fs.h"
@@ -47,8 +31,52 @@
47#include "xfs_vnode.h" 31#include "xfs_vnode.h"
48#include "xfs_dfrag.h" 32#include "xfs_dfrag.h"
49 33
34#define _NATIVE_IOC(cmd, type) \
35 _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type))
36
50#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) 37#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
51#define BROKEN_X86_ALIGNMENT 38#define BROKEN_X86_ALIGNMENT
39/* on ia32 l_start is on a 32-bit boundary */
40typedef struct xfs_flock64_32 {
41 __s16 l_type;
42 __s16 l_whence;
43 __s64 l_start __attribute__((packed));
44 /* len == 0 means until end of file */
45 __s64 l_len __attribute__((packed));
46 __s32 l_sysid;
47 __u32 l_pid;
48 __s32 l_pad[4]; /* reserve area */
49} xfs_flock64_32_t;
50
51#define XFS_IOC_ALLOCSP_32 _IOW ('X', 10, struct xfs_flock64_32)
52#define XFS_IOC_FREESP_32 _IOW ('X', 11, struct xfs_flock64_32)
53#define XFS_IOC_ALLOCSP64_32 _IOW ('X', 36, struct xfs_flock64_32)
54#define XFS_IOC_FREESP64_32 _IOW ('X', 37, struct xfs_flock64_32)
55#define XFS_IOC_RESVSP_32 _IOW ('X', 40, struct xfs_flock64_32)
56#define XFS_IOC_UNRESVSP_32 _IOW ('X', 41, struct xfs_flock64_32)
57#define XFS_IOC_RESVSP64_32 _IOW ('X', 42, struct xfs_flock64_32)
58#define XFS_IOC_UNRESVSP64_32 _IOW ('X', 43, struct xfs_flock64_32)
59
60/* just account for different alignment */
61STATIC unsigned long
62xfs_ioctl32_flock(
63 unsigned long arg)
64{
65 xfs_flock64_32_t __user *p32 = (void __user *)arg;
66 xfs_flock64_t __user *p = compat_alloc_user_space(sizeof(*p));
67
68 if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
69 copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
70 copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
71 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
72 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
73 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
74 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
75 return -EFAULT;
76
77 return (unsigned long)p;
78}
79
52#else 80#else
53 81
54typedef struct xfs_fsop_bulkreq32 { 82typedef struct xfs_fsop_bulkreq32 {
@@ -103,7 +131,6 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
103/* not handled 131/* not handled
104 case XFS_IOC_FD_TO_HANDLE: 132 case XFS_IOC_FD_TO_HANDLE:
105 case XFS_IOC_PATH_TO_HANDLE: 133 case XFS_IOC_PATH_TO_HANDLE:
106 case XFS_IOC_PATH_TO_HANDLE:
107 case XFS_IOC_PATH_TO_FSHANDLE: 134 case XFS_IOC_PATH_TO_FSHANDLE:
108 case XFS_IOC_OPEN_BY_HANDLE: 135 case XFS_IOC_OPEN_BY_HANDLE:
109 case XFS_IOC_FSSETDM_BY_HANDLE: 136 case XFS_IOC_FSSETDM_BY_HANDLE:
@@ -124,8 +151,21 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
124 case XFS_IOC_ERROR_CLEARALL: 151 case XFS_IOC_ERROR_CLEARALL:
125 break; 152 break;
126 153
127#ifndef BROKEN_X86_ALIGNMENT 154#ifdef BROKEN_X86_ALIGNMENT
128 /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */ 155 /* xfs_flock_t has wrong u32 vs u64 alignment */
156 case XFS_IOC_ALLOCSP_32:
157 case XFS_IOC_FREESP_32:
158 case XFS_IOC_ALLOCSP64_32:
159 case XFS_IOC_FREESP64_32:
160 case XFS_IOC_RESVSP_32:
161 case XFS_IOC_UNRESVSP_32:
162 case XFS_IOC_RESVSP64_32:
163 case XFS_IOC_UNRESVSP64_32:
164 arg = xfs_ioctl32_flock(arg);
165 cmd = _NATIVE_IOC(cmd, struct xfs_flock64);
166 break;
167
168#else /* These are handled fine if no alignment issues */
129 case XFS_IOC_ALLOCSP: 169 case XFS_IOC_ALLOCSP:
130 case XFS_IOC_FREESP: 170 case XFS_IOC_FREESP:
131 case XFS_IOC_RESVSP: 171 case XFS_IOC_RESVSP:
@@ -134,6 +174,9 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
134 case XFS_IOC_FREESP64: 174 case XFS_IOC_FREESP64:
135 case XFS_IOC_RESVSP64: 175 case XFS_IOC_RESVSP64:
136 case XFS_IOC_UNRESVSP64: 176 case XFS_IOC_UNRESVSP64:
177 break;
178
179 /* xfs_bstat_t still has wrong u32 vs u64 alignment */
137 case XFS_IOC_SWAPEXT: 180 case XFS_IOC_SWAPEXT:
138 break; 181 break;
139 182
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h
index c874793a1dc9..011c273bec50 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.h
@@ -1,34 +1,24 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
18#ifndef __XFS_IOCTL32_H__
19#define __XFS_IOCTL32_H__
20
21extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long);
22extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long);
32 23
33long linvfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); 24#endif /* __XFS_IOCTL32_H__ */
34long linvfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 407e99359391..14215a7db59f 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,18 +29,17 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
56#include "xfs_bmap.h" 40#include "xfs_bmap.h"
57#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -69,6 +54,137 @@
69#include <linux/xattr.h> 54#include <linux/xattr.h>
70#include <linux/namei.h> 55#include <linux/namei.h>
71 56
57/*
58 * Change the requested timestamp in the given inode.
59 * We don't lock across timestamp updates, and we don't log them but
60 * we do record the fact that there is dirty information in core.
61 *
62 * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
63 * with XFS_ICHGTIME_ACC to be sure that access time
64 * update will take. Calling first with XFS_ICHGTIME_ACC
65 * and then XFS_ICHGTIME_MOD may fail to modify the access
66 * timestamp if the filesystem is mounted noacctm.
67 */
68void
69xfs_ichgtime(
70 xfs_inode_t *ip,
71 int flags)
72{
73 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
74 timespec_t tv;
75
76 /*
77 * We're not supposed to change timestamps in readonly-mounted
78 * filesystems. Throw it away if anyone asks us.
79 */
80 if (unlikely(IS_RDONLY(inode)))
81 return;
82
83 /*
84 * Don't update access timestamps on reads if mounted "noatime".
85 * Throw it away if anyone asks us.
86 */
87 if (unlikely(
88 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
89 (flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
90 XFS_ICHGTIME_ACC))
91 return;
92
93 nanotime(&tv);
94 if (flags & XFS_ICHGTIME_MOD) {
95 inode->i_mtime = tv;
96 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
97 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
98 }
99 if (flags & XFS_ICHGTIME_ACC) {
100 inode->i_atime = tv;
101 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
102 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
103 }
104 if (flags & XFS_ICHGTIME_CHG) {
105 inode->i_ctime = tv;
106 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
107 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
108 }
109
110 /*
111 * We update the i_update_core field _after_ changing
112 * the timestamps in order to coordinate properly with
113 * xfs_iflush() so that we don't lose timestamp updates.
114 * This keeps us from having to hold the inode lock
115 * while doing this. We use the SYNCHRONIZE macro to
116 * ensure that the compiler does not reorder the update
117 * of i_update_core above the timestamp updates above.
118 */
119 SYNCHRONIZE();
120 ip->i_update_core = 1;
121 if (!(inode->i_state & I_LOCK))
122 mark_inode_dirty_sync(inode);
123}
124
125/*
126 * Variant on the above which avoids querying the system clock
127 * in situations where we know the Linux inode timestamps have
128 * just been updated (and so we can update our inode cheaply).
129 * We also skip the readonly and noatime checks here, they are
130 * also catered for already.
131 */
132void
133xfs_ichgtime_fast(
134 xfs_inode_t *ip,
135 struct inode *inode,
136 int flags)
137{
138 timespec_t *tvp;
139
140 /*
141 * We're not supposed to change timestamps in readonly-mounted
142 * filesystems. Throw it away if anyone asks us.
143 */
144 if (unlikely(IS_RDONLY(inode)))
145 return;
146
147 /*
148 * Don't update access timestamps on reads if mounted "noatime".
149 * Throw it away if anyone asks us.
150 */
151 if (unlikely(
152 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
153 ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
154 XFS_ICHGTIME_ACC)))
155 return;
156
157 if (flags & XFS_ICHGTIME_MOD) {
158 tvp = &inode->i_mtime;
159 ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
160 ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
161 }
162 if (flags & XFS_ICHGTIME_ACC) {
163 tvp = &inode->i_atime;
164 ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec;
165 ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec;
166 }
167 if (flags & XFS_ICHGTIME_CHG) {
168 tvp = &inode->i_ctime;
169 ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
170 ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec;
171 }
172
173 /*
174 * We update the i_update_core field _after_ changing
175 * the timestamps in order to coordinate properly with
176 * xfs_iflush() so that we don't lose timestamp updates.
177 * This keeps us from having to hold the inode lock
178 * while doing this. We use the SYNCHRONIZE macro to
179 * ensure that the compiler does not reorder the update
180 * of i_update_core above the timestamp updates above.
181 */
182 SYNCHRONIZE();
183 ip->i_update_core = 1;
184 if (!(inode->i_state & I_LOCK))
185 mark_inode_dirty_sync(inode);
186}
187
72 188
73/* 189/*
74 * Pull the link count and size up from the xfs inode to the linux inode 190 * Pull the link count and size up from the xfs inode to the linux inode
@@ -140,7 +256,6 @@ linvfs_mknod(
140 256
141 memset(&va, 0, sizeof(va)); 257 memset(&va, 0, sizeof(va));
142 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; 258 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
143 va.va_type = IFTOVT(mode);
144 va.va_mode = mode; 259 va.va_mode = mode;
145 260
146 switch (mode & S_IFMT) { 261 switch (mode & S_IFMT) {
@@ -308,14 +423,13 @@ linvfs_symlink(
308 cvp = NULL; 423 cvp = NULL;
309 424
310 memset(&va, 0, sizeof(va)); 425 memset(&va, 0, sizeof(va));
311 va.va_type = VLNK; 426 va.va_mode = S_IFLNK |
312 va.va_mode = irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO; 427 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
313 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; 428 va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
314 429
315 error = 0; 430 error = 0;
316 VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); 431 VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
317 if (!error && cvp) { 432 if (!error && cvp) {
318 ASSERT(cvp->v_type == VLNK);
319 ip = LINVFS_GET_IP(cvp); 433 ip = LINVFS_GET_IP(cvp);
320 d_instantiate(dentry, ip); 434 d_instantiate(dentry, ip);
321 validate_fields(dir); 435 validate_fields(dir);
@@ -374,7 +488,7 @@ linvfs_rename(
374 * we need to be very careful about how much stack we use. 488 * we need to be very careful about how much stack we use.
375 * uio is kmalloced for this reason... 489 * uio is kmalloced for this reason...
376 */ 490 */
377STATIC int 491STATIC void *
378linvfs_follow_link( 492linvfs_follow_link(
379 struct dentry *dentry, 493 struct dentry *dentry,
380 struct nameidata *nd) 494 struct nameidata *nd)
@@ -391,14 +505,14 @@ linvfs_follow_link(
391 link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL); 505 link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL);
392 if (!link) { 506 if (!link) {
393 nd_set_link(nd, ERR_PTR(-ENOMEM)); 507 nd_set_link(nd, ERR_PTR(-ENOMEM));
394 return 0; 508 return NULL;
395 } 509 }
396 510
397 uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL); 511 uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
398 if (!uio) { 512 if (!uio) {
399 kfree(link); 513 kfree(link);
400 nd_set_link(nd, ERR_PTR(-ENOMEM)); 514 nd_set_link(nd, ERR_PTR(-ENOMEM));
401 return 0; 515 return NULL;
402 } 516 }
403 517
404 vp = LINVFS_GET_VP(dentry->d_inode); 518 vp = LINVFS_GET_VP(dentry->d_inode);
@@ -422,12 +536,17 @@ linvfs_follow_link(
422 kfree(uio); 536 kfree(uio);
423 537
424 nd_set_link(nd, link); 538 nd_set_link(nd, link);
425 return 0; 539 return NULL;
426} 540}
427 541
428static void linvfs_put_link(struct dentry *dentry, struct nameidata *nd) 542STATIC void
543linvfs_put_link(
544 struct dentry *dentry,
545 struct nameidata *nd,
546 void *p)
429{ 547{
430 char *s = nd_get_link(nd); 548 char *s = nd_get_link(nd);
549
431 if (!IS_ERR(s)) 550 if (!IS_ERR(s))
432 kfree(s); 551 kfree(s);
433} 552}
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index 6a69a62c36b0..ee784b63acbf 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IOPS_H__ 18#ifndef __XFS_IOPS_H__
33#define __XFS_IOPS_H__ 19#define __XFS_IOPS_H__
@@ -48,4 +34,8 @@ extern void linvfs_unwritten_done(struct buffer_head *, int);
48extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, 34extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
49 int, unsigned int, void __user *); 35 int, unsigned int, void __user *);
50 36
37struct xfs_inode;
38extern void xfs_ichgtime(struct xfs_inode *, int);
39extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
40
51#endif /* __XFS_IOPS_H__ */ 41#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 42dc5e4662ed..44fed10af0dd 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LINUX__ 18#ifndef __XFS_LINUX__
33#define __XFS_LINUX__ 19#define __XFS_LINUX__
@@ -64,7 +50,6 @@
64#include <sema.h> 50#include <sema.h>
65#include <time.h> 51#include <time.h>
66 52
67#include <support/qsort.h>
68#include <support/ktrace.h> 53#include <support/ktrace.h>
69#include <support/debug.h> 54#include <support/debug.h>
70#include <support/move.h> 55#include <support/move.h>
@@ -104,6 +89,7 @@
104#include <xfs_stats.h> 89#include <xfs_stats.h>
105#include <xfs_sysctl.h> 90#include <xfs_sysctl.h>
106#include <xfs_iops.h> 91#include <xfs_iops.h>
92#include <xfs_aops.h>
107#include <xfs_super.h> 93#include <xfs_super.h>
108#include <xfs_globals.h> 94#include <xfs_globals.h>
109#include <xfs_fs_subr.h> 95#include <xfs_fs_subr.h>
@@ -197,10 +183,6 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
197/* bytes to clicks */ 183/* bytes to clicks */
198#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) 184#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
199 185
200#ifndef CELL_CAPABLE
201#define FSC_NOTIFY_NAME_CHANGED(vp)
202#endif
203
204#ifndef ENOATTR 186#ifndef ENOATTR
205#define ENOATTR ENODATA /* Attribute not found */ 187#define ENOATTR ENODATA /* Attribute not found */
206#endif 188#endif
@@ -235,19 +217,7 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
235#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ 217#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
236#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ 218#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
237 219
238/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ 220#define dfltprid 0
239/* we may well need to fine-tune this if it ever becomes an issue. */
240#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */
241#define ndquot DQUOT_MAX_HEURISTIC
242
243/* IRIX uses the current size of the name cache to guess a good value */
244/* - this isn't the same but is a good enough starting point for now. */
245#define DQUOT_HASH_HEURISTIC files_stat.nr_files
246
247/* IRIX inodes maintain the project ID also, zero this field on Linux */
248#define DEFAULT_PROJID 0
249#define dfltprid DEFAULT_PROJID
250
251#define MAXPATHLEN 1024 221#define MAXPATHLEN 1024
252 222
253#define MIN(a,b) (min(a,b)) 223#define MIN(a,b) (min(a,b))
@@ -255,10 +225,17 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
255#define howmany(x, y) (((x)+((y)-1))/(y)) 225#define howmany(x, y) (((x)+((y)-1))/(y))
256#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 226#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
257 227
228/*
229 * Various platform dependent calls that don't fit anywhere else
230 */
231#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
258#define xfs_stack_trace() dump_stack() 232#define xfs_stack_trace() dump_stack()
259
260#define xfs_itruncate_data(ip, off) \ 233#define xfs_itruncate_data(ip, off) \
261 (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) 234 (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
235#define xfs_statvfs_fsid(statp, mp) \
236 ({ u64 id = huge_encode_dev((mp)->m_dev); \
237 __kernel_fsid_t *fsid = &(statp)->f_fsid; \
238 (fsid->val[0] = (u32)id, fsid->val[1] = (u32)(id >> 32)); })
262 239
263 240
264/* Move the kernel do_div definition off to one side */ 241/* Move the kernel do_div definition off to one side */
@@ -371,6 +348,4 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
371 return(x * y); 348 return(x * y);
372} 349}
373 350
374#define qsort(a, n, s, cmp) sort(a, n, s, cmp, NULL)
375
376#endif /* __XFS_LINUX__ */ 351#endif /* __XFS_LINUX__ */
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index acab58c48043..279e9bc92aba 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -1,44 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32/*
33 * fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
34 *
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38
39#include "xfs_fs.h" 19#include "xfs_fs.h"
40#include "xfs_inum.h" 20#include "xfs_bit.h"
41#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
42#include "xfs_trans.h" 23#include "xfs_trans.h"
43#include "xfs_sb.h" 24#include "xfs_sb.h"
44#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -48,18 +29,17 @@
48#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
49#include "xfs_quota.h" 30#include "xfs_quota.h"
50#include "xfs_mount.h" 31#include "xfs_mount.h"
51#include "xfs_alloc_btree.h"
52#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
53#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
54#include "xfs_btree.h"
55#include "xfs_ialloc.h"
56#include "xfs_attr_sf.h"
57#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
58#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
59#include "xfs_dinode.h" 38#include "xfs_dinode.h"
60#include "xfs_inode.h" 39#include "xfs_inode.h"
61#include "xfs_bmap.h" 40#include "xfs_bmap.h"
62#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
63#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
64#include "xfs_error.h" 44#include "xfs_error.h"
65#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -302,7 +282,7 @@ xfs_read(
302 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 282 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
303 283
304 if (likely(!(ioflags & IO_INVIS))) 284 if (likely(!(ioflags & IO_INVIS)))
305 xfs_ichgtime(ip, XFS_ICHGTIME_ACC); 285 xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC);
306 286
307unlock_isem: 287unlock_isem:
308 if (unlikely(ioflags & IO_ISDIRECT)) 288 if (unlikely(ioflags & IO_ISDIRECT))
@@ -367,7 +347,7 @@ xfs_sendfile(
367 XFS_STATS_ADD(xs_read_bytes, ret); 347 XFS_STATS_ADD(xs_read_bytes, ret);
368 348
369 if (likely(!(ioflags & IO_INVIS))) 349 if (likely(!(ioflags & IO_INVIS)))
370 xfs_ichgtime(ip, XFS_ICHGTIME_ACC); 350 xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC);
371 351
372 return ret; 352 return ret;
373} 353}
@@ -660,9 +640,6 @@ xfs_write(
660 (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? 640 (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
661 mp->m_rtdev_targp : mp->m_ddev_targp; 641 mp->m_rtdev_targp : mp->m_ddev_targp;
662 642
663 if (ioflags & IO_ISAIO)
664 return XFS_ERROR(-ENOSYS);
665
666 if ((pos & target->pbr_smask) || (count & target->pbr_smask)) 643 if ((pos & target->pbr_smask) || (count & target->pbr_smask))
667 return XFS_ERROR(-EINVAL); 644 return XFS_ERROR(-EINVAL);
668 645
@@ -735,15 +712,10 @@ start:
735 } 712 }
736 } 713 }
737 714
738 /* 715 if (likely(!(ioflags & IO_INVIS))) {
739 * On Linux, generic_file_write updates the times even if
740 * no data is copied in so long as the write had a size.
741 *
742 * We must update xfs' times since revalidate will overcopy xfs.
743 */
744 if (!(ioflags & IO_INVIS)) {
745 xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
746 inode_update_time(inode, 1); 716 inode_update_time(inode, 1);
717 xfs_ichgtime_fast(xip, inode,
718 XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
747 } 719 }
748 720
749 /* 721 /*
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index f197a720e394..38864a88d42d 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LRW_H__ 18#ifndef __XFS_LRW_H__
33#define __XFS_LRW_H__ 19#define __XFS_LRW_H__
@@ -70,9 +56,10 @@ struct xfs_iomap;
70#define XFS_SENDFILE_ENTER 21 56#define XFS_SENDFILE_ENTER 21
71#define XFS_WRITEPAGE_ENTER 22 57#define XFS_WRITEPAGE_ENTER 22
72#define XFS_RELEASEPAGE_ENTER 23 58#define XFS_RELEASEPAGE_ENTER 23
73#define XFS_IOMAP_ALLOC_ENTER 24 59#define XFS_INVALIDPAGE_ENTER 24
74#define XFS_IOMAP_ALLOC_MAP 25 60#define XFS_IOMAP_ALLOC_ENTER 25
75#define XFS_IOMAP_UNWRITTEN 26 61#define XFS_IOMAP_ALLOC_MAP 26
62#define XFS_IOMAP_UNWRITTEN 27
76extern void xfs_rw_enter_trace(int, struct xfs_iocore *, 63extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
77 void *, size_t, loff_t, int); 64 void *, size_t, loff_t, int);
78extern void xfs_inval_cached_trace(struct xfs_iocore *, 65extern void xfs_inval_cached_trace(struct xfs_iocore *,
@@ -106,9 +93,4 @@ extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
106 93
107extern int xfs_dev_is_read_only(struct xfs_mount *, char *); 94extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
108 95
109#define XFS_FSB_TO_DB_IO(io,fsb) \
110 (((io)->io_flags & XFS_IOCORE_RT) ? \
111 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
112 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
113
114#endif /* __XFS_LRW_H__ */ 96#endif /* __XFS_LRW_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index aaf5ddba47f3..6c40a74be7c8 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
35 20
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/linux-2.6/xfs_stats.h
index 3f756a6c3eb0..50027c4a5618 100644
--- a/fs/xfs/linux-2.6/xfs_stats.h
+++ b/fs/xfs/linux-2.6/xfs_stats.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_STATS_H__ 18#ifndef __XFS_STATS_H__
33#define __XFS_STATS_H__ 19#define __XFS_STATS_H__
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index f6dd7de25927..6116b5bf433e 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1,60 +1,45 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_bit.h"
35#include "xfs_inum.h"
36#include "xfs_log.h" 20#include "xfs_log.h"
37#include "xfs_clnt.h" 21#include "xfs_clnt.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
40#include "xfs_dir.h" 26#include "xfs_dir.h"
41#include "xfs_dir2.h" 27#include "xfs_dir2.h"
42#include "xfs_alloc.h" 28#include "xfs_alloc.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_btree.h"
41#include "xfs_ialloc.h"
56#include "xfs_bmap.h" 42#include "xfs_bmap.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -70,11 +55,15 @@
70#include <linux/namei.h> 55#include <linux/namei.h>
71#include <linux/init.h> 56#include <linux/init.h>
72#include <linux/mount.h> 57#include <linux/mount.h>
58#include <linux/mempool.h>
73#include <linux/writeback.h> 59#include <linux/writeback.h>
60#include <linux/kthread.h>
74 61
75STATIC struct quotactl_ops linvfs_qops; 62STATIC struct quotactl_ops linvfs_qops;
76STATIC struct super_operations linvfs_sops; 63STATIC struct super_operations linvfs_sops;
77STATIC kmem_zone_t *linvfs_inode_zone; 64STATIC kmem_zone_t *xfs_vnode_zone;
65STATIC kmem_zone_t *xfs_ioend_zone;
66mempool_t *xfs_ioend_pool;
78 67
79STATIC struct xfs_mount_args * 68STATIC struct xfs_mount_args *
80xfs_args_allocate( 69xfs_args_allocate(
@@ -138,24 +127,25 @@ STATIC __inline__ void
138xfs_set_inodeops( 127xfs_set_inodeops(
139 struct inode *inode) 128 struct inode *inode)
140{ 129{
141 vnode_t *vp = LINVFS_GET_VP(inode); 130 switch (inode->i_mode & S_IFMT) {
142 131 case S_IFREG:
143 if (vp->v_type == VNON) {
144 vn_mark_bad(vp);
145 } else if (S_ISREG(inode->i_mode)) {
146 inode->i_op = &linvfs_file_inode_operations; 132 inode->i_op = &linvfs_file_inode_operations;
147 inode->i_fop = &linvfs_file_operations; 133 inode->i_fop = &linvfs_file_operations;
148 inode->i_mapping->a_ops = &linvfs_aops; 134 inode->i_mapping->a_ops = &linvfs_aops;
149 } else if (S_ISDIR(inode->i_mode)) { 135 break;
136 case S_IFDIR:
150 inode->i_op = &linvfs_dir_inode_operations; 137 inode->i_op = &linvfs_dir_inode_operations;
151 inode->i_fop = &linvfs_dir_operations; 138 inode->i_fop = &linvfs_dir_operations;
152 } else if (S_ISLNK(inode->i_mode)) { 139 break;
140 case S_IFLNK:
153 inode->i_op = &linvfs_symlink_inode_operations; 141 inode->i_op = &linvfs_symlink_inode_operations;
154 if (inode->i_blocks) 142 if (inode->i_blocks)
155 inode->i_mapping->a_ops = &linvfs_aops; 143 inode->i_mapping->a_ops = &linvfs_aops;
156 } else { 144 break;
145 default:
157 inode->i_op = &linvfs_file_inode_operations; 146 inode->i_op = &linvfs_file_inode_operations;
158 init_special_inode(inode, inode->i_mode, inode->i_rdev); 147 init_special_inode(inode, inode->i_mode, inode->i_rdev);
148 break;
159 } 149 }
160} 150}
161 151
@@ -167,17 +157,24 @@ xfs_revalidate_inode(
167{ 157{
168 struct inode *inode = LINVFS_GET_IP(vp); 158 struct inode *inode = LINVFS_GET_IP(vp);
169 159
170 inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type); 160 inode->i_mode = ip->i_d.di_mode;
171 inode->i_nlink = ip->i_d.di_nlink; 161 inode->i_nlink = ip->i_d.di_nlink;
172 inode->i_uid = ip->i_d.di_uid; 162 inode->i_uid = ip->i_d.di_uid;
173 inode->i_gid = ip->i_d.di_gid; 163 inode->i_gid = ip->i_d.di_gid;
174 if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) { 164
165 switch (inode->i_mode & S_IFMT) {
166 case S_IFBLK:
167 case S_IFCHR:
168 inode->i_rdev =
169 MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
170 sysv_minor(ip->i_df.if_u2.if_rdev));
171 break;
172 default:
175 inode->i_rdev = 0; 173 inode->i_rdev = 0;
176 } else { 174 break;
177 xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
178 inode->i_rdev = MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
179 } 175 }
180 inode->i_blksize = PAGE_CACHE_SIZE; 176
177 inode->i_blksize = xfs_preferred_iosize(mp);
181 inode->i_generation = ip->i_d.di_gen; 178 inode->i_generation = ip->i_d.di_gen;
182 i_size_write(inode, ip->i_d.di_size); 179 i_size_write(inode, ip->i_d.di_size);
183 inode->i_blocks = 180 inode->i_blocks =
@@ -231,7 +228,6 @@ xfs_initialize_vnode(
231 * finish our work. 228 * finish our work.
232 */ 229 */
233 if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) { 230 if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
234 vp->v_type = IFTOVT(ip->i_d.di_mode);
235 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 231 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
236 xfs_set_inodeops(inode); 232 xfs_set_inodeops(inode);
237 233
@@ -267,6 +263,72 @@ xfs_blkdev_put(
267 close_bdev_excl(bdev); 263 close_bdev_excl(bdev);
268} 264}
269 265
266/*
267 * Try to write out the superblock using barriers.
268 */
269STATIC int
270xfs_barrier_test(
271 xfs_mount_t *mp)
272{
273 xfs_buf_t *sbp = xfs_getsb(mp, 0);
274 int error;
275
276 XFS_BUF_UNDONE(sbp);
277 XFS_BUF_UNREAD(sbp);
278 XFS_BUF_UNDELAYWRITE(sbp);
279 XFS_BUF_WRITE(sbp);
280 XFS_BUF_UNASYNC(sbp);
281 XFS_BUF_ORDERED(sbp);
282
283 xfsbdstrat(mp, sbp);
284 error = xfs_iowait(sbp);
285
286 /*
287 * Clear all the flags we set and possible error state in the
288 * buffer. We only did the write to try out whether barriers
289 * worked and shouldn't leave any traces in the superblock
290 * buffer.
291 */
292 XFS_BUF_DONE(sbp);
293 XFS_BUF_ERROR(sbp, 0);
294 XFS_BUF_UNORDERED(sbp);
295
296 xfs_buf_relse(sbp);
297 return error;
298}
299
300void
301xfs_mountfs_check_barriers(xfs_mount_t *mp)
302{
303 int error;
304
305 if (mp->m_logdev_targp != mp->m_ddev_targp) {
306 xfs_fs_cmn_err(CE_NOTE, mp,
307 "Disabling barriers, not supported with external log device");
308 mp->m_flags &= ~XFS_MOUNT_BARRIER;
309 }
310
311 if (mp->m_ddev_targp->pbr_bdev->bd_disk->queue->ordered ==
312 QUEUE_ORDERED_NONE) {
313 xfs_fs_cmn_err(CE_NOTE, mp,
314 "Disabling barriers, not supported by the underlying device");
315 mp->m_flags &= ~XFS_MOUNT_BARRIER;
316 }
317
318 error = xfs_barrier_test(mp);
319 if (error) {
320 xfs_fs_cmn_err(CE_NOTE, mp,
321 "Disabling barriers, trial barrier write failed");
322 mp->m_flags &= ~XFS_MOUNT_BARRIER;
323 }
324}
325
326void
327xfs_blkdev_issue_flush(
328 xfs_buftarg_t *buftarg)
329{
330 blkdev_issue_flush(buftarg->pbr_bdev, NULL);
331}
270 332
271STATIC struct inode * 333STATIC struct inode *
272linvfs_alloc_inode( 334linvfs_alloc_inode(
@@ -274,8 +336,7 @@ linvfs_alloc_inode(
274{ 336{
275 vnode_t *vp; 337 vnode_t *vp;
276 338
277 vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_zone, 339 vp = kmem_cache_alloc(xfs_vnode_zone, kmem_flags_convert(KM_SLEEP));
278 kmem_flags_convert(KM_SLEEP));
279 if (!vp) 340 if (!vp)
280 return NULL; 341 return NULL;
281 return LINVFS_GET_IP(vp); 342 return LINVFS_GET_IP(vp);
@@ -285,11 +346,11 @@ STATIC void
285linvfs_destroy_inode( 346linvfs_destroy_inode(
286 struct inode *inode) 347 struct inode *inode)
287{ 348{
288 kmem_cache_free(linvfs_inode_zone, LINVFS_GET_VP(inode)); 349 kmem_zone_free(xfs_vnode_zone, LINVFS_GET_VP(inode));
289} 350}
290 351
291STATIC void 352STATIC void
292init_once( 353linvfs_inode_init_once(
293 void *data, 354 void *data,
294 kmem_cache_t *cachep, 355 kmem_cache_t *cachep,
295 unsigned long flags) 356 unsigned long flags)
@@ -302,21 +363,41 @@ init_once(
302} 363}
303 364
304STATIC int 365STATIC int
305init_inodecache( void ) 366linvfs_init_zones(void)
306{ 367{
307 linvfs_inode_zone = kmem_cache_create("linvfs_icache", 368 xfs_vnode_zone = kmem_cache_create("xfs_vnode",
308 sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT, 369 sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT,
309 init_once, NULL); 370 linvfs_inode_init_once, NULL);
310 if (linvfs_inode_zone == NULL) 371 if (!xfs_vnode_zone)
311 return -ENOMEM; 372 goto out;
373
374 xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
375 if (!xfs_ioend_zone)
376 goto out_destroy_vnode_zone;
377
378 xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE,
379 mempool_alloc_slab, mempool_free_slab,
380 xfs_ioend_zone);
381 if (!xfs_ioend_pool)
382 goto out_free_ioend_zone;
383
312 return 0; 384 return 0;
385
386
387 out_free_ioend_zone:
388 kmem_zone_destroy(xfs_ioend_zone);
389 out_destroy_vnode_zone:
390 kmem_zone_destroy(xfs_vnode_zone);
391 out:
392 return -ENOMEM;
313} 393}
314 394
315STATIC void 395STATIC void
316destroy_inodecache( void ) 396linvfs_destroy_zones(void)
317{ 397{
318 if (kmem_cache_destroy(linvfs_inode_zone)) 398 mempool_destroy(xfs_ioend_pool);
319 printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__); 399 kmem_zone_destroy(xfs_vnode_zone);
400 kmem_zone_destroy(xfs_ioend_zone);
320} 401}
321 402
322/* 403/*
@@ -354,17 +435,38 @@ linvfs_clear_inode(
354 struct inode *inode) 435 struct inode *inode)
355{ 436{
356 vnode_t *vp = LINVFS_GET_VP(inode); 437 vnode_t *vp = LINVFS_GET_VP(inode);
438 int error, cache;
357 439
358 if (vp) { 440 vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address);
359 vn_rele(vp); 441
360 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); 442 XFS_STATS_INC(vn_rele);
361 /* 443 XFS_STATS_INC(vn_remove);
362 * Do all our cleanup, and remove this vnode. 444 XFS_STATS_INC(vn_reclaim);
363 */ 445 XFS_STATS_DEC(vn_active);
364 vn_remove(vp); 446
447 /*
448 * This can happen because xfs_iget_core calls xfs_idestroy if we
449 * find an inode with di_mode == 0 but without IGET_CREATE set.
450 */
451 if (vp->v_fbhv)
452 VOP_INACTIVE(vp, NULL, cache);
453
454 VN_LOCK(vp);
455 vp->v_flag &= ~VMODIFIED;
456 VN_UNLOCK(vp, 0);
457
458 if (vp->v_fbhv) {
459 VOP_RECLAIM(vp, error);
460 if (error)
461 panic("vn_purge: cannot reclaim");
365 } 462 }
366}
367 463
464 ASSERT(vp->v_fbhv == NULL);
465
466#ifdef XFS_VNODE_TRACE
467 ktrace_free(vp->v_trace);
468#endif
469}
368 470
369/* 471/*
370 * Enqueue a work item to be picked up by the vfs xfssyncd thread. 472 * Enqueue a work item to be picked up by the vfs xfssyncd thread.
@@ -416,7 +518,7 @@ xfs_flush_inode(
416 518
417 igrab(inode); 519 igrab(inode);
418 xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work); 520 xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work);
419 delay(HZ/2); 521 delay(msecs_to_jiffies(500));
420} 522}
421 523
422/* 524/*
@@ -441,7 +543,7 @@ xfs_flush_device(
441 543
442 igrab(inode); 544 igrab(inode);
443 xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work); 545 xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work);
444 delay(HZ/2); 546 delay(msecs_to_jiffies(500));
445 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); 547 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
446} 548}
447 549
@@ -466,25 +568,15 @@ xfssyncd(
466{ 568{
467 long timeleft; 569 long timeleft;
468 vfs_t *vfsp = (vfs_t *) arg; 570 vfs_t *vfsp = (vfs_t *) arg;
469 struct list_head tmp;
470 struct vfs_sync_work *work, *n; 571 struct vfs_sync_work *work, *n;
572 LIST_HEAD (tmp);
471 573
472 daemonize("xfssyncd"); 574 timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
473
474 vfsp->vfs_sync_work.w_vfs = vfsp;
475 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
476 vfsp->vfs_sync_task = current;
477 wmb();
478 wake_up(&vfsp->vfs_wait_sync_task);
479
480 INIT_LIST_HEAD(&tmp);
481 timeleft = (xfs_syncd_centisecs * HZ) / 100;
482 for (;;) { 575 for (;;) {
483 set_current_state(TASK_INTERRUPTIBLE); 576 timeleft = schedule_timeout_interruptible(timeleft);
484 timeleft = schedule_timeout(timeleft);
485 /* swsusp */ 577 /* swsusp */
486 try_to_freeze(); 578 try_to_freeze();
487 if (vfsp->vfs_flag & VFS_UMOUNT) 579 if (kthread_should_stop())
488 break; 580 break;
489 581
490 spin_lock(&vfsp->vfs_sync_lock); 582 spin_lock(&vfsp->vfs_sync_lock);
@@ -495,7 +587,8 @@ xfssyncd(
495 */ 587 */
496 if (!timeleft || list_empty(&vfsp->vfs_sync_list)) { 588 if (!timeleft || list_empty(&vfsp->vfs_sync_list)) {
497 if (!timeleft) 589 if (!timeleft)
498 timeleft = (xfs_syncd_centisecs * HZ) / 100; 590 timeleft = xfs_syncd_centisecs *
591 msecs_to_jiffies(10);
499 INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list); 592 INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list);
500 list_add_tail(&vfsp->vfs_sync_work.w_list, 593 list_add_tail(&vfsp->vfs_sync_work.w_list,
501 &vfsp->vfs_sync_list); 594 &vfsp->vfs_sync_list);
@@ -513,10 +606,6 @@ xfssyncd(
513 } 606 }
514 } 607 }
515 608
516 vfsp->vfs_sync_task = NULL;
517 wmb();
518 wake_up(&vfsp->vfs_wait_sync_task);
519
520 return 0; 609 return 0;
521} 610}
522 611
@@ -524,13 +613,11 @@ STATIC int
524linvfs_start_syncd( 613linvfs_start_syncd(
525 vfs_t *vfsp) 614 vfs_t *vfsp)
526{ 615{
527 int pid; 616 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
528 617 vfsp->vfs_sync_work.w_vfs = vfsp;
529 pid = kernel_thread(xfssyncd, (void *) vfsp, 618 vfsp->vfs_sync_task = kthread_run(xfssyncd, vfsp, "xfssyncd");
530 CLONE_VM | CLONE_FS | CLONE_FILES); 619 if (IS_ERR(vfsp->vfs_sync_task))
531 if (pid < 0) 620 return -PTR_ERR(vfsp->vfs_sync_task);
532 return -pid;
533 wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
534 return 0; 621 return 0;
535} 622}
536 623
@@ -538,11 +625,7 @@ STATIC void
538linvfs_stop_syncd( 625linvfs_stop_syncd(
539 vfs_t *vfsp) 626 vfs_t *vfsp)
540{ 627{
541 vfsp->vfs_flag |= VFS_UMOUNT; 628 kthread_stop(vfsp->vfs_sync_task);
542 wmb();
543
544 wake_up_process(vfsp->vfs_sync_task);
545 wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
546} 629}
547 630
548STATIC void 631STATIC void
@@ -669,6 +752,18 @@ linvfs_show_options(
669} 752}
670 753
671STATIC int 754STATIC int
755linvfs_quotasync(
756 struct super_block *sb,
757 int type)
758{
759 struct vfs *vfsp = LINVFS_GET_VFS(sb);
760 int error;
761
762 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
763 return -error;
764}
765
766STATIC int
672linvfs_getxstate( 767linvfs_getxstate(
673 struct super_block *sb, 768 struct super_block *sb,
674 struct fs_quota_stat *fqs) 769 struct fs_quota_stat *fqs)
@@ -836,6 +931,7 @@ STATIC struct super_operations linvfs_sops = {
836}; 931};
837 932
838STATIC struct quotactl_ops linvfs_qops = { 933STATIC struct quotactl_ops linvfs_qops = {
934 .quota_sync = linvfs_quotasync,
839 .get_xstate = linvfs_getxstate, 935 .get_xstate = linvfs_getxstate,
840 .set_xstate = linvfs_setxstate, 936 .set_xstate = linvfs_setxstate,
841 .get_xquota = linvfs_getxquota, 937 .get_xquota = linvfs_getxquota,
@@ -866,9 +962,9 @@ init_xfs_fs( void )
866 962
867 ktrace_init(64); 963 ktrace_init(64);
868 964
869 error = init_inodecache(); 965 error = linvfs_init_zones();
870 if (error < 0) 966 if (error < 0)
871 goto undo_inodecache; 967 goto undo_zones;
872 968
873 error = pagebuf_init(); 969 error = pagebuf_init();
874 if (error < 0) 970 if (error < 0)
@@ -889,9 +985,9 @@ undo_register:
889 pagebuf_terminate(); 985 pagebuf_terminate();
890 986
891undo_pagebuf: 987undo_pagebuf:
892 destroy_inodecache(); 988 linvfs_destroy_zones();
893 989
894undo_inodecache: 990undo_zones:
895 return error; 991 return error;
896} 992}
897 993
@@ -903,7 +999,7 @@ exit_xfs_fs( void )
903 unregister_filesystem(&xfs_fs_type); 999 unregister_filesystem(&xfs_fs_type);
904 xfs_cleanup(); 1000 xfs_cleanup();
905 pagebuf_terminate(); 1001 pagebuf_terminate();
906 destroy_inodecache(); 1002 linvfs_destroy_zones();
907 ktrace_uninit(); 1003 ktrace_uninit();
908} 1004}
909 1005
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index ec7e0035c731..df59408dca06 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPER_H__ 18#ifndef __XFS_SUPER_H__
33#define __XFS_SUPER_H__ 19#define __XFS_SUPER_H__
@@ -132,6 +118,7 @@ extern void xfs_flush_device(struct xfs_inode *);
132extern int xfs_blkdev_get(struct xfs_mount *, const char *, 118extern int xfs_blkdev_get(struct xfs_mount *, const char *,
133 struct block_device **); 119 struct block_device **);
134extern void xfs_blkdev_put(struct block_device *); 120extern void xfs_blkdev_put(struct block_device *);
121extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
135 122
136extern struct export_operations linvfs_export_ops; 123extern struct export_operations linvfs_export_ops;
137 124
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index 0dc010356f4d..a02564972420 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -1,44 +1,26 @@
1/* 1/*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_rw.h"
35#include <linux/sysctl.h> 19#include <linux/sysctl.h>
36#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
37 21
38
39static struct ctl_table_header *xfs_table_header; 22static struct ctl_table_header *xfs_table_header;
40 23
41
42#ifdef CONFIG_PROC_FS 24#ifdef CONFIG_PROC_FS
43STATIC int 25STATIC int
44xfs_stats_clear_proc_handler( 26xfs_stats_clear_proc_handler(
@@ -76,7 +58,7 @@ xfs_stats_clear_proc_handler(
76STATIC ctl_table xfs_table[] = { 58STATIC ctl_table xfs_table[] = {
77 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, 59 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
78 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 60 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
79 &sysctl_intvec, NULL, 61 &sysctl_intvec, NULL,
80 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, 62 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
81 63
82 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, 64 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
@@ -86,22 +68,22 @@ STATIC ctl_table xfs_table[] = {
86 68
87 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, 69 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
88 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 70 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
89 &sysctl_intvec, NULL, 71 &sysctl_intvec, NULL,
90 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, 72 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
91 73
92 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, 74 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
93 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 75 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
94 &sysctl_intvec, NULL, 76 &sysctl_intvec, NULL,
95 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, 77 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
96 78
97 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, 79 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
98 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 80 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
99 &sysctl_intvec, NULL, 81 &sysctl_intvec, NULL,
100 &xfs_params.error_level.min, &xfs_params.error_level.max}, 82 &xfs_params.error_level.min, &xfs_params.error_level.max},
101 83
102 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, 84 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
103 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 85 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
104 &sysctl_intvec, NULL, 86 &sysctl_intvec, NULL,
105 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, 87 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
106 88
107 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, 89 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
@@ -118,7 +100,7 @@ STATIC ctl_table xfs_table[] = {
118 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 100 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
119 &sysctl_intvec, NULL, 101 &sysctl_intvec, NULL,
120 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, 102 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
121 103
122 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val, 104 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
123 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 105 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
124 &sysctl_intvec, NULL, 106 &sysctl_intvec, NULL,
@@ -136,14 +118,14 @@ STATIC ctl_table xfs_table[] = {
136 118
137 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val, 119 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
138 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 120 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
139 &sysctl_intvec, NULL, 121 &sysctl_intvec, NULL,
140 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max}, 122 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
141 123
142 /* please keep this the last entry */ 124 /* please keep this the last entry */
143#ifdef CONFIG_PROC_FS 125#ifdef CONFIG_PROC_FS
144 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, 126 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
145 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, 127 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
146 &sysctl_intvec, NULL, 128 &sysctl_intvec, NULL,
147 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, 129 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
148#endif /* CONFIG_PROC_FS */ 130#endif /* CONFIG_PROC_FS */
149 131
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/linux-2.6/xfs_sysctl.h
index a39a95020a58..bc8c11f13722 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.h
+++ b/fs/xfs/linux-2.6/xfs_sysctl.h
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#ifndef __XFS_SYSCTL_H__ 18#ifndef __XFS_SYSCTL_H__
34#define __XFS_SYSCTL_H__ 19#define __XFS_SYSCTL_H__
35 20
diff --git a/fs/xfs/linux-2.6/xfs_version.h b/fs/xfs/linux-2.6/xfs_version.h
index 96f96394417e..f8d279d7563a 100644
--- a/fs/xfs/linux-2.6/xfs_version.h
+++ b/fs/xfs/linux-2.6/xfs_version.h
@@ -1,34 +1,22 @@
1/* 1/*
2 * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
18#ifndef __XFS_VERSION_H__
19#define __XFS_VERSION_H__
32 20
33/* 21/*
34 * Dummy file that can contain a timestamp to put into the 22 * Dummy file that can contain a timestamp to put into the
@@ -36,9 +24,6 @@
36 * running 24 * running
37 */ 25 */
38 26
39#ifndef __XFS_VERSION_H__
40#define __XFS_VERSION_H__
41
42#define XFS_VERSION_STRING "SGI XFS" 27#define XFS_VERSION_STRING "SGI XFS"
43 28
44#endif /* __XFS_VERSION_H__ */ 29#endif /* __XFS_VERSION_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c
index 669c61644959..c855d62e5344 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.c
+++ b/fs/xfs/linux-2.6/xfs_vfs.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_inum.h" 20#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
38#include "xfs_clnt.h" 22#include "xfs_clnt.h"
@@ -251,7 +235,6 @@ vfs_allocate( void )
251 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs"); 235 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
252 INIT_LIST_HEAD(&vfsp->vfs_sync_list); 236 INIT_LIST_HEAD(&vfsp->vfs_sync_list);
253 spin_lock_init(&vfsp->vfs_sync_lock); 237 spin_lock_init(&vfsp->vfs_sync_lock);
254 init_waitqueue_head(&vfsp->vfs_wait_sync_task);
255 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); 238 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
256 return vfsp; 239 return vfsp;
257} 240}
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 7ee1f714e9ba..57caf9eddee0 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_VFS_H__ 18#ifndef __XFS_VFS_H__
33#define __XFS_VFS_H__ 19#define __XFS_VFS_H__
@@ -65,7 +51,6 @@ typedef struct vfs {
65 spinlock_t vfs_sync_lock; /* work item list lock */ 51 spinlock_t vfs_sync_lock; /* work item list lock */
66 int vfs_sync_seq; /* sync thread generation no. */ 52 int vfs_sync_seq; /* sync thread generation no. */
67 wait_queue_head_t vfs_wait_single_sync_task; 53 wait_queue_head_t vfs_wait_single_sync_task;
68 wait_queue_head_t vfs_wait_sync_task;
69} vfs_t; 54} vfs_t;
70 55
71#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */ 56#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
@@ -96,7 +81,7 @@ typedef enum {
96#define VFS_RDONLY 0x0001 /* read-only vfs */ 81#define VFS_RDONLY 0x0001 /* read-only vfs */
97#define VFS_GRPID 0x0002 /* group-ID assigned from directory */ 82#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
98#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ 83#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
99#define VFS_UMOUNT 0x0008 /* unmount in progress */ 84#define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */
100#define VFS_END 0x0008 /* max flag */ 85#define VFS_END 0x0008 /* max flag */
101 86
102#define SYNC_ATTR 0x0001 /* sync attributes */ 87#define SYNC_ATTR 0x0001 /* sync attributes */
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 250cad54e892..e9bbcb4d6243 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19
35
36uint64_t vn_generation; /* vnode generation number */ 20uint64_t vn_generation; /* vnode generation number */
37DEFINE_SPINLOCK(vnumber_lock); 21DEFINE_SPINLOCK(vnumber_lock);
38 22
@@ -42,93 +26,32 @@ DEFINE_SPINLOCK(vnumber_lock);
42 */ 26 */
43#define NVSYNC 37 27#define NVSYNC 37
44#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) 28#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
45sv_t vsync[NVSYNC]; 29STATIC wait_queue_head_t vsync[NVSYNC];
46
47/*
48 * Translate stat(2) file types to vnode types and vice versa.
49 * Aware of numeric order of S_IFMT and vnode type values.
50 */
51enum vtype iftovt_tab[] = {
52 VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
53 VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VNON
54};
55
56u_short vttoif_tab[] = {
57 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFIFO, 0, S_IFSOCK
58};
59
60 30
61void 31void
62vn_init(void) 32vn_init(void)
63{ 33{
64 register sv_t *svp; 34 int i;
65 register int i;
66 35
67 for (svp = vsync, i = 0; i < NVSYNC; i++, svp++) 36 for (i = 0; i < NVSYNC; i++)
68 init_sv(svp, SV_DEFAULT, "vsy", i); 37 init_waitqueue_head(&vsync[i]);
69} 38}
70 39
71/* 40void
72 * Clean a vnode of filesystem-specific data and prepare it for reuse. 41vn_iowait(
73 */
74STATIC int
75vn_reclaim(
76 struct vnode *vp) 42 struct vnode *vp)
77{ 43{
78 int error; 44 wait_queue_head_t *wq = vptosync(vp);
79
80 XFS_STATS_INC(vn_reclaim);
81 vn_trace_entry(vp, "vn_reclaim", (inst_t *)__return_address);
82
83 /*
84 * Only make the VOP_RECLAIM call if there are behaviors
85 * to call.
86 */
87 if (vp->v_fbhv) {
88 VOP_RECLAIM(vp, error);
89 if (error)
90 return -error;
91 }
92 ASSERT(vp->v_fbhv == NULL);
93
94 VN_LOCK(vp);
95 vp->v_flag &= (VRECLM|VWAIT);
96 VN_UNLOCK(vp, 0);
97
98 vp->v_type = VNON;
99 vp->v_fbhv = NULL;
100
101#ifdef XFS_VNODE_TRACE
102 ktrace_free(vp->v_trace);
103 vp->v_trace = NULL;
104#endif
105 45
106 return 0; 46 wait_event(*wq, (atomic_read(&vp->v_iocount) == 0));
107} 47}
108 48
109STATIC void 49void
110vn_wakeup( 50vn_iowake(
111 struct vnode *vp)
112{
113 VN_LOCK(vp);
114 if (vp->v_flag & VWAIT)
115 sv_broadcast(vptosync(vp));
116 vp->v_flag &= ~(VRECLM|VWAIT|VMODIFIED);
117 VN_UNLOCK(vp, 0);
118}
119
120int
121vn_wait(
122 struct vnode *vp) 51 struct vnode *vp)
123{ 52{
124 VN_LOCK(vp); 53 if (atomic_dec_and_test(&vp->v_iocount))
125 if (vp->v_flag & (VINACT | VRECLM)) { 54 wake_up(vptosync(vp));
126 vp->v_flag |= VWAIT;
127 sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
128 return 1;
129 }
130 VN_UNLOCK(vp, 0);
131 return 0;
132} 55}
133 56
134struct vnode * 57struct vnode *
@@ -154,6 +77,8 @@ vn_initialize(
154 /* Initialize the first behavior and the behavior chain head. */ 77 /* Initialize the first behavior and the behavior chain head. */
155 vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode"); 78 vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
156 79
80 atomic_set(&vp->v_iocount, 0);
81
157#ifdef XFS_VNODE_TRACE 82#ifdef XFS_VNODE_TRACE
158 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); 83 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
159#endif /* XFS_VNODE_TRACE */ 84#endif /* XFS_VNODE_TRACE */
@@ -163,30 +88,6 @@ vn_initialize(
163} 88}
164 89
165/* 90/*
166 * Get a reference on a vnode.
167 */
168vnode_t *
169vn_get(
170 struct vnode *vp,
171 vmap_t *vmap)
172{
173 struct inode *inode;
174
175 XFS_STATS_INC(vn_get);
176 inode = LINVFS_GET_IP(vp);
177 if (inode->i_state & I_FREEING)
178 return NULL;
179
180 inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
181 if (!inode) /* Inode not present */
182 return NULL;
183
184 vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
185
186 return vp;
187}
188
189/*
190 * Revalidate the Linux inode from the vattr. 91 * Revalidate the Linux inode from the vattr.
191 * Note: i_size _not_ updated; we must hold the inode 92 * Note: i_size _not_ updated; we must hold the inode
192 * semaphore when doing that - callers responsibility. 93 * semaphore when doing that - callers responsibility.
@@ -198,7 +99,7 @@ vn_revalidate_core(
198{ 99{
199 struct inode *inode = LINVFS_GET_IP(vp); 100 struct inode *inode = LINVFS_GET_IP(vp);
200 101
201 inode->i_mode = VTTOIF(vap->va_type) | vap->va_mode; 102 inode->i_mode = vap->va_mode;
202 inode->i_nlink = vap->va_nlink; 103 inode->i_nlink = vap->va_nlink;
203 inode->i_uid = vap->va_uid; 104 inode->i_uid = vap->va_uid;
204 inode->i_gid = vap->va_gid; 105 inode->i_gid = vap->va_gid;
@@ -206,6 +107,7 @@ vn_revalidate_core(
206 inode->i_mtime = vap->va_mtime; 107 inode->i_mtime = vap->va_mtime;
207 inode->i_ctime = vap->va_ctime; 108 inode->i_ctime = vap->va_ctime;
208 inode->i_atime = vap->va_atime; 109 inode->i_atime = vap->va_atime;
110 inode->i_blksize = vap->va_blocksize;
209 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) 111 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
210 inode->i_flags |= S_IMMUTABLE; 112 inode->i_flags |= S_IMMUTABLE;
211 else 113 else
@@ -247,71 +149,6 @@ vn_revalidate(
247} 149}
248 150
249/* 151/*
250 * purge a vnode from the cache
251 * At this point the vnode is guaranteed to have no references (vn_count == 0)
252 * The caller has to make sure that there are no ways someone could
253 * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock).
254 */
255void
256vn_purge(
257 struct vnode *vp,
258 vmap_t *vmap)
259{
260 vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address);
261
262again:
263 /*
264 * Check whether vp has already been reclaimed since our caller
265 * sampled its version while holding a filesystem cache lock that
266 * its VOP_RECLAIM function acquires.
267 */
268 VN_LOCK(vp);
269 if (vp->v_number != vmap->v_number) {
270 VN_UNLOCK(vp, 0);
271 return;
272 }
273
274 /*
275 * If vp is being reclaimed or inactivated, wait until it is inert,
276 * then proceed. Can't assume that vnode is actually reclaimed
277 * just because the reclaimed flag is asserted -- a vn_alloc
278 * reclaim can fail.
279 */
280 if (vp->v_flag & (VINACT | VRECLM)) {
281 ASSERT(vn_count(vp) == 0);
282 vp->v_flag |= VWAIT;
283 sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
284 goto again;
285 }
286
287 /*
288 * Another process could have raced in and gotten this vnode...
289 */
290 if (vn_count(vp) > 0) {
291 VN_UNLOCK(vp, 0);
292 return;
293 }
294
295 XFS_STATS_DEC(vn_active);
296 vp->v_flag |= VRECLM;
297 VN_UNLOCK(vp, 0);
298
299 /*
300 * Call VOP_RECLAIM and clean vp. The FSYNC_INVAL flag tells
301 * vp's filesystem to flush and invalidate all cached resources.
302 * When vn_reclaim returns, vp should have no private data,
303 * either in a system cache or attached to v_data.
304 */
305 if (vn_reclaim(vp) != 0)
306 panic("vn_purge: cannot reclaim");
307
308 /*
309 * Wakeup anyone waiting for vp to be reclaimed.
310 */
311 vn_wakeup(vp);
312}
313
314/*
315 * Add a reference to a referenced vnode. 152 * Add a reference to a referenced vnode.
316 */ 153 */
317struct vnode * 154struct vnode *
@@ -330,80 +167,6 @@ vn_hold(
330 return vp; 167 return vp;
331} 168}
332 169
333/*
334 * Call VOP_INACTIVE on last reference.
335 */
336void
337vn_rele(
338 struct vnode *vp)
339{
340 int vcnt;
341 int cache;
342
343 XFS_STATS_INC(vn_rele);
344
345 VN_LOCK(vp);
346
347 vn_trace_entry(vp, "vn_rele", (inst_t *)__return_address);
348 vcnt = vn_count(vp);
349
350 /*
351 * Since we always get called from put_inode we know
352 * that i_count won't be decremented after we
353 * return.
354 */
355 if (!vcnt) {
356 /*
357 * As soon as we turn this on, noone can find us in vn_get
358 * until we turn off VINACT or VRECLM
359 */
360 vp->v_flag |= VINACT;
361 VN_UNLOCK(vp, 0);
362
363 /*
364 * Do not make the VOP_INACTIVE call if there
365 * are no behaviors attached to the vnode to call.
366 */
367 if (vp->v_fbhv)
368 VOP_INACTIVE(vp, NULL, cache);
369
370 VN_LOCK(vp);
371 if (vp->v_flag & VWAIT)
372 sv_broadcast(vptosync(vp));
373
374 vp->v_flag &= ~(VINACT|VWAIT|VRECLM|VMODIFIED);
375 }
376
377 VN_UNLOCK(vp, 0);
378
379 vn_trace_exit(vp, "vn_rele", (inst_t *)__return_address);
380}
381
382/*
383 * Finish the removal of a vnode.
384 */
385void
386vn_remove(
387 struct vnode *vp)
388{
389 vmap_t vmap;
390
391 /* Make sure we don't do this to the same vnode twice */
392 if (!(vp->v_fbhv))
393 return;
394
395 XFS_STATS_INC(vn_remove);
396 vn_trace_exit(vp, "vn_remove", (inst_t *)__return_address);
397
398 /*
399 * After the following purge the vnode
400 * will no longer exist.
401 */
402 VMAP(vp, vmap);
403 vn_purge(vp, &vmap);
404}
405
406
407#ifdef XFS_VNODE_TRACE 170#ifdef XFS_VNODE_TRACE
408 171
409#define KTRACE_ENTER(vp, vk, s, line, ra) \ 172#define KTRACE_ENTER(vp, vk, s, line, ra) \
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index a6e57c647be4..f2bbb327c081 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 * 17 *
32 * Portions Copyright (c) 1989, 1993 18 * Portions Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved. 19 * The Regents of the University of California. All rights reserved.
@@ -65,10 +51,6 @@ struct vattr;
65struct xfs_iomap; 51struct xfs_iomap;
66struct attrlist_cursor_kern; 52struct attrlist_cursor_kern;
67 53
68/*
69 * Vnode types. VNON means no type.
70 */
71enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };
72 54
73typedef xfs_ino_t vnumber_t; 55typedef xfs_ino_t vnumber_t;
74typedef struct dentry vname_t; 56typedef struct dentry vname_t;
@@ -77,15 +59,14 @@ typedef bhv_head_t vn_bhv_head_t;
77/* 59/*
78 * MP locking protocols: 60 * MP locking protocols:
79 * v_flag, v_vfsp VN_LOCK/VN_UNLOCK 61 * v_flag, v_vfsp VN_LOCK/VN_UNLOCK
80 * v_type read-only or fs-dependent
81 */ 62 */
82typedef struct vnode { 63typedef struct vnode {
83 __u32 v_flag; /* vnode flags (see below) */ 64 __u32 v_flag; /* vnode flags (see below) */
84 enum vtype v_type; /* vnode type */
85 struct vfs *v_vfsp; /* ptr to containing VFS */ 65 struct vfs *v_vfsp; /* ptr to containing VFS */
86 vnumber_t v_number; /* in-core vnode number */ 66 vnumber_t v_number; /* in-core vnode number */
87 vn_bhv_head_t v_bh; /* behavior head */ 67 vn_bhv_head_t v_bh; /* behavior head */
88 spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */ 68 spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
69 atomic_t v_iocount; /* outstanding I/O count */
89#ifdef XFS_VNODE_TRACE 70#ifdef XFS_VNODE_TRACE
90 struct ktrace *v_trace; /* trace header structure */ 71 struct ktrace *v_trace; /* trace header structure */
91#endif 72#endif
@@ -93,6 +74,12 @@ typedef struct vnode {
93 /* inode MUST be last */ 74 /* inode MUST be last */
94} vnode_t; 75} vnode_t;
95 76
77#define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode)
78#define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode)
79#define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode)
80#define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode)
81#define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode)
82
96#define v_fbhv v_bh.bh_first /* first behavior */ 83#define v_fbhv v_bh.bh_first /* first behavior */
97#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */ 84#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */
98 85
@@ -133,22 +120,8 @@ typedef enum {
133#define LINVFS_GET_IP(vp) (&(vp)->v_inode) 120#define LINVFS_GET_IP(vp) (&(vp)->v_inode)
134 121
135/* 122/*
136 * Convert between vnode types and inode formats (since POSIX.1
137 * defines mode word of stat structure in terms of inode formats).
138 */
139extern enum vtype iftovt_tab[];
140extern u_short vttoif_tab[];
141#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
142#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
143#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
144
145
146/*
147 * Vnode flags. 123 * Vnode flags.
148 */ 124 */
149#define VINACT 0x1 /* vnode is being inactivated */
150#define VRECLM 0x2 /* vnode is being reclaimed */
151#define VWAIT 0x4 /* waiting for VINACT/VRECLM to end */
152#define VMODIFIED 0x8 /* XFS inode state possibly differs */ 125#define VMODIFIED 0x8 /* XFS inode state possibly differs */
153 /* to the Linux inode state. */ 126 /* to the Linux inode state. */
154 127
@@ -229,11 +202,12 @@ typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
229typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, 202typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
230 struct xfs_iomap *, int *); 203 struct xfs_iomap *, int *);
231typedef int (*vop_reclaim_t)(bhv_desc_t *); 204typedef int (*vop_reclaim_t)(bhv_desc_t *);
232typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int, 205typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *,
233 struct cred *); 206 int, struct cred *);
234typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int, 207typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int,
235 struct cred *); 208 int, struct cred *);
236typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *); 209typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *,
210 int, struct cred *);
237typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, 211typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
238 struct attrlist_cursor_kern *, struct cred *); 212 struct attrlist_cursor_kern *, struct cred *);
239typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int); 213typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
@@ -408,7 +382,6 @@ typedef struct vnodeops {
408 */ 382 */
409typedef struct vattr { 383typedef struct vattr {
410 int va_mask; /* bit-mask of attributes present */ 384 int va_mask; /* bit-mask of attributes present */
411 enum vtype va_type; /* vnode type (for create) */
412 mode_t va_mode; /* file access mode and type */ 385 mode_t va_mode; /* file access mode and type */
413 xfs_nlink_t va_nlink; /* number of references to file */ 386 xfs_nlink_t va_nlink; /* number of references to file */
414 uid_t va_uid; /* owner user id */ 387 uid_t va_uid; /* owner user id */
@@ -498,27 +471,12 @@ typedef struct vattr {
498 * Check whether mandatory file locking is enabled. 471 * Check whether mandatory file locking is enabled.
499 */ 472 */
500#define MANDLOCK(vp, mode) \ 473#define MANDLOCK(vp, mode) \
501 ((vp)->v_type == VREG && ((mode) & (VSGID|(VEXEC>>3))) == VSGID) 474 (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
502 475
503extern void vn_init(void); 476extern void vn_init(void);
504extern int vn_wait(struct vnode *);
505extern vnode_t *vn_initialize(struct inode *); 477extern vnode_t *vn_initialize(struct inode *);
506 478
507/* 479/*
508 * Acquiring and invalidating vnodes:
509 *
510 * if (vn_get(vp, version, 0))
511 * ...;
512 * vn_purge(vp, version);
513 *
514 * vn_get and vn_purge must be called with vmap_t arguments, sampled
515 * while a lock that the vnode's VOP_RECLAIM function acquires is
516 * held, to ensure that the vnode sampled with the lock held isn't
517 * recycled (VOP_RECLAIMed) or deallocated between the release of the lock
518 * and the subsequent vn_get or vn_purge.
519 */
520
521/*
522 * vnode_map structures _must_ match vn_epoch and vnode structure sizes. 480 * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
523 */ 481 */
524typedef struct vnode_map { 482typedef struct vnode_map {
@@ -531,11 +489,11 @@ typedef struct vnode_map {
531 (vmap).v_number = (vp)->v_number, \ 489 (vmap).v_number = (vp)->v_number, \
532 (vmap).v_ino = (vp)->v_inode.i_ino; } 490 (vmap).v_ino = (vp)->v_inode.i_ino; }
533 491
534extern void vn_purge(struct vnode *, vmap_t *);
535extern vnode_t *vn_get(struct vnode *, vmap_t *);
536extern int vn_revalidate(struct vnode *); 492extern int vn_revalidate(struct vnode *);
537extern void vn_revalidate_core(struct vnode *, vattr_t *); 493extern void vn_revalidate_core(struct vnode *, vattr_t *);
538extern void vn_remove(struct vnode *); 494
495extern void vn_iowait(struct vnode *vp);
496extern void vn_iowake(struct vnode *vp);
539 497
540static inline int vn_count(struct vnode *vp) 498static inline int vn_count(struct vnode *vp)
541{ 499{
@@ -546,7 +504,6 @@ static inline int vn_count(struct vnode *vp)
546 * Vnode reference counting functions (and macros for compatibility). 504 * Vnode reference counting functions (and macros for compatibility).
547 */ 505 */
548extern vnode_t *vn_hold(struct vnode *); 506extern vnode_t *vn_hold(struct vnode *);
549extern void vn_rele(struct vnode *);
550 507
551#if defined(XFS_VNODE_TRACE) 508#if defined(XFS_VNODE_TRACE)
552#define VN_HOLD(vp) \ 509#define VN_HOLD(vp) \
@@ -560,6 +517,12 @@ extern void vn_rele(struct vnode *);
560#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp))) 517#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
561#endif 518#endif
562 519
520static inline struct vnode *vn_grab(struct vnode *vp)
521{
522 struct inode *inode = igrab(LINVFS_GET_IP(vp));
523 return inode ? LINVFS_GET_VP(inode) : NULL;
524}
525
563/* 526/*
564 * Vname handling macros. 527 * Vname handling macros.
565 */ 528 */
@@ -590,13 +553,6 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
590} 553}
591 554
592/* 555/*
593 * Update modify/access/change times on the vnode
594 */
595#define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
596#define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp))
597#define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
598
599/*
600 * Dealing with bad inodes 556 * Dealing with bad inodes
601 */ 557 */
602static inline void vn_mark_bad(struct vnode *vp) 558static inline void vn_mark_bad(struct vnode *vp)
@@ -627,6 +583,7 @@ static inline int VN_BAD(struct vnode *vp)
627#define ATTR_LAZY 0x80 /* set/get attributes lazily */ 583#define ATTR_LAZY 0x80 /* set/get attributes lazily */
628#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ 584#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
629#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ 585#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
586#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
630 587
631/* 588/*
632 * Flags to VOP_FSYNC and VOP_RECLAIM. 589 * Flags to VOP_FSYNC and VOP_RECLAIM.