aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2008-03-01 13:29:55 -0500
committerSteve French <sfrench@us.ibm.com>2008-03-01 13:29:55 -0500
commit0dbd888936a23514716b8d944775bc56f731363a (patch)
treea2c60cdc45bdcbed47680731fa8188bffe58c098 /fs
parent0b442d2c28479332610c46e1a74e5638ab63a97d (diff)
parentd395991c117d43bfca97101a931a41d062a93852 (diff)
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs')
-rw-r--r--fs/bio.c2
-rw-r--r--fs/block_dev.c201
-rw-r--r--fs/dlm/rcom.c2
-rw-r--r--fs/efs/dir.c2
-rw-r--r--fs/efs/efs.h140
-rw-r--r--fs/efs/file.c2
-rw-r--r--fs/efs/inode.c4
-rw-r--r--fs/efs/namei.c2
-rw-r--r--fs/efs/super.c7
-rw-r--r--fs/efs/symlink.c2
-rw-r--r--fs/ext4/dir.c2
-rw-r--r--fs/ext4/extents.c59
-rw-r--r--fs/ext4/ialloc.c22
-rw-r--r--fs/ext4/inode.c56
-rw-r--r--fs/ext4/mballoc.c80
-rw-r--r--fs/ext4/migrate.c5
-rw-r--r--fs/ext4/namei.c18
-rw-r--r--fs/ext4/resize.c1
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/lockd/svc.c2
-rw-r--r--fs/nfs/callback.c3
-rw-r--r--fs/nfs/callback_xdr.c6
-rw-r--r--fs/nfs/delegation.c2
-rw-r--r--fs/nfs/idmap.c2
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfsd/nfsfh.c2
-rw-r--r--fs/proc/base.c28
-rw-r--r--fs/proc/task_mmu.c2
-rw-r--r--fs/ufs/util.h2
-rw-r--r--fs/xfs/Kbuild6
-rw-r--r--fs/xfs/Makefile118
-rw-r--r--fs/xfs/Makefile-linux-2.6117
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c14
-rw-r--r--fs/xfs/xfs_bit.c103
-rw-r--r--fs/xfs/xfs_bit.h27
-rw-r--r--fs/xfs/xfs_clnt.h2
-rw-r--r--fs/xfs/xfs_ialloc.c2
-rw-r--r--fs/xfs/xfs_mount.h2
-rw-r--r--fs/xfs/xfs_rtalloc.c19
-rw-r--r--fs/xfs/xfs_vfsops.c4
40 files changed, 606 insertions, 468 deletions
diff --git a/fs/bio.c b/fs/bio.c
index 242e409dab4b..3312fcc3c098 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -903,7 +903,7 @@ void bio_set_pages_dirty(struct bio *bio)
903 } 903 }
904} 904}
905 905
906void bio_release_pages(struct bio *bio) 906static void bio_release_pages(struct bio *bio)
907{ 907{
908 struct bio_vec *bvec = bio->bi_io_vec; 908 struct bio_vec *bvec = bio->bi_io_vec;
909 int i; 909 int i;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 67fe72ce6ac7..7d822fae7765 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -31,6 +31,8 @@ struct bdev_inode {
31 struct inode vfs_inode; 31 struct inode vfs_inode;
32}; 32};
33 33
34static const struct address_space_operations def_blk_aops;
35
34static inline struct bdev_inode *BDEV_I(struct inode *inode) 36static inline struct bdev_inode *BDEV_I(struct inode *inode)
35{ 37{
36 return container_of(inode, struct bdev_inode, vfs_inode); 38 return container_of(inode, struct bdev_inode, vfs_inode);
@@ -171,203 +173,6 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
171 iov, offset, nr_segs, blkdev_get_blocks, NULL); 173 iov, offset, nr_segs, blkdev_get_blocks, NULL);
172} 174}
173 175
174#if 0
175static void blk_end_aio(struct bio *bio, int error)
176{
177 struct kiocb *iocb = bio->bi_private;
178 atomic_t *bio_count = &iocb->ki_bio_count;
179
180 if (bio_data_dir(bio) == READ)
181 bio_check_pages_dirty(bio);
182 else {
183 bio_release_pages(bio);
184 bio_put(bio);
185 }
186
187 /* iocb->ki_nbytes stores error code from LLDD */
188 if (error)
189 iocb->ki_nbytes = -EIO;
190
191 if (atomic_dec_and_test(bio_count)) {
192 if ((long)iocb->ki_nbytes < 0)
193 aio_complete(iocb, iocb->ki_nbytes, 0);
194 else
195 aio_complete(iocb, iocb->ki_left, 0);
196 }
197
198 return 0;
199}
200
201#define VEC_SIZE 16
202struct pvec {
203 unsigned short nr;
204 unsigned short idx;
205 struct page *page[VEC_SIZE];
206};
207
208#define PAGES_SPANNED(addr, len) \
209 (DIV_ROUND_UP((addr) + (len), PAGE_SIZE) - (addr) / PAGE_SIZE);
210
211/*
212 * get page pointer for user addr, we internally cache struct page array for
213 * (addr, count) range in pvec to avoid frequent call to get_user_pages. If
214 * internal page list is exhausted, a batch count of up to VEC_SIZE is used
215 * to get next set of page struct.
216 */
217static struct page *blk_get_page(unsigned long addr, size_t count, int rw,
218 struct pvec *pvec)
219{
220 int ret, nr_pages;
221 if (pvec->idx == pvec->nr) {
222 nr_pages = PAGES_SPANNED(addr, count);
223 nr_pages = min(nr_pages, VEC_SIZE);
224 down_read(&current->mm->mmap_sem);
225 ret = get_user_pages(current, current->mm, addr, nr_pages,
226 rw == READ, 0, pvec->page, NULL);
227 up_read(&current->mm->mmap_sem);
228 if (ret < 0)
229 return ERR_PTR(ret);
230 pvec->nr = ret;
231 pvec->idx = 0;
232 }
233 return pvec->page[pvec->idx++];
234}
235
236/* return a page back to pvec array */
237static void blk_unget_page(struct page *page, struct pvec *pvec)
238{
239 pvec->page[--pvec->idx] = page;
240}
241
242static ssize_t
243blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
244 loff_t pos, unsigned long nr_segs)
245{
246 struct inode *inode = iocb->ki_filp->f_mapping->host;
247 unsigned blkbits = blksize_bits(bdev_hardsect_size(I_BDEV(inode)));
248 unsigned blocksize_mask = (1 << blkbits) - 1;
249 unsigned long seg = 0; /* iov segment iterator */
250 unsigned long nvec; /* number of bio vec needed */
251 unsigned long cur_off; /* offset into current page */
252 unsigned long cur_len; /* I/O len of current page, up to PAGE_SIZE */
253
254 unsigned long addr; /* user iovec address */
255 size_t count; /* user iovec len */
256 size_t nbytes = iocb->ki_nbytes = iocb->ki_left; /* total xfer size */
257 loff_t size; /* size of block device */
258 struct bio *bio;
259 atomic_t *bio_count = &iocb->ki_bio_count;
260 struct page *page;
261 struct pvec pvec;
262
263 pvec.nr = 0;
264 pvec.idx = 0;
265
266 if (pos & blocksize_mask)
267 return -EINVAL;
268
269 size = i_size_read(inode);
270 if (pos + nbytes > size) {
271 nbytes = size - pos;
272 iocb->ki_left = nbytes;
273 }
274
275 /*
276 * check first non-zero iov alignment, the remaining
277 * iov alignment is checked inside bio loop below.
278 */
279 do {
280 addr = (unsigned long) iov[seg].iov_base;
281 count = min(iov[seg].iov_len, nbytes);
282 if (addr & blocksize_mask || count & blocksize_mask)
283 return -EINVAL;
284 } while (!count && ++seg < nr_segs);
285 atomic_set(bio_count, 1);
286
287 while (nbytes) {
288 /* roughly estimate number of bio vec needed */
289 nvec = (nbytes + PAGE_SIZE - 1) / PAGE_SIZE;
290 nvec = max(nvec, nr_segs - seg);
291 nvec = min(nvec, (unsigned long) BIO_MAX_PAGES);
292
293 /* bio_alloc should not fail with GFP_KERNEL flag */
294 bio = bio_alloc(GFP_KERNEL, nvec);
295 bio->bi_bdev = I_BDEV(inode);
296 bio->bi_end_io = blk_end_aio;
297 bio->bi_private = iocb;
298 bio->bi_sector = pos >> blkbits;
299same_bio:
300 cur_off = addr & ~PAGE_MASK;
301 cur_len = PAGE_SIZE - cur_off;
302 if (count < cur_len)
303 cur_len = count;
304
305 page = blk_get_page(addr, count, rw, &pvec);
306 if (unlikely(IS_ERR(page)))
307 goto backout;
308
309 if (bio_add_page(bio, page, cur_len, cur_off)) {
310 pos += cur_len;
311 addr += cur_len;
312 count -= cur_len;
313 nbytes -= cur_len;
314
315 if (count)
316 goto same_bio;
317 while (++seg < nr_segs) {
318 addr = (unsigned long) iov[seg].iov_base;
319 count = iov[seg].iov_len;
320 if (!count)
321 continue;
322 if (unlikely(addr & blocksize_mask ||
323 count & blocksize_mask)) {
324 page = ERR_PTR(-EINVAL);
325 goto backout;
326 }
327 count = min(count, nbytes);
328 goto same_bio;
329 }
330 } else {
331 blk_unget_page(page, &pvec);
332 }
333
334 /* bio is ready, submit it */
335 if (rw == READ)
336 bio_set_pages_dirty(bio);
337 atomic_inc(bio_count);
338 submit_bio(rw, bio);
339 }
340
341completion:
342 iocb->ki_left -= nbytes;
343 nbytes = iocb->ki_left;
344 iocb->ki_pos += nbytes;
345
346 blk_run_address_space(inode->i_mapping);
347 if (atomic_dec_and_test(bio_count))
348 aio_complete(iocb, nbytes, 0);
349
350 return -EIOCBQUEUED;
351
352backout:
353 /*
354 * back out nbytes count constructed so far for this bio,
355 * we will throw away current bio.
356 */
357 nbytes += bio->bi_size;
358 bio_release_pages(bio);
359 bio_put(bio);
360
361 /*
362 * if no bio was submmitted, return the error code.
363 * otherwise, proceed with pending I/O completion.
364 */
365 if (atomic_read(bio_count) == 1)
366 return PTR_ERR(page);
367 goto completion;
368}
369#endif
370
371static int blkdev_writepage(struct page *page, struct writeback_control *wbc) 176static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
372{ 177{
373 return block_write_full_page(page, blkdev_get_block, wbc); 178 return block_write_full_page(page, blkdev_get_block, wbc);
@@ -1334,7 +1139,7 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1334 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); 1139 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg);
1335} 1140}
1336 1141
1337const struct address_space_operations def_blk_aops = { 1142static const struct address_space_operations def_blk_aops = {
1338 .readpage = blkdev_readpage, 1143 .readpage = blkdev_readpage,
1339 .writepage = blkdev_writepage, 1144 .writepage = blkdev_writepage,
1340 .sync_page = block_sync_page, 1145 .sync_page = block_sync_page,
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c
index 035e6f9990b0..67522c268c14 100644
--- a/fs/dlm/rcom.c
+++ b/fs/dlm/rcom.c
@@ -215,6 +215,8 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
215 ls->ls_recover_nodeid = nodeid; 215 ls->ls_recover_nodeid = nodeid;
216 216
217 if (nodeid == dlm_our_nodeid()) { 217 if (nodeid == dlm_our_nodeid()) {
218 ls->ls_recover_buf->rc_header.h_length =
219 dlm_config.ci_buffer_size;
218 dlm_copy_master_names(ls, last_name, last_len, 220 dlm_copy_master_names(ls, last_name, last_len,
219 ls->ls_recover_buf->rc_buf, 221 ls->ls_recover_buf->rc_buf,
220 max_size, nodeid); 222 max_size, nodeid);
diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index dfb5cb400217..49308a29798a 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -5,8 +5,8 @@
5 */ 5 */
6 6
7#include <linux/buffer_head.h> 7#include <linux/buffer_head.h>
8#include <linux/efs_fs.h>
9#include <linux/smp_lock.h> 8#include <linux/smp_lock.h>
9#include "efs.h"
10 10
11static int efs_readdir(struct file *, void *, filldir_t); 11static int efs_readdir(struct file *, void *, filldir_t);
12 12
diff --git a/fs/efs/efs.h b/fs/efs/efs.h
new file mode 100644
index 000000000000..d8305b582ab0
--- /dev/null
+++ b/fs/efs/efs.h
@@ -0,0 +1,140 @@
1/*
2 * Copyright (c) 1999 Al Smith
3 *
4 * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
5 * Portions derived from IRIX header files (c) 1988 Silicon Graphics
6 */
7#ifndef _EFS_EFS_H_
8#define _EFS_EFS_H_
9
10#include <linux/fs.h>
11#include <asm/uaccess.h>
12
13#define EFS_VERSION "1.0a"
14
15static const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>";
16
17
18/* 1 block is 512 bytes */
19#define EFS_BLOCKSIZE_BITS 9
20#define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS)
21
22typedef int32_t efs_block_t;
23typedef uint32_t efs_ino_t;
24
25#define EFS_DIRECTEXTENTS 12
26
27/*
28 * layout of an extent, in memory and on disk. 8 bytes exactly.
29 */
30typedef union extent_u {
31 unsigned char raw[8];
32 struct extent_s {
33 unsigned int ex_magic:8; /* magic # (zero) */
34 unsigned int ex_bn:24; /* basic block */
35 unsigned int ex_length:8; /* numblocks in this extent */
36 unsigned int ex_offset:24; /* logical offset into file */
37 } cooked;
38} efs_extent;
39
40typedef struct edevs {
41 __be16 odev;
42 __be32 ndev;
43} efs_devs;
44
45/*
46 * extent based filesystem inode as it appears on disk. The efs inode
47 * is exactly 128 bytes long.
48 */
49struct efs_dinode {
50 __be16 di_mode; /* mode and type of file */
51 __be16 di_nlink; /* number of links to file */
52 __be16 di_uid; /* owner's user id */
53 __be16 di_gid; /* owner's group id */
54 __be32 di_size; /* number of bytes in file */
55 __be32 di_atime; /* time last accessed */
56 __be32 di_mtime; /* time last modified */
57 __be32 di_ctime; /* time created */
58 __be32 di_gen; /* generation number */
59 __be16 di_numextents; /* # of extents */
60 u_char di_version; /* version of inode */
61 u_char di_spare; /* spare - used by AFS */
62 union di_addr {
63 efs_extent di_extents[EFS_DIRECTEXTENTS];
64 efs_devs di_dev; /* device for IFCHR/IFBLK */
65 } di_u;
66};
67
68/* efs inode storage in memory */
69struct efs_inode_info {
70 int numextents;
71 int lastextent;
72
73 efs_extent extents[EFS_DIRECTEXTENTS];
74 struct inode vfs_inode;
75};
76
77#include <linux/efs_fs_sb.h>
78
79#define EFS_DIRBSIZE_BITS EFS_BLOCKSIZE_BITS
80#define EFS_DIRBSIZE (1 << EFS_DIRBSIZE_BITS)
81
82struct efs_dentry {
83 __be32 inode;
84 unsigned char namelen;
85 char name[3];
86};
87
88#define EFS_DENTSIZE (sizeof(struct efs_dentry) - 3 + 1)
89#define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1)
90
91#define EFS_DIRBLK_HEADERSIZE 4
92#define EFS_DIRBLK_MAGIC 0xbeef /* moo */
93
94struct efs_dir {
95 __be16 magic;
96 unsigned char firstused;
97 unsigned char slots;
98
99 unsigned char space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE];
100};
101
102#define EFS_MAXENTS \
103 ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \
104 (EFS_DENTSIZE + sizeof(char)))
105
106#define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)->space[slot])
107
108#define EFS_REALOFF(offset) ((offset << 1))
109
110
111static inline struct efs_inode_info *INODE_INFO(struct inode *inode)
112{
113 return container_of(inode, struct efs_inode_info, vfs_inode);
114}
115
116static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb)
117{
118 return sb->s_fs_info;
119}
120
121struct statfs;
122struct fid;
123
124extern const struct inode_operations efs_dir_inode_operations;
125extern const struct file_operations efs_dir_operations;
126extern const struct address_space_operations efs_symlink_aops;
127
128extern struct inode *efs_iget(struct super_block *, unsigned long);
129extern efs_block_t efs_map_block(struct inode *, efs_block_t);
130extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int);
131
132extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct nameidata *);
133extern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid,
134 int fh_len, int fh_type);
135extern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,
136 int fh_len, int fh_type);
137extern struct dentry *efs_get_parent(struct dentry *);
138extern int efs_bmap(struct inode *, int);
139
140#endif /* _EFS_EFS_H_ */
diff --git a/fs/efs/file.c b/fs/efs/file.c
index 5db20129681e..1ccb364ffa63 100644
--- a/fs/efs/file.c
+++ b/fs/efs/file.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include <linux/buffer_head.h> 9#include <linux/buffer_head.h>
10#include <linux/efs_fs.h> 10#include "efs.h"
11 11
12int efs_get_block(struct inode *inode, sector_t iblock, 12int efs_get_block(struct inode *inode, sector_t iblock,
13 struct buffer_head *bh_result, int create) 13 struct buffer_head *bh_result, int create)
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 627c3026946d..79e19e5958e1 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -7,11 +7,11 @@
7 * and from work (c) 1998 Mike Shaver. 7 * and from work (c) 1998 Mike Shaver.
8 */ 8 */
9 9
10#include <linux/efs_fs.h>
11#include <linux/efs_fs_sb.h>
12#include <linux/buffer_head.h> 10#include <linux/buffer_head.h>
13#include <linux/module.h> 11#include <linux/module.h>
14#include <linux/fs.h> 12#include <linux/fs.h>
13#include "efs.h"
14#include <linux/efs_fs_sb.h>
15 15
16static int efs_readpage(struct file *file, struct page *page) 16static int efs_readpage(struct file *file, struct page *page)
17{ 17{
diff --git a/fs/efs/namei.c b/fs/efs/namei.c
index e26704742d41..3a404e7fad53 100644
--- a/fs/efs/namei.c
+++ b/fs/efs/namei.c
@@ -8,9 +8,9 @@
8 8
9#include <linux/buffer_head.h> 9#include <linux/buffer_head.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/efs_fs.h>
12#include <linux/smp_lock.h> 11#include <linux/smp_lock.h>
13#include <linux/exportfs.h> 12#include <linux/exportfs.h>
13#include "efs.h"
14 14
15 15
16static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) { 16static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) {
diff --git a/fs/efs/super.c b/fs/efs/super.c
index 14082405cdd1..d733531b55e2 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -8,14 +8,15 @@
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/efs_fs.h>
12#include <linux/efs_vh.h>
13#include <linux/efs_fs_sb.h>
14#include <linux/exportfs.h> 11#include <linux/exportfs.h>
15#include <linux/slab.h> 12#include <linux/slab.h>
16#include <linux/buffer_head.h> 13#include <linux/buffer_head.h>
17#include <linux/vfs.h> 14#include <linux/vfs.h>
18 15
16#include "efs.h"
17#include <linux/efs_vh.h>
18#include <linux/efs_fs_sb.h>
19
19static int efs_statfs(struct dentry *dentry, struct kstatfs *buf); 20static int efs_statfs(struct dentry *dentry, struct kstatfs *buf);
20static int efs_fill_super(struct super_block *s, void *d, int silent); 21static int efs_fill_super(struct super_block *s, void *d, int silent);
21 22
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 1d30d2ff440f..41911ec83aaf 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -7,10 +7,10 @@
7 */ 7 */
8 8
9#include <linux/string.h> 9#include <linux/string.h>
10#include <linux/efs_fs.h>
11#include <linux/pagemap.h> 10#include <linux/pagemap.h>
12#include <linux/buffer_head.h> 11#include <linux/buffer_head.h>
13#include <linux/smp_lock.h> 12#include <linux/smp_lock.h>
13#include "efs.h"
14 14
15static int efs_symlink_readpage(struct file *file, struct page *page) 15static int efs_symlink_readpage(struct file *file, struct page *page)
16{ 16{
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 33888bb58144..2c23bade9aa6 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -46,7 +46,7 @@ const struct file_operations ext4_dir_operations = {
46#ifdef CONFIG_COMPAT 46#ifdef CONFIG_COMPAT
47 .compat_ioctl = ext4_compat_ioctl, 47 .compat_ioctl = ext4_compat_ioctl,
48#endif 48#endif
49 .fsync = ext4_sync_file, /* BKL held */ 49 .fsync = ext4_sync_file,
50 .release = ext4_release_dir, 50 .release = ext4_release_dir,
51}; 51};
52 52
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index bc7081f1fbe8..9ae6e67090cd 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -148,6 +148,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
148{ 148{
149 struct ext4_inode_info *ei = EXT4_I(inode); 149 struct ext4_inode_info *ei = EXT4_I(inode);
150 ext4_fsblk_t bg_start; 150 ext4_fsblk_t bg_start;
151 ext4_fsblk_t last_block;
151 ext4_grpblk_t colour; 152 ext4_grpblk_t colour;
152 int depth; 153 int depth;
153 154
@@ -169,8 +170,13 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
169 /* OK. use inode's group */ 170 /* OK. use inode's group */
170 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) + 171 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) +
171 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block); 172 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block);
172 colour = (current->pid % 16) * 173 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
174
175 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
176 colour = (current->pid % 16) *
173 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 177 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
178 else
179 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
174 return bg_start + colour + block; 180 return bg_start + colour + block;
175} 181}
176 182
@@ -349,7 +355,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path)
349#define ext4_ext_show_leaf(inode,path) 355#define ext4_ext_show_leaf(inode,path)
350#endif 356#endif
351 357
352static void ext4_ext_drop_refs(struct ext4_ext_path *path) 358void ext4_ext_drop_refs(struct ext4_ext_path *path)
353{ 359{
354 int depth = path->p_depth; 360 int depth = path->p_depth;
355 int i; 361 int i;
@@ -2168,6 +2174,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2168 newblock = iblock - ee_block + ext_pblock(ex); 2174 newblock = iblock - ee_block + ext_pblock(ex);
2169 ex2 = ex; 2175 ex2 = ex;
2170 2176
2177 err = ext4_ext_get_access(handle, inode, path + depth);
2178 if (err)
2179 goto out;
2180
2171 /* ex1: ee_block to iblock - 1 : uninitialized */ 2181 /* ex1: ee_block to iblock - 1 : uninitialized */
2172 if (iblock > ee_block) { 2182 if (iblock > ee_block) {
2173 ex1 = ex; 2183 ex1 = ex;
@@ -2200,16 +2210,20 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2200 newdepth = ext_depth(inode); 2210 newdepth = ext_depth(inode);
2201 if (newdepth != depth) { 2211 if (newdepth != depth) {
2202 depth = newdepth; 2212 depth = newdepth;
2203 path = ext4_ext_find_extent(inode, iblock, NULL); 2213 ext4_ext_drop_refs(path);
2214 path = ext4_ext_find_extent(inode, iblock, path);
2204 if (IS_ERR(path)) { 2215 if (IS_ERR(path)) {
2205 err = PTR_ERR(path); 2216 err = PTR_ERR(path);
2206 path = NULL;
2207 goto out; 2217 goto out;
2208 } 2218 }
2209 eh = path[depth].p_hdr; 2219 eh = path[depth].p_hdr;
2210 ex = path[depth].p_ext; 2220 ex = path[depth].p_ext;
2211 if (ex2 != &newex) 2221 if (ex2 != &newex)
2212 ex2 = ex; 2222 ex2 = ex;
2223
2224 err = ext4_ext_get_access(handle, inode, path + depth);
2225 if (err)
2226 goto out;
2213 } 2227 }
2214 allocated = max_blocks; 2228 allocated = max_blocks;
2215 } 2229 }
@@ -2230,9 +2244,6 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2230 ex2->ee_len = cpu_to_le16(allocated); 2244 ex2->ee_len = cpu_to_le16(allocated);
2231 if (ex2 != ex) 2245 if (ex2 != ex)
2232 goto insert; 2246 goto insert;
2233 err = ext4_ext_get_access(handle, inode, path + depth);
2234 if (err)
2235 goto out;
2236 /* 2247 /*
2237 * New (initialized) extent starts from the first block 2248 * New (initialized) extent starts from the first block
2238 * in the current extent. i.e., ex2 == ex 2249 * in the current extent. i.e., ex2 == ex
@@ -2276,9 +2287,22 @@ out:
2276} 2287}
2277 2288
2278/* 2289/*
2290 * Block allocation/map/preallocation routine for extents based files
2291 *
2292 *
2279 * Need to be called with 2293 * Need to be called with
2280 * down_read(&EXT4_I(inode)->i_data_sem) if not allocating file system block 2294 * down_read(&EXT4_I(inode)->i_data_sem) if not allocating file system block
2281 * (ie, create is zero). Otherwise down_write(&EXT4_I(inode)->i_data_sem) 2295 * (ie, create is zero). Otherwise down_write(&EXT4_I(inode)->i_data_sem)
2296 *
2297 * return > 0, number of of blocks already mapped/allocated
2298 * if create == 0 and these are pre-allocated blocks
2299 * buffer head is unmapped
2300 * otherwise blocks are mapped
2301 *
2302 * return = 0, if plain look up failed (blocks have not been allocated)
2303 * buffer head is unmapped
2304 *
2305 * return < 0, error case.
2282 */ 2306 */
2283int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, 2307int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2284 ext4_lblk_t iblock, 2308 ext4_lblk_t iblock,
@@ -2623,7 +2647,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
2623 * modify 1 super block, 1 block bitmap and 1 group descriptor. 2647 * modify 1 super block, 1 block bitmap and 1 group descriptor.
2624 */ 2648 */
2625 credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3; 2649 credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3;
2626 down_write((&EXT4_I(inode)->i_data_sem)); 2650 mutex_lock(&inode->i_mutex);
2627retry: 2651retry:
2628 while (ret >= 0 && ret < max_blocks) { 2652 while (ret >= 0 && ret < max_blocks) {
2629 block = block + ret; 2653 block = block + ret;
@@ -2634,16 +2658,17 @@ retry:
2634 break; 2658 break;
2635 } 2659 }
2636 2660
2637 ret = ext4_ext_get_blocks(handle, inode, block, 2661 ret = ext4_get_blocks_wrap(handle, inode, block,
2638 max_blocks, &map_bh, 2662 max_blocks, &map_bh,
2639 EXT4_CREATE_UNINITIALIZED_EXT, 0); 2663 EXT4_CREATE_UNINITIALIZED_EXT, 0);
2640 WARN_ON(ret <= 0);
2641 if (ret <= 0) { 2664 if (ret <= 0) {
2642 ext4_error(inode->i_sb, "ext4_fallocate", 2665#ifdef EXT4FS_DEBUG
2643 "ext4_ext_get_blocks returned error: " 2666 WARN_ON(ret <= 0);
2644 "inode#%lu, block=%u, max_blocks=%lu", 2667 printk(KERN_ERR "%s: ext4_ext_get_blocks "
2668 "returned error inode#%lu, block=%u, "
2669 "max_blocks=%lu", __func__,
2645 inode->i_ino, block, max_blocks); 2670 inode->i_ino, block, max_blocks);
2646 ret = -EIO; 2671#endif
2647 ext4_mark_inode_dirty(handle, inode); 2672 ext4_mark_inode_dirty(handle, inode);
2648 ret2 = ext4_journal_stop(handle); 2673 ret2 = ext4_journal_stop(handle);
2649 break; 2674 break;
@@ -2680,7 +2705,6 @@ retry:
2680 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 2705 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
2681 goto retry; 2706 goto retry;
2682 2707
2683 up_write((&EXT4_I(inode)->i_data_sem));
2684 /* 2708 /*
2685 * Time to update the file size. 2709 * Time to update the file size.
2686 * Update only when preallocation was requested beyond the file size. 2710 * Update only when preallocation was requested beyond the file size.
@@ -2692,21 +2716,18 @@ retry:
2692 * if no error, we assume preallocation succeeded 2716 * if no error, we assume preallocation succeeded
2693 * completely 2717 * completely
2694 */ 2718 */
2695 mutex_lock(&inode->i_mutex);
2696 i_size_write(inode, offset + len); 2719 i_size_write(inode, offset + len);
2697 EXT4_I(inode)->i_disksize = i_size_read(inode); 2720 EXT4_I(inode)->i_disksize = i_size_read(inode);
2698 mutex_unlock(&inode->i_mutex);
2699 } else if (ret < 0 && nblocks) { 2721 } else if (ret < 0 && nblocks) {
2700 /* Handle partial allocation scenario */ 2722 /* Handle partial allocation scenario */
2701 loff_t newsize; 2723 loff_t newsize;
2702 2724
2703 mutex_lock(&inode->i_mutex);
2704 newsize = (nblocks << blkbits) + i_size_read(inode); 2725 newsize = (nblocks << blkbits) + i_size_read(inode);
2705 i_size_write(inode, EXT4_BLOCK_ALIGN(newsize, blkbits)); 2726 i_size_write(inode, EXT4_BLOCK_ALIGN(newsize, blkbits));
2706 EXT4_I(inode)->i_disksize = i_size_read(inode); 2727 EXT4_I(inode)->i_disksize = i_size_read(inode);
2707 mutex_unlock(&inode->i_mutex);
2708 } 2728 }
2709 } 2729 }
2710 2730
2731 mutex_unlock(&inode->i_mutex);
2711 return ret > 0 ? ret2 : ret; 2732 return ret > 0 ? ret2 : ret;
2712} 2733}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index da18a74b966a..8036b9b5376b 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -702,7 +702,12 @@ got:
702 ei->i_dir_start_lookup = 0; 702 ei->i_dir_start_lookup = 0;
703 ei->i_disksize = 0; 703 ei->i_disksize = 0;
704 704
705 ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL; 705 /*
706 * Don't inherit extent flag from directory. We set extent flag on
707 * newly created directory and file only if -o extent mount option is
708 * specified
709 */
710 ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
706 if (S_ISLNK(mode)) 711 if (S_ISLNK(mode))
707 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL); 712 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
708 /* dirsync only applies to directories */ 713 /* dirsync only applies to directories */
@@ -745,12 +750,15 @@ got:
745 goto fail_free_drop; 750 goto fail_free_drop;
746 } 751 }
747 if (test_opt(sb, EXTENTS)) { 752 if (test_opt(sb, EXTENTS)) {
748 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL; 753 /* set extent flag only for directory and file */
749 ext4_ext_tree_init(handle, inode); 754 if (S_ISDIR(mode) || S_ISREG(mode)) {
750 err = ext4_update_incompat_feature(handle, sb, 755 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
751 EXT4_FEATURE_INCOMPAT_EXTENTS); 756 ext4_ext_tree_init(handle, inode);
752 if (err) 757 err = ext4_update_incompat_feature(handle, sb,
753 goto fail; 758 EXT4_FEATURE_INCOMPAT_EXTENTS);
759 if (err)
760 goto fail;
761 }
754 } 762 }
755 763
756 ext4_debug("allocating inode %lu\n", inode->i_ino); 764 ext4_debug("allocating inode %lu\n", inode->i_ino);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7dd9b50d5ebc..945cbf6cb1fc 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -403,6 +403,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data; 403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
404 __le32 *p; 404 __le32 *p;
405 ext4_fsblk_t bg_start; 405 ext4_fsblk_t bg_start;
406 ext4_fsblk_t last_block;
406 ext4_grpblk_t colour; 407 ext4_grpblk_t colour;
407 408
408 /* Try to find previous block */ 409 /* Try to find previous block */
@@ -420,8 +421,13 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
420 * into the same cylinder group then. 421 * into the same cylinder group then.
421 */ 422 */
422 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group); 423 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group);
423 colour = (current->pid % 16) * 424 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
425
426 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
427 colour = (current->pid % 16) *
424 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 428 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
429 else
430 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
425 return bg_start + colour; 431 return bg_start + colour;
426} 432}
427 433
@@ -768,7 +774,6 @@ err_out:
768 * 774 *
769 * `handle' can be NULL if create == 0. 775 * `handle' can be NULL if create == 0.
770 * 776 *
771 * The BKL may not be held on entry here. Be sure to take it early.
772 * return > 0, # of blocks mapped or allocated. 777 * return > 0, # of blocks mapped or allocated.
773 * return = 0, if plain lookup failed. 778 * return = 0, if plain lookup failed.
774 * return < 0, error case. 779 * return < 0, error case.
@@ -903,11 +908,38 @@ out:
903 */ 908 */
904#define DIO_CREDITS 25 909#define DIO_CREDITS 25
905 910
911
912/*
913 *
914 *
915 * ext4_ext4 get_block() wrapper function
916 * It will do a look up first, and returns if the blocks already mapped.
917 * Otherwise it takes the write lock of the i_data_sem and allocate blocks
918 * and store the allocated blocks in the result buffer head and mark it
919 * mapped.
920 *
921 * If file type is extents based, it will call ext4_ext_get_blocks(),
922 * Otherwise, call with ext4_get_blocks_handle() to handle indirect mapping
923 * based files
924 *
925 * On success, it returns the number of blocks being mapped or allocate.
926 * if create==0 and the blocks are pre-allocated and uninitialized block,
927 * the result buffer head is unmapped. If the create ==1, it will make sure
928 * the buffer head is mapped.
929 *
930 * It returns 0 if plain look up failed (blocks have not been allocated), in
931 * that casem, buffer head is unmapped
932 *
933 * It returns the error in case of allocation failure.
934 */
906int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, 935int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
907 unsigned long max_blocks, struct buffer_head *bh, 936 unsigned long max_blocks, struct buffer_head *bh,
908 int create, int extend_disksize) 937 int create, int extend_disksize)
909{ 938{
910 int retval; 939 int retval;
940
941 clear_buffer_mapped(bh);
942
911 /* 943 /*
912 * Try to see if we can get the block without requesting 944 * Try to see if we can get the block without requesting
913 * for new file system block. 945 * for new file system block.
@@ -921,12 +953,26 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
921 inode, block, max_blocks, bh, 0, 0); 953 inode, block, max_blocks, bh, 0, 0);
922 } 954 }
923 up_read((&EXT4_I(inode)->i_data_sem)); 955 up_read((&EXT4_I(inode)->i_data_sem));
924 if (!create || (retval > 0)) 956
957 /* If it is only a block(s) look up */
958 if (!create)
959 return retval;
960
961 /*
962 * Returns if the blocks have already allocated
963 *
964 * Note that if blocks have been preallocated
965 * ext4_ext_get_block() returns th create = 0
966 * with buffer head unmapped.
967 */
968 if (retval > 0 && buffer_mapped(bh))
925 return retval; 969 return retval;
926 970
927 /* 971 /*
928 * We need to allocate new blocks which will result 972 * New blocks allocate and/or writing to uninitialized extent
929 * in i_data update 973 * will possibly result in updating i_data, so we take
974 * the write lock of i_data_sem, and call get_blocks()
975 * with create == 1 flag.
930 */ 976 */
931 down_write((&EXT4_I(inode)->i_data_sem)); 977 down_write((&EXT4_I(inode)->i_data_sem));
932 /* 978 /*
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dd0fcfcb35ce..ef97f19c2f9d 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -627,21 +627,19 @@ static ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb,
627 return block; 627 return block;
628} 628}
629 629
630static inline void *mb_correct_addr_and_bit(int *bit, void *addr)
631{
630#if BITS_PER_LONG == 64 632#if BITS_PER_LONG == 64
631#define mb_correct_addr_and_bit(bit, addr) \ 633 *bit += ((unsigned long) addr & 7UL) << 3;
632{ \ 634 addr = (void *) ((unsigned long) addr & ~7UL);
633 bit += ((unsigned long) addr & 7UL) << 3; \
634 addr = (void *) ((unsigned long) addr & ~7UL); \
635}
636#elif BITS_PER_LONG == 32 635#elif BITS_PER_LONG == 32
637#define mb_correct_addr_and_bit(bit, addr) \ 636 *bit += ((unsigned long) addr & 3UL) << 3;
638{ \ 637 addr = (void *) ((unsigned long) addr & ~3UL);
639 bit += ((unsigned long) addr & 3UL) << 3; \
640 addr = (void *) ((unsigned long) addr & ~3UL); \
641}
642#else 638#else
643#error "how many bits you are?!" 639#error "how many bits you are?!"
644#endif 640#endif
641 return addr;
642}
645 643
646static inline int mb_test_bit(int bit, void *addr) 644static inline int mb_test_bit(int bit, void *addr)
647{ 645{
@@ -649,34 +647,54 @@ static inline int mb_test_bit(int bit, void *addr)
649 * ext4_test_bit on architecture like powerpc 647 * ext4_test_bit on architecture like powerpc
650 * needs unsigned long aligned address 648 * needs unsigned long aligned address
651 */ 649 */
652 mb_correct_addr_and_bit(bit, addr); 650 addr = mb_correct_addr_and_bit(&bit, addr);
653 return ext4_test_bit(bit, addr); 651 return ext4_test_bit(bit, addr);
654} 652}
655 653
656static inline void mb_set_bit(int bit, void *addr) 654static inline void mb_set_bit(int bit, void *addr)
657{ 655{
658 mb_correct_addr_and_bit(bit, addr); 656 addr = mb_correct_addr_and_bit(&bit, addr);
659 ext4_set_bit(bit, addr); 657 ext4_set_bit(bit, addr);
660} 658}
661 659
662static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr) 660static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr)
663{ 661{
664 mb_correct_addr_and_bit(bit, addr); 662 addr = mb_correct_addr_and_bit(&bit, addr);
665 ext4_set_bit_atomic(lock, bit, addr); 663 ext4_set_bit_atomic(lock, bit, addr);
666} 664}
667 665
668static inline void mb_clear_bit(int bit, void *addr) 666static inline void mb_clear_bit(int bit, void *addr)
669{ 667{
670 mb_correct_addr_and_bit(bit, addr); 668 addr = mb_correct_addr_and_bit(&bit, addr);
671 ext4_clear_bit(bit, addr); 669 ext4_clear_bit(bit, addr);
672} 670}
673 671
674static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr) 672static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
675{ 673{
676 mb_correct_addr_and_bit(bit, addr); 674 addr = mb_correct_addr_and_bit(&bit, addr);
677 ext4_clear_bit_atomic(lock, bit, addr); 675 ext4_clear_bit_atomic(lock, bit, addr);
678} 676}
679 677
678static inline int mb_find_next_zero_bit(void *addr, int max, int start)
679{
680 int fix = 0;
681 addr = mb_correct_addr_and_bit(&fix, addr);
682 max += fix;
683 start += fix;
684
685 return ext4_find_next_zero_bit(addr, max, start) - fix;
686}
687
688static inline int mb_find_next_bit(void *addr, int max, int start)
689{
690 int fix = 0;
691 addr = mb_correct_addr_and_bit(&fix, addr);
692 max += fix;
693 start += fix;
694
695 return ext4_find_next_bit(addr, max, start) - fix;
696}
697
680static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) 698static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
681{ 699{
682 char *bb; 700 char *bb;
@@ -906,7 +924,7 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
906 unsigned short chunk; 924 unsigned short chunk;
907 unsigned short border; 925 unsigned short border;
908 926
909 BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb)); 927 BUG_ON(len > EXT4_BLOCKS_PER_GROUP(sb));
910 928
911 border = 2 << sb->s_blocksize_bits; 929 border = 2 << sb->s_blocksize_bits;
912 930
@@ -946,12 +964,12 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
946 964
947 /* initialize buddy from bitmap which is aggregation 965 /* initialize buddy from bitmap which is aggregation
948 * of on-disk bitmap and preallocations */ 966 * of on-disk bitmap and preallocations */
949 i = ext4_find_next_zero_bit(bitmap, max, 0); 967 i = mb_find_next_zero_bit(bitmap, max, 0);
950 grp->bb_first_free = i; 968 grp->bb_first_free = i;
951 while (i < max) { 969 while (i < max) {
952 fragments++; 970 fragments++;
953 first = i; 971 first = i;
954 i = ext4_find_next_bit(bitmap, max, i); 972 i = mb_find_next_bit(bitmap, max, i);
955 len = i - first; 973 len = i - first;
956 free += len; 974 free += len;
957 if (len > 1) 975 if (len > 1)
@@ -959,7 +977,7 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
959 else 977 else
960 grp->bb_counters[0]++; 978 grp->bb_counters[0]++;
961 if (i < max) 979 if (i < max)
962 i = ext4_find_next_zero_bit(bitmap, max, i); 980 i = mb_find_next_zero_bit(bitmap, max, i);
963 } 981 }
964 grp->bb_fragments = fragments; 982 grp->bb_fragments = fragments;
965 983
@@ -967,6 +985,10 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
967 ext4_error(sb, __FUNCTION__, 985 ext4_error(sb, __FUNCTION__,
968 "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n", 986 "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n",
969 group, free, grp->bb_free); 987 group, free, grp->bb_free);
988 /*
989 * If we intent to continue, we consider group descritor
990 * corrupt and update bb_free using bitmap value
991 */
970 grp->bb_free = free; 992 grp->bb_free = free;
971 } 993 }
972 994
@@ -1778,7 +1800,7 @@ static void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
1778 buddy = mb_find_buddy(e4b, i, &max); 1800 buddy = mb_find_buddy(e4b, i, &max);
1779 BUG_ON(buddy == NULL); 1801 BUG_ON(buddy == NULL);
1780 1802
1781 k = ext4_find_next_zero_bit(buddy, max, 0); 1803 k = mb_find_next_zero_bit(buddy, max, 0);
1782 BUG_ON(k >= max); 1804 BUG_ON(k >= max);
1783 1805
1784 ac->ac_found++; 1806 ac->ac_found++;
@@ -1818,11 +1840,11 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1818 i = e4b->bd_info->bb_first_free; 1840 i = e4b->bd_info->bb_first_free;
1819 1841
1820 while (free && ac->ac_status == AC_STATUS_CONTINUE) { 1842 while (free && ac->ac_status == AC_STATUS_CONTINUE) {
1821 i = ext4_find_next_zero_bit(bitmap, 1843 i = mb_find_next_zero_bit(bitmap,
1822 EXT4_BLOCKS_PER_GROUP(sb), i); 1844 EXT4_BLOCKS_PER_GROUP(sb), i);
1823 if (i >= EXT4_BLOCKS_PER_GROUP(sb)) { 1845 if (i >= EXT4_BLOCKS_PER_GROUP(sb)) {
1824 /* 1846 /*
1825 * IF we corrupt the bitmap we won't find any 1847 * IF we have corrupt bitmap, we won't find any
1826 * free blocks even though group info says we 1848 * free blocks even though group info says we
1827 * we have free blocks 1849 * we have free blocks
1828 */ 1850 */
@@ -1838,6 +1860,12 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1838 ext4_error(sb, __FUNCTION__, "%d free blocks as per " 1860 ext4_error(sb, __FUNCTION__, "%d free blocks as per "
1839 "group info. But got %d blocks\n", 1861 "group info. But got %d blocks\n",
1840 free, ex.fe_len); 1862 free, ex.fe_len);
1863 /*
1864 * The number of free blocks differs. This mostly
1865 * indicate that the bitmap is corrupt. So exit
1866 * without claiming the space.
1867 */
1868 break;
1841 } 1869 }
1842 1870
1843 ext4_mb_measure_extent(ac, &ex, e4b); 1871 ext4_mb_measure_extent(ac, &ex, e4b);
@@ -3740,10 +3768,10 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b,
3740 } 3768 }
3741 3769
3742 while (bit < end) { 3770 while (bit < end) {
3743 bit = ext4_find_next_zero_bit(bitmap_bh->b_data, end, bit); 3771 bit = mb_find_next_zero_bit(bitmap_bh->b_data, end, bit);
3744 if (bit >= end) 3772 if (bit >= end)
3745 break; 3773 break;
3746 next = ext4_find_next_bit(bitmap_bh->b_data, end, bit); 3774 next = mb_find_next_bit(bitmap_bh->b_data, end, bit);
3747 if (next > end) 3775 if (next > end)
3748 next = end; 3776 next = end;
3749 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit + 3777 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit +
@@ -3771,6 +3799,10 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b,
3771 (unsigned long) pa->pa_len); 3799 (unsigned long) pa->pa_len);
3772 ext4_error(sb, __FUNCTION__, "free %u, pa_free %u\n", 3800 ext4_error(sb, __FUNCTION__, "free %u, pa_free %u\n",
3773 free, pa->pa_free); 3801 free, pa->pa_free);
3802 /*
3803 * pa is already deleted so we use the value obtained
3804 * from the bitmap and continue.
3805 */
3774 } 3806 }
3775 atomic_add(free, &sbi->s_mb_discarded); 3807 atomic_add(free, &sbi->s_mb_discarded);
3776 if (ac) 3808 if (ac)
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 8c6c685b9d22..5c1e27de7755 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -43,6 +43,7 @@ static int finish_range(handle_t *handle, struct inode *inode,
43 43
44 if (IS_ERR(path)) { 44 if (IS_ERR(path)) {
45 retval = PTR_ERR(path); 45 retval = PTR_ERR(path);
46 path = NULL;
46 goto err_out; 47 goto err_out;
47 } 48 }
48 49
@@ -74,6 +75,10 @@ static int finish_range(handle_t *handle, struct inode *inode,
74 } 75 }
75 retval = ext4_ext_insert_extent(handle, inode, path, &newext); 76 retval = ext4_ext_insert_extent(handle, inode, path, &newext);
76err_out: 77err_out:
78 if (path) {
79 ext4_ext_drop_refs(path);
80 kfree(path);
81 }
77 lb->first_pblock = 0; 82 lb->first_pblock = 0;
78 return retval; 83 return retval;
79} 84}
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a9347fb43bcc..28aa2ed4297e 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1804,12 +1804,8 @@ retry:
1804 inode->i_fop = &ext4_dir_operations; 1804 inode->i_fop = &ext4_dir_operations;
1805 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize; 1805 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
1806 dir_block = ext4_bread (handle, inode, 0, 1, &err); 1806 dir_block = ext4_bread (handle, inode, 0, 1, &err);
1807 if (!dir_block) { 1807 if (!dir_block)
1808 ext4_dec_count(handle, inode); /* is this nlink == 0? */ 1808 goto out_clear_inode;
1809 ext4_mark_inode_dirty(handle, inode);
1810 iput (inode);
1811 goto out_stop;
1812 }
1813 BUFFER_TRACE(dir_block, "get_write_access"); 1809 BUFFER_TRACE(dir_block, "get_write_access");
1814 ext4_journal_get_write_access(handle, dir_block); 1810 ext4_journal_get_write_access(handle, dir_block);
1815 de = (struct ext4_dir_entry_2 *) dir_block->b_data; 1811 de = (struct ext4_dir_entry_2 *) dir_block->b_data;
@@ -1832,7 +1828,8 @@ retry:
1832 ext4_mark_inode_dirty(handle, inode); 1828 ext4_mark_inode_dirty(handle, inode);
1833 err = ext4_add_entry (handle, dentry, inode); 1829 err = ext4_add_entry (handle, dentry, inode);
1834 if (err) { 1830 if (err) {
1835 inode->i_nlink = 0; 1831out_clear_inode:
1832 clear_nlink(inode);
1836 ext4_mark_inode_dirty(handle, inode); 1833 ext4_mark_inode_dirty(handle, inode);
1837 iput (inode); 1834 iput (inode);
1838 goto out_stop; 1835 goto out_stop;
@@ -2164,7 +2161,7 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
2164 dir->i_ctime = dir->i_mtime = ext4_current_time(dir); 2161 dir->i_ctime = dir->i_mtime = ext4_current_time(dir);
2165 ext4_update_dx_flag(dir); 2162 ext4_update_dx_flag(dir);
2166 ext4_mark_inode_dirty(handle, dir); 2163 ext4_mark_inode_dirty(handle, dir);
2167 ext4_dec_count(handle, inode); 2164 drop_nlink(inode);
2168 if (!inode->i_nlink) 2165 if (!inode->i_nlink)
2169 ext4_orphan_add(handle, inode); 2166 ext4_orphan_add(handle, inode);
2170 inode->i_ctime = ext4_current_time(inode); 2167 inode->i_ctime = ext4_current_time(inode);
@@ -2214,7 +2211,7 @@ retry:
2214 err = __page_symlink(inode, symname, l, 2211 err = __page_symlink(inode, symname, l,
2215 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2212 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2216 if (err) { 2213 if (err) {
2217 ext4_dec_count(handle, inode); 2214 clear_nlink(inode);
2218 ext4_mark_inode_dirty(handle, inode); 2215 ext4_mark_inode_dirty(handle, inode);
2219 iput (inode); 2216 iput (inode);
2220 goto out_stop; 2217 goto out_stop;
@@ -2223,7 +2220,6 @@ retry:
2223 inode->i_op = &ext4_fast_symlink_inode_operations; 2220 inode->i_op = &ext4_fast_symlink_inode_operations;
2224 memcpy((char*)&EXT4_I(inode)->i_data,symname,l); 2221 memcpy((char*)&EXT4_I(inode)->i_data,symname,l);
2225 inode->i_size = l-1; 2222 inode->i_size = l-1;
2226 EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL;
2227 } 2223 }
2228 EXT4_I(inode)->i_disksize = inode->i_size; 2224 EXT4_I(inode)->i_disksize = inode->i_size;
2229 err = ext4_add_nondir(handle, dentry, inode); 2225 err = ext4_add_nondir(handle, dentry, inode);
@@ -2407,7 +2403,7 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
2407 ext4_dec_count(handle, old_dir); 2403 ext4_dec_count(handle, old_dir);
2408 if (new_inode) { 2404 if (new_inode) {
2409 /* checked empty_dir above, can't have another parent, 2405 /* checked empty_dir above, can't have another parent,
2410 * ext3_dec_count() won't work for many-linked dirs */ 2406 * ext4_dec_count() won't work for many-linked dirs */
2411 new_inode->i_nlink = 0; 2407 new_inode->i_nlink = 0;
2412 } else { 2408 } else {
2413 ext4_inc_count(handle, new_dir); 2409 ext4_inc_count(handle, new_dir);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9477a2bd6ff2..e29efa0f9d62 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1037,6 +1037,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1037 ext4_warning(sb, __FUNCTION__, 1037 ext4_warning(sb, __FUNCTION__,
1038 "multiple resizers run on filesystem!"); 1038 "multiple resizers run on filesystem!");
1039 unlock_super(sb); 1039 unlock_super(sb);
1040 ext4_journal_stop(handle);
1040 err = -EBUSY; 1041 err = -EBUSY;
1041 goto exit_put; 1042 goto exit_put;
1042 } 1043 }
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 7fb514b6d852..c4807b3fc8a3 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -906,7 +906,7 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
906 } 906 }
907 907
908 if (fc->flags & FUSE_DEFAULT_PERMISSIONS) { 908 if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
909 int err = generic_permission(inode, mask, NULL); 909 err = generic_permission(inode, mask, NULL);
910 910
911 /* If permission is denied, try to refresh file 911 /* If permission is denied, try to refresh file
912 attributes. This is also needed, because the root 912 attributes. This is also needed, because the root
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 08226464e563..1ed8bd4de941 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -153,7 +153,7 @@ lockd(struct svc_rqst *rqstp)
153 */ 153 */
154 while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) { 154 while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) {
155 long timeout = MAX_SCHEDULE_TIMEOUT; 155 long timeout = MAX_SCHEDULE_TIMEOUT;
156 char buf[RPC_MAX_ADDRBUFLEN]; 156 RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
157 157
158 if (signalled()) { 158 if (signalled()) {
159 flush_signals(current); 159 flush_signals(current);
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index ecc06c619494..66648dd92d97 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -93,6 +93,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
93 svc_process(rqstp); 93 svc_process(rqstp);
94 } 94 }
95 95
96 flush_signals(current);
96 svc_exit_thread(rqstp); 97 svc_exit_thread(rqstp);
97 nfs_callback_info.pid = 0; 98 nfs_callback_info.pid = 0;
98 complete(&nfs_callback_info.stopped); 99 complete(&nfs_callback_info.stopped);
@@ -171,7 +172,7 @@ void nfs_callback_down(void)
171static int nfs_callback_authenticate(struct svc_rqst *rqstp) 172static int nfs_callback_authenticate(struct svc_rqst *rqstp)
172{ 173{
173 struct nfs_client *clp; 174 struct nfs_client *clp;
174 char buf[RPC_MAX_ADDRBUFLEN]; 175 RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
175 176
176 /* Don't talk to strangers */ 177 /* Don't talk to strangers */
177 clp = nfs_find_client(svc_addr(rqstp), 4); 178 clp = nfs_find_client(svc_addr(rqstp), 4);
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index c63eb720b68b..13619d24f023 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -254,7 +254,7 @@ static __be32 encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap,
254 if (!(bitmap[0] & FATTR4_WORD0_CHANGE)) 254 if (!(bitmap[0] & FATTR4_WORD0_CHANGE))
255 return 0; 255 return 0;
256 p = xdr_reserve_space(xdr, 8); 256 p = xdr_reserve_space(xdr, 8);
257 if (unlikely(p == 0)) 257 if (unlikely(!p))
258 return htonl(NFS4ERR_RESOURCE); 258 return htonl(NFS4ERR_RESOURCE);
259 p = xdr_encode_hyper(p, change); 259 p = xdr_encode_hyper(p, change);
260 return 0; 260 return 0;
@@ -267,7 +267,7 @@ static __be32 encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, u
267 if (!(bitmap[0] & FATTR4_WORD0_SIZE)) 267 if (!(bitmap[0] & FATTR4_WORD0_SIZE))
268 return 0; 268 return 0;
269 p = xdr_reserve_space(xdr, 8); 269 p = xdr_reserve_space(xdr, 8);
270 if (unlikely(p == 0)) 270 if (unlikely(!p))
271 return htonl(NFS4ERR_RESOURCE); 271 return htonl(NFS4ERR_RESOURCE);
272 p = xdr_encode_hyper(p, size); 272 p = xdr_encode_hyper(p, size);
273 return 0; 273 return 0;
@@ -278,7 +278,7 @@ static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec *ti
278 __be32 *p; 278 __be32 *p;
279 279
280 p = xdr_reserve_space(xdr, 12); 280 p = xdr_reserve_space(xdr, 12);
281 if (unlikely(p == 0)) 281 if (unlikely(!p))
282 return htonl(NFS4ERR_RESOURCE); 282 return htonl(NFS4ERR_RESOURCE);
283 p = xdr_encode_hyper(p, time->tv_sec); 283 p = xdr_encode_hyper(p, time->tv_sec);
284 *p = htonl(time->tv_nsec); 284 *p = htonl(time->tv_nsec);
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index b9eadd18ba70..00a5e4405e16 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -49,7 +49,7 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_
49 struct file_lock *fl; 49 struct file_lock *fl;
50 int status; 50 int status;
51 51
52 for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { 52 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
53 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 53 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
54 continue; 54 continue;
55 if (nfs_file_open_context(fl->fl_file) != ctx) 55 if (nfs_file_open_context(fl->fl_file) != ctx)
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 8ae5dba2d4e5..86147b0ab2cf 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -309,7 +309,7 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
309 mutex_lock(&idmap->idmap_im_lock); 309 mutex_lock(&idmap->idmap_im_lock);
310 310
311 he = idmap_lookup_id(h, id); 311 he = idmap_lookup_id(h, id);
312 if (he != 0) { 312 if (he) {
313 memcpy(name, he->ih_name, he->ih_namelen); 313 memcpy(name, he->ih_name, he->ih_namelen);
314 ret = he->ih_namelen; 314 ret = he->ih_namelen;
315 goto out; 315 goto out;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 6233eb5e98c1..b962397004c1 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -785,7 +785,7 @@ static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_s
785 struct file_lock *fl; 785 struct file_lock *fl;
786 int status = 0; 786 int status = 0;
787 787
788 for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { 788 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
789 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 789 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
790 continue; 790 continue;
791 if (nfs_file_open_context(fl->fl_file)->state != state) 791 if (nfs_file_open_context(fl->fl_file)->state != state)
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 0130b345234d..1eb771d79cca 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -101,7 +101,7 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
101{ 101{
102 /* Check if the request originated from a secure port. */ 102 /* Check if the request originated from a secure port. */
103 if (!rqstp->rq_secure && EX_SECURE(exp)) { 103 if (!rqstp->rq_secure && EX_SECURE(exp)) {
104 char buf[RPC_MAX_ADDRBUFLEN]; 104 RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
105 dprintk(KERN_WARNING 105 dprintk(KERN_WARNING
106 "nfsd: request from insecure port %s!\n", 106 "nfsd: request from insecure port %s!\n",
107 svc_print_addr(rqstp, buf, sizeof(buf))); 107 svc_print_addr(rqstp, buf, sizeof(buf)));
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 88f8edf18258..91a1bd67ac1d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -314,9 +314,12 @@ static int proc_pid_schedstat(struct task_struct *task, char *buffer)
314static int lstats_show_proc(struct seq_file *m, void *v) 314static int lstats_show_proc(struct seq_file *m, void *v)
315{ 315{
316 int i; 316 int i;
317 struct task_struct *task = m->private; 317 struct inode *inode = m->private;
318 seq_puts(m, "Latency Top version : v0.1\n"); 318 struct task_struct *task = get_proc_task(inode);
319 319
320 if (!task)
321 return -ESRCH;
322 seq_puts(m, "Latency Top version : v0.1\n");
320 for (i = 0; i < 32; i++) { 323 for (i = 0; i < 32; i++) {
321 if (task->latency_record[i].backtrace[0]) { 324 if (task->latency_record[i].backtrace[0]) {
322 int q; 325 int q;
@@ -341,32 +344,24 @@ static int lstats_show_proc(struct seq_file *m, void *v)
341 } 344 }
342 345
343 } 346 }
347 put_task_struct(task);
344 return 0; 348 return 0;
345} 349}
346 350
347static int lstats_open(struct inode *inode, struct file *file) 351static int lstats_open(struct inode *inode, struct file *file)
348{ 352{
349 int ret; 353 return single_open(file, lstats_show_proc, inode);
350 struct seq_file *m;
351 struct task_struct *task = get_proc_task(inode);
352
353 ret = single_open(file, lstats_show_proc, NULL);
354 if (!ret) {
355 m = file->private_data;
356 m->private = task;
357 }
358 return ret;
359} 354}
360 355
361static ssize_t lstats_write(struct file *file, const char __user *buf, 356static ssize_t lstats_write(struct file *file, const char __user *buf,
362 size_t count, loff_t *offs) 357 size_t count, loff_t *offs)
363{ 358{
364 struct seq_file *m; 359 struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
365 struct task_struct *task;
366 360
367 m = file->private_data; 361 if (!task)
368 task = m->private; 362 return -ESRCH;
369 clear_all_latency_tracing(task); 363 clear_all_latency_tracing(task);
364 put_task_struct(task);
370 365
371 return count; 366 return count;
372} 367}
@@ -416,6 +411,7 @@ static const struct limit_names lnames[RLIM_NLIMITS] = {
416 [RLIMIT_MSGQUEUE] = {"Max msgqueue size", "bytes"}, 411 [RLIMIT_MSGQUEUE] = {"Max msgqueue size", "bytes"},
417 [RLIMIT_NICE] = {"Max nice priority", NULL}, 412 [RLIMIT_NICE] = {"Max nice priority", NULL},
418 [RLIMIT_RTPRIO] = {"Max realtime priority", NULL}, 413 [RLIMIT_RTPRIO] = {"Max realtime priority", NULL},
414 [RLIMIT_RTTIME] = {"Max realtime timeout", "us"},
419}; 415};
420 416
421/* Display limits for a process */ 417/* Display limits for a process */
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 49958cffbd8d..6dc0334815f7 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -531,7 +531,7 @@ struct pagemapread {
531#define PM_RESERVED_BITS 3 531#define PM_RESERVED_BITS 3
532#define PM_RESERVED_OFFSET (64 - PM_RESERVED_BITS) 532#define PM_RESERVED_OFFSET (64 - PM_RESERVED_BITS)
533#define PM_RESERVED_MASK (((1LL<<PM_RESERVED_BITS)-1) << PM_RESERVED_OFFSET) 533#define PM_RESERVED_MASK (((1LL<<PM_RESERVED_BITS)-1) << PM_RESERVED_OFFSET)
534#define PM_SPECIAL(nr) (((nr) << PM_RESERVED_OFFSET) | PM_RESERVED_MASK) 534#define PM_SPECIAL(nr) (((nr) << PM_RESERVED_OFFSET) & PM_RESERVED_MASK)
535#define PM_NOT_PRESENT PM_SPECIAL(1LL) 535#define PM_NOT_PRESENT PM_SPECIAL(1LL)
536#define PM_SWAP PM_SPECIAL(2LL) 536#define PM_SWAP PM_SPECIAL(2LL)
537#define PM_END_OF_BUFFER 1 537#define PM_END_OF_BUFFER 1
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index b26fc4dec1e7..23ceed8c8fb9 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -58,7 +58,7 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,
58{ 58{
59 switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { 59 switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
60 case UFS_ST_SUNOS: 60 case UFS_ST_SUNOS:
61 if (fs32_to_cpu(sb, usb3->fs_postblformat == UFS_42POSTBLFMT)) { 61 if (fs32_to_cpu(sb, usb3->fs_postblformat) == UFS_42POSTBLFMT) {
62 usb1->fs_u0.fs_sun.fs_state = cpu_to_fs32(sb, value); 62 usb1->fs_u0.fs_sun.fs_state = cpu_to_fs32(sb, value);
63 break; 63 break;
64 } 64 }
diff --git a/fs/xfs/Kbuild b/fs/xfs/Kbuild
deleted file mode 100644
index 2566e96706f1..000000000000
--- a/fs/xfs/Kbuild
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# The xfs people like to share Makefile with 2.6 and 2.4.
3# Utilise file named Kbuild file which has precedence over Makefile.
4#
5
6include $(srctree)/$(obj)/Makefile-linux-2.6
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 49e3e7e5e3dc..36ec614e699a 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -1 +1,117 @@
1include $(TOPDIR)/fs/xfs/Makefile-linux-$(VERSION).$(PATCHLEVEL) 1#
2# Copyright (c) 2000-2005 Silicon Graphics, Inc.
3# All Rights Reserved.
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it would be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write the Free Software Foundation,
16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17#
18
19EXTRA_CFLAGS += -I$(src) -I$(src)/linux-2.6 -funsigned-char
20
21XFS_LINUX := linux-2.6
22
23ifeq ($(CONFIG_XFS_DEBUG),y)
24 EXTRA_CFLAGS += -g
25endif
26
27obj-$(CONFIG_XFS_FS) += xfs.o
28
29xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \
30 xfs_dquot.o \
31 xfs_dquot_item.o \
32 xfs_trans_dquot.o \
33 xfs_qm_syscalls.o \
34 xfs_qm_bhv.o \
35 xfs_qm.o)
36
37ifeq ($(CONFIG_XFS_QUOTA),y)
38xfs-$(CONFIG_PROC_FS) += quota/xfs_qm_stats.o
39endif
40
41xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
42xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
43xfs-$(CONFIG_PROC_FS) += $(XFS_LINUX)/xfs_stats.o
44xfs-$(CONFIG_SYSCTL) += $(XFS_LINUX)/xfs_sysctl.o
45xfs-$(CONFIG_COMPAT) += $(XFS_LINUX)/xfs_ioctl32.o
46
47
48xfs-y += xfs_alloc.o \
49 xfs_alloc_btree.o \
50 xfs_attr.o \
51 xfs_attr_leaf.o \
52 xfs_bit.o \
53 xfs_bmap.o \
54 xfs_bmap_btree.o \
55 xfs_btree.o \
56 xfs_buf_item.o \
57 xfs_da_btree.o \
58 xfs_dir2.o \
59 xfs_dir2_block.o \
60 xfs_dir2_data.o \
61 xfs_dir2_leaf.o \
62 xfs_dir2_node.o \
63 xfs_dir2_sf.o \
64 xfs_error.o \
65 xfs_extfree_item.o \
66 xfs_filestream.o \
67 xfs_fsops.o \
68 xfs_ialloc.o \
69 xfs_ialloc_btree.o \
70 xfs_iget.o \
71 xfs_inode.o \
72 xfs_inode_item.o \
73 xfs_iomap.o \
74 xfs_itable.o \
75 xfs_dfrag.o \
76 xfs_log.o \
77 xfs_log_recover.o \
78 xfs_mount.o \
79 xfs_mru_cache.o \
80 xfs_rename.o \
81 xfs_trans.o \
82 xfs_trans_ail.o \
83 xfs_trans_buf.o \
84 xfs_trans_extfree.o \
85 xfs_trans_inode.o \
86 xfs_trans_item.o \
87 xfs_utils.o \
88 xfs_vfsops.o \
89 xfs_vnodeops.o \
90 xfs_rw.o \
91 xfs_dmops.o \
92 xfs_qmops.o
93
94xfs-$(CONFIG_XFS_TRACE) += xfs_dir2_trace.o
95
96# Objects in linux/
97xfs-y += $(addprefix $(XFS_LINUX)/, \
98 kmem.o \
99 xfs_aops.o \
100 xfs_buf.o \
101 xfs_export.o \
102 xfs_file.o \
103 xfs_fs_subr.o \
104 xfs_globals.o \
105 xfs_ioctl.o \
106 xfs_iops.o \
107 xfs_lrw.o \
108 xfs_super.o \
109 xfs_vnode.o)
110
111# Objects in support/
112xfs-y += $(addprefix support/, \
113 debug.o \
114 uuid.o)
115
116xfs-$(CONFIG_XFS_TRACE) += support/ktrace.o
117
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6
deleted file mode 100644
index 97316451fc6d..000000000000
--- a/fs/xfs/Makefile-linux-2.6
+++ /dev/null
@@ -1,117 +0,0 @@
1#
2# Copyright (c) 2000-2005 Silicon Graphics, Inc.
3# All Rights Reserved.
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it would be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write the Free Software Foundation,
16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17#
18
19EXTRA_CFLAGS += -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char
20
21XFS_LINUX := linux-2.6
22
23ifeq ($(CONFIG_XFS_DEBUG),y)
24 EXTRA_CFLAGS += -g
25endif
26
27obj-$(CONFIG_XFS_FS) += xfs.o
28
29xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \
30 xfs_dquot.o \
31 xfs_dquot_item.o \
32 xfs_trans_dquot.o \
33 xfs_qm_syscalls.o \
34 xfs_qm_bhv.o \
35 xfs_qm.o)
36
37ifeq ($(CONFIG_XFS_QUOTA),y)
38xfs-$(CONFIG_PROC_FS) += quota/xfs_qm_stats.o
39endif
40
41xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
42xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
43xfs-$(CONFIG_PROC_FS) += $(XFS_LINUX)/xfs_stats.o
44xfs-$(CONFIG_SYSCTL) += $(XFS_LINUX)/xfs_sysctl.o
45xfs-$(CONFIG_COMPAT) += $(XFS_LINUX)/xfs_ioctl32.o
46
47
48xfs-y += xfs_alloc.o \
49 xfs_alloc_btree.o \
50 xfs_attr.o \
51 xfs_attr_leaf.o \
52 xfs_bit.o \
53 xfs_bmap.o \
54 xfs_bmap_btree.o \
55 xfs_btree.o \
56 xfs_buf_item.o \
57 xfs_da_btree.o \
58 xfs_dir2.o \
59 xfs_dir2_block.o \
60 xfs_dir2_data.o \
61 xfs_dir2_leaf.o \
62 xfs_dir2_node.o \
63 xfs_dir2_sf.o \
64 xfs_error.o \
65 xfs_extfree_item.o \
66 xfs_filestream.o \
67 xfs_fsops.o \
68 xfs_ialloc.o \
69 xfs_ialloc_btree.o \
70 xfs_iget.o \
71 xfs_inode.o \
72 xfs_inode_item.o \
73 xfs_iomap.o \
74 xfs_itable.o \
75 xfs_dfrag.o \
76 xfs_log.o \
77 xfs_log_recover.o \
78 xfs_mount.o \
79 xfs_mru_cache.o \
80 xfs_rename.o \
81 xfs_trans.o \
82 xfs_trans_ail.o \
83 xfs_trans_buf.o \
84 xfs_trans_extfree.o \
85 xfs_trans_inode.o \
86 xfs_trans_item.o \
87 xfs_utils.o \
88 xfs_vfsops.o \
89 xfs_vnodeops.o \
90 xfs_rw.o \
91 xfs_dmops.o \
92 xfs_qmops.o
93
94xfs-$(CONFIG_XFS_TRACE) += xfs_dir2_trace.o
95
96# Objects in linux/
97xfs-y += $(addprefix $(XFS_LINUX)/, \
98 kmem.o \
99 xfs_aops.o \
100 xfs_buf.o \
101 xfs_export.o \
102 xfs_file.o \
103 xfs_fs_subr.o \
104 xfs_globals.o \
105 xfs_ioctl.o \
106 xfs_iops.o \
107 xfs_lrw.o \
108 xfs_super.o \
109 xfs_vnode.o)
110
111# Objects in support/
112xfs-y += $(addprefix support/, \
113 debug.o \
114 uuid.o)
115
116xfs-$(CONFIG_XFS_TRACE) += support/ktrace.o
117
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 21dfc9da235e..8831d9518790 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -171,7 +171,7 @@ xfs_parseargs(
171 char *this_char, *value, *eov; 171 char *this_char, *value, *eov;
172 int dsunit, dswidth, vol_dsunit, vol_dswidth; 172 int dsunit, dswidth, vol_dsunit, vol_dswidth;
173 int iosize; 173 int iosize;
174 int ikeep = 0; 174 int dmapi_implies_ikeep = 1;
175 175
176 args->flags |= XFSMNT_BARRIER; 176 args->flags |= XFSMNT_BARRIER;
177 args->flags2 |= XFSMNT2_COMPAT_IOSIZE; 177 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
@@ -302,10 +302,10 @@ xfs_parseargs(
302 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) { 302 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
303 args->flags &= ~XFSMNT_BARRIER; 303 args->flags &= ~XFSMNT_BARRIER;
304 } else if (!strcmp(this_char, MNTOPT_IKEEP)) { 304 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
305 ikeep = 1; 305 args->flags |= XFSMNT_IKEEP;
306 args->flags &= ~XFSMNT_IDELETE;
307 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { 306 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
308 args->flags |= XFSMNT_IDELETE; 307 dmapi_implies_ikeep = 0;
308 args->flags &= ~XFSMNT_IKEEP;
309 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { 309 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
310 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE; 310 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
311 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { 311 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
@@ -410,8 +410,8 @@ xfs_parseargs(
410 * Note that if "ikeep" or "noikeep" mount options are 410 * Note that if "ikeep" or "noikeep" mount options are
411 * supplied, then they are honored. 411 * supplied, then they are honored.
412 */ 412 */
413 if (!(args->flags & XFSMNT_DMAPI) && !ikeep) 413 if ((args->flags & XFSMNT_DMAPI) && dmapi_implies_ikeep)
414 args->flags |= XFSMNT_IDELETE; 414 args->flags |= XFSMNT_IKEEP;
415 415
416 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { 416 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
417 if (dsunit) { 417 if (dsunit) {
@@ -446,6 +446,7 @@ xfs_showargs(
446{ 446{
447 static struct proc_xfs_info xfs_info_set[] = { 447 static struct proc_xfs_info xfs_info_set[] = {
448 /* the few simple ones we can get from the mount struct */ 448 /* the few simple ones we can get from the mount struct */
449 { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
449 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC }, 450 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
450 { XFS_MOUNT_INO64, "," MNTOPT_INO64 }, 451 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
451 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN }, 452 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
@@ -461,7 +462,6 @@ xfs_showargs(
461 }; 462 };
462 static struct proc_xfs_info xfs_info_unset[] = { 463 static struct proc_xfs_info xfs_info_unset[] = {
463 /* the few simple ones we can get from the mount struct */ 464 /* the few simple ones we can get from the mount struct */
464 { XFS_MOUNT_IDELETE, "," MNTOPT_IKEEP },
465 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO }, 465 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
466 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER }, 466 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
467 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE }, 467 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 48228848f5ae..fab0b6d5a41b 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -25,6 +25,109 @@
25 * XFS bit manipulation routines, used in non-realtime code. 25 * XFS bit manipulation routines, used in non-realtime code.
26 */ 26 */
27 27
28#ifndef HAVE_ARCH_HIGHBIT
29/*
30 * Index of high bit number in byte, -1 for none set, 0..7 otherwise.
31 */
32static const char xfs_highbit[256] = {
33 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */
34 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */
35 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */
36 4, 4, 4, 4, 4, 4, 4, 4, /* 18 .. 1f */
37 5, 5, 5, 5, 5, 5, 5, 5, /* 20 .. 27 */
38 5, 5, 5, 5, 5, 5, 5, 5, /* 28 .. 2f */
39 5, 5, 5, 5, 5, 5, 5, 5, /* 30 .. 37 */
40 5, 5, 5, 5, 5, 5, 5, 5, /* 38 .. 3f */
41 6, 6, 6, 6, 6, 6, 6, 6, /* 40 .. 47 */
42 6, 6, 6, 6, 6, 6, 6, 6, /* 48 .. 4f */
43 6, 6, 6, 6, 6, 6, 6, 6, /* 50 .. 57 */
44 6, 6, 6, 6, 6, 6, 6, 6, /* 58 .. 5f */
45 6, 6, 6, 6, 6, 6, 6, 6, /* 60 .. 67 */
46 6, 6, 6, 6, 6, 6, 6, 6, /* 68 .. 6f */
47 6, 6, 6, 6, 6, 6, 6, 6, /* 70 .. 77 */
48 6, 6, 6, 6, 6, 6, 6, 6, /* 78 .. 7f */
49 7, 7, 7, 7, 7, 7, 7, 7, /* 80 .. 87 */
50 7, 7, 7, 7, 7, 7, 7, 7, /* 88 .. 8f */
51 7, 7, 7, 7, 7, 7, 7, 7, /* 90 .. 97 */
52 7, 7, 7, 7, 7, 7, 7, 7, /* 98 .. 9f */
53 7, 7, 7, 7, 7, 7, 7, 7, /* a0 .. a7 */
54 7, 7, 7, 7, 7, 7, 7, 7, /* a8 .. af */
55 7, 7, 7, 7, 7, 7, 7, 7, /* b0 .. b7 */
56 7, 7, 7, 7, 7, 7, 7, 7, /* b8 .. bf */
57 7, 7, 7, 7, 7, 7, 7, 7, /* c0 .. c7 */
58 7, 7, 7, 7, 7, 7, 7, 7, /* c8 .. cf */
59 7, 7, 7, 7, 7, 7, 7, 7, /* d0 .. d7 */
60 7, 7, 7, 7, 7, 7, 7, 7, /* d8 .. df */
61 7, 7, 7, 7, 7, 7, 7, 7, /* e0 .. e7 */
62 7, 7, 7, 7, 7, 7, 7, 7, /* e8 .. ef */
63 7, 7, 7, 7, 7, 7, 7, 7, /* f0 .. f7 */
64 7, 7, 7, 7, 7, 7, 7, 7, /* f8 .. ff */
65};
66#endif
67
68/*
69 * xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set.
70 */
71inline int
72xfs_highbit32(
73 __uint32_t v)
74{
75#ifdef HAVE_ARCH_HIGHBIT
76 return highbit32(v);
77#else
78 int i;
79
80 if (v & 0xffff0000)
81 if (v & 0xff000000)
82 i = 24;
83 else
84 i = 16;
85 else if (v & 0x0000ffff)
86 if (v & 0x0000ff00)
87 i = 8;
88 else
89 i = 0;
90 else
91 return -1;
92 return i + xfs_highbit[(v >> i) & 0xff];
93#endif
94}
95
96/*
97 * xfs_lowbit64: get low bit set out of 64-bit argument, -1 if none set.
98 */
99int
100xfs_lowbit64(
101 __uint64_t v)
102{
103 __uint32_t w = (__uint32_t)v;
104 int n = 0;
105
106 if (w) { /* lower bits */
107 n = ffs(w);
108 } else { /* upper bits */
109 w = (__uint32_t)(v >> 32);
110 if (w && (n = ffs(w)))
111 n += 32;
112 }
113 return n - 1;
114}
115
116/*
117 * xfs_highbit64: get high bit set out of 64-bit argument, -1 if none set.
118 */
119int
120xfs_highbit64(
121 __uint64_t v)
122{
123 __uint32_t h = (__uint32_t)(v >> 32);
124
125 if (h)
126 return xfs_highbit32(h) + 32;
127 return xfs_highbit32((__uint32_t)v);
128}
129
130
28/* 131/*
29 * Return whether bitmap is empty. 132 * Return whether bitmap is empty.
30 * Size is number of words in the bitmap, which is padded to word boundary 133 * Size is number of words in the bitmap, which is padded to word boundary
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 325a007dec91..082641a9782c 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -47,30 +47,13 @@ static inline __uint64_t xfs_mask64lo(int n)
47} 47}
48 48
49/* Get high bit set out of 32-bit argument, -1 if none set */ 49/* Get high bit set out of 32-bit argument, -1 if none set */
50static inline int xfs_highbit32(__uint32_t v) 50extern int xfs_highbit32(__uint32_t v);
51{
52 return fls(v) - 1;
53}
54
55/* Get high bit set out of 64-bit argument, -1 if none set */
56static inline int xfs_highbit64(__uint64_t v)
57{
58 return fls64(v) - 1;
59}
60
61/* Get low bit set out of 32-bit argument, -1 if none set */
62static inline int xfs_lowbit32(__uint32_t v)
63{
64 __uint32_t t = v;
65 return (t) ? find_first_bit((unsigned long *)&t, 32) : -1;
66}
67 51
68/* Get low bit set out of 64-bit argument, -1 if none set */ 52/* Get low bit set out of 64-bit argument, -1 if none set */
69static inline int xfs_lowbit64(__uint64_t v) 53extern int xfs_lowbit64(__uint64_t v);
70{ 54
71 __uint64_t t = v; 55/* Get high bit set out of 64-bit argument, -1 if none set */
72 return (t) ? find_first_bit((unsigned long *)&t, 64) : -1; 56extern int xfs_highbit64(__uint64_t);
73}
74 57
75/* Return whether bitmap is empty (1 == empty) */ 58/* Return whether bitmap is empty (1 == empty) */
76extern int xfs_bitmap_empty(uint *map, uint size); 59extern int xfs_bitmap_empty(uint *map, uint size);
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h
index d16c1b971074..d5d1e60ee224 100644
--- a/fs/xfs/xfs_clnt.h
+++ b/fs/xfs/xfs_clnt.h
@@ -86,7 +86,7 @@ struct xfs_mount_args {
86#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ 86#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */
87#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ 87#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */
88#define XFSMNT_BARRIER 0x04000000 /* use write barriers */ 88#define XFSMNT_BARRIER 0x04000000 /* use write barriers */
89#define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ 89#define XFSMNT_IKEEP 0x08000000 /* inode cluster delete */
90#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width 90#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width
91 * allocation */ 91 * allocation */
92#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename 92#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index c5836b951d0c..db9d5fa600af 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -1053,7 +1053,7 @@ xfs_difree(
1053 /* 1053 /*
1054 * When an inode cluster is free, it becomes eligible for removal 1054 * When an inode cluster is free, it becomes eligible for removal
1055 */ 1055 */
1056 if ((mp->m_flags & XFS_MOUNT_IDELETE) && 1056 if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
1057 (rec.ir_freecount == XFS_IALLOC_INODES(mp))) { 1057 (rec.ir_freecount == XFS_IALLOC_INODES(mp))) {
1058 1058
1059 *delete = 1; 1059 *delete = 1;
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index f7c620ec6e69..1d8a4728d847 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -366,7 +366,7 @@ typedef struct xfs_mount {
366#define XFS_MOUNT_SMALL_INUMS (1ULL << 15) /* users wants 32bit inodes */ 366#define XFS_MOUNT_SMALL_INUMS (1ULL << 15) /* users wants 32bit inodes */
367#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */ 367#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */
368#define XFS_MOUNT_BARRIER (1ULL << 17) 368#define XFS_MOUNT_BARRIER (1ULL << 17)
369#define XFS_MOUNT_IDELETE (1ULL << 18) /* delete empty inode clusters*/ 369#define XFS_MOUNT_IKEEP (1ULL << 18) /* keep empty inode clusters*/
370#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width 370#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width
371 * allocation */ 371 * allocation */
372#define XFS_MOUNT_RDONLY (1ULL << 20) /* read-only fs */ 372#define XFS_MOUNT_RDONLY (1ULL << 20) /* read-only fs */
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index ca83ddf72af4..47082c01872d 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -73,6 +73,18 @@ STATIC int xfs_rtmodify_summary(xfs_mount_t *, xfs_trans_t *, int,
73 */ 73 */
74 74
75/* 75/*
76 * xfs_lowbit32: get low bit set out of 32-bit argument, -1 if none set.
77 */
78STATIC int
79xfs_lowbit32(
80 __uint32_t v)
81{
82 if (v)
83 return ffs(v) - 1;
84 return -1;
85}
86
87/*
76 * Allocate space to the bitmap or summary file, and zero it, for growfs. 88 * Allocate space to the bitmap or summary file, and zero it, for growfs.
77 */ 89 */
78STATIC int /* error */ 90STATIC int /* error */
@@ -432,7 +444,6 @@ xfs_rtallocate_extent_near(
432 } 444 }
433 bbno = XFS_BITTOBLOCK(mp, bno); 445 bbno = XFS_BITTOBLOCK(mp, bno);
434 i = 0; 446 i = 0;
435 ASSERT(minlen != 0);
436 log2len = xfs_highbit32(minlen); 447 log2len = xfs_highbit32(minlen);
437 /* 448 /*
438 * Loop over all bitmap blocks (bbno + i is current block). 449 * Loop over all bitmap blocks (bbno + i is current block).
@@ -601,8 +612,6 @@ xfs_rtallocate_extent_size(
601 xfs_suminfo_t sum; /* summary information for extents */ 612 xfs_suminfo_t sum; /* summary information for extents */
602 613
603 ASSERT(minlen % prod == 0 && maxlen % prod == 0); 614 ASSERT(minlen % prod == 0 && maxlen % prod == 0);
604 ASSERT(maxlen != 0);
605
606 /* 615 /*
607 * Loop over all the levels starting with maxlen. 616 * Loop over all the levels starting with maxlen.
608 * At each level, look at all the bitmap blocks, to see if there 617 * At each level, look at all the bitmap blocks, to see if there
@@ -660,9 +669,6 @@ xfs_rtallocate_extent_size(
660 *rtblock = NULLRTBLOCK; 669 *rtblock = NULLRTBLOCK;
661 return 0; 670 return 0;
662 } 671 }
663 ASSERT(minlen != 0);
664 ASSERT(maxlen != 0);
665
666 /* 672 /*
667 * Loop over sizes, from maxlen down to minlen. 673 * Loop over sizes, from maxlen down to minlen.
668 * This time, when we do the allocations, allow smaller ones 674 * This time, when we do the allocations, allow smaller ones
@@ -1948,7 +1954,6 @@ xfs_growfs_rt(
1948 nsbp->sb_blocksize * nsbp->sb_rextsize); 1954 nsbp->sb_blocksize * nsbp->sb_rextsize);
1949 nsbp->sb_rextents = nsbp->sb_rblocks; 1955 nsbp->sb_rextents = nsbp->sb_rblocks;
1950 do_div(nsbp->sb_rextents, nsbp->sb_rextsize); 1956 do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
1951 ASSERT(nsbp->sb_rextents != 0);
1952 nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents); 1957 nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
1953 nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1; 1958 nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;
1954 nrsumsize = 1959 nrsumsize =
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 413587f02155..7321304a69cc 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -281,8 +281,8 @@ xfs_start_flags(
281 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog; 281 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
282 } 282 }
283 283
284 if (ap->flags & XFSMNT_IDELETE) 284 if (ap->flags & XFSMNT_IKEEP)
285 mp->m_flags |= XFS_MOUNT_IDELETE; 285 mp->m_flags |= XFS_MOUNT_IKEEP;
286 if (ap->flags & XFSMNT_DIRSYNC) 286 if (ap->flags & XFSMNT_DIRSYNC)
287 mp->m_flags |= XFS_MOUNT_DIRSYNC; 287 mp->m_flags |= XFS_MOUNT_DIRSYNC;
288 if (ap->flags & XFSMNT_ATTR2) 288 if (ap->flags & XFSMNT_ATTR2)