aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/conv.c32
-rw-r--r--fs/autofs4/root.c2
-rw-r--r--fs/binfmt_elf.c4
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/bio.c4
-rw-r--r--fs/buffer.c8
-rw-r--r--fs/char_dev.c96
-rw-r--r--fs/compat.c4
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/efs/super.c5
-rw-r--r--fs/exec.c6
-rw-r--r--fs/ext2/namei.c5
-rw-r--r--fs/ext3/namei.c5
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/fuse/dev.c225
-rw-r--r--fs/fuse/dir.c18
-rw-r--r--fs/fuse/file.c83
-rw-r--r--fs/fuse/fuse_i.h98
-rw-r--r--fs/fuse/inode.c268
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/isofs/namei.c5
-rw-r--r--fs/jffs2/build.c2
-rw-r--r--fs/jffs2/nodelist.c4
-rw-r--r--fs/lockd/xdr.c6
-rw-r--r--fs/mbcache.c6
-rw-r--r--fs/namei.c16
-rw-r--r--fs/namespace.c5
-rw-r--r--fs/ncpfs/inode.c19
-rw-r--r--fs/ncpfs/ioctl.c20
-rw-r--r--fs/nfsd/nfsxdr.c4
-rw-r--r--fs/partitions/Kconfig7
-rw-r--r--fs/partitions/Makefile1
-rw-r--r--fs/partitions/check.c4
-rw-r--r--fs/partitions/karma.c57
-rw-r--r--fs/partitions/karma.h8
-rw-r--r--fs/pipe.c4
-rw-r--r--fs/proc/proc_devtree.c24
-rw-r--r--fs/proc/proc_misc.c160
-rw-r--r--fs/quota_v2.c3
-rw-r--r--fs/reiserfs/namei.c6
-rw-r--r--fs/smbfs/Makefile1
-rw-r--r--fs/smbfs/inode.c32
-rw-r--r--fs/smbfs/request.c13
-rw-r--r--fs/sysv/ChangeLog2
-rw-r--r--fs/ufs/balloc.c19
-rw-r--r--fs/ufs/ialloc.c4
-rw-r--r--fs/ufs/inode.c11
-rw-r--r--fs/ufs/super.c57
-rw-r--r--fs/ufs/util.h28
-rw-r--r--fs/xfs/linux-2.6/mutex.h12
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c16
-rw-r--r--fs/xfs/quota/xfs_qm.c116
-rw-r--r--fs/xfs/xfs_dir_leaf.c96
-rw-r--r--fs/xfs/xfs_fsops.c4
-rw-r--r--fs/xfs/xfs_log.c52
-rw-r--r--fs/xfs/xfs_mount.c66
-rw-r--r--fs/xfs/xfs_trans_item.c22
-rw-r--r--fs/xfs/xfs_vnodeops.c59
58 files changed, 1180 insertions, 662 deletions
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index 55ccfa10ee9e..32a9f99154e2 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -56,7 +56,7 @@ static inline int buf_check_overflow(struct cbuf *buf)
56 return buf->p > buf->ep; 56 return buf->p > buf->ep;
57} 57}
58 58
59static inline int buf_check_size(struct cbuf *buf, int len) 59static int buf_check_size(struct cbuf *buf, int len)
60{ 60{
61 if (buf->p + len > buf->ep) { 61 if (buf->p + len > buf->ep) {
62 if (buf->p < buf->ep) { 62 if (buf->p < buf->ep) {
@@ -72,7 +72,7 @@ static inline int buf_check_size(struct cbuf *buf, int len)
72 return 1; 72 return 1;
73} 73}
74 74
75static inline void *buf_alloc(struct cbuf *buf, int len) 75static void *buf_alloc(struct cbuf *buf, int len)
76{ 76{
77 void *ret = NULL; 77 void *ret = NULL;
78 78
@@ -84,7 +84,7 @@ static inline void *buf_alloc(struct cbuf *buf, int len)
84 return ret; 84 return ret;
85} 85}
86 86
87static inline void buf_put_int8(struct cbuf *buf, u8 val) 87static void buf_put_int8(struct cbuf *buf, u8 val)
88{ 88{
89 if (buf_check_size(buf, 1)) { 89 if (buf_check_size(buf, 1)) {
90 buf->p[0] = val; 90 buf->p[0] = val;
@@ -92,7 +92,7 @@ static inline void buf_put_int8(struct cbuf *buf, u8 val)
92 } 92 }
93} 93}
94 94
95static inline void buf_put_int16(struct cbuf *buf, u16 val) 95static void buf_put_int16(struct cbuf *buf, u16 val)
96{ 96{
97 if (buf_check_size(buf, 2)) { 97 if (buf_check_size(buf, 2)) {
98 *(__le16 *) buf->p = cpu_to_le16(val); 98 *(__le16 *) buf->p = cpu_to_le16(val);
@@ -100,7 +100,7 @@ static inline void buf_put_int16(struct cbuf *buf, u16 val)
100 } 100 }
101} 101}
102 102
103static inline void buf_put_int32(struct cbuf *buf, u32 val) 103static void buf_put_int32(struct cbuf *buf, u32 val)
104{ 104{
105 if (buf_check_size(buf, 4)) { 105 if (buf_check_size(buf, 4)) {
106 *(__le32 *)buf->p = cpu_to_le32(val); 106 *(__le32 *)buf->p = cpu_to_le32(val);
@@ -108,7 +108,7 @@ static inline void buf_put_int32(struct cbuf *buf, u32 val)
108 } 108 }
109} 109}
110 110
111static inline void buf_put_int64(struct cbuf *buf, u64 val) 111static void buf_put_int64(struct cbuf *buf, u64 val)
112{ 112{
113 if (buf_check_size(buf, 8)) { 113 if (buf_check_size(buf, 8)) {
114 *(__le64 *)buf->p = cpu_to_le64(val); 114 *(__le64 *)buf->p = cpu_to_le64(val);
@@ -116,7 +116,7 @@ static inline void buf_put_int64(struct cbuf *buf, u64 val)
116 } 116 }
117} 117}
118 118
119static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) 119static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
120{ 120{
121 if (buf_check_size(buf, slen + 2)) { 121 if (buf_check_size(buf, slen + 2)) {
122 buf_put_int16(buf, slen); 122 buf_put_int16(buf, slen);
@@ -130,7 +130,7 @@ static inline void buf_put_string(struct cbuf *buf, const char *s)
130 buf_put_stringn(buf, s, strlen(s)); 130 buf_put_stringn(buf, s, strlen(s));
131} 131}
132 132
133static inline u8 buf_get_int8(struct cbuf *buf) 133static u8 buf_get_int8(struct cbuf *buf)
134{ 134{
135 u8 ret = 0; 135 u8 ret = 0;
136 136
@@ -142,7 +142,7 @@ static inline u8 buf_get_int8(struct cbuf *buf)
142 return ret; 142 return ret;
143} 143}
144 144
145static inline u16 buf_get_int16(struct cbuf *buf) 145static u16 buf_get_int16(struct cbuf *buf)
146{ 146{
147 u16 ret = 0; 147 u16 ret = 0;
148 148
@@ -154,7 +154,7 @@ static inline u16 buf_get_int16(struct cbuf *buf)
154 return ret; 154 return ret;
155} 155}
156 156
157static inline u32 buf_get_int32(struct cbuf *buf) 157static u32 buf_get_int32(struct cbuf *buf)
158{ 158{
159 u32 ret = 0; 159 u32 ret = 0;
160 160
@@ -166,7 +166,7 @@ static inline u32 buf_get_int32(struct cbuf *buf)
166 return ret; 166 return ret;
167} 167}
168 168
169static inline u64 buf_get_int64(struct cbuf *buf) 169static u64 buf_get_int64(struct cbuf *buf)
170{ 170{
171 u64 ret = 0; 171 u64 ret = 0;
172 172
@@ -178,7 +178,7 @@ static inline u64 buf_get_int64(struct cbuf *buf)
178 return ret; 178 return ret;
179} 179}
180 180
181static inline void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr) 181static void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr)
182{ 182{
183 vstr->len = buf_get_int16(buf); 183 vstr->len = buf_get_int16(buf);
184 if (!buf_check_overflow(buf) && buf_check_size(buf, vstr->len)) { 184 if (!buf_check_overflow(buf) && buf_check_size(buf, vstr->len)) {
@@ -190,7 +190,7 @@ static inline void buf_get_str(struct cbuf *buf, struct v9fs_str *vstr)
190 } 190 }
191} 191}
192 192
193static inline void buf_get_qid(struct cbuf *bufp, struct v9fs_qid *qid) 193static void buf_get_qid(struct cbuf *bufp, struct v9fs_qid *qid)
194{ 194{
195 qid->type = buf_get_int8(bufp); 195 qid->type = buf_get_int8(bufp);
196 qid->version = buf_get_int32(bufp); 196 qid->version = buf_get_int32(bufp);
@@ -254,7 +254,7 @@ static int v9fs_size_wstat(struct v9fs_wstat *wstat, int extended)
254 * 254 *
255 */ 255 */
256 256
257static inline void 257static void
258buf_get_stat(struct cbuf *bufp, struct v9fs_stat *stat, int extended) 258buf_get_stat(struct cbuf *bufp, struct v9fs_stat *stat, int extended)
259{ 259{
260 stat->size = buf_get_int16(bufp); 260 stat->size = buf_get_int16(bufp);
@@ -427,7 +427,7 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p)
427 buf_put_int64(bufp, val); 427 buf_put_int64(bufp, val);
428} 428}
429 429
430static inline void 430static void
431v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) 431v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
432{ 432{
433 if (data) { 433 if (data) {
@@ -441,7 +441,7 @@ v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
441 buf_put_stringn(bufp, data, str->len); 441 buf_put_stringn(bufp, data, str->len);
442} 442}
443 443
444static inline int 444static int
445v9fs_put_user_data(struct cbuf *bufp, const char __user * data, int count, 445v9fs_put_user_data(struct cbuf *bufp, const char __user * data, int count,
446 unsigned char **pdata) 446 unsigned char **pdata)
447{ 447{
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index e93a7ae467c9..62d8d4acb8bb 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -195,6 +195,8 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
195 if (!empty) 195 if (!empty)
196 d_invalidate(dentry); 196 d_invalidate(dentry);
197 197
198 nd.dentry = dentry;
199 nd.mnt = mnt;
198 nd.flags = LOOKUP_DIRECTORY; 200 nd.flags = LOOKUP_DIRECTORY;
199 status = (dentry->d_op->d_revalidate)(dentry, &nd); 201 status = (dentry->d_op->d_revalidate)(dentry, &nd);
200 202
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f979ebbce49c..1b117a441298 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1218,7 +1218,7 @@ static int writenote(struct memelfnote *men, struct file *file)
1218 if (!dump_seek(file, (off))) \ 1218 if (!dump_seek(file, (off))) \
1219 goto end_coredump; 1219 goto end_coredump;
1220 1220
1221static inline void fill_elf_header(struct elfhdr *elf, int segs) 1221static void fill_elf_header(struct elfhdr *elf, int segs)
1222{ 1222{
1223 memcpy(elf->e_ident, ELFMAG, SELFMAG); 1223 memcpy(elf->e_ident, ELFMAG, SELFMAG);
1224 elf->e_ident[EI_CLASS] = ELF_CLASS; 1224 elf->e_ident[EI_CLASS] = ELF_CLASS;
@@ -1243,7 +1243,7 @@ static inline void fill_elf_header(struct elfhdr *elf, int segs)
1243 return; 1243 return;
1244} 1244}
1245 1245
1246static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset) 1246static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset)
1247{ 1247{
1248 phdr->p_type = PT_NOTE; 1248 phdr->p_type = PT_NOTE;
1249 phdr->p_offset = offset; 1249 phdr->p_offset = offset;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 9ccc7d8275b8..6a7b730c206b 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -264,7 +264,7 @@ static int unquote(char *from)
264 return p - from; 264 return p - from;
265} 265}
266 266
267static inline char * check_special_flags (char * sfs, Node * e) 267static char * check_special_flags (char * sfs, Node * e)
268{ 268{
269 char * p = sfs; 269 char * p = sfs;
270 int cont = 1; 270 int cont = 1;
diff --git a/fs/bio.c b/fs/bio.c
index 7b3069589951..bbc442b8c867 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -123,7 +123,7 @@ static void bio_fs_destructor(struct bio *bio)
123 bio_free(bio, fs_bio_set); 123 bio_free(bio, fs_bio_set);
124} 124}
125 125
126inline void bio_init(struct bio *bio) 126void bio_init(struct bio *bio)
127{ 127{
128 bio->bi_next = NULL; 128 bio->bi_next = NULL;
129 bio->bi_bdev = NULL; 129 bio->bi_bdev = NULL;
@@ -253,7 +253,7 @@ inline int bio_hw_segments(request_queue_t *q, struct bio *bio)
253 * the actual data it points to. Reference count of returned 253 * the actual data it points to. Reference count of returned
254 * bio will be one. 254 * bio will be one.
255 */ 255 */
256inline void __bio_clone(struct bio *bio, struct bio *bio_src) 256void __bio_clone(struct bio *bio, struct bio *bio_src)
257{ 257{
258 request_queue_t *q = bdev_get_queue(bio_src->bi_bdev); 258 request_queue_t *q = bdev_get_queue(bio_src->bi_bdev);
259 259
diff --git a/fs/buffer.c b/fs/buffer.c
index b9bb7ad6897b..3dc712f29d2d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1027,7 +1027,7 @@ try_again:
1027 /* Link the buffer to its page */ 1027 /* Link the buffer to its page */
1028 set_bh_page(bh, page, offset); 1028 set_bh_page(bh, page, offset);
1029 1029
1030 bh->b_end_io = NULL; 1030 init_buffer(bh, NULL, NULL);
1031 } 1031 }
1032 return head; 1032 return head;
1033/* 1033/*
@@ -1165,7 +1165,7 @@ failed:
1165 * some of those buffers may be aliases of filesystem data. 1165 * some of those buffers may be aliases of filesystem data.
1166 * grow_dev_page() will go BUG() if this happens. 1166 * grow_dev_page() will go BUG() if this happens.
1167 */ 1167 */
1168static inline int 1168static int
1169grow_buffers(struct block_device *bdev, sector_t block, int size) 1169grow_buffers(struct block_device *bdev, sector_t block, int size)
1170{ 1170{
1171 struct page *page; 1171 struct page *page;
@@ -1391,7 +1391,7 @@ static void bh_lru_install(struct buffer_head *bh)
1391/* 1391/*
1392 * Look up the bh in this cpu's LRU. If it's there, move it to the head. 1392 * Look up the bh in this cpu's LRU. If it's there, move it to the head.
1393 */ 1393 */
1394static inline struct buffer_head * 1394static struct buffer_head *
1395lookup_bh_lru(struct block_device *bdev, sector_t block, int size) 1395lookup_bh_lru(struct block_device *bdev, sector_t block, int size)
1396{ 1396{
1397 struct buffer_head *ret = NULL; 1397 struct buffer_head *ret = NULL;
@@ -1541,7 +1541,7 @@ EXPORT_SYMBOL(set_bh_page);
1541/* 1541/*
1542 * Called when truncating a buffer on a page completely. 1542 * Called when truncating a buffer on a page completely.
1543 */ 1543 */
1544static inline void discard_buffer(struct buffer_head * bh) 1544static void discard_buffer(struct buffer_head * bh)
1545{ 1545{
1546 lock_buffer(bh); 1546 lock_buffer(bh);
1547 clear_buffer_dirty(bh); 1547 clear_buffer_dirty(bh);
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 3b1b1eefdbb0..21195c481637 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -35,7 +35,7 @@ static struct char_device_struct {
35 unsigned int major; 35 unsigned int major;
36 unsigned int baseminor; 36 unsigned int baseminor;
37 int minorct; 37 int minorct;
38 const char *name; 38 char name[64];
39 struct file_operations *fops; 39 struct file_operations *fops;
40 struct cdev *cdev; /* will die */ 40 struct cdev *cdev; /* will die */
41} *chrdevs[MAX_PROBE_HASH]; 41} *chrdevs[MAX_PROBE_HASH];
@@ -46,34 +46,84 @@ static inline int major_to_index(int major)
46 return major % MAX_PROBE_HASH; 46 return major % MAX_PROBE_HASH;
47} 47}
48 48
49/* get char device names in somewhat random order */ 49struct chrdev_info {
50int get_chrdev_list(char *page) 50 int index;
51{
52 struct char_device_struct *cd; 51 struct char_device_struct *cd;
53 int i, len; 52};
54 53
55 len = sprintf(page, "Character devices:\n"); 54void *get_next_chrdev(void *dev)
55{
56 struct chrdev_info *info;
56 57
58 if (dev == NULL) {
59 info = kmalloc(sizeof(*info), GFP_KERNEL);
60 if (!info)
61 goto out;
62 info->index=0;
63 info->cd = chrdevs[info->index];
64 if (info->cd)
65 goto out;
66 } else {
67 info = dev;
68 }
69
70 while (info->index < ARRAY_SIZE(chrdevs)) {
71 if (info->cd)
72 info->cd = info->cd->next;
73 if (info->cd)
74 goto out;
75 /*
76 * No devices on this chain, move to the next
77 */
78 info->index++;
79 info->cd = (info->index < ARRAY_SIZE(chrdevs)) ?
80 chrdevs[info->index] : NULL;
81 if (info->cd)
82 goto out;
83 }
84
85out:
86 return info;
87}
88
89void *acquire_chrdev_list(void)
90{
57 down(&chrdevs_lock); 91 down(&chrdevs_lock);
92 return get_next_chrdev(NULL);
93}
94
95void release_chrdev_list(void *dev)
96{
97 up(&chrdevs_lock);
98 kfree(dev);
99}
100
101
102int count_chrdev_list(void)
103{
104 struct char_device_struct *cd;
105 int i, count;
106
107 count = 0;
108
58 for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) { 109 for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) {
59 for (cd = chrdevs[i]; cd; cd = cd->next) { 110 for (cd = chrdevs[i]; cd; cd = cd->next)
60 /* 111 count++;
61 * if the current name, plus the 5 extra characters
62 * in the device line for this entry
63 * would run us off the page, we're done
64 */
65 if ((len+strlen(cd->name) + 5) >= PAGE_SIZE)
66 goto page_full;
67
68
69 len += sprintf(page+len, "%3d %s\n",
70 cd->major, cd->name);
71 }
72 } 112 }
73page_full:
74 up(&chrdevs_lock);
75 113
76 return len; 114 return count;
115}
116
117int get_chrdev_info(void *dev, int *major, char **name)
118{
119 struct chrdev_info *info = dev;
120
121 if (info->cd == NULL)
122 return 1;
123
124 *major = info->cd->major;
125 *name = info->cd->name;
126 return 0;
77} 127}
78 128
79/* 129/*
@@ -121,7 +171,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
121 cd->major = major; 171 cd->major = major;
122 cd->baseminor = baseminor; 172 cd->baseminor = baseminor;
123 cd->minorct = minorct; 173 cd->minorct = minorct;
124 cd->name = name; 174 strncpy(cd->name,name, 64);
125 175
126 i = major_to_index(major); 176 i = major_to_index(major);
127 177
diff --git a/fs/compat.c b/fs/compat.c
index 271b75d1597f..2468ac1df2f0 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1537,7 +1537,7 @@ out_ret:
1537 * Ooo, nasty. We need here to frob 32-bit unsigned longs to 1537 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
1538 * 64-bit unsigned longs. 1538 * 64-bit unsigned longs.
1539 */ 1539 */
1540static inline 1540static
1541int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1541int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1542 unsigned long *fdset) 1542 unsigned long *fdset)
1543{ 1543{
@@ -1570,7 +1570,7 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1570 return 0; 1570 return 0;
1571} 1571}
1572 1572
1573static inline 1573static
1574void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1574void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1575 unsigned long *fdset) 1575 unsigned long *fdset)
1576{ 1576{
diff --git a/fs/dcache.c b/fs/dcache.c
index 134d6775183f..86bdb93789c6 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -94,7 +94,7 @@ static void d_free(struct dentry *dentry)
94 * d_iput() operation if defined. 94 * d_iput() operation if defined.
95 * Called with dcache_lock and per dentry lock held, drops both. 95 * Called with dcache_lock and per dentry lock held, drops both.
96 */ 96 */
97static inline void dentry_iput(struct dentry * dentry) 97static void dentry_iput(struct dentry * dentry)
98{ 98{
99 struct inode *inode = dentry->d_inode; 99 struct inode *inode = dentry->d_inode;
100 if (inode) { 100 if (inode) {
diff --git a/fs/efs/super.c b/fs/efs/super.c
index d8d5ea9a9997..afc4891feb36 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -222,12 +222,13 @@ static efs_block_t efs_validate_vh(struct volume_header *vh) {
222 sblock); 222 sblock);
223#endif 223#endif
224 } 224 }
225 return(sblock); 225 return sblock;
226} 226}
227 227
228static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) { 228static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) {
229 229
230 if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic))) return -1; 230 if (!IS_EFS_MAGIC(be32_to_cpu(super->fs_magic)))
231 return -1;
231 232
232 sb->fs_magic = be32_to_cpu(super->fs_magic); 233 sb->fs_magic = be32_to_cpu(super->fs_magic);
233 sb->total_blocks = be32_to_cpu(super->fs_size); 234 sb->total_blocks = be32_to_cpu(super->fs_size);
diff --git a/fs/exec.c b/fs/exec.c
index b5bcf1aae0ab..62b40af68cc4 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -575,7 +575,7 @@ static int exec_mmap(struct mm_struct *mm)
575 * disturbing other processes. (Other processes might share the signal 575 * disturbing other processes. (Other processes might share the signal
576 * table via the CLONE_SIGHAND option to clone().) 576 * table via the CLONE_SIGHAND option to clone().)
577 */ 577 */
578static inline int de_thread(struct task_struct *tsk) 578static int de_thread(struct task_struct *tsk)
579{ 579{
580 struct signal_struct *sig = tsk->signal; 580 struct signal_struct *sig = tsk->signal;
581 struct sighand_struct *newsighand, *oldsighand = tsk->sighand; 581 struct sighand_struct *newsighand, *oldsighand = tsk->sighand;
@@ -780,7 +780,7 @@ no_thread_group:
780 * so that a new one can be started 780 * so that a new one can be started
781 */ 781 */
782 782
783static inline void flush_old_files(struct files_struct * files) 783static void flush_old_files(struct files_struct * files)
784{ 784{
785 long j = -1; 785 long j = -1;
786 struct fdtable *fdt; 786 struct fdtable *fdt;
@@ -964,7 +964,7 @@ int prepare_binprm(struct linux_binprm *bprm)
964 964
965EXPORT_SYMBOL(prepare_binprm); 965EXPORT_SYMBOL(prepare_binprm);
966 966
967static inline int unsafe_exec(struct task_struct *p) 967static int unsafe_exec(struct task_struct *p)
968{ 968{
969 int unsafe = 0; 969 int unsafe = 0;
970 if (p->ptrace & PT_PTRACED) { 970 if (p->ptrace & PT_PTRACED) {
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index c5513953c825..ad1432a2a62e 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -83,10 +83,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
83 if (!inode) 83 if (!inode)
84 return ERR_PTR(-EACCES); 84 return ERR_PTR(-EACCES);
85 } 85 }
86 if (inode) 86 return d_splice_alias(inode, dentry);
87 return d_splice_alias(inode, dentry);
88 d_add(dentry, inode);
89 return NULL;
90} 87}
91 88
92struct dentry *ext2_get_parent(struct dentry *child) 89struct dentry *ext2_get_parent(struct dentry *child)
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index af193a304ee5..8bd8ac077704 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1005,10 +1005,7 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
1005 if (!inode) 1005 if (!inode)
1006 return ERR_PTR(-EACCES); 1006 return ERR_PTR(-EACCES);
1007 } 1007 }
1008 if (inode) 1008 return d_splice_alias(inode, dentry);
1009 return d_splice_alias(inode, dentry);
1010 d_add(dentry, inode);
1011 return NULL;
1012} 1009}
1013 1010
1014 1011
diff --git a/fs/fcntl.c b/fs/fcntl.c
index d0767fe58362..5f96786d1c73 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -36,7 +36,7 @@ void fastcall set_close_on_exec(unsigned int fd, int flag)
36 spin_unlock(&files->file_lock); 36 spin_unlock(&files->file_lock);
37} 37}
38 38
39static inline int get_close_on_exec(unsigned int fd) 39static int get_close_on_exec(unsigned int fd)
40{ 40{
41 struct files_struct *files = current->files; 41 struct files_struct *files = current->files;
42 struct fdtable *fdt; 42 struct fdtable *fdt;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index e08ab4702d97..4526da8907c6 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -21,18 +21,18 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR);
21 21
22static kmem_cache_t *fuse_req_cachep; 22static kmem_cache_t *fuse_req_cachep;
23 23
24static inline struct fuse_conn *fuse_get_conn(struct file *file) 24static struct fuse_conn *fuse_get_conn(struct file *file)
25{ 25{
26 struct fuse_conn *fc; 26 struct fuse_conn *fc;
27 spin_lock(&fuse_lock); 27 spin_lock(&fuse_lock);
28 fc = file->private_data; 28 fc = file->private_data;
29 if (fc && !fc->mounted) 29 if (fc && !fc->connected)
30 fc = NULL; 30 fc = NULL;
31 spin_unlock(&fuse_lock); 31 spin_unlock(&fuse_lock);
32 return fc; 32 return fc;
33} 33}
34 34
35static inline void fuse_request_init(struct fuse_req *req) 35static void fuse_request_init(struct fuse_req *req)
36{ 36{
37 memset(req, 0, sizeof(*req)); 37 memset(req, 0, sizeof(*req));
38 INIT_LIST_HEAD(&req->list); 38 INIT_LIST_HEAD(&req->list);
@@ -53,7 +53,7 @@ void fuse_request_free(struct fuse_req *req)
53 kmem_cache_free(fuse_req_cachep, req); 53 kmem_cache_free(fuse_req_cachep, req);
54} 54}
55 55
56static inline void block_sigs(sigset_t *oldset) 56static void block_sigs(sigset_t *oldset)
57{ 57{
58 sigset_t mask; 58 sigset_t mask;
59 59
@@ -61,7 +61,7 @@ static inline void block_sigs(sigset_t *oldset)
61 sigprocmask(SIG_BLOCK, &mask, oldset); 61 sigprocmask(SIG_BLOCK, &mask, oldset);
62} 62}
63 63
64static inline void restore_sigs(sigset_t *oldset) 64static void restore_sigs(sigset_t *oldset)
65{ 65{
66 sigprocmask(SIG_SETMASK, oldset, NULL); 66 sigprocmask(SIG_SETMASK, oldset, NULL);
67} 67}
@@ -109,18 +109,24 @@ struct fuse_req *fuse_get_request(struct fuse_conn *fc)
109 int intr; 109 int intr;
110 sigset_t oldset; 110 sigset_t oldset;
111 111
112 atomic_inc(&fc->num_waiting);
112 block_sigs(&oldset); 113 block_sigs(&oldset);
113 intr = down_interruptible(&fc->outstanding_sem); 114 intr = down_interruptible(&fc->outstanding_sem);
114 restore_sigs(&oldset); 115 restore_sigs(&oldset);
115 return intr ? NULL : do_get_request(fc); 116 if (intr) {
117 atomic_dec(&fc->num_waiting);
118 return NULL;
119 }
120 return do_get_request(fc);
116} 121}
117 122
118static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req) 123static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req)
119{ 124{
120 spin_lock(&fuse_lock); 125 spin_lock(&fuse_lock);
121 if (req->preallocated) 126 if (req->preallocated) {
127 atomic_dec(&fc->num_waiting);
122 list_add(&req->list, &fc->unused_list); 128 list_add(&req->list, &fc->unused_list);
123 else 129 } else
124 fuse_request_free(req); 130 fuse_request_free(req);
125 131
126 /* If we are in debt decrease that first */ 132 /* If we are in debt decrease that first */
@@ -148,42 +154,23 @@ void fuse_release_background(struct fuse_req *req)
148 spin_unlock(&fuse_lock); 154 spin_unlock(&fuse_lock);
149} 155}
150 156
151static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
152{
153 int i;
154 struct fuse_init_out *arg = &req->misc.init_out;
155
156 if (arg->major != FUSE_KERNEL_VERSION)
157 fc->conn_error = 1;
158 else {
159 fc->minor = arg->minor;
160 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
161 }
162
163 /* After INIT reply is received other requests can go
164 out. So do (FUSE_MAX_OUTSTANDING - 1) number of
165 up()s on outstanding_sem. The last up() is done in
166 fuse_putback_request() */
167 for (i = 1; i < FUSE_MAX_OUTSTANDING; i++)
168 up(&fc->outstanding_sem);
169}
170
171/* 157/*
172 * This function is called when a request is finished. Either a reply 158 * This function is called when a request is finished. Either a reply
173 * has arrived or it was interrupted (and not yet sent) or some error 159 * has arrived or it was interrupted (and not yet sent) or some error
174 * occurred during communication with userspace, or the device file was 160 * occurred during communication with userspace, or the device file
175 * closed. It decreases the reference count for the request. In case 161 * was closed. In case of a background request the reference to the
176 * of a background request the reference to the stored objects are 162 * stored objects are released. The requester thread is woken up (if
177 * released. The requester thread is woken up (if still waiting), and 163 * still waiting), the 'end' callback is called if given, else the
178 * finally the request is either freed or put on the unused_list 164 * reference to the request is released
179 * 165 *
180 * Called with fuse_lock, unlocks it 166 * Called with fuse_lock, unlocks it
181 */ 167 */
182static void request_end(struct fuse_conn *fc, struct fuse_req *req) 168static void request_end(struct fuse_conn *fc, struct fuse_req *req)
183{ 169{
184 int putback; 170 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
185 req->finished = 1; 171 req->end = NULL;
186 putback = atomic_dec_and_test(&req->count); 172 list_del(&req->list);
173 req->state = FUSE_REQ_FINISHED;
187 spin_unlock(&fuse_lock); 174 spin_unlock(&fuse_lock);
188 if (req->background) { 175 if (req->background) {
189 down_read(&fc->sbput_sem); 176 down_read(&fc->sbput_sem);
@@ -192,18 +179,10 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
192 up_read(&fc->sbput_sem); 179 up_read(&fc->sbput_sem);
193 } 180 }
194 wake_up(&req->waitq); 181 wake_up(&req->waitq);
195 if (req->in.h.opcode == FUSE_INIT) 182 if (end)
196 process_init_reply(fc, req); 183 end(fc, req);
197 else if (req->in.h.opcode == FUSE_RELEASE && req->inode == NULL) { 184 else
198 /* Special case for failed iget in CREATE */ 185 fuse_put_request(fc, req);
199 u64 nodeid = req->in.h.nodeid;
200 __fuse_get_request(req);
201 fuse_reset_request(req);
202 fuse_send_forget(fc, req, nodeid, 1);
203 putback = 0;
204 }
205 if (putback)
206 fuse_putback_request(fc, req);
207} 186}
208 187
209/* 188/*
@@ -254,14 +233,16 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
254 233
255 spin_unlock(&fuse_lock); 234 spin_unlock(&fuse_lock);
256 block_sigs(&oldset); 235 block_sigs(&oldset);
257 wait_event_interruptible(req->waitq, req->finished); 236 wait_event_interruptible(req->waitq, req->state == FUSE_REQ_FINISHED);
258 restore_sigs(&oldset); 237 restore_sigs(&oldset);
259 spin_lock(&fuse_lock); 238 spin_lock(&fuse_lock);
260 if (req->finished) 239 if (req->state == FUSE_REQ_FINISHED && !req->interrupted)
261 return; 240 return;
262 241
263 req->out.h.error = -EINTR; 242 if (!req->interrupted) {
264 req->interrupted = 1; 243 req->out.h.error = -EINTR;
244 req->interrupted = 1;
245 }
265 if (req->locked) { 246 if (req->locked) {
266 /* This is uninterruptible sleep, because data is 247 /* This is uninterruptible sleep, because data is
267 being copied to/from the buffers of req. During 248 being copied to/from the buffers of req. During
@@ -272,10 +253,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
272 wait_event(req->waitq, !req->locked); 253 wait_event(req->waitq, !req->locked);
273 spin_lock(&fuse_lock); 254 spin_lock(&fuse_lock);
274 } 255 }
275 if (!req->sent && !list_empty(&req->list)) { 256 if (req->state == FUSE_REQ_PENDING) {
276 list_del(&req->list); 257 list_del(&req->list);
277 __fuse_put_request(req); 258 __fuse_put_request(req);
278 } else if (!req->finished && req->sent) 259 } else if (req->state == FUSE_REQ_SENT)
279 background_request(fc, req); 260 background_request(fc, req);
280} 261}
281 262
@@ -310,6 +291,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
310 fc->outstanding_debt++; 291 fc->outstanding_debt++;
311 } 292 }
312 list_add_tail(&req->list, &fc->pending); 293 list_add_tail(&req->list, &fc->pending);
294 req->state = FUSE_REQ_PENDING;
313 wake_up(&fc->waitq); 295 wake_up(&fc->waitq);
314} 296}
315 297
@@ -362,34 +344,12 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req)
362 request_send_nowait(fc, req); 344 request_send_nowait(fc, req);
363} 345}
364 346
365void fuse_send_init(struct fuse_conn *fc)
366{
367 /* This is called from fuse_read_super() so there's guaranteed
368 to be a request available */
369 struct fuse_req *req = do_get_request(fc);
370 struct fuse_init_in *arg = &req->misc.init_in;
371 arg->major = FUSE_KERNEL_VERSION;
372 arg->minor = FUSE_KERNEL_MINOR_VERSION;
373 req->in.h.opcode = FUSE_INIT;
374 req->in.numargs = 1;
375 req->in.args[0].size = sizeof(*arg);
376 req->in.args[0].value = arg;
377 req->out.numargs = 1;
378 /* Variable length arguement used for backward compatibility
379 with interface version < 7.5. Rest of init_out is zeroed
380 by do_get_request(), so a short reply is not a problem */
381 req->out.argvar = 1;
382 req->out.args[0].size = sizeof(struct fuse_init_out);
383 req->out.args[0].value = &req->misc.init_out;
384 request_send_background(fc, req);
385}
386
387/* 347/*
388 * Lock the request. Up to the next unlock_request() there mustn't be 348 * Lock the request. Up to the next unlock_request() there mustn't be
389 * anything that could cause a page-fault. If the request was already 349 * anything that could cause a page-fault. If the request was already
390 * interrupted bail out. 350 * interrupted bail out.
391 */ 351 */
392static inline int lock_request(struct fuse_req *req) 352static int lock_request(struct fuse_req *req)
393{ 353{
394 int err = 0; 354 int err = 0;
395 if (req) { 355 if (req) {
@@ -408,7 +368,7 @@ static inline int lock_request(struct fuse_req *req)
408 * requester thread is currently waiting for it to be unlocked, so 368 * requester thread is currently waiting for it to be unlocked, so
409 * wake it up. 369 * wake it up.
410 */ 370 */
411static inline void unlock_request(struct fuse_req *req) 371static void unlock_request(struct fuse_req *req)
412{ 372{
413 if (req) { 373 if (req) {
414 spin_lock(&fuse_lock); 374 spin_lock(&fuse_lock);
@@ -444,7 +404,7 @@ static void fuse_copy_init(struct fuse_copy_state *cs, int write,
444} 404}
445 405
446/* Unmap and put previous page of userspace buffer */ 406/* Unmap and put previous page of userspace buffer */
447static inline void fuse_copy_finish(struct fuse_copy_state *cs) 407static void fuse_copy_finish(struct fuse_copy_state *cs)
448{ 408{
449 if (cs->mapaddr) { 409 if (cs->mapaddr) {
450 kunmap_atomic(cs->mapaddr, KM_USER0); 410 kunmap_atomic(cs->mapaddr, KM_USER0);
@@ -493,8 +453,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
493} 453}
494 454
495/* Do as much copy to/from userspace buffer as we can */ 455/* Do as much copy to/from userspace buffer as we can */
496static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val, 456static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size)
497 unsigned *size)
498{ 457{
499 unsigned ncpy = min(*size, cs->len); 458 unsigned ncpy = min(*size, cs->len);
500 if (val) { 459 if (val) {
@@ -514,8 +473,8 @@ static inline int fuse_copy_do(struct fuse_copy_state *cs, void **val,
514 * Copy a page in the request to/from the userspace buffer. Must be 473 * Copy a page in the request to/from the userspace buffer. Must be
515 * done atomically 474 * done atomically
516 */ 475 */
517static inline int fuse_copy_page(struct fuse_copy_state *cs, struct page *page, 476static int fuse_copy_page(struct fuse_copy_state *cs, struct page *page,
518 unsigned offset, unsigned count, int zeroing) 477 unsigned offset, unsigned count, int zeroing)
519{ 478{
520 if (page && zeroing && count < PAGE_SIZE) { 479 if (page && zeroing && count < PAGE_SIZE) {
521 void *mapaddr = kmap_atomic(page, KM_USER1); 480 void *mapaddr = kmap_atomic(page, KM_USER1);
@@ -597,7 +556,7 @@ static void request_wait(struct fuse_conn *fc)
597 DECLARE_WAITQUEUE(wait, current); 556 DECLARE_WAITQUEUE(wait, current);
598 557
599 add_wait_queue_exclusive(&fc->waitq, &wait); 558 add_wait_queue_exclusive(&fc->waitq, &wait);
600 while (fc->mounted && list_empty(&fc->pending)) { 559 while (fc->connected && list_empty(&fc->pending)) {
601 set_current_state(TASK_INTERRUPTIBLE); 560 set_current_state(TASK_INTERRUPTIBLE);
602 if (signal_pending(current)) 561 if (signal_pending(current))
603 break; 562 break;
@@ -637,14 +596,15 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
637 goto err_unlock; 596 goto err_unlock;
638 request_wait(fc); 597 request_wait(fc);
639 err = -ENODEV; 598 err = -ENODEV;
640 if (!fc->mounted) 599 if (!fc->connected)
641 goto err_unlock; 600 goto err_unlock;
642 err = -ERESTARTSYS; 601 err = -ERESTARTSYS;
643 if (list_empty(&fc->pending)) 602 if (list_empty(&fc->pending))
644 goto err_unlock; 603 goto err_unlock;
645 604
646 req = list_entry(fc->pending.next, struct fuse_req, list); 605 req = list_entry(fc->pending.next, struct fuse_req, list);
647 list_del_init(&req->list); 606 req->state = FUSE_REQ_READING;
607 list_move(&req->list, &fc->io);
648 608
649 in = &req->in; 609 in = &req->in;
650 reqsize = in->h.len; 610 reqsize = in->h.len;
@@ -677,8 +637,8 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
677 if (!req->isreply) 637 if (!req->isreply)
678 request_end(fc, req); 638 request_end(fc, req);
679 else { 639 else {
680 req->sent = 1; 640 req->state = FUSE_REQ_SENT;
681 list_add_tail(&req->list, &fc->processing); 641 list_move_tail(&req->list, &fc->processing);
682 spin_unlock(&fuse_lock); 642 spin_unlock(&fuse_lock);
683 } 643 }
684 return reqsize; 644 return reqsize;
@@ -766,17 +726,23 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
766 goto err_finish; 726 goto err_finish;
767 727
768 spin_lock(&fuse_lock); 728 spin_lock(&fuse_lock);
729 err = -ENOENT;
730 if (!fc->connected)
731 goto err_unlock;
732
769 req = request_find(fc, oh.unique); 733 req = request_find(fc, oh.unique);
770 err = -EINVAL; 734 err = -EINVAL;
771 if (!req) 735 if (!req)
772 goto err_unlock; 736 goto err_unlock;
773 737
774 list_del_init(&req->list);
775 if (req->interrupted) { 738 if (req->interrupted) {
776 request_end(fc, req); 739 spin_unlock(&fuse_lock);
777 fuse_copy_finish(&cs); 740 fuse_copy_finish(&cs);
741 spin_lock(&fuse_lock);
742 request_end(fc, req);
778 return -ENOENT; 743 return -ENOENT;
779 } 744 }
745 list_move(&req->list, &fc->io);
780 req->out.h = oh; 746 req->out.h = oh;
781 req->locked = 1; 747 req->locked = 1;
782 cs.req = req; 748 cs.req = req;
@@ -830,19 +796,90 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
830 return mask; 796 return mask;
831} 797}
832 798
833/* Abort all requests on the given list (pending or processing) */ 799/*
800 * Abort all requests on the given list (pending or processing)
801 *
802 * This function releases and reacquires fuse_lock
803 */
834static void end_requests(struct fuse_conn *fc, struct list_head *head) 804static void end_requests(struct fuse_conn *fc, struct list_head *head)
835{ 805{
836 while (!list_empty(head)) { 806 while (!list_empty(head)) {
837 struct fuse_req *req; 807 struct fuse_req *req;
838 req = list_entry(head->next, struct fuse_req, list); 808 req = list_entry(head->next, struct fuse_req, list);
839 list_del_init(&req->list);
840 req->out.h.error = -ECONNABORTED; 809 req->out.h.error = -ECONNABORTED;
841 request_end(fc, req); 810 request_end(fc, req);
842 spin_lock(&fuse_lock); 811 spin_lock(&fuse_lock);
843 } 812 }
844} 813}
845 814
815/*
816 * Abort requests under I/O
817 *
818 * The requests are set to interrupted and finished, and the request
819 * waiter is woken up. This will make request_wait_answer() wait
820 * until the request is unlocked and then return.
821 *
822 * If the request is asynchronous, then the end function needs to be
823 * called after waiting for the request to be unlocked (if it was
824 * locked).
825 */
826static void end_io_requests(struct fuse_conn *fc)
827{
828 while (!list_empty(&fc->io)) {
829 struct fuse_req *req =
830 list_entry(fc->io.next, struct fuse_req, list);
831 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
832
833 req->interrupted = 1;
834 req->out.h.error = -ECONNABORTED;
835 req->state = FUSE_REQ_FINISHED;
836 list_del_init(&req->list);
837 wake_up(&req->waitq);
838 if (end) {
839 req->end = NULL;
840 /* The end function will consume this reference */
841 __fuse_get_request(req);
842 spin_unlock(&fuse_lock);
843 wait_event(req->waitq, !req->locked);
844 end(fc, req);
845 spin_lock(&fuse_lock);
846 }
847 }
848}
849
850/*
851 * Abort all requests.
852 *
853 * Emergency exit in case of a malicious or accidental deadlock, or
854 * just a hung filesystem.
855 *
856 * The same effect is usually achievable through killing the
857 * filesystem daemon and all users of the filesystem. The exception
858 * is the combination of an asynchronous request and the tricky
859 * deadlock (see Documentation/filesystems/fuse.txt).
860 *
861 * During the aborting, progression of requests from the pending and
862 * processing lists onto the io list, and progression of new requests
863 * onto the pending list is prevented by req->connected being false.
864 *
865 * Progression of requests under I/O to the processing list is
866 * prevented by the req->interrupted flag being true for these
867 * requests. For this reason requests on the io list must be aborted
868 * first.
869 */
870void fuse_abort_conn(struct fuse_conn *fc)
871{
872 spin_lock(&fuse_lock);
873 if (fc->connected) {
874 fc->connected = 0;
875 end_io_requests(fc);
876 end_requests(fc, &fc->pending);
877 end_requests(fc, &fc->processing);
878 wake_up_all(&fc->waitq);
879 }
880 spin_unlock(&fuse_lock);
881}
882
846static int fuse_dev_release(struct inode *inode, struct file *file) 883static int fuse_dev_release(struct inode *inode, struct file *file)
847{ 884{
848 struct fuse_conn *fc; 885 struct fuse_conn *fc;
@@ -853,9 +890,11 @@ static int fuse_dev_release(struct inode *inode, struct file *file)
853 fc->connected = 0; 890 fc->connected = 0;
854 end_requests(fc, &fc->pending); 891 end_requests(fc, &fc->pending);
855 end_requests(fc, &fc->processing); 892 end_requests(fc, &fc->processing);
856 fuse_release_conn(fc);
857 } 893 }
858 spin_unlock(&fuse_lock); 894 spin_unlock(&fuse_lock);
895 if (fc)
896 kobject_put(&fc->kobj);
897
859 return 0; 898 return 0;
860} 899}
861 900
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 417bcee466f6..21fd59c7bc24 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -23,8 +23,7 @@
23/* 23/*
24 * Calculate the time in jiffies until a dentry/attributes are valid 24 * Calculate the time in jiffies until a dentry/attributes are valid
25 */ 25 */
26static inline unsigned long time_to_jiffies(unsigned long sec, 26static unsigned long time_to_jiffies(unsigned long sec, unsigned long nsec)
27 unsigned long nsec)
28{ 27{
29 struct timespec ts = {sec, nsec}; 28 struct timespec ts = {sec, nsec};
30 return jiffies + timespec_to_jiffies(&ts); 29 return jiffies + timespec_to_jiffies(&ts);
@@ -157,7 +156,7 @@ static int dir_alias(struct inode *inode)
157 return 0; 156 return 0;
158} 157}
159 158
160static inline int invalid_nodeid(u64 nodeid) 159static int invalid_nodeid(u64 nodeid)
161{ 160{
162 return !nodeid || nodeid == FUSE_ROOT_ID; 161 return !nodeid || nodeid == FUSE_ROOT_ID;
163} 162}
@@ -166,7 +165,7 @@ static struct dentry_operations fuse_dentry_operations = {
166 .d_revalidate = fuse_dentry_revalidate, 165 .d_revalidate = fuse_dentry_revalidate,
167}; 166};
168 167
169static inline int valid_mode(int m) 168static int valid_mode(int m)
170{ 169{
171 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || 170 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) ||
172 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); 171 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
@@ -763,13 +762,6 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
763 return 0; 762 return 0;
764} 763}
765 764
766static inline size_t fuse_send_readdir(struct fuse_req *req, struct file *file,
767 struct inode *inode, loff_t pos,
768 size_t count)
769{
770 return fuse_send_read_common(req, file, inode, pos, count, 1);
771}
772
773static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) 765static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
774{ 766{
775 int err; 767 int err;
@@ -793,7 +785,9 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
793 } 785 }
794 req->num_pages = 1; 786 req->num_pages = 1;
795 req->pages[0] = page; 787 req->pages[0] = page;
796 nbytes = fuse_send_readdir(req, file, inode, file->f_pos, PAGE_SIZE); 788 fuse_read_fill(req, file, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR);
789 request_send(fc, req);
790 nbytes = req->out.args[0].size;
797 err = req->out.h.error; 791 err = req->out.h.error;
798 fuse_put_request(fc, req); 792 fuse_put_request(fc, req);
799 if (!err) 793 if (!err)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 63d2980df5c9..a7ef5e716f3c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -113,6 +113,14 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
113 return err; 113 return err;
114} 114}
115 115
116/* Special case for failed iget in CREATE */
117static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req)
118{
119 u64 nodeid = req->in.h.nodeid;
120 fuse_reset_request(req);
121 fuse_send_forget(fc, req, nodeid, 1);
122}
123
116void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff, 124void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff,
117 u64 nodeid, struct inode *inode, int flags, int isdir) 125 u64 nodeid, struct inode *inode, int flags, int isdir)
118{ 126{
@@ -128,6 +136,8 @@ void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff,
128 req->in.args[0].size = sizeof(struct fuse_release_in); 136 req->in.args[0].size = sizeof(struct fuse_release_in);
129 req->in.args[0].value = inarg; 137 req->in.args[0].value = inarg;
130 request_send_background(fc, req); 138 request_send_background(fc, req);
139 if (!inode)
140 req->end = fuse_release_end;
131 kfree(ff); 141 kfree(ff);
132} 142}
133 143
@@ -240,38 +250,35 @@ static int fuse_fsync(struct file *file, struct dentry *de, int datasync)
240 return fuse_fsync_common(file, de, datasync, 0); 250 return fuse_fsync_common(file, de, datasync, 0);
241} 251}
242 252
243size_t fuse_send_read_common(struct fuse_req *req, struct file *file, 253void fuse_read_fill(struct fuse_req *req, struct file *file,
244 struct inode *inode, loff_t pos, size_t count, 254 struct inode *inode, loff_t pos, size_t count, int opcode)
245 int isdir)
246{ 255{
247 struct fuse_conn *fc = get_fuse_conn(inode);
248 struct fuse_file *ff = file->private_data; 256 struct fuse_file *ff = file->private_data;
249 struct fuse_read_in inarg; 257 struct fuse_read_in *inarg = &req->misc.read_in;
250 258
251 memset(&inarg, 0, sizeof(struct fuse_read_in)); 259 inarg->fh = ff->fh;
252 inarg.fh = ff->fh; 260 inarg->offset = pos;
253 inarg.offset = pos; 261 inarg->size = count;
254 inarg.size = count; 262 req->in.h.opcode = opcode;
255 req->in.h.opcode = isdir ? FUSE_READDIR : FUSE_READ;
256 req->in.h.nodeid = get_node_id(inode); 263 req->in.h.nodeid = get_node_id(inode);
257 req->inode = inode; 264 req->inode = inode;
258 req->file = file; 265 req->file = file;
259 req->in.numargs = 1; 266 req->in.numargs = 1;
260 req->in.args[0].size = sizeof(struct fuse_read_in); 267 req->in.args[0].size = sizeof(struct fuse_read_in);
261 req->in.args[0].value = &inarg; 268 req->in.args[0].value = inarg;
262 req->out.argpages = 1; 269 req->out.argpages = 1;
263 req->out.argvar = 1; 270 req->out.argvar = 1;
264 req->out.numargs = 1; 271 req->out.numargs = 1;
265 req->out.args[0].size = count; 272 req->out.args[0].size = count;
266 request_send(fc, req);
267 return req->out.args[0].size;
268} 273}
269 274
270static inline size_t fuse_send_read(struct fuse_req *req, struct file *file, 275static size_t fuse_send_read(struct fuse_req *req, struct file *file,
271 struct inode *inode, loff_t pos, 276 struct inode *inode, loff_t pos, size_t count)
272 size_t count)
273{ 277{
274 return fuse_send_read_common(req, file, inode, pos, count, 0); 278 struct fuse_conn *fc = get_fuse_conn(inode);
279 fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
280 request_send(fc, req);
281 return req->out.args[0].size;
275} 282}
276 283
277static int fuse_readpage(struct file *file, struct page *page) 284static int fuse_readpage(struct file *file, struct page *page)
@@ -304,21 +311,33 @@ static int fuse_readpage(struct file *file, struct page *page)
304 return err; 311 return err;
305} 312}
306 313
307static int fuse_send_readpages(struct fuse_req *req, struct file *file, 314static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
308 struct inode *inode)
309{ 315{
310 loff_t pos = page_offset(req->pages[0]); 316 int i;
311 size_t count = req->num_pages << PAGE_CACHE_SHIFT; 317
312 unsigned i; 318 fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */
313 req->out.page_zeroing = 1; 319
314 fuse_send_read(req, file, inode, pos, count);
315 for (i = 0; i < req->num_pages; i++) { 320 for (i = 0; i < req->num_pages; i++) {
316 struct page *page = req->pages[i]; 321 struct page *page = req->pages[i];
317 if (!req->out.h.error) 322 if (!req->out.h.error)
318 SetPageUptodate(page); 323 SetPageUptodate(page);
324 else
325 SetPageError(page);
319 unlock_page(page); 326 unlock_page(page);
320 } 327 }
321 return req->out.h.error; 328 fuse_put_request(fc, req);
329}
330
331static void fuse_send_readpages(struct fuse_req *req, struct file *file,
332 struct inode *inode)
333{
334 struct fuse_conn *fc = get_fuse_conn(inode);
335 loff_t pos = page_offset(req->pages[0]);
336 size_t count = req->num_pages << PAGE_CACHE_SHIFT;
337 req->out.page_zeroing = 1;
338 req->end = fuse_readpages_end;
339 fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
340 request_send_background(fc, req);
322} 341}
323 342
324struct fuse_readpages_data { 343struct fuse_readpages_data {
@@ -338,12 +357,12 @@ static int fuse_readpages_fill(void *_data, struct page *page)
338 (req->num_pages == FUSE_MAX_PAGES_PER_REQ || 357 (req->num_pages == FUSE_MAX_PAGES_PER_REQ ||
339 (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || 358 (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read ||
340 req->pages[req->num_pages - 1]->index + 1 != page->index)) { 359 req->pages[req->num_pages - 1]->index + 1 != page->index)) {
341 int err = fuse_send_readpages(req, data->file, inode); 360 fuse_send_readpages(req, data->file, inode);
342 if (err) { 361 data->req = req = fuse_get_request(fc);
362 if (!req) {
343 unlock_page(page); 363 unlock_page(page);
344 return err; 364 return -EINTR;
345 } 365 }
346 fuse_reset_request(req);
347 } 366 }
348 req->pages[req->num_pages] = page; 367 req->pages[req->num_pages] = page;
349 req->num_pages ++; 368 req->num_pages ++;
@@ -368,10 +387,8 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
368 return -EINTR; 387 return -EINTR;
369 388
370 err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); 389 err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
371 if (!err && data.req->num_pages) 390 if (!err)
372 err = fuse_send_readpages(data.req, file, inode); 391 fuse_send_readpages(data.req, file, inode);
373 fuse_put_request(fc, data.req);
374 fuse_invalidate_attr(inode); /* atime changed */
375 return err; 392 return err;
376} 393}
377 394
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 74c8d098a14a..46cf933aa3bf 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -94,6 +94,11 @@ struct fuse_out {
94 /** Header returned from userspace */ 94 /** Header returned from userspace */
95 struct fuse_out_header h; 95 struct fuse_out_header h;
96 96
97 /*
98 * The following bitfields are not changed during the request
99 * processing
100 */
101
97 /** Last argument is variable length (can be shorter than 102 /** Last argument is variable length (can be shorter than
98 arg->size) */ 103 arg->size) */
99 unsigned argvar:1; 104 unsigned argvar:1;
@@ -111,12 +116,23 @@ struct fuse_out {
111 struct fuse_arg args[3]; 116 struct fuse_arg args[3];
112}; 117};
113 118
119/** The request state */
120enum fuse_req_state {
121 FUSE_REQ_INIT = 0,
122 FUSE_REQ_PENDING,
123 FUSE_REQ_READING,
124 FUSE_REQ_SENT,
125 FUSE_REQ_FINISHED
126};
127
128struct fuse_conn;
129
114/** 130/**
115 * A request to the client 131 * A request to the client
116 */ 132 */
117struct fuse_req { 133struct fuse_req {
118 /** This can be on either unused_list, pending or processing 134 /** This can be on either unused_list, pending processing or
119 lists in fuse_conn */ 135 io lists in fuse_conn */
120 struct list_head list; 136 struct list_head list;
121 137
122 /** Entry on the background list */ 138 /** Entry on the background list */
@@ -125,6 +141,12 @@ struct fuse_req {
125 /** refcount */ 141 /** refcount */
126 atomic_t count; 142 atomic_t count;
127 143
144 /*
145 * The following bitfields are either set once before the
146 * request is queued or setting/clearing them is protected by
147 * fuse_lock
148 */
149
128 /** True if the request has reply */ 150 /** True if the request has reply */
129 unsigned isreply:1; 151 unsigned isreply:1;
130 152
@@ -140,11 +162,8 @@ struct fuse_req {
140 /** Data is being copied to/from the request */ 162 /** Data is being copied to/from the request */
141 unsigned locked:1; 163 unsigned locked:1;
142 164
143 /** Request has been sent to userspace */ 165 /** State of the request */
144 unsigned sent:1; 166 enum fuse_req_state state;
145
146 /** The request is finished */
147 unsigned finished:1;
148 167
149 /** The request input */ 168 /** The request input */
150 struct fuse_in in; 169 struct fuse_in in;
@@ -161,6 +180,7 @@ struct fuse_req {
161 struct fuse_release_in release_in; 180 struct fuse_release_in release_in;
162 struct fuse_init_in init_in; 181 struct fuse_init_in init_in;
163 struct fuse_init_out init_out; 182 struct fuse_init_out init_out;
183 struct fuse_read_in read_in;
164 } misc; 184 } misc;
165 185
166 /** page vector */ 186 /** page vector */
@@ -180,6 +200,9 @@ struct fuse_req {
180 200
181 /** File used in the request (or NULL) */ 201 /** File used in the request (or NULL) */
182 struct file *file; 202 struct file *file;
203
204 /** Request completion callback */
205 void (*end)(struct fuse_conn *, struct fuse_req *);
183}; 206};
184 207
185/** 208/**
@@ -190,9 +213,6 @@ struct fuse_req {
190 * unmounted. 213 * unmounted.
191 */ 214 */
192struct fuse_conn { 215struct fuse_conn {
193 /** Reference count */
194 int count;
195
196 /** The user id for this mount */ 216 /** The user id for this mount */
197 uid_t user_id; 217 uid_t user_id;
198 218
@@ -217,6 +237,9 @@ struct fuse_conn {
217 /** The list of requests being processed */ 237 /** The list of requests being processed */
218 struct list_head processing; 238 struct list_head processing;
219 239
240 /** The list of requests under I/O */
241 struct list_head io;
242
220 /** Requests put in the background (RELEASE or any other 243 /** Requests put in the background (RELEASE or any other
221 interrupted request) */ 244 interrupted request) */
222 struct list_head background; 245 struct list_head background;
@@ -238,14 +261,22 @@ struct fuse_conn {
238 u64 reqctr; 261 u64 reqctr;
239 262
240 /** Mount is active */ 263 /** Mount is active */
241 unsigned mounted : 1; 264 unsigned mounted;
242 265
243 /** Connection established */ 266 /** Connection established, cleared on umount, connection
244 unsigned connected : 1; 267 abort and device release */
268 unsigned connected;
245 269
246 /** Connection failed (version mismatch) */ 270 /** Connection failed (version mismatch). Cannot race with
271 setting other bitfields since it is only set once in INIT
272 reply, before any other request, and never cleared */
247 unsigned conn_error : 1; 273 unsigned conn_error : 1;
248 274
275 /*
276 * The following bitfields are only for optimization purposes
277 * and hence races in setting them will not cause malfunction
278 */
279
249 /** Is fsync not implemented by fs? */ 280 /** Is fsync not implemented by fs? */
250 unsigned no_fsync : 1; 281 unsigned no_fsync : 1;
251 282
@@ -273,21 +304,22 @@ struct fuse_conn {
273 /** Is create not implemented by fs? */ 304 /** Is create not implemented by fs? */
274 unsigned no_create : 1; 305 unsigned no_create : 1;
275 306
307 /** The number of requests waiting for completion */
308 atomic_t num_waiting;
309
276 /** Negotiated minor version */ 310 /** Negotiated minor version */
277 unsigned minor; 311 unsigned minor;
278 312
279 /** Backing dev info */ 313 /** Backing dev info */
280 struct backing_dev_info bdi; 314 struct backing_dev_info bdi;
281};
282 315
283static inline struct fuse_conn **get_fuse_conn_super_p(struct super_block *sb) 316 /** kobject */
284{ 317 struct kobject kobj;
285 return (struct fuse_conn **) &sb->s_fs_info; 318};
286}
287 319
288static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 320static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
289{ 321{
290 return *get_fuse_conn_super_p(sb); 322 return sb->s_fs_info;
291} 323}
292 324
293static inline struct fuse_conn *get_fuse_conn(struct inode *inode) 325static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
@@ -295,6 +327,11 @@ static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
295 return get_fuse_conn_super(inode->i_sb); 327 return get_fuse_conn_super(inode->i_sb);
296} 328}
297 329
330static inline struct fuse_conn *get_fuse_conn_kobj(struct kobject *obj)
331{
332 return container_of(obj, struct fuse_conn, kobj);
333}
334
298static inline struct fuse_inode *get_fuse_inode(struct inode *inode) 335static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
299{ 336{
300 return container_of(inode, struct fuse_inode, inode); 337 return container_of(inode, struct fuse_inode, inode);
@@ -336,11 +373,10 @@ void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
336 unsigned long nodeid, u64 nlookup); 373 unsigned long nodeid, u64 nlookup);
337 374
338/** 375/**
339 * Send READ or READDIR request 376 * Initialize READ or READDIR request
340 */ 377 */
341size_t fuse_send_read_common(struct fuse_req *req, struct file *file, 378void fuse_read_fill(struct fuse_req *req, struct file *file,
342 struct inode *inode, loff_t pos, size_t count, 379 struct inode *inode, loff_t pos, size_t count, int opcode);
343 int isdir);
344 380
345/** 381/**
346 * Send OPEN or OPENDIR request 382 * Send OPEN or OPENDIR request
@@ -395,12 +431,6 @@ void fuse_init_symlink(struct inode *inode);
395void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr); 431void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr);
396 432
397/** 433/**
398 * Check if the connection can be released, and if yes, then free the
399 * connection structure
400 */
401void fuse_release_conn(struct fuse_conn *fc);
402
403/**
404 * Initialize the client device 434 * Initialize the client device
405 */ 435 */
406int fuse_dev_init(void); 436int fuse_dev_init(void);
@@ -456,6 +486,9 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
456 */ 486 */
457void fuse_release_background(struct fuse_req *req); 487void fuse_release_background(struct fuse_req *req);
458 488
489/* Abort all requests */
490void fuse_abort_conn(struct fuse_conn *fc);
491
459/** 492/**
460 * Get the attributes of a file 493 * Get the attributes of a file
461 */ 494 */
@@ -465,8 +498,3 @@ int fuse_do_getattr(struct inode *inode);
465 * Invalidate inode attributes 498 * Invalidate inode attributes
466 */ 499 */
467void fuse_invalidate_attr(struct inode *inode); 500void fuse_invalidate_attr(struct inode *inode);
468
469/**
470 * Send the INIT message
471 */
472void fuse_send_init(struct fuse_conn *fc);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 04c80cc957a3..c755a0440a66 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -24,6 +24,13 @@ MODULE_LICENSE("GPL");
24 24
25spinlock_t fuse_lock; 25spinlock_t fuse_lock;
26static kmem_cache_t *fuse_inode_cachep; 26static kmem_cache_t *fuse_inode_cachep;
27static struct subsystem connections_subsys;
28
29struct fuse_conn_attr {
30 struct attribute attr;
31 ssize_t (*show)(struct fuse_conn *, char *);
32 ssize_t (*store)(struct fuse_conn *, const char *, size_t);
33};
27 34
28#define FUSE_SUPER_MAGIC 0x65735546 35#define FUSE_SUPER_MAGIC 0x65735546
29 36
@@ -189,6 +196,11 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
189 return inode; 196 return inode;
190} 197}
191 198
199static void fuse_umount_begin(struct super_block *sb)
200{
201 fuse_abort_conn(get_fuse_conn_super(sb));
202}
203
192static void fuse_put_super(struct super_block *sb) 204static void fuse_put_super(struct super_block *sb)
193{ 205{
194 struct fuse_conn *fc = get_fuse_conn_super(sb); 206 struct fuse_conn *fc = get_fuse_conn_super(sb);
@@ -200,14 +212,13 @@ static void fuse_put_super(struct super_block *sb)
200 212
201 spin_lock(&fuse_lock); 213 spin_lock(&fuse_lock);
202 fc->mounted = 0; 214 fc->mounted = 0;
203 fc->user_id = 0; 215 fc->connected = 0;
204 fc->group_id = 0; 216 spin_unlock(&fuse_lock);
205 fc->flags = 0; 217 up_write(&fc->sbput_sem);
206 /* Flush all readers on this fs */ 218 /* Flush all readers on this fs */
207 wake_up_all(&fc->waitq); 219 wake_up_all(&fc->waitq);
208 up_write(&fc->sbput_sem); 220 kobject_del(&fc->kobj);
209 fuse_release_conn(fc); 221 kobject_put(&fc->kobj);
210 spin_unlock(&fuse_lock);
211} 222}
212 223
213static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) 224static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr)
@@ -356,8 +367,10 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
356 return 0; 367 return 0;
357} 368}
358 369
359static void free_conn(struct fuse_conn *fc) 370static void fuse_conn_release(struct kobject *kobj)
360{ 371{
372 struct fuse_conn *fc = get_fuse_conn_kobj(kobj);
373
361 while (!list_empty(&fc->unused_list)) { 374 while (!list_empty(&fc->unused_list)) {
362 struct fuse_req *req; 375 struct fuse_req *req;
363 req = list_entry(fc->unused_list.next, struct fuse_req, list); 376 req = list_entry(fc->unused_list.next, struct fuse_req, list);
@@ -367,33 +380,28 @@ static void free_conn(struct fuse_conn *fc)
367 kfree(fc); 380 kfree(fc);
368} 381}
369 382
370/* Must be called with the fuse lock held */
371void fuse_release_conn(struct fuse_conn *fc)
372{
373 fc->count--;
374 if (!fc->count)
375 free_conn(fc);
376}
377
378static struct fuse_conn *new_conn(void) 383static struct fuse_conn *new_conn(void)
379{ 384{
380 struct fuse_conn *fc; 385 struct fuse_conn *fc;
381 386
382 fc = kmalloc(sizeof(*fc), GFP_KERNEL); 387 fc = kzalloc(sizeof(*fc), GFP_KERNEL);
383 if (fc != NULL) { 388 if (fc) {
384 int i; 389 int i;
385 memset(fc, 0, sizeof(*fc));
386 init_waitqueue_head(&fc->waitq); 390 init_waitqueue_head(&fc->waitq);
387 INIT_LIST_HEAD(&fc->pending); 391 INIT_LIST_HEAD(&fc->pending);
388 INIT_LIST_HEAD(&fc->processing); 392 INIT_LIST_HEAD(&fc->processing);
393 INIT_LIST_HEAD(&fc->io);
389 INIT_LIST_HEAD(&fc->unused_list); 394 INIT_LIST_HEAD(&fc->unused_list);
390 INIT_LIST_HEAD(&fc->background); 395 INIT_LIST_HEAD(&fc->background);
391 sema_init(&fc->outstanding_sem, 0); 396 sema_init(&fc->outstanding_sem, 1); /* One for INIT */
392 init_rwsem(&fc->sbput_sem); 397 init_rwsem(&fc->sbput_sem);
398 kobj_set_kset_s(fc, connections_subsys);
399 kobject_init(&fc->kobj);
400 atomic_set(&fc->num_waiting, 0);
393 for (i = 0; i < FUSE_MAX_OUTSTANDING; i++) { 401 for (i = 0; i < FUSE_MAX_OUTSTANDING; i++) {
394 struct fuse_req *req = fuse_request_alloc(); 402 struct fuse_req *req = fuse_request_alloc();
395 if (!req) { 403 if (!req) {
396 free_conn(fc); 404 kobject_put(&fc->kobj);
397 return NULL; 405 return NULL;
398 } 406 }
399 list_add(&req->list, &fc->unused_list); 407 list_add(&req->list, &fc->unused_list);
@@ -408,25 +416,32 @@ static struct fuse_conn *new_conn(void)
408static struct fuse_conn *get_conn(struct file *file, struct super_block *sb) 416static struct fuse_conn *get_conn(struct file *file, struct super_block *sb)
409{ 417{
410 struct fuse_conn *fc; 418 struct fuse_conn *fc;
419 int err;
411 420
421 err = -EINVAL;
412 if (file->f_op != &fuse_dev_operations) 422 if (file->f_op != &fuse_dev_operations)
413 return ERR_PTR(-EINVAL); 423 goto out_err;
424
425 err = -ENOMEM;
414 fc = new_conn(); 426 fc = new_conn();
415 if (fc == NULL) 427 if (!fc)
416 return ERR_PTR(-ENOMEM); 428 goto out_err;
429
417 spin_lock(&fuse_lock); 430 spin_lock(&fuse_lock);
418 if (file->private_data) { 431 err = -EINVAL;
419 free_conn(fc); 432 if (file->private_data)
420 fc = ERR_PTR(-EINVAL); 433 goto out_unlock;
421 } else { 434
422 file->private_data = fc; 435 kobject_get(&fc->kobj);
423 *get_fuse_conn_super_p(sb) = fc; 436 file->private_data = fc;
424 fc->mounted = 1;
425 fc->connected = 1;
426 fc->count = 2;
427 }
428 spin_unlock(&fuse_lock); 437 spin_unlock(&fuse_lock);
429 return fc; 438 return fc;
439
440 out_unlock:
441 spin_unlock(&fuse_lock);
442 kobject_put(&fc->kobj);
443 out_err:
444 return ERR_PTR(err);
430} 445}
431 446
432static struct inode *get_root_inode(struct super_block *sb, unsigned mode) 447static struct inode *get_root_inode(struct super_block *sb, unsigned mode)
@@ -445,16 +460,74 @@ static struct super_operations fuse_super_operations = {
445 .read_inode = fuse_read_inode, 460 .read_inode = fuse_read_inode,
446 .clear_inode = fuse_clear_inode, 461 .clear_inode = fuse_clear_inode,
447 .put_super = fuse_put_super, 462 .put_super = fuse_put_super,
463 .umount_begin = fuse_umount_begin,
448 .statfs = fuse_statfs, 464 .statfs = fuse_statfs,
449 .show_options = fuse_show_options, 465 .show_options = fuse_show_options,
450}; 466};
451 467
468static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
469{
470 int i;
471 struct fuse_init_out *arg = &req->misc.init_out;
472
473 if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION)
474 fc->conn_error = 1;
475 else {
476 fc->minor = arg->minor;
477 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
478 }
479
480 /* After INIT reply is received other requests can go
481 out. So do (FUSE_MAX_OUTSTANDING - 1) number of
482 up()s on outstanding_sem. The last up() is done in
483 fuse_putback_request() */
484 for (i = 1; i < FUSE_MAX_OUTSTANDING; i++)
485 up(&fc->outstanding_sem);
486
487 fuse_put_request(fc, req);
488}
489
490static void fuse_send_init(struct fuse_conn *fc)
491{
492 /* This is called from fuse_read_super() so there's guaranteed
493 to be exactly one request available */
494 struct fuse_req *req = fuse_get_request(fc);
495 struct fuse_init_in *arg = &req->misc.init_in;
496
497 arg->major = FUSE_KERNEL_VERSION;
498 arg->minor = FUSE_KERNEL_MINOR_VERSION;
499 req->in.h.opcode = FUSE_INIT;
500 req->in.numargs = 1;
501 req->in.args[0].size = sizeof(*arg);
502 req->in.args[0].value = arg;
503 req->out.numargs = 1;
504 /* Variable length arguement used for backward compatibility
505 with interface version < 7.5. Rest of init_out is zeroed
506 by do_get_request(), so a short reply is not a problem */
507 req->out.argvar = 1;
508 req->out.args[0].size = sizeof(struct fuse_init_out);
509 req->out.args[0].value = &req->misc.init_out;
510 req->end = process_init_reply;
511 request_send_background(fc, req);
512}
513
514static unsigned long long conn_id(void)
515{
516 static unsigned long long ctr = 1;
517 unsigned long long val;
518 spin_lock(&fuse_lock);
519 val = ctr++;
520 spin_unlock(&fuse_lock);
521 return val;
522}
523
452static int fuse_fill_super(struct super_block *sb, void *data, int silent) 524static int fuse_fill_super(struct super_block *sb, void *data, int silent)
453{ 525{
454 struct fuse_conn *fc; 526 struct fuse_conn *fc;
455 struct inode *root; 527 struct inode *root;
456 struct fuse_mount_data d; 528 struct fuse_mount_data d;
457 struct file *file; 529 struct file *file;
530 struct dentry *root_dentry;
458 int err; 531 int err;
459 532
460 if (!parse_fuse_opt((char *) data, &d)) 533 if (!parse_fuse_opt((char *) data, &d))
@@ -482,23 +555,42 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
482 if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages) 555 if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages)
483 fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE; 556 fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE;
484 557
558 /* Used by get_root_inode() */
559 sb->s_fs_info = fc;
560
485 err = -ENOMEM; 561 err = -ENOMEM;
486 root = get_root_inode(sb, d.rootmode); 562 root = get_root_inode(sb, d.rootmode);
487 if (root == NULL) 563 if (!root)
488 goto err; 564 goto err;
489 565
490 sb->s_root = d_alloc_root(root); 566 root_dentry = d_alloc_root(root);
491 if (!sb->s_root) { 567 if (!root_dentry) {
492 iput(root); 568 iput(root);
493 goto err; 569 goto err;
494 } 570 }
571
572 err = kobject_set_name(&fc->kobj, "%llu", conn_id());
573 if (err)
574 goto err_put_root;
575
576 err = kobject_add(&fc->kobj);
577 if (err)
578 goto err_put_root;
579
580 sb->s_root = root_dentry;
581 spin_lock(&fuse_lock);
582 fc->mounted = 1;
583 fc->connected = 1;
584 spin_unlock(&fuse_lock);
585
495 fuse_send_init(fc); 586 fuse_send_init(fc);
587
496 return 0; 588 return 0;
497 589
590 err_put_root:
591 dput(root_dentry);
498 err: 592 err:
499 spin_lock(&fuse_lock); 593 kobject_put(&fc->kobj);
500 fuse_release_conn(fc);
501 spin_unlock(&fuse_lock);
502 return err; 594 return err;
503} 595}
504 596
@@ -516,6 +608,69 @@ static struct file_system_type fuse_fs_type = {
516 .kill_sb = kill_anon_super, 608 .kill_sb = kill_anon_super,
517}; 609};
518 610
611static ssize_t fuse_conn_waiting_show(struct fuse_conn *fc, char *page)
612{
613 return sprintf(page, "%i\n", atomic_read(&fc->num_waiting));
614}
615
616static ssize_t fuse_conn_abort_store(struct fuse_conn *fc, const char *page,
617 size_t count)
618{
619 fuse_abort_conn(fc);
620 return count;
621}
622
623static struct fuse_conn_attr fuse_conn_waiting =
624 __ATTR(waiting, 0400, fuse_conn_waiting_show, NULL);
625static struct fuse_conn_attr fuse_conn_abort =
626 __ATTR(abort, 0600, NULL, fuse_conn_abort_store);
627
628static struct attribute *fuse_conn_attrs[] = {
629 &fuse_conn_waiting.attr,
630 &fuse_conn_abort.attr,
631 NULL,
632};
633
634static ssize_t fuse_conn_attr_show(struct kobject *kobj,
635 struct attribute *attr,
636 char *page)
637{
638 struct fuse_conn_attr *fca =
639 container_of(attr, struct fuse_conn_attr, attr);
640
641 if (fca->show)
642 return fca->show(get_fuse_conn_kobj(kobj), page);
643 else
644 return -EACCES;
645}
646
647static ssize_t fuse_conn_attr_store(struct kobject *kobj,
648 struct attribute *attr,
649 const char *page, size_t count)
650{
651 struct fuse_conn_attr *fca =
652 container_of(attr, struct fuse_conn_attr, attr);
653
654 if (fca->store)
655 return fca->store(get_fuse_conn_kobj(kobj), page, count);
656 else
657 return -EACCES;
658}
659
660static struct sysfs_ops fuse_conn_sysfs_ops = {
661 .show = &fuse_conn_attr_show,
662 .store = &fuse_conn_attr_store,
663};
664
665static struct kobj_type ktype_fuse_conn = {
666 .release = fuse_conn_release,
667 .sysfs_ops = &fuse_conn_sysfs_ops,
668 .default_attrs = fuse_conn_attrs,
669};
670
671static decl_subsys(fuse, NULL, NULL);
672static decl_subsys(connections, &ktype_fuse_conn, NULL);
673
519static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep, 674static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep,
520 unsigned long flags) 675 unsigned long flags)
521{ 676{
@@ -553,6 +708,34 @@ static void fuse_fs_cleanup(void)
553 kmem_cache_destroy(fuse_inode_cachep); 708 kmem_cache_destroy(fuse_inode_cachep);
554} 709}
555 710
711static int fuse_sysfs_init(void)
712{
713 int err;
714
715 kset_set_kset_s(&fuse_subsys, fs_subsys);
716 err = subsystem_register(&fuse_subsys);
717 if (err)
718 goto out_err;
719
720 kset_set_kset_s(&connections_subsys, fuse_subsys);
721 err = subsystem_register(&connections_subsys);
722 if (err)
723 goto out_fuse_unregister;
724
725 return 0;
726
727 out_fuse_unregister:
728 subsystem_unregister(&fuse_subsys);
729 out_err:
730 return err;
731}
732
733static void fuse_sysfs_cleanup(void)
734{
735 subsystem_unregister(&connections_subsys);
736 subsystem_unregister(&fuse_subsys);
737}
738
556static int __init fuse_init(void) 739static int __init fuse_init(void)
557{ 740{
558 int res; 741 int res;
@@ -569,8 +752,14 @@ static int __init fuse_init(void)
569 if (res) 752 if (res)
570 goto err_fs_cleanup; 753 goto err_fs_cleanup;
571 754
755 res = fuse_sysfs_init();
756 if (res)
757 goto err_dev_cleanup;
758
572 return 0; 759 return 0;
573 760
761 err_dev_cleanup:
762 fuse_dev_cleanup();
574 err_fs_cleanup: 763 err_fs_cleanup:
575 fuse_fs_cleanup(); 764 fuse_fs_cleanup();
576 err: 765 err:
@@ -581,6 +770,7 @@ static void __exit fuse_exit(void)
581{ 770{
582 printk(KERN_DEBUG "fuse exit\n"); 771 printk(KERN_DEBUG "fuse exit\n");
583 772
773 fuse_sysfs_cleanup();
584 fuse_fs_cleanup(); 774 fuse_fs_cleanup();
585 fuse_dev_cleanup(); 775 fuse_dev_cleanup();
586} 776}
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ab4c3a9d51b8..f568102da1e8 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -402,7 +402,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
402 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 402 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
403 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 403 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
404 info = HUGETLBFS_I(inode); 404 info = HUGETLBFS_I(inode);
405 mpol_shared_policy_init(&info->policy); 405 mpol_shared_policy_init(&info->policy, MPOL_DEFAULT, NULL);
406 switch (mode & S_IFMT) { 406 switch (mode & S_IFMT) {
407 default: 407 default:
408 init_special_inode(inode, mode, dev); 408 init_special_inode(inode, mode, dev);
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index e37e82b7cbf0..e7ba0c30e071 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -185,8 +185,5 @@ struct dentry *isofs_lookup(struct inode * dir, struct dentry * dentry, struct n
185 } 185 }
186 } 186 }
187 unlock_kernel(); 187 unlock_kernel();
188 if (inode) 188 return d_splice_alias(inode, dentry);
189 return d_splice_alias(inode, dentry);
190 d_add(dentry, inode);
191 return NULL;
192} 189}
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
index fff108bb118b..70f7a896c04a 100644
--- a/fs/jffs2/build.c
+++ b/fs/jffs2/build.c
@@ -47,7 +47,7 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
47 ic = next_inode(&i, ic, (c))) 47 ic = next_inode(&i, ic, (c)))
48 48
49 49
50static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, 50static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
51 struct jffs2_inode_cache *ic) 51 struct jffs2_inode_cache *ic)
52{ 52{
53 struct jffs2_full_dirent *fd; 53 struct jffs2_full_dirent *fd;
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index c79eebb8ab32..b635e167a3fa 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -134,7 +134,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_
134/* 134/*
135 * Allocate and initializes a new fragment. 135 * Allocate and initializes a new fragment.
136 */ 136 */
137static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size) 137static struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size)
138{ 138{
139 struct jffs2_node_frag *newfrag; 139 struct jffs2_node_frag *newfrag;
140 140
@@ -513,7 +513,7 @@ free_out:
513 * 513 *
514 * Checks the node if we are in the checking stage. 514 * Checks the node if we are in the checking stage.
515 */ 515 */
516static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn) 516static int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn)
517{ 517{
518 int ret; 518 int ret;
519 519
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index f01e9c0d2677..200fbda2c6d1 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -44,7 +44,7 @@ loff_t_to_s32(loff_t offset)
44/* 44/*
45 * XDR functions for basic NLM types 45 * XDR functions for basic NLM types
46 */ 46 */
47static inline u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c) 47static u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c)
48{ 48{
49 unsigned int len; 49 unsigned int len;
50 50
@@ -79,7 +79,7 @@ nlm_encode_cookie(u32 *p, struct nlm_cookie *c)
79 return p; 79 return p;
80} 80}
81 81
82static inline u32 * 82static u32 *
83nlm_decode_fh(u32 *p, struct nfs_fh *f) 83nlm_decode_fh(u32 *p, struct nfs_fh *f)
84{ 84{
85 unsigned int len; 85 unsigned int len;
@@ -119,7 +119,7 @@ nlm_encode_oh(u32 *p, struct xdr_netobj *oh)
119 return xdr_encode_netobj(p, oh); 119 return xdr_encode_netobj(p, oh);
120} 120}
121 121
122static inline u32 * 122static u32 *
123nlm_decode_lock(u32 *p, struct nlm_lock *lock) 123nlm_decode_lock(u32 *p, struct nlm_lock *lock)
124{ 124{
125 struct file_lock *fl = &lock->fl; 125 struct file_lock *fl = &lock->fl;
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 0f1e4530670f..f5bbe4c97c58 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -126,7 +126,7 @@ __mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
126} 126}
127 127
128 128
129static inline void 129static void
130__mb_cache_entry_unhash(struct mb_cache_entry *ce) 130__mb_cache_entry_unhash(struct mb_cache_entry *ce)
131{ 131{
132 int n; 132 int n;
@@ -139,7 +139,7 @@ __mb_cache_entry_unhash(struct mb_cache_entry *ce)
139} 139}
140 140
141 141
142static inline void 142static void
143__mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask) 143__mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask)
144{ 144{
145 struct mb_cache *cache = ce->e_cache; 145 struct mb_cache *cache = ce->e_cache;
@@ -158,7 +158,7 @@ __mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask)
158} 158}
159 159
160 160
161static inline void 161static void
162__mb_cache_entry_release_unlock(struct mb_cache_entry *ce) 162__mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
163{ 163{
164 /* Wake up all processes queuing for this cache entry. */ 164 /* Wake up all processes queuing for this cache entry. */
diff --git a/fs/namei.c b/fs/namei.c
index 1e5746eb1380..33fb5bd34a81 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -113,7 +113,7 @@
113 * POSIX.1 2.4: an empty pathname is invalid (ENOENT). 113 * POSIX.1 2.4: an empty pathname is invalid (ENOENT).
114 * PATH_MAX includes the nul terminator --RR. 114 * PATH_MAX includes the nul terminator --RR.
115 */ 115 */
116static inline int do_getname(const char __user *filename, char *page) 116static int do_getname(const char __user *filename, char *page)
117{ 117{
118 int retval; 118 int retval;
119 unsigned long len = PATH_MAX; 119 unsigned long len = PATH_MAX;
@@ -396,7 +396,7 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name,
396 * short-cut DAC fails, then call permission() to do more 396 * short-cut DAC fails, then call permission() to do more
397 * complete permission check. 397 * complete permission check.
398 */ 398 */
399static inline int exec_permission_lite(struct inode *inode, 399static int exec_permission_lite(struct inode *inode,
400 struct nameidata *nd) 400 struct nameidata *nd)
401{ 401{
402 umode_t mode = inode->i_mode; 402 umode_t mode = inode->i_mode;
@@ -486,7 +486,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
486static int __emul_lookup_dentry(const char *, struct nameidata *); 486static int __emul_lookup_dentry(const char *, struct nameidata *);
487 487
488/* SMP-safe */ 488/* SMP-safe */
489static inline int 489static __always_inline int
490walk_init_root(const char *name, struct nameidata *nd) 490walk_init_root(const char *name, struct nameidata *nd)
491{ 491{
492 read_lock(&current->fs->lock); 492 read_lock(&current->fs->lock);
@@ -504,7 +504,7 @@ walk_init_root(const char *name, struct nameidata *nd)
504 return 1; 504 return 1;
505} 505}
506 506
507static inline int __vfs_follow_link(struct nameidata *nd, const char *link) 507static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link)
508{ 508{
509 int res = 0; 509 int res = 0;
510 char *name; 510 char *name;
@@ -544,7 +544,7 @@ struct path {
544 struct dentry *dentry; 544 struct dentry *dentry;
545}; 545};
546 546
547static inline int __do_follow_link(struct path *path, struct nameidata *nd) 547static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd)
548{ 548{
549 int error; 549 int error;
550 void *cookie; 550 void *cookie;
@@ -690,7 +690,7 @@ int follow_down(struct vfsmount **mnt, struct dentry **dentry)
690 return 0; 690 return 0;
691} 691}
692 692
693static inline void follow_dotdot(struct nameidata *nd) 693static __always_inline void follow_dotdot(struct nameidata *nd)
694{ 694{
695 while(1) { 695 while(1) {
696 struct vfsmount *parent; 696 struct vfsmount *parent;
@@ -1294,7 +1294,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
1294 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by 1294 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
1295 * nfs_async_unlink(). 1295 * nfs_async_unlink().
1296 */ 1296 */
1297static inline int may_delete(struct inode *dir,struct dentry *victim,int isdir) 1297static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
1298{ 1298{
1299 int error; 1299 int error;
1300 1300
@@ -2315,7 +2315,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2315 return error; 2315 return error;
2316} 2316}
2317 2317
2318static inline int do_rename(const char * oldname, const char * newname) 2318static int do_rename(const char * oldname, const char * newname)
2319{ 2319{
2320 int error = 0; 2320 int error = 0;
2321 struct dentry * old_dir, * new_dir; 2321 struct dentry * old_dir, * new_dir;
diff --git a/fs/namespace.c b/fs/namespace.c
index 8bc15b362d23..ce97becff461 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -48,6 +48,10 @@ static int hash_mask __read_mostly, hash_bits __read_mostly;
48static kmem_cache_t *mnt_cache; 48static kmem_cache_t *mnt_cache;
49static struct rw_semaphore namespace_sem; 49static struct rw_semaphore namespace_sem;
50 50
51/* /sys/fs */
52decl_subsys(fs, NULL, NULL);
53EXPORT_SYMBOL_GPL(fs_subsys);
54
51static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) 55static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
52{ 56{
53 unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES); 57 unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES);
@@ -1725,6 +1729,7 @@ void __init mnt_init(unsigned long mempages)
1725 i--; 1729 i--;
1726 } while (i); 1730 } while (i);
1727 sysfs_init(); 1731 sysfs_init();
1732 subsystem_register(&fs_subsys);
1728 init_rootfs(); 1733 init_rootfs();
1729 init_mount_tree(); 1734 init_mount_tree();
1730} 1735}
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 8c8839203cd5..d277a58bd128 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -716,10 +716,8 @@ static void ncp_put_super(struct super_block *sb)
716 fput(server->ncp_filp); 716 fput(server->ncp_filp);
717 kill_proc(server->m.wdog_pid, SIGTERM, 1); 717 kill_proc(server->m.wdog_pid, SIGTERM, 1);
718 718
719 if (server->priv.data) 719 kfree(server->priv.data);
720 ncp_kfree_s(server->priv.data, server->priv.len); 720 kfree(server->auth.object_name);
721 if (server->auth.object_name)
722 ncp_kfree_s(server->auth.object_name, server->auth.object_name_len);
723 vfree(server->packet); 721 vfree(server->packet);
724 sb->s_fs_info = NULL; 722 sb->s_fs_info = NULL;
725 kfree(server); 723 kfree(server);
@@ -958,11 +956,6 @@ out:
958 return result; 956 return result;
959} 957}
960 958
961#ifdef DEBUG_NCP_MALLOC
962int ncp_malloced;
963int ncp_current_malloced;
964#endif
965
966static struct super_block *ncp_get_sb(struct file_system_type *fs_type, 959static struct super_block *ncp_get_sb(struct file_system_type *fs_type,
967 int flags, const char *dev_name, void *data) 960 int flags, const char *dev_name, void *data)
968{ 961{
@@ -981,10 +974,6 @@ static int __init init_ncp_fs(void)
981 int err; 974 int err;
982 DPRINTK("ncpfs: init_module called\n"); 975 DPRINTK("ncpfs: init_module called\n");
983 976
984#ifdef DEBUG_NCP_MALLOC
985 ncp_malloced = 0;
986 ncp_current_malloced = 0;
987#endif
988 err = init_inodecache(); 977 err = init_inodecache();
989 if (err) 978 if (err)
990 goto out1; 979 goto out1;
@@ -1003,10 +992,6 @@ static void __exit exit_ncp_fs(void)
1003 DPRINTK("ncpfs: cleanup_module called\n"); 992 DPRINTK("ncpfs: cleanup_module called\n");
1004 unregister_filesystem(&ncp_fs_type); 993 unregister_filesystem(&ncp_fs_type);
1005 destroy_inodecache(); 994 destroy_inodecache();
1006#ifdef DEBUG_NCP_MALLOC
1007 PRINTK("ncp_malloced: %d\n", ncp_malloced);
1008 PRINTK("ncp_current_malloced: %d\n", ncp_current_malloced);
1009#endif
1010} 995}
1011 996
1012module_init(init_ncp_fs) 997module_init(init_ncp_fs)
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index d6e0c089e1b1..eb3813ad136f 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -518,10 +518,11 @@ outrel:
518 if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN) 518 if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
519 return -ENOMEM; 519 return -ENOMEM;
520 if (user.object_name_len) { 520 if (user.object_name_len) {
521 newname = ncp_kmalloc(user.object_name_len, GFP_USER); 521 newname = kmalloc(user.object_name_len, GFP_USER);
522 if (!newname) return -ENOMEM; 522 if (!newname)
523 return -ENOMEM;
523 if (copy_from_user(newname, user.object_name, user.object_name_len)) { 524 if (copy_from_user(newname, user.object_name, user.object_name_len)) {
524 ncp_kfree_s(newname, user.object_name_len); 525 kfree(newname);
525 return -EFAULT; 526 return -EFAULT;
526 } 527 }
527 } else { 528 } else {
@@ -540,8 +541,8 @@ outrel:
540 server->priv.len = 0; 541 server->priv.len = 0;
541 server->priv.data = NULL; 542 server->priv.data = NULL;
542 /* leave critical section */ 543 /* leave critical section */
543 if (oldprivate) ncp_kfree_s(oldprivate, oldprivatelen); 544 kfree(oldprivate);
544 if (oldname) ncp_kfree_s(oldname, oldnamelen); 545 kfree(oldname);
545 return 0; 546 return 0;
546 } 547 }
547 case NCP_IOC_GETPRIVATEDATA: 548 case NCP_IOC_GETPRIVATEDATA:
@@ -581,10 +582,11 @@ outrel:
581 if (user.len > NCP_PRIVATE_DATA_MAX_LEN) 582 if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
582 return -ENOMEM; 583 return -ENOMEM;
583 if (user.len) { 584 if (user.len) {
584 new = ncp_kmalloc(user.len, GFP_USER); 585 new = kmalloc(user.len, GFP_USER);
585 if (!new) return -ENOMEM; 586 if (!new)
587 return -ENOMEM;
586 if (copy_from_user(new, user.data, user.len)) { 588 if (copy_from_user(new, user.data, user.len)) {
587 ncp_kfree_s(new, user.len); 589 kfree(new);
588 return -EFAULT; 590 return -EFAULT;
589 } 591 }
590 } else { 592 } else {
@@ -596,7 +598,7 @@ outrel:
596 server->priv.len = user.len; 598 server->priv.len = user.len;
597 server->priv.data = new; 599 server->priv.data = new;
598 /* leave critical section */ 600 /* leave critical section */
599 if (old) ncp_kfree_s(old, oldlen); 601 kfree(old);
600 return 0; 602 return 0;
601 } 603 }
602 604
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index aa7bb41b293d..e3a0797dd56b 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -37,7 +37,7 @@ static u32 nfs_ftypes[] = {
37/* 37/*
38 * XDR functions for basic NFS types 38 * XDR functions for basic NFS types
39 */ 39 */
40static inline u32 * 40static u32 *
41decode_fh(u32 *p, struct svc_fh *fhp) 41decode_fh(u32 *p, struct svc_fh *fhp)
42{ 42{
43 fh_init(fhp, NFS_FHSIZE); 43 fh_init(fhp, NFS_FHSIZE);
@@ -151,7 +151,7 @@ decode_sattr(u32 *p, struct iattr *iap)
151 return p; 151 return p;
152} 152}
153 153
154static inline u32 * 154static u32 *
155encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, 155encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp,
156 struct kstat *stat) 156 struct kstat *stat)
157{ 157{
diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig
index 7490cc9208b3..c9a478099281 100644
--- a/fs/partitions/Kconfig
+++ b/fs/partitions/Kconfig
@@ -222,6 +222,13 @@ config SUN_PARTITION
222 given by the tar program ("man tar" or preferably "info tar"). If 222 given by the tar program ("man tar" or preferably "info tar"). If
223 you don't know what all this is about, say N. 223 you don't know what all this is about, say N.
224 224
225config KARMA_PARTITION
226 bool "Karma Partition support"
227 depends on PARTITION_ADVANCED
228 help
229 Say Y here if you would like to mount the Rio Karma MP3 player, as it
230 uses a proprietary partition table.
231
225config EFI_PARTITION 232config EFI_PARTITION
226 bool "EFI GUID Partition support" 233 bool "EFI GUID Partition support"
227 depends on PARTITION_ADVANCED 234 depends on PARTITION_ADVANCED
diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile
index 66d5cc26fafb..42c7d3878ed0 100644
--- a/fs/partitions/Makefile
+++ b/fs/partitions/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_SUN_PARTITION) += sun.o
17obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o 17obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o
18obj-$(CONFIG_IBM_PARTITION) += ibm.o 18obj-$(CONFIG_IBM_PARTITION) += ibm.o
19obj-$(CONFIG_EFI_PARTITION) += efi.o 19obj-$(CONFIG_EFI_PARTITION) += efi.o
20obj-$(CONFIG_KARMA_PARTITION) += karma.o
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 7881ce05daef..f924f459bdb8 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -35,6 +35,7 @@
35#include "ibm.h" 35#include "ibm.h"
36#include "ultrix.h" 36#include "ultrix.h"
37#include "efi.h" 37#include "efi.h"
38#include "karma.h"
38 39
39#ifdef CONFIG_BLK_DEV_MD 40#ifdef CONFIG_BLK_DEV_MD
40extern void md_autodetect_dev(dev_t dev); 41extern void md_autodetect_dev(dev_t dev);
@@ -103,6 +104,9 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
103#ifdef CONFIG_IBM_PARTITION 104#ifdef CONFIG_IBM_PARTITION
104 ibm_partition, 105 ibm_partition,
105#endif 106#endif
107#ifdef CONFIG_KARMA_PARTITION
108 karma_partition,
109#endif
106 NULL 110 NULL
107}; 111};
108 112
diff --git a/fs/partitions/karma.c b/fs/partitions/karma.c
new file mode 100644
index 000000000000..176d89bcf123
--- /dev/null
+++ b/fs/partitions/karma.c
@@ -0,0 +1,57 @@
1/*
2 * fs/partitions/karma.c
3 * Rio Karma partition info.
4 *
5 * Copyright (C) 2006 Bob Copeland (me@bobcopeland.com)
6 * based on osf.c
7 */
8
9#include "check.h"
10#include "karma.h"
11
12int karma_partition(struct parsed_partitions *state, struct block_device *bdev)
13{
14 int i;
15 int slot = 1;
16 Sector sect;
17 unsigned char *data;
18 struct disklabel {
19 u8 d_reserved[270];
20 struct d_partition {
21 __le32 p_res;
22 u8 p_fstype;
23 u8 p_res2[3];
24 __le32 p_offset;
25 __le32 p_size;
26 } d_partitions[2];
27 u8 d_blank[208];
28 __le16 d_magic;
29 } __attribute__((packed)) *label;
30 struct d_partition *p;
31
32 data = read_dev_sector(bdev, 0, &sect);
33 if (!data)
34 return -1;
35
36 label = (struct disklabel *)data;
37 if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) {
38 put_dev_sector(sect);
39 return 0;
40 }
41
42 p = label->d_partitions;
43 for (i = 0 ; i < 2; i++, p++) {
44 if (slot == state->limit)
45 break;
46
47 if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) {
48 put_partition(state, slot, le32_to_cpu(p->p_offset),
49 le32_to_cpu(p->p_size));
50 }
51 slot++;
52 }
53 printk("\n");
54 put_dev_sector(sect);
55 return 1;
56}
57
diff --git a/fs/partitions/karma.h b/fs/partitions/karma.h
new file mode 100644
index 000000000000..ecf7d3f2a3d8
--- /dev/null
+++ b/fs/partitions/karma.h
@@ -0,0 +1,8 @@
1/*
2 * fs/partitions/karma.h
3 */
4
5#define KARMA_LABEL_MAGIC 0xAB56
6
7int karma_partition(struct parsed_partitions *state, struct block_device *bdev);
8
diff --git a/fs/pipe.c b/fs/pipe.c
index eef0f29e86ef..d722579df79a 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -50,7 +50,7 @@ void pipe_wait(struct inode * inode)
50 mutex_lock(PIPE_MUTEX(*inode)); 50 mutex_lock(PIPE_MUTEX(*inode));
51} 51}
52 52
53static inline int 53static int
54pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len) 54pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len)
55{ 55{
56 unsigned long copy; 56 unsigned long copy;
@@ -70,7 +70,7 @@ pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len)
70 return 0; 70 return 0;
71} 71}
72 72
73static inline int 73static int
74pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len) 74pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len)
75{ 75{
76 unsigned long copy; 76 unsigned long copy;
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index fb117b74809e..9bdd077d6f55 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -81,6 +81,30 @@ void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop
81 __proc_device_tree_add_prop(pde, prop); 81 __proc_device_tree_add_prop(pde, prop);
82} 82}
83 83
84void proc_device_tree_remove_prop(struct proc_dir_entry *pde,
85 struct property *prop)
86{
87 remove_proc_entry(prop->name, pde);
88}
89
90void proc_device_tree_update_prop(struct proc_dir_entry *pde,
91 struct property *newprop,
92 struct property *oldprop)
93{
94 struct proc_dir_entry *ent;
95
96 for (ent = pde->subdir; ent != NULL; ent = ent->next)
97 if (ent->data == oldprop)
98 break;
99 if (ent == NULL) {
100 printk(KERN_WARNING "device-tree: property \"%s\" "
101 " does not exist\n", oldprop->name);
102 } else {
103 ent->data = newprop;
104 ent->size = newprop->length;
105 }
106}
107
84/* 108/*
85 * Process a node, adding entries for its children and its properties. 109 * Process a node, adding entries for its children and its properties.
86 */ 110 */
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 63bf6c00fa0c..8f8014285a34 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -20,6 +20,7 @@
20#include <linux/time.h> 20#include <linux/time.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/kernel_stat.h> 22#include <linux/kernel_stat.h>
23#include <linux/fs.h>
23#include <linux/tty.h> 24#include <linux/tty.h>
24#include <linux/string.h> 25#include <linux/string.h>
25#include <linux/mman.h> 26#include <linux/mman.h>
@@ -62,7 +63,6 @@
62 */ 63 */
63extern int get_hardware_list(char *); 64extern int get_hardware_list(char *);
64extern int get_stram_list(char *); 65extern int get_stram_list(char *);
65extern int get_chrdev_list(char *);
66extern int get_filesystem_list(char *); 66extern int get_filesystem_list(char *);
67extern int get_exec_domain_list(char *); 67extern int get_exec_domain_list(char *);
68extern int get_dma_list(char *); 68extern int get_dma_list(char *);
@@ -248,6 +248,154 @@ static int cpuinfo_open(struct inode *inode, struct file *file)
248{ 248{
249 return seq_open(file, &cpuinfo_op); 249 return seq_open(file, &cpuinfo_op);
250} 250}
251
252enum devinfo_states {
253 CHR_HDR,
254 CHR_LIST,
255 BLK_HDR,
256 BLK_LIST,
257 DEVINFO_DONE
258};
259
260struct devinfo_state {
261 void *chrdev;
262 void *blkdev;
263 unsigned int num_records;
264 unsigned int cur_record;
265 enum devinfo_states state;
266};
267
268static void *devinfo_start(struct seq_file *f, loff_t *pos)
269{
270 struct devinfo_state *info = f->private;
271
272 if (*pos) {
273 if ((info) && (*pos <= info->num_records))
274 return info;
275 return NULL;
276 }
277 info = kmalloc(sizeof(*info), GFP_KERNEL);
278 f->private = info;
279 info->chrdev = acquire_chrdev_list();
280 info->blkdev = acquire_blkdev_list();
281 info->state = CHR_HDR;
282 info->num_records = count_chrdev_list();
283 info->num_records += count_blkdev_list();
284 info->num_records += 2; /* Character and Block headers */
285 *pos = 1;
286 info->cur_record = *pos;
287 return info;
288}
289
290static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
291{
292 int idummy;
293 char *ndummy;
294 struct devinfo_state *info = f->private;
295
296 switch (info->state) {
297 case CHR_HDR:
298 info->state = CHR_LIST;
299 (*pos)++;
300 /*fallthrough*/
301 case CHR_LIST:
302 if (get_chrdev_info(info->chrdev,&idummy,&ndummy)) {
303 /*
304 * The character dev list is complete
305 */
306 info->state = BLK_HDR;
307 } else {
308 info->chrdev = get_next_chrdev(info->chrdev);
309 }
310 (*pos)++;
311 break;
312 case BLK_HDR:
313 info->state = BLK_LIST;
314 (*pos)++;
315 break;
316 case BLK_LIST:
317 if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) {
318 /*
319 * The block dev list is complete
320 */
321 info->state = DEVINFO_DONE;
322 } else {
323 info->blkdev = get_next_blkdev(info->blkdev);
324 }
325 (*pos)++;
326 break;
327 case DEVINFO_DONE:
328 (*pos)++;
329 info->cur_record = *pos;
330 info = NULL;
331 break;
332 default:
333 break;
334 }
335 if (info)
336 info->cur_record = *pos;
337 return info;
338}
339
340static void devinfo_stop(struct seq_file *f, void *v)
341{
342 struct devinfo_state *info = f->private;
343
344 if (info) {
345 release_chrdev_list(info->chrdev);
346 release_blkdev_list(info->blkdev);
347 f->private = NULL;
348 kfree(info);
349 }
350}
351
352static int devinfo_show(struct seq_file *f, void *arg)
353{
354 int major;
355 char *name;
356 struct devinfo_state *info = f->private;
357
358 switch(info->state) {
359 case CHR_HDR:
360 seq_printf(f,"Character devices:\n");
361 /* fallthrough */
362 case CHR_LIST:
363 if (!get_chrdev_info(info->chrdev,&major,&name))
364 seq_printf(f,"%3d %s\n",major,name);
365 break;
366 case BLK_HDR:
367 seq_printf(f,"\nBlock devices:\n");
368 /* fallthrough */
369 case BLK_LIST:
370 if (!get_blkdev_info(info->blkdev,&major,&name))
371 seq_printf(f,"%3d %s\n",major,name);
372 break;
373 default:
374 break;
375 }
376
377 return 0;
378}
379
380static struct seq_operations devinfo_op = {
381 .start = devinfo_start,
382 .next = devinfo_next,
383 .stop = devinfo_stop,
384 .show = devinfo_show,
385};
386
387static int devinfo_open(struct inode *inode, struct file *file)
388{
389 return seq_open(file, &devinfo_op);
390}
391
392static struct file_operations proc_devinfo_operations = {
393 .open = devinfo_open,
394 .read = seq_read,
395 .llseek = seq_lseek,
396 .release = seq_release,
397};
398
251static struct file_operations proc_cpuinfo_operations = { 399static struct file_operations proc_cpuinfo_operations = {
252 .open = cpuinfo_open, 400 .open = cpuinfo_open,
253 .read = seq_read, 401 .read = seq_read,
@@ -450,14 +598,6 @@ static struct file_operations proc_stat_operations = {
450 .release = single_release, 598 .release = single_release,
451}; 599};
452 600
453static int devices_read_proc(char *page, char **start, off_t off,
454 int count, int *eof, void *data)
455{
456 int len = get_chrdev_list(page);
457 len += get_blkdev_list(page+len, len);
458 return proc_calc_metrics(page, start, off, count, eof, len);
459}
460
461/* 601/*
462 * /proc/interrupts 602 * /proc/interrupts
463 */ 603 */
@@ -582,7 +722,6 @@ void __init proc_misc_init(void)
582#ifdef CONFIG_STRAM_PROC 722#ifdef CONFIG_STRAM_PROC
583 {"stram", stram_read_proc}, 723 {"stram", stram_read_proc},
584#endif 724#endif
585 {"devices", devices_read_proc},
586 {"filesystems", filesystems_read_proc}, 725 {"filesystems", filesystems_read_proc},
587 {"cmdline", cmdline_read_proc}, 726 {"cmdline", cmdline_read_proc},
588 {"locks", locks_read_proc}, 727 {"locks", locks_read_proc},
@@ -598,6 +737,7 @@ void __init proc_misc_init(void)
598 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); 737 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
599 if (entry) 738 if (entry)
600 entry->proc_fops = &proc_kmsg_operations; 739 entry->proc_fops = &proc_kmsg_operations;
740 create_seq_entry("devices", 0, &proc_devinfo_operations);
601 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); 741 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
602 create_seq_entry("partitions", 0, &proc_partitions_operations); 742 create_seq_entry("partitions", 0, &proc_partitions_operations);
603 create_seq_entry("stat", 0, &proc_stat_operations); 743 create_seq_entry("stat", 0, &proc_stat_operations);
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index 7afcbb1b9376..a4ef91bb4f3b 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -35,7 +35,8 @@ static int v2_check_quota_file(struct super_block *sb, int type)
35 35
36 size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0); 36 size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0);
37 if (size != sizeof(struct v2_disk_dqheader)) { 37 if (size != sizeof(struct v2_disk_dqheader)) {
38 printk("failed read\n"); 38 printk("quota_v2: failed read expected=%d got=%d\n",
39 sizeof(struct v2_disk_dqheader), size);
39 return 0; 40 return 0;
40 } 41 }
41 if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] || 42 if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 3549067c42d9..8f8d8d01107c 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -375,11 +375,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
375 return ERR_PTR(-EIO); 375 return ERR_PTR(-EIO);
376 } 376 }
377 377
378 if (inode) 378 return d_splice_alias(inode, dentry);
379 return d_splice_alias(inode, dentry);
380
381 d_add(dentry, inode);
382 return NULL;
383} 379}
384 380
385/* 381/*
diff --git a/fs/smbfs/Makefile b/fs/smbfs/Makefile
index 93246b7dd6fb..6673ee82cb4c 100644
--- a/fs/smbfs/Makefile
+++ b/fs/smbfs/Makefile
@@ -13,7 +13,6 @@ smbfs-objs := proc.o dir.o cache.o sock.o inode.o file.o ioctl.o getopt.o \
13EXTRA_CFLAGS += -DSMBFS_PARANOIA 13EXTRA_CFLAGS += -DSMBFS_PARANOIA
14#EXTRA_CFLAGS += -DSMBFS_DEBUG 14#EXTRA_CFLAGS += -DSMBFS_DEBUG
15#EXTRA_CFLAGS += -DSMBFS_DEBUG_VERBOSE 15#EXTRA_CFLAGS += -DSMBFS_DEBUG_VERBOSE
16#EXTRA_CFLAGS += -DDEBUG_SMB_MALLOC
17#EXTRA_CFLAGS += -DDEBUG_SMB_TIMESTAMP 16#EXTRA_CFLAGS += -DDEBUG_SMB_TIMESTAMP
18#EXTRA_CFLAGS += -Werror 17#EXTRA_CFLAGS += -Werror
19 18
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 6ec88bf59b2d..02e3e82d465c 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -487,11 +487,11 @@ smb_put_super(struct super_block *sb)
487 if (server->conn_pid) 487 if (server->conn_pid)
488 kill_proc(server->conn_pid, SIGTERM, 1); 488 kill_proc(server->conn_pid, SIGTERM, 1);
489 489
490 smb_kfree(server->ops); 490 kfree(server->ops);
491 smb_unload_nls(server); 491 smb_unload_nls(server);
492 sb->s_fs_info = NULL; 492 sb->s_fs_info = NULL;
493 smb_unlock_server(server); 493 smb_unlock_server(server);
494 smb_kfree(server); 494 kfree(server);
495} 495}
496 496
497static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) 497static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
@@ -519,11 +519,10 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
519 sb->s_op = &smb_sops; 519 sb->s_op = &smb_sops;
520 sb->s_time_gran = 100; 520 sb->s_time_gran = 100;
521 521
522 server = smb_kmalloc(sizeof(struct smb_sb_info), GFP_KERNEL); 522 server = kzalloc(sizeof(struct smb_sb_info), GFP_KERNEL);
523 if (!server) 523 if (!server)
524 goto out_no_server; 524 goto out_no_server;
525 sb->s_fs_info = server; 525 sb->s_fs_info = server;
526 memset(server, 0, sizeof(struct smb_sb_info));
527 526
528 server->super_block = sb; 527 server->super_block = sb;
529 server->mnt = NULL; 528 server->mnt = NULL;
@@ -542,8 +541,8 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
542 /* FIXME: move these to the smb_sb_info struct */ 541 /* FIXME: move these to the smb_sb_info struct */
543 VERBOSE("alloc chunk = %d\n", sizeof(struct smb_ops) + 542 VERBOSE("alloc chunk = %d\n", sizeof(struct smb_ops) +
544 sizeof(struct smb_mount_data_kernel)); 543 sizeof(struct smb_mount_data_kernel));
545 mem = smb_kmalloc(sizeof(struct smb_ops) + 544 mem = kmalloc(sizeof(struct smb_ops) +
546 sizeof(struct smb_mount_data_kernel), GFP_KERNEL); 545 sizeof(struct smb_mount_data_kernel), GFP_KERNEL);
547 if (!mem) 546 if (!mem)
548 goto out_no_mem; 547 goto out_no_mem;
549 548
@@ -621,12 +620,12 @@ out_no_root:
621out_no_smbiod: 620out_no_smbiod:
622 smb_unload_nls(server); 621 smb_unload_nls(server);
623out_bad_option: 622out_bad_option:
624 smb_kfree(mem); 623 kfree(mem);
625out_no_mem: 624out_no_mem:
626 if (!server->mnt) 625 if (!server->mnt)
627 printk(KERN_ERR "smb_fill_super: allocation failure\n"); 626 printk(KERN_ERR "smb_fill_super: allocation failure\n");
628 sb->s_fs_info = NULL; 627 sb->s_fs_info = NULL;
629 smb_kfree(server); 628 kfree(server);
630 goto out_fail; 629 goto out_fail;
631out_wrong_data: 630out_wrong_data:
632 printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver); 631 printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver);
@@ -782,12 +781,6 @@ out:
782 return error; 781 return error;
783} 782}
784 783
785#ifdef DEBUG_SMB_MALLOC
786int smb_malloced;
787int smb_current_kmalloced;
788int smb_current_vmalloced;
789#endif
790
791static struct super_block *smb_get_sb(struct file_system_type *fs_type, 784static struct super_block *smb_get_sb(struct file_system_type *fs_type,
792 int flags, const char *dev_name, void *data) 785 int flags, const char *dev_name, void *data)
793{ 786{
@@ -807,12 +800,6 @@ static int __init init_smb_fs(void)
807 int err; 800 int err;
808 DEBUG1("registering ...\n"); 801 DEBUG1("registering ...\n");
809 802
810#ifdef DEBUG_SMB_MALLOC
811 smb_malloced = 0;
812 smb_current_kmalloced = 0;
813 smb_current_vmalloced = 0;
814#endif
815
816 err = init_inodecache(); 803 err = init_inodecache();
817 if (err) 804 if (err)
818 goto out_inode; 805 goto out_inode;
@@ -837,11 +824,6 @@ static void __exit exit_smb_fs(void)
837 unregister_filesystem(&smb_fs_type); 824 unregister_filesystem(&smb_fs_type);
838 smb_destroy_request_cache(); 825 smb_destroy_request_cache();
839 destroy_inodecache(); 826 destroy_inodecache();
840#ifdef DEBUG_SMB_MALLOC
841 printk(KERN_DEBUG "smb_malloced: %d\n", smb_malloced);
842 printk(KERN_DEBUG "smb_current_kmalloced: %d\n",smb_current_kmalloced);
843 printk(KERN_DEBUG "smb_current_vmalloced: %d\n",smb_current_vmalloced);
844#endif
845} 827}
846 828
847module_init(init_smb_fs) 829module_init(init_smb_fs)
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c
index a0f296d9928a..c71c375863cc 100644
--- a/fs/smbfs/request.c
+++ b/fs/smbfs/request.c
@@ -68,7 +68,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
68 goto out; 68 goto out;
69 69
70 if (bufsize > 0) { 70 if (bufsize > 0) {
71 buf = smb_kmalloc(bufsize, GFP_NOFS); 71 buf = kmalloc(bufsize, GFP_NOFS);
72 if (!buf) { 72 if (!buf) {
73 kmem_cache_free(req_cachep, req); 73 kmem_cache_free(req_cachep, req);
74 return NULL; 74 return NULL;
@@ -124,9 +124,8 @@ static void smb_free_request(struct smb_request *req)
124{ 124{
125 atomic_dec(&req->rq_server->nr_requests); 125 atomic_dec(&req->rq_server->nr_requests);
126 if (req->rq_buffer && !(req->rq_flags & SMB_REQ_STATIC)) 126 if (req->rq_buffer && !(req->rq_flags & SMB_REQ_STATIC))
127 smb_kfree(req->rq_buffer); 127 kfree(req->rq_buffer);
128 if (req->rq_trans2buffer) 128 kfree(req->rq_trans2buffer);
129 smb_kfree(req->rq_trans2buffer);
130 kmem_cache_free(req_cachep, req); 129 kmem_cache_free(req_cachep, req);
131} 130}
132 131
@@ -183,8 +182,7 @@ static int smb_setup_request(struct smb_request *req)
183 req->rq_err = 0; 182 req->rq_err = 0;
184 req->rq_errno = 0; 183 req->rq_errno = 0;
185 req->rq_fragment = 0; 184 req->rq_fragment = 0;
186 if (req->rq_trans2buffer) 185 kfree(req->rq_trans2buffer);
187 smb_kfree(req->rq_trans2buffer);
188 186
189 return 0; 187 return 0;
190} 188}
@@ -647,10 +645,9 @@ static int smb_recv_trans2(struct smb_sb_info *server, struct smb_request *req)
647 goto out_too_long; 645 goto out_too_long;
648 646
649 req->rq_trans2bufsize = buf_len; 647 req->rq_trans2bufsize = buf_len;
650 req->rq_trans2buffer = smb_kmalloc(buf_len, GFP_NOFS); 648 req->rq_trans2buffer = kzalloc(buf_len, GFP_NOFS);
651 if (!req->rq_trans2buffer) 649 if (!req->rq_trans2buffer)
652 goto out_no_mem; 650 goto out_no_mem;
653 memset(req->rq_trans2buffer, 0, buf_len);
654 651
655 req->rq_parm = req->rq_trans2buffer; 652 req->rq_parm = req->rq_trans2buffer;
656 req->rq_data = req->rq_trans2buffer + parm_tot; 653 req->rq_data = req->rq_trans2buffer + parm_tot;
diff --git a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog
index 18e3487debdb..f403f8b91b80 100644
--- a/fs/sysv/ChangeLog
+++ b/fs/sysv/ChangeLog
@@ -54,7 +54,7 @@ Fri Jan 4 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
54 (sysv_read_super): Likewise. 54 (sysv_read_super): Likewise.
55 (v7_read_super): Likewise. 55 (v7_read_super): Likewise.
56 56
57Sun Dec 30 2001 Manfred Spraul <manfreds@colorfullife.com> 57Sun Dec 30 2001 Manfred Spraul <manfred@colorfullife.com>
58 58
59 * dir.c (dir_commit_chunk): Do not set dir->i_version. 59 * dir.c (dir_commit_chunk): Do not set dir->i_version.
60 (sysv_readdir): Likewise. 60 (sysv_readdir): Likewise.
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index a9f4421ddb6f..3ada9dcf55b8 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -49,7 +49,7 @@ void ufs_free_fragments (struct inode * inode, unsigned fragment, unsigned count
49 49
50 sb = inode->i_sb; 50 sb = inode->i_sb;
51 uspi = UFS_SB(sb)->s_uspi; 51 uspi = UFS_SB(sb)->s_uspi;
52 usb1 = ubh_get_usb_first(USPI_UBH); 52 usb1 = ubh_get_usb_first(uspi);
53 53
54 UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) 54 UFSD(("ENTER, fragment %u, count %u\n", fragment, count))
55 55
@@ -81,8 +81,9 @@ void ufs_free_fragments (struct inode * inode, unsigned fragment, unsigned count
81 for (i = bit; i < end_bit; i++) { 81 for (i = bit; i < end_bit; i++) {
82 if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i)) 82 if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i))
83 ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i); 83 ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i);
84 else ufs_error (sb, "ufs_free_fragments", 84 else
85 "bit already cleared for fragment %u", i); 85 ufs_error (sb, "ufs_free_fragments",
86 "bit already cleared for fragment %u", i);
86 } 87 }
87 88
88 DQUOT_FREE_BLOCK (inode, count); 89 DQUOT_FREE_BLOCK (inode, count);
@@ -143,7 +144,7 @@ void ufs_free_blocks (struct inode * inode, unsigned fragment, unsigned count) {
143 144
144 sb = inode->i_sb; 145 sb = inode->i_sb;
145 uspi = UFS_SB(sb)->s_uspi; 146 uspi = UFS_SB(sb)->s_uspi;
146 usb1 = ubh_get_usb_first(USPI_UBH); 147 usb1 = ubh_get_usb_first(uspi);
147 148
148 UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) 149 UFSD(("ENTER, fragment %u, count %u\n", fragment, count))
149 150
@@ -247,7 +248,7 @@ unsigned ufs_new_fragments (struct inode * inode, __fs32 * p, unsigned fragment,
247 248
248 sb = inode->i_sb; 249 sb = inode->i_sb;
249 uspi = UFS_SB(sb)->s_uspi; 250 uspi = UFS_SB(sb)->s_uspi;
250 usb1 = ubh_get_usb_first(USPI_UBH); 251 usb1 = ubh_get_usb_first(uspi);
251 *err = -ENOSPC; 252 *err = -ENOSPC;
252 253
253 lock_super (sb); 254 lock_super (sb);
@@ -407,7 +408,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
407 408
408 sb = inode->i_sb; 409 sb = inode->i_sb;
409 uspi = UFS_SB(sb)->s_uspi; 410 uspi = UFS_SB(sb)->s_uspi;
410 usb1 = ubh_get_usb_first (USPI_UBH); 411 usb1 = ubh_get_usb_first (uspi);
411 count = newcount - oldcount; 412 count = newcount - oldcount;
412 413
413 cgno = ufs_dtog(fragment); 414 cgno = ufs_dtog(fragment);
@@ -490,7 +491,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno,
490 491
491 sb = inode->i_sb; 492 sb = inode->i_sb;
492 uspi = UFS_SB(sb)->s_uspi; 493 uspi = UFS_SB(sb)->s_uspi;
493 usb1 = ubh_get_usb_first(USPI_UBH); 494 usb1 = ubh_get_usb_first(uspi);
494 oldcg = cgno; 495 oldcg = cgno;
495 496
496 /* 497 /*
@@ -606,7 +607,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
606 607
607 sb = inode->i_sb; 608 sb = inode->i_sb;
608 uspi = UFS_SB(sb)->s_uspi; 609 uspi = UFS_SB(sb)->s_uspi;
609 usb1 = ubh_get_usb_first(USPI_UBH); 610 usb1 = ubh_get_usb_first(uspi);
610 ucg = ubh_get_ucg(UCPI_UBH); 611 ucg = ubh_get_ucg(UCPI_UBH);
611 612
612 if (goal == 0) { 613 if (goal == 0) {
@@ -663,7 +664,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
663 UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count)) 664 UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count))
664 665
665 uspi = UFS_SB(sb)->s_uspi; 666 uspi = UFS_SB(sb)->s_uspi;
666 usb1 = ubh_get_usb_first (USPI_UBH); 667 usb1 = ubh_get_usb_first (uspi);
667 ucg = ubh_get_ucg(UCPI_UBH); 668 ucg = ubh_get_ucg(UCPI_UBH);
668 669
669 if (goal) 670 if (goal)
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 0938945b9cbc..c7a47ed4f430 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -72,7 +72,7 @@ void ufs_free_inode (struct inode * inode)
72 72
73 sb = inode->i_sb; 73 sb = inode->i_sb;
74 uspi = UFS_SB(sb)->s_uspi; 74 uspi = UFS_SB(sb)->s_uspi;
75 usb1 = ubh_get_usb_first(USPI_UBH); 75 usb1 = ubh_get_usb_first(uspi);
76 76
77 ino = inode->i_ino; 77 ino = inode->i_ino;
78 78
@@ -167,7 +167,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
167 ufsi = UFS_I(inode); 167 ufsi = UFS_I(inode);
168 sbi = UFS_SB(sb); 168 sbi = UFS_SB(sb);
169 uspi = sbi->s_uspi; 169 uspi = sbi->s_uspi;
170 usb1 = ubh_get_usb_first(USPI_UBH); 170 usb1 = ubh_get_usb_first(uspi);
171 171
172 lock_super (sb); 172 lock_super (sb);
173 173
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 55f4aa16e3fc..e0c04e36a051 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -61,7 +61,7 @@ static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t off
61 int n = 0; 61 int n = 0;
62 62
63 63
64 UFSD(("ptrs=uspi->s_apb = %d,double_blocks=%d \n",ptrs,double_blocks)); 64 UFSD(("ptrs=uspi->s_apb = %d,double_blocks=%ld \n",ptrs,double_blocks));
65 if (i_block < 0) { 65 if (i_block < 0) {
66 ufs_warning(inode->i_sb, "ufs_block_to_path", "block < 0"); 66 ufs_warning(inode->i_sb, "ufs_block_to_path", "block < 0");
67 } else if (i_block < direct_blocks) { 67 } else if (i_block < direct_blocks) {
@@ -104,7 +104,7 @@ u64 ufs_frag_map(struct inode *inode, sector_t frag)
104 unsigned flags = UFS_SB(sb)->s_flags; 104 unsigned flags = UFS_SB(sb)->s_flags;
105 u64 temp = 0L; 105 u64 temp = 0L;
106 106
107 UFSD((": frag = %lu depth = %d\n",frag,depth)); 107 UFSD((": frag = %llu depth = %d\n", (unsigned long long)frag, depth));
108 UFSD((": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",uspi->s_fpbshift,uspi->s_apbmask,mask)); 108 UFSD((": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",uspi->s_fpbshift,uspi->s_apbmask,mask));
109 109
110 if (depth == 0) 110 if (depth == 0)
@@ -365,9 +365,10 @@ repeat:
365 sync_dirty_buffer(bh); 365 sync_dirty_buffer(bh);
366 inode->i_ctime = CURRENT_TIME_SEC; 366 inode->i_ctime = CURRENT_TIME_SEC;
367 mark_inode_dirty(inode); 367 mark_inode_dirty(inode);
368 UFSD(("result %u\n", tmp + blockoff));
368out: 369out:
369 brelse (bh); 370 brelse (bh);
370 UFSD(("EXIT, result %u\n", tmp + blockoff)) 371 UFSD(("EXIT\n"));
371 return result; 372 return result;
372} 373}
373 374
@@ -386,7 +387,7 @@ static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf
386 387
387 if (!create) { 388 if (!create) {
388 phys64 = ufs_frag_map(inode, fragment); 389 phys64 = ufs_frag_map(inode, fragment);
389 UFSD(("phys64 = %lu \n",phys64)); 390 UFSD(("phys64 = %llu \n",phys64));
390 if (phys64) 391 if (phys64)
391 map_bh(bh_result, sb, phys64); 392 map_bh(bh_result, sb, phys64);
392 return 0; 393 return 0;
@@ -401,7 +402,7 @@ static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf
401 402
402 lock_kernel(); 403 lock_kernel();
403 404
404 UFSD(("ENTER, ino %lu, fragment %u\n", inode->i_ino, fragment)) 405 UFSD(("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment))
405 if (fragment < 0) 406 if (fragment < 0)
406 goto abort_negative; 407 goto abort_negative;
407 if (fragment > 408 if (fragment >
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index e9a42c711a9e..d4aacee593ff 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -221,7 +221,7 @@ void ufs_error (struct super_block * sb, const char * function,
221 va_list args; 221 va_list args;
222 222
223 uspi = UFS_SB(sb)->s_uspi; 223 uspi = UFS_SB(sb)->s_uspi;
224 usb1 = ubh_get_usb_first(USPI_UBH); 224 usb1 = ubh_get_usb_first(uspi);
225 225
226 if (!(sb->s_flags & MS_RDONLY)) { 226 if (!(sb->s_flags & MS_RDONLY)) {
227 usb1->fs_clean = UFS_FSBAD; 227 usb1->fs_clean = UFS_FSBAD;
@@ -253,7 +253,7 @@ void ufs_panic (struct super_block * sb, const char * function,
253 va_list args; 253 va_list args;
254 254
255 uspi = UFS_SB(sb)->s_uspi; 255 uspi = UFS_SB(sb)->s_uspi;
256 usb1 = ubh_get_usb_first(USPI_UBH); 256 usb1 = ubh_get_usb_first(uspi);
257 257
258 if (!(sb->s_flags & MS_RDONLY)) { 258 if (!(sb->s_flags & MS_RDONLY)) {
259 usb1->fs_clean = UFS_FSBAD; 259 usb1->fs_clean = UFS_FSBAD;
@@ -420,21 +420,18 @@ static int ufs_read_cylinder_structures (struct super_block *sb) {
420 if (i + uspi->s_fpb > blks) 420 if (i + uspi->s_fpb > blks)
421 size = (blks - i) * uspi->s_fsize; 421 size = (blks - i) * uspi->s_fsize;
422 422
423 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { 423 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
424 ubh = ubh_bread(sb, 424 ubh = ubh_bread(sb,
425 fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); 425 fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size);
426 if (!ubh) 426 else
427 goto failed;
428 ubh_ubhcpymem (space, ubh, size);
429 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space;
430 }
431 else {
432 ubh = ubh_bread(sb, uspi->s_csaddr + i, size); 427 ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
433 if (!ubh) 428
434 goto failed; 429 if (!ubh)
435 ubh_ubhcpymem(space, ubh, size); 430 goto failed;
436 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space; 431
437 } 432 ubh_ubhcpymem (space, ubh, size);
433 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space;
434
438 space += size; 435 space += size;
439 ubh_brelse (ubh); 436 ubh_brelse (ubh);
440 ubh = NULL; 437 ubh = NULL;
@@ -539,6 +536,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
539 struct inode *inode; 536 struct inode *inode;
540 unsigned block_size, super_block_size; 537 unsigned block_size, super_block_size;
541 unsigned flags; 538 unsigned flags;
539 unsigned super_block_offset;
542 540
543 uspi = NULL; 541 uspi = NULL;
544 ubh = NULL; 542 ubh = NULL;
@@ -586,10 +584,11 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
586 if (!uspi) 584 if (!uspi)
587 goto failed; 585 goto failed;
588 586
587 super_block_offset=UFS_SBLOCK;
588
589 /* Keep 2Gig file limit. Some UFS variants need to override 589 /* Keep 2Gig file limit. Some UFS variants need to override
590 this but as I don't know which I'll let those in the know loosen 590 this but as I don't know which I'll let those in the know loosen
591 the rules */ 591 the rules */
592
593 switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { 592 switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) {
594 case UFS_MOUNT_UFSTYPE_44BSD: 593 case UFS_MOUNT_UFSTYPE_44BSD:
595 UFSD(("ufstype=44bsd\n")) 594 UFSD(("ufstype=44bsd\n"))
@@ -601,7 +600,8 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
601 flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; 600 flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
602 break; 601 break;
603 case UFS_MOUNT_UFSTYPE_UFS2: 602 case UFS_MOUNT_UFSTYPE_UFS2:
604 UFSD(("ufstype=ufs2\n")) 603 UFSD(("ufstype=ufs2\n"));
604 super_block_offset=SBLOCK_UFS2;
605 uspi->s_fsize = block_size = 512; 605 uspi->s_fsize = block_size = 512;
606 uspi->s_fmask = ~(512 - 1); 606 uspi->s_fmask = ~(512 - 1);
607 uspi->s_fshift = 9; 607 uspi->s_fshift = 9;
@@ -725,19 +725,16 @@ again:
725 /* 725 /*
726 * read ufs super block from device 726 * read ufs super block from device
727 */ 727 */
728 if ( (flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { 728
729 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + SBLOCK_UFS2/block_size, super_block_size); 729 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + super_block_offset/block_size, super_block_size);
730 } 730
731 else {
732 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + UFS_SBLOCK/block_size, super_block_size);
733 }
734 if (!ubh) 731 if (!ubh)
735 goto failed; 732 goto failed;
736 733
737 734
738 usb1 = ubh_get_usb_first(USPI_UBH); 735 usb1 = ubh_get_usb_first(uspi);
739 usb2 = ubh_get_usb_second(USPI_UBH); 736 usb2 = ubh_get_usb_second(uspi);
740 usb3 = ubh_get_usb_third(USPI_UBH); 737 usb3 = ubh_get_usb_third(uspi);
741 usb = (struct ufs_super_block *) 738 usb = (struct ufs_super_block *)
742 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; 739 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ;
743 740
@@ -1006,8 +1003,8 @@ static void ufs_write_super (struct super_block *sb) {
1006 UFSD(("ENTER\n")) 1003 UFSD(("ENTER\n"))
1007 flags = UFS_SB(sb)->s_flags; 1004 flags = UFS_SB(sb)->s_flags;
1008 uspi = UFS_SB(sb)->s_uspi; 1005 uspi = UFS_SB(sb)->s_uspi;
1009 usb1 = ubh_get_usb_first(USPI_UBH); 1006 usb1 = ubh_get_usb_first(uspi);
1010 usb3 = ubh_get_usb_third(USPI_UBH); 1007 usb3 = ubh_get_usb_third(uspi);
1011 1008
1012 if (!(sb->s_flags & MS_RDONLY)) { 1009 if (!(sb->s_flags & MS_RDONLY)) {
1013 usb1->fs_time = cpu_to_fs32(sb, get_seconds()); 1010 usb1->fs_time = cpu_to_fs32(sb, get_seconds());
@@ -1049,8 +1046,8 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1049 1046
1050 uspi = UFS_SB(sb)->s_uspi; 1047 uspi = UFS_SB(sb)->s_uspi;
1051 flags = UFS_SB(sb)->s_flags; 1048 flags = UFS_SB(sb)->s_flags;
1052 usb1 = ubh_get_usb_first(USPI_UBH); 1049 usb1 = ubh_get_usb_first(uspi);
1053 usb3 = ubh_get_usb_third(USPI_UBH); 1050 usb3 = ubh_get_usb_third(uspi);
1054 1051
1055 /* 1052 /*
1056 * Allow the "check" option to be passed as a remount option. 1053 * Allow the "check" option to be passed as a remount option.
@@ -1124,7 +1121,7 @@ static int ufs_statfs (struct super_block *sb, struct kstatfs *buf)
1124 lock_kernel(); 1121 lock_kernel();
1125 1122
1126 uspi = UFS_SB(sb)->s_uspi; 1123 uspi = UFS_SB(sb)->s_uspi;
1127 usb1 = ubh_get_usb_first (USPI_UBH); 1124 usb1 = ubh_get_usb_first (uspi);
1128 usb = (struct ufs_super_block *) 1125 usb = (struct ufs_super_block *)
1129 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; 1126 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ;
1130 1127
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index b2640076679a..48d6d9bcc157 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -249,18 +249,28 @@ extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head
249 249
250 250
251/* 251/*
252 * macros to get important structures from ufs_buffer_head 252 * macros and inline function to get important structures from ufs_sb_private_info
253 */ 253 */
254#define ubh_get_usb_first(ubh) \
255 ((struct ufs_super_block_first *)((ubh)->bh[0]->b_data))
256 254
257#define ubh_get_usb_second(ubh) \ 255static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
258 ((struct ufs_super_block_second *)(ubh)-> \ 256 unsigned int offset)
259 bh[UFS_SECTOR_SIZE >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE & ~uspi->s_fmask)) 257{
258 unsigned int index;
259
260 index = offset >> uspi->s_fshift;
261 offset &= ~uspi->s_fmask;
262 return uspi->s_ubh.bh[index]->b_data + offset;
263}
264
265#define ubh_get_usb_first(uspi) \
266 ((struct ufs_super_block_first *)get_usb_offset((uspi), 0))
267
268#define ubh_get_usb_second(uspi) \
269 ((struct ufs_super_block_second *)get_usb_offset((uspi), UFS_SECTOR_SIZE))
270
271#define ubh_get_usb_third(uspi) \
272 ((struct ufs_super_block_third *)get_usb_offset((uspi), 2*UFS_SECTOR_SIZE))
260 273
261#define ubh_get_usb_third(ubh) \
262 ((struct ufs_super_block_third *)((ubh)-> \
263 bh[UFS_SECTOR_SIZE*2 >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE*2 & ~uspi->s_fmask)))
264 274
265#define ubh_get_ucg(ubh) \ 275#define ubh_get_ucg(ubh) \
266 ((struct ufs_cylinder_group *)((ubh)->bh[0]->b_data)) 276 ((struct ufs_cylinder_group *)((ubh)->bh[0]->b_data))
diff --git a/fs/xfs/linux-2.6/mutex.h b/fs/xfs/linux-2.6/mutex.h
index d3369b6ca168..2a88d56c4dc2 100644
--- a/fs/xfs/linux-2.6/mutex.h
+++ b/fs/xfs/linux-2.6/mutex.h
@@ -18,18 +18,8 @@
18#ifndef __XFS_SUPPORT_MUTEX_H__ 18#ifndef __XFS_SUPPORT_MUTEX_H__
19#define __XFS_SUPPORT_MUTEX_H__ 19#define __XFS_SUPPORT_MUTEX_H__
20 20
21#include <linux/spinlock.h>
22#include <linux/mutex.h> 21#include <linux/mutex.h>
23 22
24/* 23typedef struct mutex mutex_t;
25 * Map the mutex'es from IRIX to Linux semaphores.
26 *
27 * Destroy just simply initializes to -99 which should block all other
28 * callers.
29 */
30#define MUTEX_DEFAULT 0x0
31
32typedef struct mutex mutex_t;
33//#define mutex_destroy(lock) do{}while(0)
34 24
35#endif /* __XFS_SUPPORT_MUTEX_H__ */ 25#endif /* __XFS_SUPPORT_MUTEX_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 4bd3d03b23ed..76c6df34d0db 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -56,9 +56,6 @@
56#include <linux/namei.h> 56#include <linux/namei.h>
57#include <linux/security.h> 57#include <linux/security.h>
58 58
59#define IS_NOATIME(inode) ((inode->i_sb->s_flags & MS_NOATIME) || \
60 (S_ISDIR(inode->i_mode) && inode->i_sb->s_flags & MS_NODIRATIME))
61
62/* 59/*
63 * Get a XFS inode from a given vnode. 60 * Get a XFS inode from a given vnode.
64 */ 61 */
@@ -474,11 +471,14 @@ linvfs_symlink(
474 471
475 error = 0; 472 error = 0;
476 VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); 473 VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
477 if (!error && cvp) { 474 if (likely(!error && cvp)) {
478 ip = LINVFS_GET_IP(cvp); 475 error = linvfs_init_security(cvp, dir);
479 d_instantiate(dentry, ip); 476 if (likely(!error)) {
480 validate_fields(dir); 477 ip = LINVFS_GET_IP(cvp);
481 validate_fields(ip); /* size needs update */ 478 d_instantiate(dentry, ip);
479 validate_fields(dir);
480 validate_fields(ip);
481 }
482 } 482 }
483 return -error; 483 return -error;
484} 484}
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 7dcdd0640c32..53a00fb217fa 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -167,7 +167,7 @@ xfs_Gqm_init(void)
167 xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO; 167 xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO;
168 xqm->qm_nrefs = 0; 168 xqm->qm_nrefs = 0;
169#ifdef DEBUG 169#ifdef DEBUG
170 xfs_mutex_init(&qcheck_lock, MUTEX_DEFAULT, "qchk"); 170 mutex_init(&qcheck_lock);
171#endif 171#endif
172 return xqm; 172 return xqm;
173} 173}
@@ -497,7 +497,7 @@ xfs_qm_dqflush_all(
497 int error; 497 int error;
498 498
499 if (mp->m_quotainfo == NULL) 499 if (mp->m_quotainfo == NULL)
500 return (0); 500 return 0;
501 niters = 0; 501 niters = 0;
502again: 502again:
503 xfs_qm_mplist_lock(mp); 503 xfs_qm_mplist_lock(mp);
@@ -528,7 +528,7 @@ again:
528 error = xfs_qm_dqflush(dqp, flags); 528 error = xfs_qm_dqflush(dqp, flags);
529 xfs_dqunlock(dqp); 529 xfs_dqunlock(dqp);
530 if (error) 530 if (error)
531 return (error); 531 return error;
532 532
533 xfs_qm_mplist_lock(mp); 533 xfs_qm_mplist_lock(mp);
534 if (recl != XFS_QI_MPLRECLAIMS(mp)) { 534 if (recl != XFS_QI_MPLRECLAIMS(mp)) {
@@ -540,7 +540,7 @@ again:
540 540
541 xfs_qm_mplist_unlock(mp); 541 xfs_qm_mplist_unlock(mp);
542 /* return ! busy */ 542 /* return ! busy */
543 return (0); 543 return 0;
544} 544}
545/* 545/*
546 * Release the group dquot pointers the user dquots may be 546 * Release the group dquot pointers the user dquots may be
@@ -599,7 +599,7 @@ xfs_qm_dqpurge_int(
599 int nmisses; 599 int nmisses;
600 600
601 if (mp->m_quotainfo == NULL) 601 if (mp->m_quotainfo == NULL)
602 return (0); 602 return 0;
603 603
604 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0; 604 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0;
605 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0; 605 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0;
@@ -796,7 +796,7 @@ xfs_qm_dqattach_one(
796 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 796 ASSERT(XFS_DQ_IS_LOCKED(dqp));
797 } 797 }
798#endif 798#endif
799 return (error); 799 return error;
800} 800}
801 801
802 802
@@ -897,7 +897,7 @@ xfs_qm_dqattach(
897 (! XFS_NOT_DQATTACHED(mp, ip)) || 897 (! XFS_NOT_DQATTACHED(mp, ip)) ||
898 (ip->i_ino == mp->m_sb.sb_uquotino) || 898 (ip->i_ino == mp->m_sb.sb_uquotino) ||
899 (ip->i_ino == mp->m_sb.sb_gquotino)) 899 (ip->i_ino == mp->m_sb.sb_gquotino))
900 return (0); 900 return 0;
901 901
902 ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || 902 ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 ||
903 XFS_ISLOCKED_INODE_EXCL(ip)); 903 XFS_ISLOCKED_INODE_EXCL(ip));
@@ -984,7 +984,7 @@ xfs_qm_dqattach(
984 else 984 else
985 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); 985 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
986#endif 986#endif
987 return (error); 987 return error;
988} 988}
989 989
990/* 990/*
@@ -1049,7 +1049,7 @@ xfs_qm_sync(
1049 */ 1049 */
1050 if (! XFS_IS_QUOTA_ON(mp)) { 1050 if (! XFS_IS_QUOTA_ON(mp)) {
1051 xfs_qm_mplist_unlock(mp); 1051 xfs_qm_mplist_unlock(mp);
1052 return (0); 1052 return 0;
1053 } 1053 }
1054 FOREACH_DQUOT_IN_MP(dqp, mp) { 1054 FOREACH_DQUOT_IN_MP(dqp, mp) {
1055 /* 1055 /*
@@ -1109,9 +1109,9 @@ xfs_qm_sync(
1109 error = xfs_qm_dqflush(dqp, flush_flags); 1109 error = xfs_qm_dqflush(dqp, flush_flags);
1110 xfs_dqunlock(dqp); 1110 xfs_dqunlock(dqp);
1111 if (error && XFS_FORCED_SHUTDOWN(mp)) 1111 if (error && XFS_FORCED_SHUTDOWN(mp))
1112 return(0); /* Need to prevent umount failure */ 1112 return 0; /* Need to prevent umount failure */
1113 else if (error) 1113 else if (error)
1114 return (error); 1114 return error;
1115 1115
1116 xfs_qm_mplist_lock(mp); 1116 xfs_qm_mplist_lock(mp);
1117 if (recl != XFS_QI_MPLRECLAIMS(mp)) { 1117 if (recl != XFS_QI_MPLRECLAIMS(mp)) {
@@ -1124,7 +1124,7 @@ xfs_qm_sync(
1124 } 1124 }
1125 1125
1126 xfs_qm_mplist_unlock(mp); 1126 xfs_qm_mplist_unlock(mp);
1127 return (0); 1127 return 0;
1128} 1128}
1129 1129
1130 1130
@@ -1146,7 +1146,7 @@ xfs_qm_init_quotainfo(
1146 * Tell XQM that we exist as soon as possible. 1146 * Tell XQM that we exist as soon as possible.
1147 */ 1147 */
1148 if ((error = xfs_qm_hold_quotafs_ref(mp))) { 1148 if ((error = xfs_qm_hold_quotafs_ref(mp))) {
1149 return (error); 1149 return error;
1150 } 1150 }
1151 1151
1152 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); 1152 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
@@ -1158,7 +1158,7 @@ xfs_qm_init_quotainfo(
1158 if ((error = xfs_qm_init_quotainos(mp))) { 1158 if ((error = xfs_qm_init_quotainos(mp))) {
1159 kmem_free(qinf, sizeof(xfs_quotainfo_t)); 1159 kmem_free(qinf, sizeof(xfs_quotainfo_t));
1160 mp->m_quotainfo = NULL; 1160 mp->m_quotainfo = NULL;
1161 return (error); 1161 return error;
1162 } 1162 }
1163 1163
1164 spinlock_init(&qinf->qi_pinlock, "xfs_qinf_pin"); 1164 spinlock_init(&qinf->qi_pinlock, "xfs_qinf_pin");
@@ -1232,7 +1232,7 @@ xfs_qm_init_quotainfo(
1232 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT; 1232 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
1233 } 1233 }
1234 1234
1235 return (0); 1235 return 0;
1236} 1236}
1237 1237
1238 1238
@@ -1332,7 +1332,7 @@ xfs_qm_dqget_noattach(
1332 */ 1332 */
1333 ASSERT(error != ESRCH); 1333 ASSERT(error != ESRCH);
1334 ASSERT(error != ENOENT); 1334 ASSERT(error != ENOENT);
1335 return (error); 1335 return error;
1336 } 1336 }
1337 ASSERT(udqp); 1337 ASSERT(udqp);
1338 } 1338 }
@@ -1355,7 +1355,7 @@ xfs_qm_dqget_noattach(
1355 xfs_qm_dqrele(udqp); 1355 xfs_qm_dqrele(udqp);
1356 ASSERT(error != ESRCH); 1356 ASSERT(error != ESRCH);
1357 ASSERT(error != ENOENT); 1357 ASSERT(error != ENOENT);
1358 return (error); 1358 return error;
1359 } 1359 }
1360 ASSERT(gdqp); 1360 ASSERT(gdqp);
1361 1361
@@ -1376,7 +1376,7 @@ xfs_qm_dqget_noattach(
1376 if (udqp) ASSERT(XFS_DQ_IS_LOCKED(udqp)); 1376 if (udqp) ASSERT(XFS_DQ_IS_LOCKED(udqp));
1377 if (gdqp) ASSERT(XFS_DQ_IS_LOCKED(gdqp)); 1377 if (gdqp) ASSERT(XFS_DQ_IS_LOCKED(gdqp));
1378#endif 1378#endif
1379 return (0); 1379 return 0;
1380} 1380}
1381 1381
1382/* 1382/*
@@ -1404,7 +1404,7 @@ xfs_qm_qino_alloc(
1404 XFS_TRANS_PERM_LOG_RES, 1404 XFS_TRANS_PERM_LOG_RES,
1405 XFS_CREATE_LOG_COUNT))) { 1405 XFS_CREATE_LOG_COUNT))) {
1406 xfs_trans_cancel(tp, 0); 1406 xfs_trans_cancel(tp, 0);
1407 return (error); 1407 return error;
1408 } 1408 }
1409 memset(&zerocr, 0, sizeof(zerocr)); 1409 memset(&zerocr, 0, sizeof(zerocr));
1410 memset(&zeroino, 0, sizeof(zeroino)); 1410 memset(&zeroino, 0, sizeof(zeroino));
@@ -1413,7 +1413,7 @@ xfs_qm_qino_alloc(
1413 &zerocr, 0, 1, ip, &committed))) { 1413 &zerocr, 0, 1, ip, &committed))) {
1414 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | 1414 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
1415 XFS_TRANS_ABORT); 1415 XFS_TRANS_ABORT);
1416 return (error); 1416 return error;
1417 } 1417 }
1418 1418
1419 /* 1419 /*
@@ -1461,9 +1461,9 @@ xfs_qm_qino_alloc(
1461 if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, 1461 if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES,
1462 NULL))) { 1462 NULL))) {
1463 xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!"); 1463 xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!");
1464 return (error); 1464 return error;
1465 } 1465 }
1466 return (0); 1466 return 0;
1467} 1467}
1468 1468
1469 1469
@@ -1508,7 +1508,7 @@ xfs_qm_reset_dqcounts(
1508 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); 1508 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
1509 } 1509 }
1510 1510
1511 return (0); 1511 return 0;
1512} 1512}
1513 1513
1514STATIC int 1514STATIC int
@@ -1557,7 +1557,7 @@ xfs_qm_dqiter_bufs(
1557 bno++; 1557 bno++;
1558 firstid += XFS_QM_DQPERBLK(mp); 1558 firstid += XFS_QM_DQPERBLK(mp);
1559 } 1559 }
1560 return (error); 1560 return error;
1561} 1561}
1562 1562
1563/* 1563/*
@@ -1586,7 +1586,7 @@ xfs_qm_dqiterate(
1586 * happens only at mount time which is single threaded. 1586 * happens only at mount time which is single threaded.
1587 */ 1587 */
1588 if (qip->i_d.di_nblocks == 0) 1588 if (qip->i_d.di_nblocks == 0)
1589 return (0); 1589 return 0;
1590 1590
1591 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP); 1591 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP);
1592 1592
@@ -1655,7 +1655,7 @@ xfs_qm_dqiterate(
1655 1655
1656 kmem_free(map, XFS_DQITER_MAP_SIZE * sizeof(*map)); 1656 kmem_free(map, XFS_DQITER_MAP_SIZE * sizeof(*map));
1657 1657
1658 return (error); 1658 return error;
1659} 1659}
1660 1660
1661/* 1661/*
@@ -1715,7 +1715,7 @@ xfs_qm_get_rtblks(
1715 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1715 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1716 if (!(ifp->if_flags & XFS_IFEXTENTS)) { 1716 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1717 if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK))) 1717 if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK)))
1718 return (error); 1718 return error;
1719 } 1719 }
1720 rtblks = 0; 1720 rtblks = 0;
1721 nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t); 1721 nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
@@ -1723,7 +1723,7 @@ xfs_qm_get_rtblks(
1723 for (ep = base; ep < &base[nextents]; ep++) 1723 for (ep = base; ep < &base[nextents]; ep++)
1724 rtblks += xfs_bmbt_get_blockcount(ep); 1724 rtblks += xfs_bmbt_get_blockcount(ep);
1725 *O_rtblks = (xfs_qcnt_t)rtblks; 1725 *O_rtblks = (xfs_qcnt_t)rtblks;
1726 return (0); 1726 return 0;
1727} 1727}
1728 1728
1729/* 1729/*
@@ -1767,7 +1767,7 @@ xfs_qm_dqusage_adjust(
1767 */ 1767 */
1768 if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) { 1768 if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
1769 *res = BULKSTAT_RV_NOTHING; 1769 *res = BULKSTAT_RV_NOTHING;
1770 return (error); 1770 return error;
1771 } 1771 }
1772 1772
1773 if (ip->i_d.di_mode == 0) { 1773 if (ip->i_d.di_mode == 0) {
@@ -1785,7 +1785,7 @@ xfs_qm_dqusage_adjust(
1785 if ((error = xfs_qm_dqget_noattach(ip, &udqp, &gdqp))) { 1785 if ((error = xfs_qm_dqget_noattach(ip, &udqp, &gdqp))) {
1786 xfs_iput(ip, XFS_ILOCK_EXCL); 1786 xfs_iput(ip, XFS_ILOCK_EXCL);
1787 *res = BULKSTAT_RV_GIVEUP; 1787 *res = BULKSTAT_RV_GIVEUP;
1788 return (error); 1788 return error;
1789 } 1789 }
1790 1790
1791 rtblks = 0; 1791 rtblks = 0;
@@ -1802,7 +1802,7 @@ xfs_qm_dqusage_adjust(
1802 if (gdqp) 1802 if (gdqp)
1803 xfs_qm_dqput(gdqp); 1803 xfs_qm_dqput(gdqp);
1804 *res = BULKSTAT_RV_GIVEUP; 1804 *res = BULKSTAT_RV_GIVEUP;
1805 return (error); 1805 return error;
1806 } 1806 }
1807 nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks; 1807 nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
1808 } 1808 }
@@ -1847,7 +1847,7 @@ xfs_qm_dqusage_adjust(
1847 * Goto next inode. 1847 * Goto next inode.
1848 */ 1848 */
1849 *res = BULKSTAT_RV_DIDONE; 1849 *res = BULKSTAT_RV_DIDONE;
1850 return (0); 1850 return 0;
1851} 1851}
1852 1852
1853/* 1853/*
@@ -2041,7 +2041,7 @@ xfs_qm_init_quotainos(
2041 XFS_QI_UQIP(mp) = uip; 2041 XFS_QI_UQIP(mp) = uip;
2042 XFS_QI_GQIP(mp) = gip; 2042 XFS_QI_GQIP(mp) = gip;
2043 2043
2044 return (0); 2044 return 0;
2045} 2045}
2046 2046
2047 2047
@@ -2062,7 +2062,7 @@ xfs_qm_shake_freelist(
2062 int nflushes; 2062 int nflushes;
2063 2063
2064 if (howmany <= 0) 2064 if (howmany <= 0)
2065 return (0); 2065 return 0;
2066 2066
2067 nreclaimed = 0; 2067 nreclaimed = 0;
2068 restarts = 0; 2068 restarts = 0;
@@ -2088,7 +2088,7 @@ xfs_qm_shake_freelist(
2088 xfs_dqunlock(dqp); 2088 xfs_dqunlock(dqp);
2089 xfs_qm_freelist_unlock(xfs_Gqm); 2089 xfs_qm_freelist_unlock(xfs_Gqm);
2090 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2090 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2091 return (nreclaimed); 2091 return nreclaimed;
2092 XQM_STATS_INC(xqmstats.xs_qm_dqwants); 2092 XQM_STATS_INC(xqmstats.xs_qm_dqwants);
2093 goto tryagain; 2093 goto tryagain;
2094 } 2094 }
@@ -2163,7 +2163,7 @@ xfs_qm_shake_freelist(
2163 XFS_DQ_HASH_UNLOCK(hash); 2163 XFS_DQ_HASH_UNLOCK(hash);
2164 xfs_qm_freelist_unlock(xfs_Gqm); 2164 xfs_qm_freelist_unlock(xfs_Gqm);
2165 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2165 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2166 return (nreclaimed); 2166 return nreclaimed;
2167 goto tryagain; 2167 goto tryagain;
2168 } 2168 }
2169 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); 2169 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
@@ -2188,7 +2188,7 @@ xfs_qm_shake_freelist(
2188 dqp = nextdqp; 2188 dqp = nextdqp;
2189 } 2189 }
2190 xfs_qm_freelist_unlock(xfs_Gqm); 2190 xfs_qm_freelist_unlock(xfs_Gqm);
2191 return (nreclaimed); 2191 return nreclaimed;
2192} 2192}
2193 2193
2194 2194
@@ -2202,9 +2202,9 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask)
2202 int ndqused, nfree, n; 2202 int ndqused, nfree, n;
2203 2203
2204 if (!kmem_shake_allow(gfp_mask)) 2204 if (!kmem_shake_allow(gfp_mask))
2205 return (0); 2205 return 0;
2206 if (!xfs_Gqm) 2206 if (!xfs_Gqm)
2207 return (0); 2207 return 0;
2208 2208
2209 nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */ 2209 nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
2210 /* incore dquots in all f/s's */ 2210 /* incore dquots in all f/s's */
@@ -2213,7 +2213,7 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask)
2213 ASSERT(ndqused >= 0); 2213 ASSERT(ndqused >= 0);
2214 2214
2215 if (nfree <= ndqused && nfree < ndquot) 2215 if (nfree <= ndqused && nfree < ndquot)
2216 return (0); 2216 return 0;
2217 2217
2218 ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */ 2218 ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */
2219 n = nfree - ndqused - ndquot; /* # over target */ 2219 n = nfree - ndqused - ndquot; /* # over target */
@@ -2257,7 +2257,7 @@ xfs_qm_dqreclaim_one(void)
2257 xfs_dqunlock(dqp); 2257 xfs_dqunlock(dqp);
2258 xfs_qm_freelist_unlock(xfs_Gqm); 2258 xfs_qm_freelist_unlock(xfs_Gqm);
2259 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2259 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2260 return (NULL); 2260 return NULL;
2261 XQM_STATS_INC(xqmstats.xs_qm_dqwants); 2261 XQM_STATS_INC(xqmstats.xs_qm_dqwants);
2262 goto startagain; 2262 goto startagain;
2263 } 2263 }
@@ -2333,7 +2333,7 @@ xfs_qm_dqreclaim_one(void)
2333 } 2333 }
2334 2334
2335 xfs_qm_freelist_unlock(xfs_Gqm); 2335 xfs_qm_freelist_unlock(xfs_Gqm);
2336 return (dqpout); 2336 return dqpout;
2337} 2337}
2338 2338
2339 2339
@@ -2369,7 +2369,7 @@ xfs_qm_dqalloc_incore(
2369 */ 2369 */
2370 memset(&dqp->q_core, 0, sizeof(dqp->q_core)); 2370 memset(&dqp->q_core, 0, sizeof(dqp->q_core));
2371 *O_dqpp = dqp; 2371 *O_dqpp = dqp;
2372 return (B_FALSE); 2372 return B_FALSE;
2373 } 2373 }
2374 XQM_STATS_INC(xqmstats.xs_qm_dqreclaim_misses); 2374 XQM_STATS_INC(xqmstats.xs_qm_dqreclaim_misses);
2375 } 2375 }
@@ -2382,7 +2382,7 @@ xfs_qm_dqalloc_incore(
2382 *O_dqpp = kmem_zone_zalloc(xfs_Gqm->qm_dqzone, KM_SLEEP); 2382 *O_dqpp = kmem_zone_zalloc(xfs_Gqm->qm_dqzone, KM_SLEEP);
2383 atomic_inc(&xfs_Gqm->qm_totaldquots); 2383 atomic_inc(&xfs_Gqm->qm_totaldquots);
2384 2384
2385 return (B_TRUE); 2385 return B_TRUE;
2386} 2386}
2387 2387
2388 2388
@@ -2407,13 +2407,13 @@ xfs_qm_write_sb_changes(
2407 0, 2407 0,
2408 XFS_DEFAULT_LOG_COUNT))) { 2408 XFS_DEFAULT_LOG_COUNT))) {
2409 xfs_trans_cancel(tp, 0); 2409 xfs_trans_cancel(tp, 0);
2410 return (error); 2410 return error;
2411 } 2411 }
2412 2412
2413 xfs_mod_sb(tp, flags); 2413 xfs_mod_sb(tp, flags);
2414 (void) xfs_trans_commit(tp, 0, NULL); 2414 (void) xfs_trans_commit(tp, 0, NULL);
2415 2415
2416 return (0); 2416 return 0;
2417} 2417}
2418 2418
2419 2419
@@ -2463,7 +2463,7 @@ xfs_qm_vop_dqalloc(
2463 if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | 2463 if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC |
2464 XFS_QMOPT_ILOCKED))) { 2464 XFS_QMOPT_ILOCKED))) {
2465 xfs_iunlock(ip, lockflags); 2465 xfs_iunlock(ip, lockflags);
2466 return (error); 2466 return error;
2467 } 2467 }
2468 } 2468 }
2469 2469
@@ -2486,7 +2486,7 @@ xfs_qm_vop_dqalloc(
2486 XFS_QMOPT_DOWARN, 2486 XFS_QMOPT_DOWARN,
2487 &uq))) { 2487 &uq))) {
2488 ASSERT(error != ENOENT); 2488 ASSERT(error != ENOENT);
2489 return (error); 2489 return error;
2490 } 2490 }
2491 /* 2491 /*
2492 * Get the ilock in the right order. 2492 * Get the ilock in the right order.
@@ -2517,7 +2517,7 @@ xfs_qm_vop_dqalloc(
2517 if (uq) 2517 if (uq)
2518 xfs_qm_dqrele(uq); 2518 xfs_qm_dqrele(uq);
2519 ASSERT(error != ENOENT); 2519 ASSERT(error != ENOENT);
2520 return (error); 2520 return error;
2521 } 2521 }
2522 xfs_dqunlock(gq); 2522 xfs_dqunlock(gq);
2523 lockflags = XFS_ILOCK_SHARED; 2523 lockflags = XFS_ILOCK_SHARED;
@@ -2565,7 +2565,7 @@ xfs_qm_vop_dqalloc(
2565 *O_gdqpp = gq; 2565 *O_gdqpp = gq;
2566 else if (gq) 2566 else if (gq)
2567 xfs_qm_dqrele(gq); 2567 xfs_qm_dqrele(gq);
2568 return (0); 2568 return 0;
2569} 2569}
2570 2570
2571/* 2571/*
@@ -2608,7 +2608,7 @@ xfs_qm_vop_chown(
2608 xfs_dqunlock(newdq); 2608 xfs_dqunlock(newdq);
2609 *IO_olddq = newdq; 2609 *IO_olddq = newdq;
2610 2610
2611 return (prevdq); 2611 return prevdq;
2612} 2612}
2613 2613
2614/* 2614/*
@@ -2702,12 +2702,12 @@ xfs_qm_vop_rename_dqattach(
2702 ip = i_tab[0]; 2702 ip = i_tab[0];
2703 2703
2704 if (! XFS_IS_QUOTA_ON(ip->i_mount)) 2704 if (! XFS_IS_QUOTA_ON(ip->i_mount))
2705 return (0); 2705 return 0;
2706 2706
2707 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2707 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
2708 error = xfs_qm_dqattach(ip, 0); 2708 error = xfs_qm_dqattach(ip, 0);
2709 if (error) 2709 if (error)
2710 return (error); 2710 return error;
2711 } 2711 }
2712 for (i = 1; (i < 4 && i_tab[i]); i++) { 2712 for (i = 1; (i < 4 && i_tab[i]); i++) {
2713 /* 2713 /*
@@ -2717,11 +2717,11 @@ xfs_qm_vop_rename_dqattach(
2717 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2717 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
2718 error = xfs_qm_dqattach(ip, 0); 2718 error = xfs_qm_dqattach(ip, 0);
2719 if (error) 2719 if (error)
2720 return (error); 2720 return error;
2721 } 2721 }
2722 } 2722 }
2723 } 2723 }
2724 return (0); 2724 return 0;
2725} 2725}
2726 2726
2727void 2727void
@@ -2834,7 +2834,7 @@ xfs_qm_dqhashlock_nowait(
2834 int locked; 2834 int locked;
2835 2835
2836 locked = mutex_trylock(&((dqp)->q_hash->qh_lock)); 2836 locked = mutex_trylock(&((dqp)->q_hash->qh_lock));
2837 return (locked); 2837 return locked;
2838} 2838}
2839 2839
2840int 2840int
@@ -2844,7 +2844,7 @@ xfs_qm_freelist_lock_nowait(
2844 int locked; 2844 int locked;
2845 2845
2846 locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock)); 2846 locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock));
2847 return (locked); 2847 return locked;
2848} 2848}
2849 2849
2850STATIC int 2850STATIC int
@@ -2855,5 +2855,5 @@ xfs_qm_mplist_nowait(
2855 2855
2856 ASSERT(mp->m_quotainfo); 2856 ASSERT(mp->m_quotainfo);
2857 locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp))); 2857 locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp)));
2858 return (locked); 2858 return locked;
2859} 2859}
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index 950df31efc46..e83074016abb 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -147,7 +147,7 @@ xfs_dir_shortform_create(xfs_da_args_t *args, xfs_ino_t parent)
147 hdr->count = 0; 147 hdr->count = 0;
148 dp->i_d.di_size = sizeof(*hdr); 148 dp->i_d.di_size = sizeof(*hdr);
149 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); 149 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
150 return(0); 150 return 0;
151} 151}
152 152
153/* 153/*
@@ -180,7 +180,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
180 if (sfe->namelen == args->namelen && 180 if (sfe->namelen == args->namelen &&
181 args->name[0] == sfe->name[0] && 181 args->name[0] == sfe->name[0] &&
182 memcmp(args->name, sfe->name, args->namelen) == 0) 182 memcmp(args->name, sfe->name, args->namelen) == 0)
183 return(XFS_ERROR(EEXIST)); 183 return XFS_ERROR(EEXIST);
184 sfe = XFS_DIR_SF_NEXTENTRY(sfe); 184 sfe = XFS_DIR_SF_NEXTENTRY(sfe);
185 } 185 }
186 186
@@ -198,7 +198,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
198 dp->i_d.di_size += size; 198 dp->i_d.di_size += size;
199 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); 199 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
200 200
201 return(0); 201 return 0;
202} 202}
203 203
204/* 204/*
@@ -238,7 +238,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
238 } 238 }
239 if (i < 0) { 239 if (i < 0) {
240 ASSERT(args->oknoent); 240 ASSERT(args->oknoent);
241 return(XFS_ERROR(ENOENT)); 241 return XFS_ERROR(ENOENT);
242 } 242 }
243 243
244 if ((base + size) != dp->i_d.di_size) { 244 if ((base + size) != dp->i_d.di_size) {
@@ -251,7 +251,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
251 dp->i_d.di_size -= size; 251 dp->i_d.di_size -= size;
252 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); 252 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
253 253
254 return(0); 254 return 0;
255} 255}
256 256
257/* 257/*
@@ -390,7 +390,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs)
390 390
391out: 391out:
392 kmem_free(tmpbuffer, size); 392 kmem_free(tmpbuffer, size);
393 return(retval); 393 return retval;
394} 394}
395 395
396STATIC int 396STATIC int
@@ -596,7 +596,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args)
596 /* XXX - replace assert? */ 596 /* XXX - replace assert? */
597 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sf->hdr.parent); 597 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sf->hdr.parent);
598 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); 598 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA);
599 return(0); 599 return 0;
600 } 600 }
601 ASSERT(args->namelen != 1 || args->name[0] != '.'); 601 ASSERT(args->namelen != 1 || args->name[0] != '.');
602 sfe = &sf->list[0]; 602 sfe = &sf->list[0];
@@ -608,12 +608,12 @@ xfs_dir_shortform_replace(xfs_da_args_t *args)
608 (char *)&sfe->inumber, sizeof(xfs_ino_t))); 608 (char *)&sfe->inumber, sizeof(xfs_ino_t)));
609 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); 609 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber);
610 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); 610 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA);
611 return(0); 611 return 0;
612 } 612 }
613 sfe = XFS_DIR_SF_NEXTENTRY(sfe); 613 sfe = XFS_DIR_SF_NEXTENTRY(sfe);
614 } 614 }
615 ASSERT(args->oknoent); 615 ASSERT(args->oknoent);
616 return(XFS_ERROR(ENOENT)); 616 return XFS_ERROR(ENOENT);
617} 617}
618 618
619/* 619/*
@@ -695,7 +695,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
695 695
696out: 696out:
697 kmem_free(tmpbuffer, XFS_LBSIZE(dp->i_mount)); 697 kmem_free(tmpbuffer, XFS_LBSIZE(dp->i_mount));
698 return(retval); 698 return retval;
699} 699}
700 700
701/* 701/*
@@ -715,17 +715,17 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
715 retval = xfs_da_grow_inode(args, &blkno); 715 retval = xfs_da_grow_inode(args, &blkno);
716 ASSERT(blkno == 1); 716 ASSERT(blkno == 1);
717 if (retval) 717 if (retval)
718 return(retval); 718 return retval;
719 retval = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp1, 719 retval = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp1,
720 XFS_DATA_FORK); 720 XFS_DATA_FORK);
721 if (retval) 721 if (retval)
722 return(retval); 722 return retval;
723 ASSERT(bp1 != NULL); 723 ASSERT(bp1 != NULL);
724 retval = xfs_da_get_buf(args->trans, args->dp, 1, -1, &bp2, 724 retval = xfs_da_get_buf(args->trans, args->dp, 1, -1, &bp2,
725 XFS_DATA_FORK); 725 XFS_DATA_FORK);
726 if (retval) { 726 if (retval) {
727 xfs_da_buf_done(bp1); 727 xfs_da_buf_done(bp1);
728 return(retval); 728 return retval;
729 } 729 }
730 ASSERT(bp2 != NULL); 730 ASSERT(bp2 != NULL);
731 memcpy(bp2->data, bp1->data, XFS_LBSIZE(dp->i_mount)); 731 memcpy(bp2->data, bp1->data, XFS_LBSIZE(dp->i_mount));
@@ -738,7 +738,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
738 retval = xfs_da_node_create(args, 0, 1, &bp1, XFS_DATA_FORK); 738 retval = xfs_da_node_create(args, 0, 1, &bp1, XFS_DATA_FORK);
739 if (retval) { 739 if (retval) {
740 xfs_da_buf_done(bp2); 740 xfs_da_buf_done(bp2);
741 return(retval); 741 return retval;
742 } 742 }
743 node = bp1->data; 743 node = bp1->data;
744 leaf = bp2->data; 744 leaf = bp2->data;
@@ -751,7 +751,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
751 XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); 751 XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0])));
752 xfs_da_buf_done(bp1); 752 xfs_da_buf_done(bp1);
753 753
754 return(retval); 754 return retval;
755} 755}
756 756
757 757
@@ -776,7 +776,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
776 ASSERT(dp != NULL); 776 ASSERT(dp != NULL);
777 retval = xfs_da_get_buf(args->trans, dp, blkno, -1, &bp, XFS_DATA_FORK); 777 retval = xfs_da_get_buf(args->trans, dp, blkno, -1, &bp, XFS_DATA_FORK);
778 if (retval) 778 if (retval)
779 return(retval); 779 return retval;
780 ASSERT(bp != NULL); 780 ASSERT(bp != NULL);
781 leaf = bp->data; 781 leaf = bp->data;
782 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); 782 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
@@ -791,7 +791,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
791 xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); 791 xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1);
792 792
793 *bpp = bp; 793 *bpp = bp;
794 return(0); 794 return 0;
795} 795}
796 796
797/* 797/*
@@ -813,10 +813,10 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
813 ASSERT(oldblk->magic == XFS_DIR_LEAF_MAGIC); 813 ASSERT(oldblk->magic == XFS_DIR_LEAF_MAGIC);
814 error = xfs_da_grow_inode(args, &blkno); 814 error = xfs_da_grow_inode(args, &blkno);
815 if (error) 815 if (error)
816 return(error); 816 return error;
817 error = xfs_dir_leaf_create(args, blkno, &newblk->bp); 817 error = xfs_dir_leaf_create(args, blkno, &newblk->bp);
818 if (error) 818 if (error)
819 return(error); 819 return error;
820 newblk->blkno = blkno; 820 newblk->blkno = blkno;
821 newblk->magic = XFS_DIR_LEAF_MAGIC; 821 newblk->magic = XFS_DIR_LEAF_MAGIC;
822 822
@@ -826,7 +826,7 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
826 xfs_dir_leaf_rebalance(state, oldblk, newblk); 826 xfs_dir_leaf_rebalance(state, oldblk, newblk);
827 error = xfs_da_blk_link(state, oldblk, newblk); 827 error = xfs_da_blk_link(state, oldblk, newblk);
828 if (error) 828 if (error)
829 return(error); 829 return error;
830 830
831 /* 831 /*
832 * Insert the new entry in the correct block. 832 * Insert the new entry in the correct block.
@@ -842,7 +842,7 @@ xfs_dir_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
842 */ 842 */
843 oldblk->hashval = xfs_dir_leaf_lasthash(oldblk->bp, NULL); 843 oldblk->hashval = xfs_dir_leaf_lasthash(oldblk->bp, NULL);
844 newblk->hashval = xfs_dir_leaf_lasthash(newblk->bp, NULL); 844 newblk->hashval = xfs_dir_leaf_lasthash(newblk->bp, NULL);
845 return(error); 845 return error;
846} 846}
847 847
848/* 848/*
@@ -885,7 +885,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
885 if (INT_GET(map->size, ARCH_CONVERT) >= tmp) { 885 if (INT_GET(map->size, ARCH_CONVERT) >= tmp) {
886 if (!args->justcheck) 886 if (!args->justcheck)
887 xfs_dir_leaf_add_work(bp, args, index, i); 887 xfs_dir_leaf_add_work(bp, args, index, i);
888 return(0); 888 return 0;
889 } 889 }
890 sum += INT_GET(map->size, ARCH_CONVERT); 890 sum += INT_GET(map->size, ARCH_CONVERT);
891 } 891 }
@@ -896,7 +896,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
896 * no good and we should just give up. 896 * no good and we should just give up.
897 */ 897 */
898 if (!hdr->holes && (sum < entsize)) 898 if (!hdr->holes && (sum < entsize))
899 return(XFS_ERROR(ENOSPC)); 899 return XFS_ERROR(ENOSPC);
900 900
901 /* 901 /*
902 * Compact the entries to coalesce free space. 902 * Compact the entries to coalesce free space.
@@ -909,18 +909,18 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
909 (uint)sizeof(xfs_dir_leaf_entry_t) : 0, 909 (uint)sizeof(xfs_dir_leaf_entry_t) : 0,
910 args->justcheck); 910 args->justcheck);
911 if (error) 911 if (error)
912 return(error); 912 return error;
913 /* 913 /*
914 * After compaction, the block is guaranteed to have only one 914 * After compaction, the block is guaranteed to have only one
915 * free region, in freemap[0]. If it is not big enough, give up. 915 * free region, in freemap[0]. If it is not big enough, give up.
916 */ 916 */
917 if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT) < 917 if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT) <
918 (entsize + (uint)sizeof(xfs_dir_leaf_entry_t))) 918 (entsize + (uint)sizeof(xfs_dir_leaf_entry_t)))
919 return(XFS_ERROR(ENOSPC)); 919 return XFS_ERROR(ENOSPC);
920 920
921 if (!args->justcheck) 921 if (!args->justcheck)
922 xfs_dir_leaf_add_work(bp, args, index, 0); 922 xfs_dir_leaf_add_work(bp, args, index, 0);
923 return(0); 923 return 0;
924} 924}
925 925
926/* 926/*
@@ -1072,7 +1072,7 @@ xfs_dir_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp, int musthave,
1072 kmem_free(tmpbuffer, lbsize); 1072 kmem_free(tmpbuffer, lbsize);
1073 if (musthave || justcheck) 1073 if (musthave || justcheck)
1074 kmem_free(tmpbuffer2, lbsize); 1074 kmem_free(tmpbuffer2, lbsize);
1075 return(rval); 1075 return rval;
1076} 1076}
1077 1077
1078/* 1078/*
@@ -1292,7 +1292,7 @@ xfs_dir_leaf_figure_balance(xfs_da_state_t *state,
1292 1292
1293 *countarg = count; 1293 *countarg = count;
1294 *namebytesarg = totallen; 1294 *namebytesarg = totallen;
1295 return(foundit); 1295 return foundit;
1296} 1296}
1297 1297
1298/*======================================================================== 1298/*========================================================================
@@ -1334,7 +1334,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1334 INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); 1334 INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
1335 if (bytes > (state->blocksize >> 1)) { 1335 if (bytes > (state->blocksize >> 1)) {
1336 *action = 0; /* blk over 50%, don't try to join */ 1336 *action = 0; /* blk over 50%, don't try to join */
1337 return(0); 1337 return 0;
1338 } 1338 }
1339 1339
1340 /* 1340 /*
@@ -1353,13 +1353,13 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1353 error = xfs_da_path_shift(state, &state->altpath, forward, 1353 error = xfs_da_path_shift(state, &state->altpath, forward,
1354 0, &retval); 1354 0, &retval);
1355 if (error) 1355 if (error)
1356 return(error); 1356 return error;
1357 if (retval) { 1357 if (retval) {
1358 *action = 0; 1358 *action = 0;
1359 } else { 1359 } else {
1360 *action = 2; 1360 *action = 2;
1361 } 1361 }
1362 return(0); 1362 return 0;
1363 } 1363 }
1364 1364
1365 /* 1365 /*
@@ -1381,7 +1381,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1381 blkno, -1, &bp, 1381 blkno, -1, &bp,
1382 XFS_DATA_FORK); 1382 XFS_DATA_FORK);
1383 if (error) 1383 if (error)
1384 return(error); 1384 return error;
1385 ASSERT(bp != NULL); 1385 ASSERT(bp != NULL);
1386 1386
1387 leaf = (xfs_dir_leafblock_t *)info; 1387 leaf = (xfs_dir_leafblock_t *)info;
@@ -1402,7 +1402,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1402 } 1402 }
1403 if (i >= 2) { 1403 if (i >= 2) {
1404 *action = 0; 1404 *action = 0;
1405 return(0); 1405 return 0;
1406 } 1406 }
1407 xfs_da_buf_done(bp); 1407 xfs_da_buf_done(bp);
1408 1408
@@ -1419,13 +1419,13 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1419 0, &retval); 1419 0, &retval);
1420 } 1420 }
1421 if (error) 1421 if (error)
1422 return(error); 1422 return error;
1423 if (retval) { 1423 if (retval) {
1424 *action = 0; 1424 *action = 0;
1425 } else { 1425 } else {
1426 *action = 1; 1426 *action = 1;
1427 } 1427 }
1428 return(0); 1428 return 0;
1429} 1429}
1430 1430
1431/* 1431/*
@@ -1575,8 +1575,8 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
1575 tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT) * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); 1575 tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT) * ((uint)sizeof(xfs_dir_leaf_name_t) - 1);
1576 tmp += INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); 1576 tmp += INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
1577 if (tmp < mp->m_dir_magicpct) 1577 if (tmp < mp->m_dir_magicpct)
1578 return(1); /* leaf is < 37% full */ 1578 return 1; /* leaf is < 37% full */
1579 return(0); 1579 return 0;
1580} 1580}
1581 1581
1582/* 1582/*
@@ -1732,7 +1732,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
1732 if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT)) || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { 1732 if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT)) || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) {
1733 *index = probe; 1733 *index = probe;
1734 ASSERT(args->oknoent); 1734 ASSERT(args->oknoent);
1735 return(XFS_ERROR(ENOENT)); 1735 return XFS_ERROR(ENOENT);
1736 } 1736 }
1737 1737
1738 /* 1738 /*
@@ -1745,14 +1745,14 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
1745 memcmp(args->name, namest->name, args->namelen) == 0) { 1745 memcmp(args->name, namest->name, args->namelen) == 0) {
1746 XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args->inumber); 1746 XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args->inumber);
1747 *index = probe; 1747 *index = probe;
1748 return(XFS_ERROR(EEXIST)); 1748 return XFS_ERROR(EEXIST);
1749 } 1749 }
1750 entry++; 1750 entry++;
1751 probe++; 1751 probe++;
1752 } 1752 }
1753 *index = probe; 1753 *index = probe;
1754 ASSERT(probe == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); 1754 ASSERT(probe == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent);
1755 return(XFS_ERROR(ENOENT)); 1755 return XFS_ERROR(ENOENT);
1756} 1756}
1757 1757
1758/*======================================================================== 1758/*========================================================================
@@ -1890,9 +1890,9 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
1890 INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || 1890 INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) ||
1891 (INT_GET(leaf2->entries[ INT_GET(leaf2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < 1891 (INT_GET(leaf2->entries[ INT_GET(leaf2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) <
1892 INT_GET(leaf1->entries[ INT_GET(leaf1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { 1892 INT_GET(leaf1->entries[ INT_GET(leaf1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) {
1893 return(1); 1893 return 1;
1894 } 1894 }
1895 return(0); 1895 return 0;
1896} 1896}
1897 1897
1898/* 1898/*
@@ -1942,7 +1942,7 @@ xfs_dir_leaf_getdents_int(
1942 leaf = bp->data; 1942 leaf = bp->data;
1943 if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { 1943 if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) {
1944 *eobp = 1; 1944 *eobp = 1;
1945 return(XFS_ERROR(ENOENT)); /* XXX wrong code */ 1945 return XFS_ERROR(ENOENT); /* XXX wrong code */
1946 } 1946 }
1947 1947
1948 want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); 1948 want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset);
@@ -2000,7 +2000,7 @@ xfs_dir_leaf_getdents_int(
2000 * the node code will be setting uio_offset anyway. 2000 * the node code will be setting uio_offset anyway.
2001 */ 2001 */
2002 *eobp = 0; 2002 *eobp = 0;
2003 return(0); 2003 return 0;
2004 } 2004 }
2005 xfs_dir_trace_g_due("leaf: hash found", dp, uio, entry); 2005 xfs_dir_trace_g_due("leaf: hash found", dp, uio, entry);
2006 2006
@@ -2057,7 +2057,7 @@ xfs_dir_leaf_getdents_int(
2057 retval = xfs_da_read_buf(dp->i_transp, dp, thishash, 2057 retval = xfs_da_read_buf(dp->i_transp, dp, thishash,
2058 nextda, &bp2, XFS_DATA_FORK); 2058 nextda, &bp2, XFS_DATA_FORK);
2059 if (retval) 2059 if (retval)
2060 return(retval); 2060 return retval;
2061 2061
2062 ASSERT(bp2 != NULL); 2062 ASSERT(bp2 != NULL);
2063 2063
@@ -2073,7 +2073,7 @@ xfs_dir_leaf_getdents_int(
2073 leaf2); 2073 leaf2);
2074 xfs_da_brelse(dp->i_transp, bp2); 2074 xfs_da_brelse(dp->i_transp, bp2);
2075 2075
2076 return(XFS_ERROR(EFSCORRUPTED)); 2076 return XFS_ERROR(EFSCORRUPTED);
2077 } 2077 }
2078 2078
2079 nexthash = INT_GET(leaf2->entries[0].hashval, 2079 nexthash = INT_GET(leaf2->entries[0].hashval,
@@ -2139,7 +2139,7 @@ xfs_dir_leaf_getdents_int(
2139 2139
2140 xfs_dir_trace_g_du("leaf: E-O-B", dp, uio); 2140 xfs_dir_trace_g_du("leaf: E-O-B", dp, uio);
2141 2141
2142 return(retval); 2142 return retval;
2143 } 2143 }
2144 } 2144 }
2145 2145
@@ -2149,7 +2149,7 @@ xfs_dir_leaf_getdents_int(
2149 2149
2150 xfs_dir_trace_g_du("leaf: E-O-F", dp, uio); 2150 xfs_dir_trace_g_du("leaf: E-O-F", dp, uio);
2151 2151
2152 return(0); 2152 return 0;
2153} 2153}
2154 2154
2155/* 2155/*
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 163031c1e394..b4d971b01588 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -501,7 +501,7 @@ xfs_reserve_blocks(
501 if (inval == (__uint64_t *)NULL) { 501 if (inval == (__uint64_t *)NULL) {
502 outval->resblks = mp->m_resblks; 502 outval->resblks = mp->m_resblks;
503 outval->resblks_avail = mp->m_resblks_avail; 503 outval->resblks_avail = mp->m_resblks_avail;
504 return(0); 504 return 0;
505 } 505 }
506 506
507 request = *inval; 507 request = *inval;
@@ -537,7 +537,7 @@ xfs_reserve_blocks(
537 outval->resblks = mp->m_resblks; 537 outval->resblks = mp->m_resblks;
538 outval->resblks_avail = mp->m_resblks_avail; 538 outval->resblks_avail = mp->m_resblks_avail;
539 XFS_SB_UNLOCK(mp, s); 539 XFS_SB_UNLOCK(mp, s);
540 return(0); 540 return 0;
541} 541}
542 542
543void 543void
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3d9a36e77363..9176995160ed 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -403,7 +403,7 @@ xfs_log_release_iclog(xfs_mount_t *mp,
403 403
404 if (xlog_state_release_iclog(log, iclog)) { 404 if (xlog_state_release_iclog(log, iclog)) {
405 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); 405 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR);
406 return(EIO); 406 return EIO;
407 } 407 }
408 408
409 return 0; 409 return 0;
@@ -556,7 +556,7 @@ xfs_log_unmount(xfs_mount_t *mp)
556 556
557 error = xfs_log_unmount_write(mp); 557 error = xfs_log_unmount_write(mp);
558 xfs_log_unmount_dealloc(mp); 558 xfs_log_unmount_dealloc(mp);
559 return (error); 559 return error;
560} 560}
561 561
562/* 562/*
@@ -728,7 +728,7 @@ xfs_log_write(xfs_mount_t * mp,
728 if ((error = xlog_write(mp, reg, nentries, tic, start_lsn, NULL, 0))) { 728 if ((error = xlog_write(mp, reg, nentries, tic, start_lsn, NULL, 0))) {
729 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); 729 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR);
730 } 730 }
731 return (error); 731 return error;
732} /* xfs_log_write */ 732} /* xfs_log_write */
733 733
734 734
@@ -836,7 +836,7 @@ xfs_log_need_covered(xfs_mount_t *mp)
836 needed = 1; 836 needed = 1;
837 } 837 }
838 LOG_UNLOCK(log, s); 838 LOG_UNLOCK(log, s);
839 return(needed); 839 return needed;
840} 840}
841 841
842/****************************************************************************** 842/******************************************************************************
@@ -1003,7 +1003,7 @@ xlog_bdstrat_cb(struct xfs_buf *bp)
1003 XFS_BUF_ERROR(bp, EIO); 1003 XFS_BUF_ERROR(bp, EIO);
1004 XFS_BUF_STALE(bp); 1004 XFS_BUF_STALE(bp);
1005 xfs_biodone(bp); 1005 xfs_biodone(bp);
1006 return (XFS_ERROR(EIO)); 1006 return XFS_ERROR(EIO);
1007 1007
1008 1008
1009} 1009}
@@ -1263,7 +1263,7 @@ xlog_commit_record(xfs_mount_t *mp,
1263 iclog, XLOG_COMMIT_TRANS))) { 1263 iclog, XLOG_COMMIT_TRANS))) {
1264 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); 1264 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR);
1265 } 1265 }
1266 return (error); 1266 return error;
1267} /* xlog_commit_record */ 1267} /* xlog_commit_record */
1268 1268
1269 1269
@@ -1460,7 +1460,7 @@ xlog_sync(xlog_t *log,
1460 if ((error = XFS_bwrite(bp))) { 1460 if ((error = XFS_bwrite(bp))) {
1461 xfs_ioerror_alert("xlog_sync", log->l_mp, bp, 1461 xfs_ioerror_alert("xlog_sync", log->l_mp, bp,
1462 XFS_BUF_ADDR(bp)); 1462 XFS_BUF_ADDR(bp));
1463 return (error); 1463 return error;
1464 } 1464 }
1465 if (split) { 1465 if (split) {
1466 bp = iclog->ic_log->l_xbuf; 1466 bp = iclog->ic_log->l_xbuf;
@@ -1498,10 +1498,10 @@ xlog_sync(xlog_t *log,
1498 if ((error = XFS_bwrite(bp))) { 1498 if ((error = XFS_bwrite(bp))) {
1499 xfs_ioerror_alert("xlog_sync (split)", log->l_mp, 1499 xfs_ioerror_alert("xlog_sync (split)", log->l_mp,
1500 bp, XFS_BUF_ADDR(bp)); 1500 bp, XFS_BUF_ADDR(bp));
1501 return (error); 1501 return error;
1502 } 1502 }
1503 } 1503 }
1504 return (0); 1504 return 0;
1505} /* xlog_sync */ 1505} /* xlog_sync */
1506 1506
1507 1507
@@ -1798,7 +1798,7 @@ xlog_write(xfs_mount_t * mp,
1798 for (index = 0; index < nentries; ) { 1798 for (index = 0; index < nentries; ) {
1799 if ((error = xlog_state_get_iclog_space(log, len, &iclog, ticket, 1799 if ((error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
1800 &contwr, &log_offset))) 1800 &contwr, &log_offset)))
1801 return (error); 1801 return error;
1802 1802
1803 ASSERT(log_offset <= iclog->ic_size - 1); 1803 ASSERT(log_offset <= iclog->ic_size - 1);
1804 ptr = (__psint_t) ((char *)iclog->ic_datap+log_offset); 1804 ptr = (__psint_t) ((char *)iclog->ic_datap+log_offset);
@@ -1903,7 +1903,7 @@ xlog_write(xfs_mount_t * mp,
1903 xlog_state_finish_copy(log, iclog, record_cnt, data_cnt); 1903 xlog_state_finish_copy(log, iclog, record_cnt, data_cnt);
1904 record_cnt = data_cnt = 0; 1904 record_cnt = data_cnt = 0;
1905 if ((error = xlog_state_release_iclog(log, iclog))) 1905 if ((error = xlog_state_release_iclog(log, iclog)))
1906 return (error); 1906 return error;
1907 break; /* don't increment index */ 1907 break; /* don't increment index */
1908 } else { /* copied entire region */ 1908 } else { /* copied entire region */
1909 index++; 1909 index++;
@@ -1917,7 +1917,7 @@ xlog_write(xfs_mount_t * mp,
1917 ASSERT(flags & XLOG_COMMIT_TRANS); 1917 ASSERT(flags & XLOG_COMMIT_TRANS);
1918 *commit_iclog = iclog; 1918 *commit_iclog = iclog;
1919 } else if ((error = xlog_state_release_iclog(log, iclog))) 1919 } else if ((error = xlog_state_release_iclog(log, iclog)))
1920 return (error); 1920 return error;
1921 if (index == nentries) 1921 if (index == nentries)
1922 return 0; /* we are done */ 1922 return 0; /* we are done */
1923 else 1923 else
@@ -1934,7 +1934,7 @@ xlog_write(xfs_mount_t * mp,
1934 *commit_iclog = iclog; 1934 *commit_iclog = iclog;
1935 return 0; 1935 return 0;
1936 } 1936 }
1937 return (xlog_state_release_iclog(log, iclog)); 1937 return xlog_state_release_iclog(log, iclog);
1938} /* xlog_write */ 1938} /* xlog_write */
1939 1939
1940 1940
@@ -2050,7 +2050,7 @@ xlog_get_lowest_lsn(
2050 } 2050 }
2051 lsn_log = lsn_log->ic_next; 2051 lsn_log = lsn_log->ic_next;
2052 } while (lsn_log != log->l_iclog); 2052 } while (lsn_log != log->l_iclog);
2053 return(lowest_lsn); 2053 return lowest_lsn;
2054} 2054}
2055 2055
2056 2056
@@ -2402,7 +2402,7 @@ restart:
2402 if (iclog->ic_refcnt == 1) { 2402 if (iclog->ic_refcnt == 1) {
2403 LOG_UNLOCK(log, s); 2403 LOG_UNLOCK(log, s);
2404 if ((error = xlog_state_release_iclog(log, iclog))) 2404 if ((error = xlog_state_release_iclog(log, iclog)))
2405 return (error); 2405 return error;
2406 } else { 2406 } else {
2407 iclog->ic_refcnt--; 2407 iclog->ic_refcnt--;
2408 LOG_UNLOCK(log, s); 2408 LOG_UNLOCK(log, s);
@@ -2569,7 +2569,7 @@ xlog_regrant_write_log_space(xlog_t *log,
2569 XLOG_TIC_RESET_RES(tic); 2569 XLOG_TIC_RESET_RES(tic);
2570 2570
2571 if (tic->t_cnt > 0) 2571 if (tic->t_cnt > 0)
2572 return (0); 2572 return 0;
2573 2573
2574#ifdef DEBUG 2574#ifdef DEBUG
2575 if (log->l_flags & XLOG_ACTIVE_RECOVERY) 2575 if (log->l_flags & XLOG_ACTIVE_RECOVERY)
@@ -2667,7 +2667,7 @@ redo:
2667 xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit"); 2667 xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit");
2668 xlog_verify_grant_head(log, 1); 2668 xlog_verify_grant_head(log, 1);
2669 GRANT_UNLOCK(log, s); 2669 GRANT_UNLOCK(log, s);
2670 return (0); 2670 return 0;
2671 2671
2672 2672
2673 error_return: 2673 error_return:
@@ -2837,7 +2837,7 @@ xlog_state_release_iclog(xlog_t *log,
2837 if (sync) { 2837 if (sync) {
2838 return xlog_sync(log, iclog); 2838 return xlog_sync(log, iclog);
2839 } 2839 }
2840 return (0); 2840 return 0;
2841 2841
2842} /* xlog_state_release_iclog */ 2842} /* xlog_state_release_iclog */
2843 2843
@@ -3127,7 +3127,7 @@ try_again:
3127 } while (iclog != log->l_iclog); 3127 } while (iclog != log->l_iclog);
3128 3128
3129 LOG_UNLOCK(log, s); 3129 LOG_UNLOCK(log, s);
3130 return (0); 3130 return 0;
3131} /* xlog_state_sync */ 3131} /* xlog_state_sync */
3132 3132
3133 3133
@@ -3545,12 +3545,12 @@ xlog_state_ioerror(
3545 ic->ic_state = XLOG_STATE_IOERROR; 3545 ic->ic_state = XLOG_STATE_IOERROR;
3546 ic = ic->ic_next; 3546 ic = ic->ic_next;
3547 } while (ic != iclog); 3547 } while (ic != iclog);
3548 return (0); 3548 return 0;
3549 } 3549 }
3550 /* 3550 /*
3551 * Return non-zero, if state transition has already happened. 3551 * Return non-zero, if state transition has already happened.
3552 */ 3552 */
3553 return (1); 3553 return 1;
3554} 3554}
3555 3555
3556/* 3556/*
@@ -3587,7 +3587,7 @@ xfs_log_force_umount(
3587 log->l_flags & XLOG_ACTIVE_RECOVERY) { 3587 log->l_flags & XLOG_ACTIVE_RECOVERY) {
3588 mp->m_flags |= XFS_MOUNT_FS_SHUTDOWN; 3588 mp->m_flags |= XFS_MOUNT_FS_SHUTDOWN;
3589 XFS_BUF_DONE(mp->m_sb_bp); 3589 XFS_BUF_DONE(mp->m_sb_bp);
3590 return (0); 3590 return 0;
3591 } 3591 }
3592 3592
3593 /* 3593 /*
@@ -3596,7 +3596,7 @@ xfs_log_force_umount(
3596 */ 3596 */
3597 if (logerror && log->l_iclog->ic_state & XLOG_STATE_IOERROR) { 3597 if (logerror && log->l_iclog->ic_state & XLOG_STATE_IOERROR) {
3598 ASSERT(XLOG_FORCED_SHUTDOWN(log)); 3598 ASSERT(XLOG_FORCED_SHUTDOWN(log));
3599 return (1); 3599 return 1;
3600 } 3600 }
3601 retval = 0; 3601 retval = 0;
3602 /* 3602 /*
@@ -3678,7 +3678,7 @@ xfs_log_force_umount(
3678 } 3678 }
3679#endif 3679#endif
3680 /* return non-zero if log IOERROR transition had already happened */ 3680 /* return non-zero if log IOERROR transition had already happened */
3681 return (retval); 3681 return retval;
3682} 3682}
3683 3683
3684STATIC int 3684STATIC int
@@ -3692,8 +3692,8 @@ xlog_iclogs_empty(xlog_t *log)
3692 * any language. 3692 * any language.
3693 */ 3693 */
3694 if (iclog->ic_header.h_num_logops) 3694 if (iclog->ic_header.h_num_logops)
3695 return(0); 3695 return 0;
3696 iclog = iclog->ic_next; 3696 iclog = iclog->ic_next;
3697 } while (iclog != log->l_iclog); 3697 } while (iclog != log->l_iclog);
3698 return(1); 3698 return 1;
3699} 3699}
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 6088e14f84e3..62188ea392c7 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -646,7 +646,7 @@ xfs_mountfs(
646 646
647 if (mp->m_sb_bp == NULL) { 647 if (mp->m_sb_bp == NULL) {
648 if ((error = xfs_readsb(mp))) { 648 if ((error = xfs_readsb(mp))) {
649 return (error); 649 return error;
650 } 650 }
651 } 651 }
652 xfs_mount_common(mp, sbp); 652 xfs_mount_common(mp, sbp);
@@ -889,7 +889,7 @@ xfs_mountfs(
889 * For client case we are done now 889 * For client case we are done now
890 */ 890 */
891 if (mfsi_flags & XFS_MFSI_CLIENT) { 891 if (mfsi_flags & XFS_MFSI_CLIENT) {
892 return(0); 892 return 0;
893 } 893 }
894 894
895 /* 895 /*
@@ -1182,7 +1182,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
1182 xfs_fs_cmn_err(CE_ALERT, mp, "Superblock write error detected while unmounting. Filesystem may not be marked shared readonly"); 1182 xfs_fs_cmn_err(CE_ALERT, mp, "Superblock write error detected while unmounting. Filesystem may not be marked shared readonly");
1183 } 1183 }
1184 xfs_buf_relse(sbp); 1184 xfs_buf_relse(sbp);
1185 return (error); 1185 return error;
1186} 1186}
1187 1187
1188/* 1188/*
@@ -1257,19 +1257,19 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
1257 lcounter += delta; 1257 lcounter += delta;
1258 if (lcounter < 0) { 1258 if (lcounter < 0) {
1259 ASSERT(0); 1259 ASSERT(0);
1260 return (XFS_ERROR(EINVAL)); 1260 return XFS_ERROR(EINVAL);
1261 } 1261 }
1262 mp->m_sb.sb_icount = lcounter; 1262 mp->m_sb.sb_icount = lcounter;
1263 return (0); 1263 return 0;
1264 case XFS_SBS_IFREE: 1264 case XFS_SBS_IFREE:
1265 lcounter = (long long)mp->m_sb.sb_ifree; 1265 lcounter = (long long)mp->m_sb.sb_ifree;
1266 lcounter += delta; 1266 lcounter += delta;
1267 if (lcounter < 0) { 1267 if (lcounter < 0) {
1268 ASSERT(0); 1268 ASSERT(0);
1269 return (XFS_ERROR(EINVAL)); 1269 return XFS_ERROR(EINVAL);
1270 } 1270 }
1271 mp->m_sb.sb_ifree = lcounter; 1271 mp->m_sb.sb_ifree = lcounter;
1272 return (0); 1272 return 0;
1273 case XFS_SBS_FDBLOCKS: 1273 case XFS_SBS_FDBLOCKS:
1274 1274
1275 lcounter = (long long)mp->m_sb.sb_fdblocks; 1275 lcounter = (long long)mp->m_sb.sb_fdblocks;
@@ -1296,101 +1296,101 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
1296 if (rsvd) { 1296 if (rsvd) {
1297 lcounter = (long long)mp->m_resblks_avail + delta; 1297 lcounter = (long long)mp->m_resblks_avail + delta;
1298 if (lcounter < 0) { 1298 if (lcounter < 0) {
1299 return (XFS_ERROR(ENOSPC)); 1299 return XFS_ERROR(ENOSPC);
1300 } 1300 }
1301 mp->m_resblks_avail = lcounter; 1301 mp->m_resblks_avail = lcounter;
1302 return (0); 1302 return 0;
1303 } else { /* not reserved */ 1303 } else { /* not reserved */
1304 return (XFS_ERROR(ENOSPC)); 1304 return XFS_ERROR(ENOSPC);
1305 } 1305 }
1306 } 1306 }
1307 } 1307 }
1308 1308
1309 mp->m_sb.sb_fdblocks = lcounter; 1309 mp->m_sb.sb_fdblocks = lcounter;
1310 return (0); 1310 return 0;
1311 case XFS_SBS_FREXTENTS: 1311 case XFS_SBS_FREXTENTS:
1312 lcounter = (long long)mp->m_sb.sb_frextents; 1312 lcounter = (long long)mp->m_sb.sb_frextents;
1313 lcounter += delta; 1313 lcounter += delta;
1314 if (lcounter < 0) { 1314 if (lcounter < 0) {
1315 return (XFS_ERROR(ENOSPC)); 1315 return XFS_ERROR(ENOSPC);
1316 } 1316 }
1317 mp->m_sb.sb_frextents = lcounter; 1317 mp->m_sb.sb_frextents = lcounter;
1318 return (0); 1318 return 0;
1319 case XFS_SBS_DBLOCKS: 1319 case XFS_SBS_DBLOCKS:
1320 lcounter = (long long)mp->m_sb.sb_dblocks; 1320 lcounter = (long long)mp->m_sb.sb_dblocks;
1321 lcounter += delta; 1321 lcounter += delta;
1322 if (lcounter < 0) { 1322 if (lcounter < 0) {
1323 ASSERT(0); 1323 ASSERT(0);
1324 return (XFS_ERROR(EINVAL)); 1324 return XFS_ERROR(EINVAL);
1325 } 1325 }
1326 mp->m_sb.sb_dblocks = lcounter; 1326 mp->m_sb.sb_dblocks = lcounter;
1327 return (0); 1327 return 0;
1328 case XFS_SBS_AGCOUNT: 1328 case XFS_SBS_AGCOUNT:
1329 scounter = mp->m_sb.sb_agcount; 1329 scounter = mp->m_sb.sb_agcount;
1330 scounter += delta; 1330 scounter += delta;
1331 if (scounter < 0) { 1331 if (scounter < 0) {
1332 ASSERT(0); 1332 ASSERT(0);
1333 return (XFS_ERROR(EINVAL)); 1333 return XFS_ERROR(EINVAL);
1334 } 1334 }
1335 mp->m_sb.sb_agcount = scounter; 1335 mp->m_sb.sb_agcount = scounter;
1336 return (0); 1336 return 0;
1337 case XFS_SBS_IMAX_PCT: 1337 case XFS_SBS_IMAX_PCT:
1338 scounter = mp->m_sb.sb_imax_pct; 1338 scounter = mp->m_sb.sb_imax_pct;
1339 scounter += delta; 1339 scounter += delta;
1340 if (scounter < 0) { 1340 if (scounter < 0) {
1341 ASSERT(0); 1341 ASSERT(0);
1342 return (XFS_ERROR(EINVAL)); 1342 return XFS_ERROR(EINVAL);
1343 } 1343 }
1344 mp->m_sb.sb_imax_pct = scounter; 1344 mp->m_sb.sb_imax_pct = scounter;
1345 return (0); 1345 return 0;
1346 case XFS_SBS_REXTSIZE: 1346 case XFS_SBS_REXTSIZE:
1347 scounter = mp->m_sb.sb_rextsize; 1347 scounter = mp->m_sb.sb_rextsize;
1348 scounter += delta; 1348 scounter += delta;
1349 if (scounter < 0) { 1349 if (scounter < 0) {
1350 ASSERT(0); 1350 ASSERT(0);
1351 return (XFS_ERROR(EINVAL)); 1351 return XFS_ERROR(EINVAL);
1352 } 1352 }
1353 mp->m_sb.sb_rextsize = scounter; 1353 mp->m_sb.sb_rextsize = scounter;
1354 return (0); 1354 return 0;
1355 case XFS_SBS_RBMBLOCKS: 1355 case XFS_SBS_RBMBLOCKS:
1356 scounter = mp->m_sb.sb_rbmblocks; 1356 scounter = mp->m_sb.sb_rbmblocks;
1357 scounter += delta; 1357 scounter += delta;
1358 if (scounter < 0) { 1358 if (scounter < 0) {
1359 ASSERT(0); 1359 ASSERT(0);
1360 return (XFS_ERROR(EINVAL)); 1360 return XFS_ERROR(EINVAL);
1361 } 1361 }
1362 mp->m_sb.sb_rbmblocks = scounter; 1362 mp->m_sb.sb_rbmblocks = scounter;
1363 return (0); 1363 return 0;
1364 case XFS_SBS_RBLOCKS: 1364 case XFS_SBS_RBLOCKS:
1365 lcounter = (long long)mp->m_sb.sb_rblocks; 1365 lcounter = (long long)mp->m_sb.sb_rblocks;
1366 lcounter += delta; 1366 lcounter += delta;
1367 if (lcounter < 0) { 1367 if (lcounter < 0) {
1368 ASSERT(0); 1368 ASSERT(0);
1369 return (XFS_ERROR(EINVAL)); 1369 return XFS_ERROR(EINVAL);
1370 } 1370 }
1371 mp->m_sb.sb_rblocks = lcounter; 1371 mp->m_sb.sb_rblocks = lcounter;
1372 return (0); 1372 return 0;
1373 case XFS_SBS_REXTENTS: 1373 case XFS_SBS_REXTENTS:
1374 lcounter = (long long)mp->m_sb.sb_rextents; 1374 lcounter = (long long)mp->m_sb.sb_rextents;
1375 lcounter += delta; 1375 lcounter += delta;
1376 if (lcounter < 0) { 1376 if (lcounter < 0) {
1377 ASSERT(0); 1377 ASSERT(0);
1378 return (XFS_ERROR(EINVAL)); 1378 return XFS_ERROR(EINVAL);
1379 } 1379 }
1380 mp->m_sb.sb_rextents = lcounter; 1380 mp->m_sb.sb_rextents = lcounter;
1381 return (0); 1381 return 0;
1382 case XFS_SBS_REXTSLOG: 1382 case XFS_SBS_REXTSLOG:
1383 scounter = mp->m_sb.sb_rextslog; 1383 scounter = mp->m_sb.sb_rextslog;
1384 scounter += delta; 1384 scounter += delta;
1385 if (scounter < 0) { 1385 if (scounter < 0) {
1386 ASSERT(0); 1386 ASSERT(0);
1387 return (XFS_ERROR(EINVAL)); 1387 return XFS_ERROR(EINVAL);
1388 } 1388 }
1389 mp->m_sb.sb_rextslog = scounter; 1389 mp->m_sb.sb_rextslog = scounter;
1390 return (0); 1390 return 0;
1391 default: 1391 default:
1392 ASSERT(0); 1392 ASSERT(0);
1393 return (XFS_ERROR(EINVAL)); 1393 return XFS_ERROR(EINVAL);
1394 } 1394 }
1395} 1395}
1396 1396
@@ -1409,7 +1409,7 @@ xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd)
1409 s = XFS_SB_LOCK(mp); 1409 s = XFS_SB_LOCK(mp);
1410 status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); 1410 status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
1411 XFS_SB_UNLOCK(mp, s); 1411 XFS_SB_UNLOCK(mp, s);
1412 return (status); 1412 return status;
1413} 1413}
1414 1414
1415/* 1415/*
@@ -1470,7 +1470,7 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
1470 } 1470 }
1471 } 1471 }
1472 XFS_SB_UNLOCK(mp, s); 1472 XFS_SB_UNLOCK(mp, s);
1473 return (status); 1473 return status;
1474} 1474}
1475 1475
1476/* 1476/*
@@ -1500,7 +1500,7 @@ xfs_getsb(
1500 } 1500 }
1501 XFS_BUF_HOLD(bp); 1501 XFS_BUF_HOLD(bp);
1502 ASSERT(XFS_BUF_ISDONE(bp)); 1502 ASSERT(XFS_BUF_ISDONE(bp));
1503 return (bp); 1503 return bp;
1504} 1504}
1505 1505
1506/* 1506/*
diff --git a/fs/xfs/xfs_trans_item.c b/fs/xfs/xfs_trans_item.c
index 486147ef0e3d..1117d600d741 100644
--- a/fs/xfs/xfs_trans_item.c
+++ b/fs/xfs/xfs_trans_item.c
@@ -78,7 +78,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
78 lidp->lid_size = 0; 78 lidp->lid_size = 0;
79 lip->li_desc = lidp; 79 lip->li_desc = lidp;
80 lip->li_mountp = tp->t_mountp; 80 lip->li_mountp = tp->t_mountp;
81 return (lidp); 81 return lidp;
82 } 82 }
83 83
84 /* 84 /*
@@ -119,7 +119,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
119 lidp->lid_size = 0; 119 lidp->lid_size = 0;
120 lip->li_desc = lidp; 120 lip->li_desc = lidp;
121 lip->li_mountp = tp->t_mountp; 121 lip->li_mountp = tp->t_mountp;
122 return (lidp); 122 return lidp;
123} 123}
124 124
125/* 125/*
@@ -180,7 +180,7 @@ xfs_trans_find_item(xfs_trans_t *tp, xfs_log_item_t *lip)
180{ 180{
181 ASSERT(lip->li_desc != NULL); 181 ASSERT(lip->li_desc != NULL);
182 182
183 return (lip->li_desc); 183 return lip->li_desc;
184} 184}
185 185
186 186
@@ -219,10 +219,10 @@ xfs_trans_first_item(xfs_trans_t *tp)
219 continue; 219 continue;
220 } 220 }
221 221
222 return (XFS_LIC_SLOT(licp, i)); 222 return XFS_LIC_SLOT(licp, i);
223 } 223 }
224 cmn_err(CE_WARN, "xfs_trans_first_item() -- no first item"); 224 cmn_err(CE_WARN, "xfs_trans_first_item() -- no first item");
225 return(NULL); 225 return NULL;
226} 226}
227 227
228 228
@@ -252,7 +252,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
252 continue; 252 continue;
253 } 253 }
254 254
255 return (XFS_LIC_SLOT(licp, i)); 255 return XFS_LIC_SLOT(licp, i);
256 } 256 }
257 257
258 /* 258 /*
@@ -261,7 +261,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
261 * If there is no next chunk, return NULL. 261 * If there is no next chunk, return NULL.
262 */ 262 */
263 if (licp->lic_next == NULL) { 263 if (licp->lic_next == NULL) {
264 return (NULL); 264 return NULL;
265 } 265 }
266 266
267 licp = licp->lic_next; 267 licp = licp->lic_next;
@@ -271,7 +271,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
271 continue; 271 continue;
272 } 272 }
273 273
274 return (XFS_LIC_SLOT(licp, i)); 274 return XFS_LIC_SLOT(licp, i);
275 } 275 }
276 ASSERT(0); 276 ASSERT(0);
277 /* NOTREACHED */ 277 /* NOTREACHED */
@@ -425,7 +425,7 @@ xfs_trans_unlock_chunk(
425 } 425 }
426 } 426 }
427 427
428 return (freed); 428 return freed;
429} 429}
430 430
431 431
@@ -478,7 +478,7 @@ xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx)
478 */ 478 */
479 lbsp->lbc_ag = ag; 479 lbsp->lbc_ag = ag;
480 lbsp->lbc_idx = idx; 480 lbsp->lbc_idx = idx;
481 return (lbsp); 481 return lbsp;
482 } 482 }
483 483
484 /* 484 /*
@@ -512,7 +512,7 @@ xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx)
512 tp->t_busy_free--; 512 tp->t_busy_free--;
513 lbsp->lbc_ag = ag; 513 lbsp->lbc_ag = ag;
514 lbsp->lbc_idx = idx; 514 lbsp->lbc_idx = idx;
515 return (lbsp); 515 return lbsp;
516} 516}
517 517
518 518
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 8076cc981e11..eaab355f5a89 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -338,7 +338,7 @@ xfs_setattr(
338 code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, projid, qflags, 338 code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, projid, qflags,
339 &udqp, &gdqp); 339 &udqp, &gdqp);
340 if (code) 340 if (code)
341 return (code); 341 return code;
342 } 342 }
343 343
344 /* 344 /*
@@ -1027,11 +1027,8 @@ xfs_readlink(
1027 1027
1028 } 1028 }
1029 1029
1030
1031error_return: 1030error_return:
1032
1033 xfs_iunlock(ip, XFS_ILOCK_SHARED); 1031 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1034
1035 return error; 1032 return error;
1036} 1033}
1037 1034
@@ -1206,7 +1203,7 @@ xfs_inactive_free_eofblocks(
1206 last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 1203 last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
1207 map_len = last_fsb - end_fsb; 1204 map_len = last_fsb - end_fsb;
1208 if (map_len <= 0) 1205 if (map_len <= 0)
1209 return (0); 1206 return 0;
1210 1207
1211 nimaps = 1; 1208 nimaps = 1;
1212 xfs_ilock(ip, XFS_ILOCK_SHARED); 1209 xfs_ilock(ip, XFS_ILOCK_SHARED);
@@ -1221,7 +1218,7 @@ xfs_inactive_free_eofblocks(
1221 * Attach the dquots to the inode up front. 1218 * Attach the dquots to the inode up front.
1222 */ 1219 */
1223 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 1220 if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
1224 return (error); 1221 return error;
1225 1222
1226 /* 1223 /*
1227 * There are blocks after the end of file. 1224 * There are blocks after the end of file.
@@ -1249,7 +1246,7 @@ xfs_inactive_free_eofblocks(
1249 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1246 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1250 xfs_trans_cancel(tp, 0); 1247 xfs_trans_cancel(tp, 0);
1251 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 1248 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
1252 return (error); 1249 return error;
1253 } 1250 }
1254 1251
1255 xfs_ilock(ip, XFS_ILOCK_EXCL); 1252 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -1277,7 +1274,7 @@ xfs_inactive_free_eofblocks(
1277 } 1274 }
1278 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1275 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
1279 } 1276 }
1280 return (error); 1277 return error;
1281} 1278}
1282 1279
1283/* 1280/*
@@ -1455,7 +1452,7 @@ xfs_inactive_symlink_local(
1455 if (error) { 1452 if (error) {
1456 xfs_trans_cancel(*tpp, 0); 1453 xfs_trans_cancel(*tpp, 0);
1457 *tpp = NULL; 1454 *tpp = NULL;
1458 return (error); 1455 return error;
1459 } 1456 }
1460 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 1457 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
1461 1458
@@ -1468,7 +1465,7 @@ xfs_inactive_symlink_local(
1468 XFS_DATA_FORK); 1465 XFS_DATA_FORK);
1469 ASSERT(ip->i_df.if_bytes == 0); 1466 ASSERT(ip->i_df.if_bytes == 0);
1470 } 1467 }
1471 return (0); 1468 return 0;
1472} 1469}
1473 1470
1474/* 1471/*
@@ -1494,7 +1491,7 @@ xfs_inactive_attrs(
1494 if (error) { 1491 if (error) {
1495 *tpp = NULL; 1492 *tpp = NULL;
1496 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 1493 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
1497 return (error); /* goto out*/ 1494 return error; /* goto out */
1498 } 1495 }
1499 1496
1500 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 1497 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
@@ -1507,7 +1504,7 @@ xfs_inactive_attrs(
1507 xfs_trans_cancel(tp, 0); 1504 xfs_trans_cancel(tp, 0);
1508 *tpp = NULL; 1505 *tpp = NULL;
1509 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 1506 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
1510 return (error); 1507 return error;
1511 } 1508 }
1512 1509
1513 xfs_ilock(ip, XFS_ILOCK_EXCL); 1510 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -1518,7 +1515,7 @@ xfs_inactive_attrs(
1518 ASSERT(ip->i_d.di_anextents == 0); 1515 ASSERT(ip->i_d.di_anextents == 0);
1519 1516
1520 *tpp = tp; 1517 *tpp = tp;
1521 return (0); 1518 return 0;
1522} 1519}
1523 1520
1524STATIC int 1521STATIC int
@@ -1557,7 +1554,7 @@ xfs_release(
1557 (!(ip->i_d.di_flags & 1554 (!(ip->i_d.di_flags &
1558 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) { 1555 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) {
1559 if ((error = xfs_inactive_free_eofblocks(mp, ip))) 1556 if ((error = xfs_inactive_free_eofblocks(mp, ip)))
1560 return (error); 1557 return error;
1561 /* Update linux inode block count after free above */ 1558 /* Update linux inode block count after free above */
1562 LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, 1559 LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp,
1563 ip->i_d.di_nblocks + ip->i_delayed_blks); 1560 ip->i_d.di_nblocks + ip->i_delayed_blks);
@@ -1638,7 +1635,7 @@ xfs_inactive(
1638 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || 1635 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) ||
1639 (ip->i_delayed_blks != 0)))) { 1636 (ip->i_delayed_blks != 0)))) {
1640 if ((error = xfs_inactive_free_eofblocks(mp, ip))) 1637 if ((error = xfs_inactive_free_eofblocks(mp, ip)))
1641 return (VN_INACTIVE_CACHE); 1638 return VN_INACTIVE_CACHE;
1642 /* Update linux inode block count after free above */ 1639 /* Update linux inode block count after free above */
1643 LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp, 1640 LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp,
1644 ip->i_d.di_nblocks + ip->i_delayed_blks); 1641 ip->i_d.di_nblocks + ip->i_delayed_blks);
@@ -1649,7 +1646,7 @@ xfs_inactive(
1649 ASSERT(ip->i_d.di_nlink == 0); 1646 ASSERT(ip->i_d.di_nlink == 0);
1650 1647
1651 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 1648 if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
1652 return (VN_INACTIVE_CACHE); 1649 return VN_INACTIVE_CACHE;
1653 1650
1654 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 1651 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
1655 if (truncate) { 1652 if (truncate) {
@@ -1672,7 +1669,7 @@ xfs_inactive(
1672 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1669 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1673 xfs_trans_cancel(tp, 0); 1670 xfs_trans_cancel(tp, 0);
1674 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 1671 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
1675 return (VN_INACTIVE_CACHE); 1672 return VN_INACTIVE_CACHE;
1676 } 1673 }
1677 1674
1678 xfs_ilock(ip, XFS_ILOCK_EXCL); 1675 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -1693,7 +1690,7 @@ xfs_inactive(
1693 xfs_trans_cancel(tp, 1690 xfs_trans_cancel(tp,
1694 XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); 1691 XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
1695 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1692 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
1696 return (VN_INACTIVE_CACHE); 1693 return VN_INACTIVE_CACHE;
1697 } 1694 }
1698 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFLNK) { 1695 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFLNK) {
1699 1696
@@ -1707,7 +1704,7 @@ xfs_inactive(
1707 1704
1708 if (error) { 1705 if (error) {
1709 ASSERT(tp == NULL); 1706 ASSERT(tp == NULL);
1710 return (VN_INACTIVE_CACHE); 1707 return VN_INACTIVE_CACHE;
1711 } 1708 }
1712 1709
1713 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1710 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
@@ -1720,7 +1717,7 @@ xfs_inactive(
1720 if (error) { 1717 if (error) {
1721 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1718 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1722 xfs_trans_cancel(tp, 0); 1719 xfs_trans_cancel(tp, 0);
1723 return (VN_INACTIVE_CACHE); 1720 return VN_INACTIVE_CACHE;
1724 } 1721 }
1725 1722
1726 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 1723 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
@@ -1742,7 +1739,7 @@ xfs_inactive(
1742 * cancelled, and the inode is unlocked. Just get out. 1739 * cancelled, and the inode is unlocked. Just get out.
1743 */ 1740 */
1744 if (error) 1741 if (error)
1745 return (VN_INACTIVE_CACHE); 1742 return VN_INACTIVE_CACHE;
1746 } else if (ip->i_afp) { 1743 } else if (ip->i_afp) {
1747 xfs_idestroy_fork(ip, XFS_ATTR_FORK); 1744 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
1748 } 1745 }
@@ -2049,8 +2046,8 @@ std_return:
2049 abort_return: 2046 abort_return:
2050 cancel_flags |= XFS_TRANS_ABORT; 2047 cancel_flags |= XFS_TRANS_ABORT;
2051 /* FALLTHROUGH */ 2048 /* FALLTHROUGH */
2052 error_return:
2053 2049
2050 error_return:
2054 if (tp != NULL) 2051 if (tp != NULL)
2055 xfs_trans_cancel(tp, cancel_flags); 2052 xfs_trans_cancel(tp, cancel_flags);
2056 2053
@@ -2724,9 +2721,9 @@ std_return:
2724 abort_return: 2721 abort_return:
2725 cancel_flags |= XFS_TRANS_ABORT; 2722 cancel_flags |= XFS_TRANS_ABORT;
2726 /* FALLTHROUGH */ 2723 /* FALLTHROUGH */
2724
2727 error_return: 2725 error_return:
2728 xfs_trans_cancel(tp, cancel_flags); 2726 xfs_trans_cancel(tp, cancel_flags);
2729
2730 goto std_return; 2727 goto std_return;
2731} 2728}
2732/* 2729/*
@@ -3199,10 +3196,12 @@ std_return:
3199 } 3196 }
3200 return error; 3197 return error;
3201 3198
3202 error1: 3199error1:
3203 xfs_bmap_cancel(&free_list); 3200 xfs_bmap_cancel(&free_list);
3204 cancel_flags |= XFS_TRANS_ABORT; 3201 cancel_flags |= XFS_TRANS_ABORT;
3205 error_return: 3202 /* FALLTHROUGH */
3203
3204error_return:
3206 xfs_trans_cancel(tp, cancel_flags); 3205 xfs_trans_cancel(tp, cancel_flags);
3207 goto std_return; 3206 goto std_return;
3208} 3207}
@@ -3618,9 +3617,9 @@ xfs_rwlock(
3618 if (locktype == VRWLOCK_WRITE) { 3617 if (locktype == VRWLOCK_WRITE) {
3619 xfs_ilock(ip, XFS_IOLOCK_EXCL); 3618 xfs_ilock(ip, XFS_IOLOCK_EXCL);
3620 } else if (locktype == VRWLOCK_TRY_READ) { 3619 } else if (locktype == VRWLOCK_TRY_READ) {
3621 return (xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)); 3620 return xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED);
3622 } else if (locktype == VRWLOCK_TRY_WRITE) { 3621 } else if (locktype == VRWLOCK_TRY_WRITE) {
3623 return (xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)); 3622 return xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL);
3624 } else { 3623 } else {
3625 ASSERT((locktype == VRWLOCK_READ) || 3624 ASSERT((locktype == VRWLOCK_READ) ||
3626 (locktype == VRWLOCK_WRITE_DIRECT)); 3625 (locktype == VRWLOCK_WRITE_DIRECT));
@@ -3868,7 +3867,7 @@ xfs_finish_reclaim(
3868 xfs_ifunlock(ip); 3867 xfs_ifunlock(ip);
3869 xfs_iunlock(ip, XFS_ILOCK_EXCL); 3868 xfs_iunlock(ip, XFS_ILOCK_EXCL);
3870 } 3869 }
3871 return(1); 3870 return 1;
3872 } 3871 }
3873 ip->i_flags |= XFS_IRECLAIM; 3872 ip->i_flags |= XFS_IRECLAIM;
3874 write_unlock(&ih->ih_lock); 3873 write_unlock(&ih->ih_lock);
@@ -4045,7 +4044,7 @@ xfs_alloc_file_space(
4045 offset, end_dmi_offset - offset, 4044 offset, end_dmi_offset - offset,
4046 0, NULL); 4045 0, NULL);
4047 if (error) 4046 if (error)
4048 return(error); 4047 return error;
4049 } 4048 }
4050 4049
4051 /* 4050 /*
@@ -4305,7 +4304,7 @@ xfs_free_file_space(
4305 offset, end_dmi_offset - offset, 4304 offset, end_dmi_offset - offset,
4306 AT_DELAY_FLAG(attr_flags), NULL); 4305 AT_DELAY_FLAG(attr_flags), NULL);
4307 if (error) 4306 if (error)
4308 return(error); 4307 return error;
4309 } 4308 }
4310 4309
4311 ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1); 4310 ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1);