aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/adfs/dir_f.c2
-rw-r--r--fs/aio.c7
-rw-r--r--fs/bad_inode.c330
-rw-r--r--fs/binfmt_elf.c8
-rw-r--r--fs/block_dev.c12
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cifs/file.c26
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/jffs/jffs_fm.c3
-rw-r--r--fs/jffs2/debug.c4
-rw-r--r--fs/jffs2/debug.h1
-rw-r--r--fs/jffs2/fs.c3
-rw-r--r--fs/jffs2/gc.c2
-rw-r--r--fs/jffs2/nodelist.h10
-rw-r--r--fs/jffs2/readinode.c3
-rw-r--r--fs/jffs2/scan.c6
-rw-r--r--fs/jffs2/summary.c6
-rw-r--r--fs/jffs2/super.c7
-rw-r--r--fs/jffs2/symlink.c2
-rw-r--r--fs/jffs2/wbuf.c21
-rw-r--r--fs/jffs2/xattr.c5
-rw-r--r--fs/nfs/file.c16
-rw-r--r--fs/ntfs/ChangeLog7
-rw-r--r--fs/ntfs/Makefile2
-rw-r--r--fs/ntfs/dir.c45
-rw-r--r--fs/ntfs/inode.c69
-rw-r--r--fs/ntfs/inode.h6
-rw-r--r--fs/ntfs/super.c7
-rw-r--r--fs/ocfs2/aops.c24
-rw-r--r--fs/ocfs2/cluster/heartbeat.c17
-rw-r--r--fs/ocfs2/dlmglue.c10
-rw-r--r--fs/ocfs2/export.c5
-rw-r--r--fs/ocfs2/file.c13
-rw-r--r--fs/ocfs2/inode.c11
-rw-r--r--fs/ocfs2/namei.c69
-rw-r--r--fs/ocfs2/ocfs2_fs.h43
-rw-r--r--fs/ocfs2/symlink.c3
-rw-r--r--fs/proc/proc_misc.c8
-rw-r--r--fs/ramfs/file-mmu.c4
-rw-r--r--fs/ramfs/file-nommu.c4
-rw-r--r--fs/reiserfs/file.c20
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/stree.c2
-rw-r--r--fs/super.c4
-rw-r--r--fs/ufs/balloc.c25
-rw-r--r--fs/ufs/inode.c41
46 files changed, 626 insertions, 299 deletions
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
index bbfc86259272..b9b2b27b68c3 100644
--- a/fs/adfs/dir_f.c
+++ b/fs/adfs/dir_f.c
@@ -53,7 +53,7 @@ static inline int adfs_readname(char *buf, char *ptr, int maxlen)
53{ 53{
54 char *old_buf = buf; 54 char *old_buf = buf;
55 55
56 while (*ptr >= ' ' && maxlen--) { 56 while ((unsigned char)*ptr >= ' ' && maxlen--) {
57 if (*ptr == '/') 57 if (*ptr == '/')
58 *buf++ = '.'; 58 *buf++ = '.';
59 else 59 else
diff --git a/fs/aio.c b/fs/aio.c
index 5f577a63bdf0..ee20fc4240e0 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -599,9 +599,6 @@ static void use_mm(struct mm_struct *mm)
599 * by the calling kernel thread 599 * by the calling kernel thread
600 * (Note: this routine is intended to be called only 600 * (Note: this routine is intended to be called only
601 * from a kernel thread context) 601 * from a kernel thread context)
602 *
603 * Comments: Called with ctx->ctx_lock held. This nests
604 * task_lock instead ctx_lock.
605 */ 602 */
606static void unuse_mm(struct mm_struct *mm) 603static void unuse_mm(struct mm_struct *mm)
607{ 604{
@@ -850,14 +847,16 @@ static void aio_kick_handler(struct work_struct *work)
850{ 847{
851 struct kioctx *ctx = container_of(work, struct kioctx, wq.work); 848 struct kioctx *ctx = container_of(work, struct kioctx, wq.work);
852 mm_segment_t oldfs = get_fs(); 849 mm_segment_t oldfs = get_fs();
850 struct mm_struct *mm;
853 int requeue; 851 int requeue;
854 852
855 set_fs(USER_DS); 853 set_fs(USER_DS);
856 use_mm(ctx->mm); 854 use_mm(ctx->mm);
857 spin_lock_irq(&ctx->ctx_lock); 855 spin_lock_irq(&ctx->ctx_lock);
858 requeue =__aio_run_iocbs(ctx); 856 requeue =__aio_run_iocbs(ctx);
859 unuse_mm(ctx->mm); 857 mm = ctx->mm;
860 spin_unlock_irq(&ctx->ctx_lock); 858 spin_unlock_irq(&ctx->ctx_lock);
859 unuse_mm(mm);
861 set_fs(oldfs); 860 set_fs(oldfs);
862 /* 861 /*
863 * we're in a worker thread already, don't use queue_delayed_work, 862 * we're in a worker thread already, don't use queue_delayed_work,
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 34e6d7b220c3..869f5193ecc2 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -14,59 +14,307 @@
14#include <linux/time.h> 14#include <linux/time.h>
15#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
16#include <linux/namei.h> 16#include <linux/namei.h>
17#include <linux/poll.h>
17 18
18static int return_EIO(void) 19
20static loff_t bad_file_llseek(struct file *file, loff_t offset, int origin)
21{
22 return -EIO;
23}
24
25static ssize_t bad_file_read(struct file *filp, char __user *buf,
26 size_t size, loff_t *ppos)
27{
28 return -EIO;
29}
30
31static ssize_t bad_file_write(struct file *filp, const char __user *buf,
32 size_t siz, loff_t *ppos)
33{
34 return -EIO;
35}
36
37static ssize_t bad_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
38 unsigned long nr_segs, loff_t pos)
39{
40 return -EIO;
41}
42
43static ssize_t bad_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
44 unsigned long nr_segs, loff_t pos)
45{
46 return -EIO;
47}
48
49static int bad_file_readdir(struct file *filp, void *dirent, filldir_t filldir)
50{
51 return -EIO;
52}
53
54static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
55{
56 return POLLERR;
57}
58
59static int bad_file_ioctl (struct inode *inode, struct file *filp,
60 unsigned int cmd, unsigned long arg)
61{
62 return -EIO;
63}
64
65static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd,
66 unsigned long arg)
67{
68 return -EIO;
69}
70
71static long bad_file_compat_ioctl(struct file *file, unsigned int cmd,
72 unsigned long arg)
73{
74 return -EIO;
75}
76
77static int bad_file_mmap(struct file *file, struct vm_area_struct *vma)
78{
79 return -EIO;
80}
81
82static int bad_file_open(struct inode *inode, struct file *filp)
83{
84 return -EIO;
85}
86
87static int bad_file_flush(struct file *file, fl_owner_t id)
88{
89 return -EIO;
90}
91
92static int bad_file_release(struct inode *inode, struct file *filp)
93{
94 return -EIO;
95}
96
97static int bad_file_fsync(struct file *file, struct dentry *dentry,
98 int datasync)
99{
100 return -EIO;
101}
102
103static int bad_file_aio_fsync(struct kiocb *iocb, int datasync)
104{
105 return -EIO;
106}
107
108static int bad_file_fasync(int fd, struct file *filp, int on)
109{
110 return -EIO;
111}
112
113static int bad_file_lock(struct file *file, int cmd, struct file_lock *fl)
114{
115 return -EIO;
116}
117
118static ssize_t bad_file_sendfile(struct file *in_file, loff_t *ppos,
119 size_t count, read_actor_t actor, void *target)
120{
121 return -EIO;
122}
123
124static ssize_t bad_file_sendpage(struct file *file, struct page *page,
125 int off, size_t len, loff_t *pos, int more)
126{
127 return -EIO;
128}
129
130static unsigned long bad_file_get_unmapped_area(struct file *file,
131 unsigned long addr, unsigned long len,
132 unsigned long pgoff, unsigned long flags)
133{
134 return -EIO;
135}
136
137static int bad_file_check_flags(int flags)
19{ 138{
20 return -EIO; 139 return -EIO;
21} 140}
22 141
23#define EIO_ERROR ((void *) (return_EIO)) 142static int bad_file_dir_notify(struct file *file, unsigned long arg)
143{
144 return -EIO;
145}
146
147static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl)
148{
149 return -EIO;
150}
151
152static ssize_t bad_file_splice_write(struct pipe_inode_info *pipe,
153 struct file *out, loff_t *ppos, size_t len,
154 unsigned int flags)
155{
156 return -EIO;
157}
158
159static ssize_t bad_file_splice_read(struct file *in, loff_t *ppos,
160 struct pipe_inode_info *pipe, size_t len,
161 unsigned int flags)
162{
163 return -EIO;
164}
24 165
25static const struct file_operations bad_file_ops = 166static const struct file_operations bad_file_ops =
26{ 167{
27 .llseek = EIO_ERROR, 168 .llseek = bad_file_llseek,
28 .aio_read = EIO_ERROR, 169 .read = bad_file_read,
29 .read = EIO_ERROR, 170 .write = bad_file_write,
30 .write = EIO_ERROR, 171 .aio_read = bad_file_aio_read,
31 .aio_write = EIO_ERROR, 172 .aio_write = bad_file_aio_write,
32 .readdir = EIO_ERROR, 173 .readdir = bad_file_readdir,
33 .poll = EIO_ERROR, 174 .poll = bad_file_poll,
34 .ioctl = EIO_ERROR, 175 .ioctl = bad_file_ioctl,
35 .mmap = EIO_ERROR, 176 .unlocked_ioctl = bad_file_unlocked_ioctl,
36 .open = EIO_ERROR, 177 .compat_ioctl = bad_file_compat_ioctl,
37 .flush = EIO_ERROR, 178 .mmap = bad_file_mmap,
38 .release = EIO_ERROR, 179 .open = bad_file_open,
39 .fsync = EIO_ERROR, 180 .flush = bad_file_flush,
40 .aio_fsync = EIO_ERROR, 181 .release = bad_file_release,
41 .fasync = EIO_ERROR, 182 .fsync = bad_file_fsync,
42 .lock = EIO_ERROR, 183 .aio_fsync = bad_file_aio_fsync,
43 .sendfile = EIO_ERROR, 184 .fasync = bad_file_fasync,
44 .sendpage = EIO_ERROR, 185 .lock = bad_file_lock,
45 .get_unmapped_area = EIO_ERROR, 186 .sendfile = bad_file_sendfile,
187 .sendpage = bad_file_sendpage,
188 .get_unmapped_area = bad_file_get_unmapped_area,
189 .check_flags = bad_file_check_flags,
190 .dir_notify = bad_file_dir_notify,
191 .flock = bad_file_flock,
192 .splice_write = bad_file_splice_write,
193 .splice_read = bad_file_splice_read,
46}; 194};
47 195
196static int bad_inode_create (struct inode *dir, struct dentry *dentry,
197 int mode, struct nameidata *nd)
198{
199 return -EIO;
200}
201
202static struct dentry *bad_inode_lookup(struct inode *dir,
203 struct dentry *dentry, struct nameidata *nd)
204{
205 return ERR_PTR(-EIO);
206}
207
208static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
209 struct dentry *dentry)
210{
211 return -EIO;
212}
213
214static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
215{
216 return -EIO;
217}
218
219static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
220 const char *symname)
221{
222 return -EIO;
223}
224
225static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
226 int mode)
227{
228 return -EIO;
229}
230
231static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
232{
233 return -EIO;
234}
235
236static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
237 int mode, dev_t rdev)
238{
239 return -EIO;
240}
241
242static int bad_inode_rename (struct inode *old_dir, struct dentry *old_dentry,
243 struct inode *new_dir, struct dentry *new_dentry)
244{
245 return -EIO;
246}
247
248static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
249 int buflen)
250{
251 return -EIO;
252}
253
254static int bad_inode_permission(struct inode *inode, int mask,
255 struct nameidata *nd)
256{
257 return -EIO;
258}
259
260static int bad_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
261 struct kstat *stat)
262{
263 return -EIO;
264}
265
266static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
267{
268 return -EIO;
269}
270
271static int bad_inode_setxattr(struct dentry *dentry, const char *name,
272 const void *value, size_t size, int flags)
273{
274 return -EIO;
275}
276
277static ssize_t bad_inode_getxattr(struct dentry *dentry, const char *name,
278 void *buffer, size_t size)
279{
280 return -EIO;
281}
282
283static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
284 size_t buffer_size)
285{
286 return -EIO;
287}
288
289static int bad_inode_removexattr(struct dentry *dentry, const char *name)
290{
291 return -EIO;
292}
293
48static struct inode_operations bad_inode_ops = 294static struct inode_operations bad_inode_ops =
49{ 295{
50 .create = EIO_ERROR, 296 .create = bad_inode_create,
51 .lookup = EIO_ERROR, 297 .lookup = bad_inode_lookup,
52 .link = EIO_ERROR, 298 .link = bad_inode_link,
53 .unlink = EIO_ERROR, 299 .unlink = bad_inode_unlink,
54 .symlink = EIO_ERROR, 300 .symlink = bad_inode_symlink,
55 .mkdir = EIO_ERROR, 301 .mkdir = bad_inode_mkdir,
56 .rmdir = EIO_ERROR, 302 .rmdir = bad_inode_rmdir,
57 .mknod = EIO_ERROR, 303 .mknod = bad_inode_mknod,
58 .rename = EIO_ERROR, 304 .rename = bad_inode_rename,
59 .readlink = EIO_ERROR, 305 .readlink = bad_inode_readlink,
60 /* follow_link must be no-op, otherwise unmounting this inode 306 /* follow_link must be no-op, otherwise unmounting this inode
61 won't work */ 307 won't work */
62 .truncate = EIO_ERROR, 308 /* put_link returns void */
63 .permission = EIO_ERROR, 309 /* truncate returns void */
64 .getattr = EIO_ERROR, 310 .permission = bad_inode_permission,
65 .setattr = EIO_ERROR, 311 .getattr = bad_inode_getattr,
66 .setxattr = EIO_ERROR, 312 .setattr = bad_inode_setattr,
67 .getxattr = EIO_ERROR, 313 .setxattr = bad_inode_setxattr,
68 .listxattr = EIO_ERROR, 314 .getxattr = bad_inode_getxattr,
69 .removexattr = EIO_ERROR, 315 .listxattr = bad_inode_listxattr,
316 .removexattr = bad_inode_removexattr,
317 /* truncate_range returns void */
70}; 318};
71 319
72 320
@@ -88,7 +336,7 @@ static struct inode_operations bad_inode_ops =
88 * on it to fail from this point on. 336 * on it to fail from this point on.
89 */ 337 */
90 338
91void make_bad_inode(struct inode * inode) 339void make_bad_inode(struct inode *inode)
92{ 340{
93 remove_inode_hash(inode); 341 remove_inode_hash(inode);
94 342
@@ -113,7 +361,7 @@ EXPORT_SYMBOL(make_bad_inode);
113 * Returns true if the inode in question has been marked as bad. 361 * Returns true if the inode in question has been marked as bad.
114 */ 362 */
115 363
116int is_bad_inode(struct inode * inode) 364int is_bad_inode(struct inode *inode)
117{ 365{
118 return (inode->i_op == &bad_inode_ops); 366 return (inode->i_op == &bad_inode_ops);
119} 367}
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index d3adfd353ff9..7cb28720f90e 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -854,13 +854,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
854 * default mmap base, as well as whatever program they 854 * default mmap base, as well as whatever program they
855 * might try to exec. This is because the brk will 855 * might try to exec. This is because the brk will
856 * follow the loader, and is not movable. */ 856 * follow the loader, and is not movable. */
857 if (current->flags & PF_RANDOMIZE) 857 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
858 load_bias = randomize_range(0x10000,
859 ELF_ET_DYN_BASE,
860 0);
861 else
862 load_bias = ELF_ET_DYN_BASE;
863 load_bias = ELF_PAGESTART(load_bias - vaddr);
864 } 858 }
865 859
866 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, 860 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1715d6b5f411..d9bdf2b3ade2 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -146,7 +146,7 @@ static int blk_end_aio(struct bio *bio, unsigned int bytes_done, int error)
146 iocb->ki_nbytes = -EIO; 146 iocb->ki_nbytes = -EIO;
147 147
148 if (atomic_dec_and_test(bio_count)) { 148 if (atomic_dec_and_test(bio_count)) {
149 if (iocb->ki_nbytes < 0) 149 if ((long)iocb->ki_nbytes < 0)
150 aio_complete(iocb, iocb->ki_nbytes, 0); 150 aio_complete(iocb, iocb->ki_nbytes, 0);
151 else 151 else
152 aio_complete(iocb, iocb->ki_left, 0); 152 aio_complete(iocb, iocb->ki_left, 0);
@@ -190,6 +190,12 @@ static struct page *blk_get_page(unsigned long addr, size_t count, int rw,
190 return pvec->page[pvec->idx++]; 190 return pvec->page[pvec->idx++];
191} 191}
192 192
193/* return a page back to pvec array */
194static void blk_unget_page(struct page *page, struct pvec *pvec)
195{
196 pvec->page[--pvec->idx] = page;
197}
198
193static ssize_t 199static ssize_t
194blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 200blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
195 loff_t pos, unsigned long nr_segs) 201 loff_t pos, unsigned long nr_segs)
@@ -278,6 +284,8 @@ same_bio:
278 count = min(count, nbytes); 284 count = min(count, nbytes);
279 goto same_bio; 285 goto same_bio;
280 } 286 }
287 } else {
288 blk_unget_page(page, &pvec);
281 } 289 }
282 290
283 /* bio is ready, submit it */ 291 /* bio is ready, submit it */
@@ -411,7 +419,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
411 { 419 {
412 memset(bdev, 0, sizeof(*bdev)); 420 memset(bdev, 0, sizeof(*bdev));
413 mutex_init(&bdev->bd_mutex); 421 mutex_init(&bdev->bd_mutex);
414 mutex_init(&bdev->bd_mount_mutex); 422 sema_init(&bdev->bd_mount_sem, 1);
415 INIT_LIST_HEAD(&bdev->bd_inodes); 423 INIT_LIST_HEAD(&bdev->bd_inodes);
416 INIT_LIST_HEAD(&bdev->bd_list); 424 INIT_LIST_HEAD(&bdev->bd_list);
417#ifdef CONFIG_SYSFS 425#ifdef CONFIG_SYSFS
diff --git a/fs/buffer.c b/fs/buffer.c
index 263f88e4dffb..3b116078b4c3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -180,7 +180,7 @@ int fsync_bdev(struct block_device *bdev)
180 * freeze_bdev -- lock a filesystem and force it into a consistent state 180 * freeze_bdev -- lock a filesystem and force it into a consistent state
181 * @bdev: blockdevice to lock 181 * @bdev: blockdevice to lock
182 * 182 *
183 * This takes the block device bd_mount_mutex to make sure no new mounts 183 * This takes the block device bd_mount_sem to make sure no new mounts
184 * happen on bdev until thaw_bdev() is called. 184 * happen on bdev until thaw_bdev() is called.
185 * If a superblock is found on this device, we take the s_umount semaphore 185 * If a superblock is found on this device, we take the s_umount semaphore
186 * on it to make sure nobody unmounts until the snapshot creation is done. 186 * on it to make sure nobody unmounts until the snapshot creation is done.
@@ -189,7 +189,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
189{ 189{
190 struct super_block *sb; 190 struct super_block *sb;
191 191
192 mutex_lock(&bdev->bd_mount_mutex); 192 down(&bdev->bd_mount_sem);
193 sb = get_super(bdev); 193 sb = get_super(bdev);
194 if (sb && !(sb->s_flags & MS_RDONLY)) { 194 if (sb && !(sb->s_flags & MS_RDONLY)) {
195 sb->s_frozen = SB_FREEZE_WRITE; 195 sb->s_frozen = SB_FREEZE_WRITE;
@@ -231,7 +231,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
231 drop_super(sb); 231 drop_super(sb);
232 } 232 }
233 233
234 mutex_unlock(&bdev->bd_mount_mutex); 234 up(&bdev->bd_mount_sem);
235} 235}
236EXPORT_SYMBOL(thaw_bdev); 236EXPORT_SYMBOL(thaw_bdev);
237 237
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 0f05cab5d24a..8a49b2e77d37 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1245,14 +1245,21 @@ retry:
1245 wait_on_page_writeback(page); 1245 wait_on_page_writeback(page);
1246 1246
1247 if (PageWriteback(page) || 1247 if (PageWriteback(page) ||
1248 !test_clear_page_dirty(page)) { 1248 !clear_page_dirty_for_io(page)) {
1249 unlock_page(page); 1249 unlock_page(page);
1250 break; 1250 break;
1251 } 1251 }
1252 1252
1253 /*
1254 * This actually clears the dirty bit in the radix tree.
1255 * See cifs_writepage() for more commentary.
1256 */
1257 set_page_writeback(page);
1258
1253 if (page_offset(page) >= mapping->host->i_size) { 1259 if (page_offset(page) >= mapping->host->i_size) {
1254 done = 1; 1260 done = 1;
1255 unlock_page(page); 1261 unlock_page(page);
1262 end_page_writeback(page);
1256 break; 1263 break;
1257 } 1264 }
1258 1265
@@ -1316,6 +1323,7 @@ retry:
1316 SetPageError(page); 1323 SetPageError(page);
1317 kunmap(page); 1324 kunmap(page);
1318 unlock_page(page); 1325 unlock_page(page);
1326 end_page_writeback(page);
1319 page_cache_release(page); 1327 page_cache_release(page);
1320 } 1328 }
1321 if ((wbc->nr_to_write -= n_iov) <= 0) 1329 if ((wbc->nr_to_write -= n_iov) <= 0)
@@ -1352,11 +1360,23 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc)
1352 if (!PageUptodate(page)) { 1360 if (!PageUptodate(page)) {
1353 cFYI(1, ("ppw - page not up to date")); 1361 cFYI(1, ("ppw - page not up to date"));
1354 } 1362 }
1355 1363
1364 /*
1365 * Set the "writeback" flag, and clear "dirty" in the radix tree.
1366 *
1367 * A writepage() implementation always needs to do either this,
1368 * or re-dirty the page with "redirty_page_for_writepage()" in
1369 * the case of a failure.
1370 *
1371 * Just unlocking the page will cause the radix tree tag-bits
1372 * to fail to update with the state of the page correctly.
1373 */
1374 set_page_writeback(page);
1356 rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE); 1375 rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE);
1357 SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ 1376 SetPageUptodate(page); /* BB add check for error and Clearuptodate? */
1358 unlock_page(page); 1377 unlock_page(page);
1359 page_cache_release(page); 1378 end_page_writeback(page);
1379 page_cache_release(page);
1360 FreeXid(xid); 1380 FreeXid(xid);
1361 return rc; 1381 return rc;
1362} 1382}
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d14e139d2674..ee80b8a5e7bc 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -867,9 +867,9 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
867 error = -EBUSY; 867 error = -EBUSY;
868 goto error; 868 goto error;
869 } 869 }
870 mutex_lock(&sb->s_bdev->bd_mount_mutex); 870 down(&sb->s_bdev->bd_mount_sem);
871 new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev); 871 new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev);
872 mutex_unlock(&sb->s_bdev->bd_mount_mutex); 872 up(&sb->s_bdev->bd_mount_sem);
873 if (IS_ERR(new)) { 873 if (IS_ERR(new)) {
874 error = PTR_ERR(new); 874 error = PTR_ERR(new);
875 goto error; 875 goto error;
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 077258b2103e..5a95fbdd6fdb 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/err.h>
20#include <linux/blkdev.h> 21#include <linux/blkdev.h>
21#include <linux/jffs.h> 22#include <linux/jffs.h>
22#include "jffs_fm.h" 23#include "jffs_fm.h"
@@ -104,7 +105,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
104 105
105 mtd = get_mtd_device(NULL, unit); 106 mtd = get_mtd_device(NULL, unit);
106 107
107 if (!mtd) { 108 if (IS_ERR(mtd)) {
108 kfree(fmc); 109 kfree(fmc);
109 DJM(no_jffs_fmcontrol--); 110 DJM(no_jffs_fmcontrol--);
110 return NULL; 111 return NULL;
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 72b4fc13a106..4189e4a36050 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -178,8 +178,8 @@ __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
178 while (ref2) { 178 while (ref2) {
179 uint32_t totlen = ref_totlen(c, jeb, ref2); 179 uint32_t totlen = ref_totlen(c, jeb, ref2);
180 180
181 if (ref2->flash_offset < jeb->offset || 181 if (ref_offset(ref2) < jeb->offset ||
182 ref2->flash_offset > jeb->offset + c->sector_size) { 182 ref_offset(ref2) > jeb->offset + c->sector_size) {
183 JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n", 183 JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n",
184 ref_offset(ref2), jeb->offset); 184 ref_offset(ref2), jeb->offset);
185 goto error; 185 goto error;
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h
index 3daf3bca0376..f89c85d5a3f8 100644
--- a/fs/jffs2/debug.h
+++ b/fs/jffs2/debug.h
@@ -13,6 +13,7 @@
13#ifndef _JFFS2_DEBUG_H_ 13#ifndef _JFFS2_DEBUG_H_
14#define _JFFS2_DEBUG_H_ 14#define _JFFS2_DEBUG_H_
15 15
16#include <linux/sched.h>
16 17
17#ifndef CONFIG_JFFS2_FS_DEBUG 18#ifndef CONFIG_JFFS2_FS_DEBUG
18#define CONFIG_JFFS2_FS_DEBUG 0 19#define CONFIG_JFFS2_FS_DEBUG 0
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 7bc1a4201c0c..abb90c0c09cc 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -502,12 +502,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
502 if (ret) 502 if (ret)
503 return ret; 503 return ret;
504 504
505 c->inocache_list = kmalloc(INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *), GFP_KERNEL); 505 c->inocache_list = kcalloc(INOCACHE_HASHSIZE, sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
506 if (!c->inocache_list) { 506 if (!c->inocache_list) {
507 ret = -ENOMEM; 507 ret = -ENOMEM;
508 goto out_wbuf; 508 goto out_wbuf;
509 } 509 }
510 memset(c->inocache_list, 0, INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *));
511 510
512 jffs2_init_xattr_subsystem(c); 511 jffs2_init_xattr_subsystem(c);
513 512
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index daff3341ff92..3a3cf225981f 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -838,6 +838,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
838 838
839 for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) { 839 for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) {
840 840
841 cond_resched();
842
841 /* We only care about obsolete ones */ 843 /* We only care about obsolete ones */
842 if (!(ref_obsolete(raw))) 844 if (!(ref_obsolete(raw)))
843 continue; 845 continue;
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 0ddfd70307fb..4178b4b55948 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -294,23 +294,21 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev)
294 294
295static inline struct jffs2_node_frag *frag_first(struct rb_root *root) 295static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
296{ 296{
297 struct rb_node *node = root->rb_node; 297 struct rb_node *node = rb_first(root);
298 298
299 if (!node) 299 if (!node)
300 return NULL; 300 return NULL;
301 while(node->rb_left) 301
302 node = node->rb_left;
303 return rb_entry(node, struct jffs2_node_frag, rb); 302 return rb_entry(node, struct jffs2_node_frag, rb);
304} 303}
305 304
306static inline struct jffs2_node_frag *frag_last(struct rb_root *root) 305static inline struct jffs2_node_frag *frag_last(struct rb_root *root)
307{ 306{
308 struct rb_node *node = root->rb_node; 307 struct rb_node *node = rb_last(root);
309 308
310 if (!node) 309 if (!node)
311 return NULL; 310 return NULL;
312 while(node->rb_right) 311
313 node = node->rb_right;
314 return rb_entry(node, struct jffs2_node_frag, rb); 312 return rb_entry(node, struct jffs2_node_frag, rb);
315} 313}
316 314
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 266423b2709d..58a0b912e9d0 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -944,13 +944,12 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
944int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) 944int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic)
945{ 945{
946 struct jffs2_raw_inode n; 946 struct jffs2_raw_inode n;
947 struct jffs2_inode_info *f = kmalloc(sizeof(*f), GFP_KERNEL); 947 struct jffs2_inode_info *f = kzalloc(sizeof(*f), GFP_KERNEL);
948 int ret; 948 int ret;
949 949
950 if (!f) 950 if (!f)
951 return -ENOMEM; 951 return -ENOMEM;
952 952
953 memset(f, 0, sizeof(*f));
954 init_MUTEX_LOCKED(&f->sem); 953 init_MUTEX_LOCKED(&f->sem);
955 f->inocache = ic; 954 f->inocache = ic;
956 955
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index e2413466ddd5..3af746eaff0e 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -128,17 +128,19 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
128 } 128 }
129 129
130 if (jffs2_sum_active()) { 130 if (jffs2_sum_active()) {
131 s = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); 131 s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
132 if (!s) { 132 if (!s) {
133 kfree(flashbuf);
133 JFFS2_WARNING("Can't allocate memory for summary\n"); 134 JFFS2_WARNING("Can't allocate memory for summary\n");
134 return -ENOMEM; 135 return -ENOMEM;
135 } 136 }
136 memset(s, 0, sizeof(struct jffs2_summary));
137 } 137 }
138 138
139 for (i=0; i<c->nr_blocks; i++) { 139 for (i=0; i<c->nr_blocks; i++) {
140 struct jffs2_eraseblock *jeb = &c->blocks[i]; 140 struct jffs2_eraseblock *jeb = &c->blocks[i];
141 141
142 cond_resched();
143
142 /* reset summary info for next eraseblock scan */ 144 /* reset summary info for next eraseblock scan */
143 jffs2_sum_reset_collected(s); 145 jffs2_sum_reset_collected(s);
144 146
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index e52cef526d90..25265965bdc1 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -26,15 +26,13 @@
26 26
27int jffs2_sum_init(struct jffs2_sb_info *c) 27int jffs2_sum_init(struct jffs2_sb_info *c)
28{ 28{
29 c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); 29 c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
30 30
31 if (!c->summary) { 31 if (!c->summary) {
32 JFFS2_WARNING("Can't allocate memory for summary information!\n"); 32 JFFS2_WARNING("Can't allocate memory for summary information!\n");
33 return -ENOMEM; 33 return -ENOMEM;
34 } 34 }
35 35
36 memset(c->summary, 0, sizeof(struct jffs2_summary));
37
38 c->summary->sum_buf = vmalloc(c->sector_size); 36 c->summary->sum_buf = vmalloc(c->sector_size);
39 37
40 if (!c->summary->sum_buf) { 38 if (!c->summary->sum_buf) {
@@ -398,6 +396,8 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
398 for (i=0; i<je32_to_cpu(summary->sum_num); i++) { 396 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
399 dbg_summary("processing summary index %d\n", i); 397 dbg_summary("processing summary index %d\n", i);
400 398
399 cond_resched();
400
401 /* Make sure there's a spare ref for dirty space */ 401 /* Make sure there's a spare ref for dirty space */
402 err = jffs2_prealloc_raw_node_refs(c, jeb, 2); 402 err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
403 if (err) 403 if (err)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 7deb78254021..08a0e6c49e61 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/err.h>
20#include <linux/mount.h> 21#include <linux/mount.h>
21#include <linux/jffs2.h> 22#include <linux/jffs2.h>
22#include <linux/pagemap.h> 23#include <linux/pagemap.h>
@@ -184,9 +185,9 @@ static int jffs2_get_sb_mtdnr(struct file_system_type *fs_type,
184 struct mtd_info *mtd; 185 struct mtd_info *mtd;
185 186
186 mtd = get_mtd_device(NULL, mtdnr); 187 mtd = get_mtd_device(NULL, mtdnr);
187 if (!mtd) { 188 if (IS_ERR(mtd)) {
188 D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr)); 189 D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr));
189 return -EINVAL; 190 return PTR_ERR(mtd);
190 } 191 }
191 192
192 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); 193 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);
@@ -221,7 +222,7 @@ static int jffs2_get_sb(struct file_system_type *fs_type,
221 D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4)); 222 D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4));
222 for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) { 223 for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) {
223 mtd = get_mtd_device(NULL, mtdnr); 224 mtd = get_mtd_device(NULL, mtdnr);
224 if (mtd) { 225 if (!IS_ERR(mtd)) {
225 if (!strcmp(mtd->name, dev_name+4)) 226 if (!strcmp(mtd->name, dev_name+4))
226 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); 227 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);
227 put_mtd_device(mtd); 228 put_mtd_device(mtd);
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c
index fc211b6e9b03..b90d5aa3d969 100644
--- a/fs/jffs2/symlink.c
+++ b/fs/jffs2/symlink.c
@@ -51,7 +51,7 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
51 */ 51 */
52 52
53 if (!p) { 53 if (!p) {
54 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); 54 printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n");
55 p = ERR_PTR(-EIO); 55 p = ERR_PTR(-EIO);
56 } 56 }
57 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); 57 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target));
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 70707309dfa1..9c99859f5edd 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -969,8 +969,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
969 int oobsize = c->mtd->oobsize; 969 int oobsize = c->mtd->oobsize;
970 struct mtd_oob_ops ops; 970 struct mtd_oob_ops ops;
971 971
972 ops.len = NR_OOB_SCAN_PAGES * oobsize; 972 ops.ooblen = NR_OOB_SCAN_PAGES * oobsize;
973 ops.ooblen = oobsize;
974 ops.oobbuf = c->oobbuf; 973 ops.oobbuf = c->oobbuf;
975 ops.ooboffs = 0; 974 ops.ooboffs = 0;
976 ops.datbuf = NULL; 975 ops.datbuf = NULL;
@@ -983,10 +982,10 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
983 return ret; 982 return ret;
984 } 983 }
985 984
986 if (ops.retlen < ops.len) { 985 if (ops.oobretlen < ops.ooblen) {
987 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB " 986 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB "
988 "returned short read (%zd bytes not %d) for block " 987 "returned short read (%zd bytes not %d) for block "
989 "at %08x\n", ops.retlen, ops.len, jeb->offset)); 988 "at %08x\n", ops.oobretlen, ops.ooblen, jeb->offset));
990 return -EIO; 989 return -EIO;
991 } 990 }
992 991
@@ -1005,7 +1004,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
1005 } 1004 }
1006 1005
1007 /* we know, we are aligned :) */ 1006 /* we know, we are aligned :) */
1008 for (page = oobsize; page < ops.len; page += sizeof(long)) { 1007 for (page = oobsize; page < ops.ooblen; page += sizeof(long)) {
1009 long dat = *(long *)(&ops.oobbuf[page]); 1008 long dat = *(long *)(&ops.oobbuf[page]);
1010 if(dat != -1) 1009 if(dat != -1)
1011 return 1; 1010 return 1;
@@ -1033,7 +1032,6 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1033 return 2; 1032 return 2;
1034 } 1033 }
1035 1034
1036 ops.len = oobsize;
1037 ops.ooblen = oobsize; 1035 ops.ooblen = oobsize;
1038 ops.oobbuf = c->oobbuf; 1036 ops.oobbuf = c->oobbuf;
1039 ops.ooboffs = 0; 1037 ops.ooboffs = 0;
@@ -1048,10 +1046,10 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1048 return ret; 1046 return ret;
1049 } 1047 }
1050 1048
1051 if (ops.retlen < ops.len) { 1049 if (ops.oobretlen < ops.ooblen) {
1052 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): " 1050 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): "
1053 "Read OOB return short read (%zd bytes not %d) " 1051 "Read OOB return short read (%zd bytes not %d) "
1054 "for block at %08x\n", ops.retlen, ops.len, 1052 "for block at %08x\n", ops.oobretlen, ops.ooblen,
1055 jeb->offset)); 1053 jeb->offset));
1056 return -EIO; 1054 return -EIO;
1057 } 1055 }
@@ -1090,8 +1088,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1090 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); 1088 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
1091 n.totlen = cpu_to_je32(8); 1089 n.totlen = cpu_to_je32(8);
1092 1090
1093 ops.len = c->fsdata_len; 1091 ops.ooblen = c->fsdata_len;
1094 ops.ooblen = c->fsdata_len;;
1095 ops.oobbuf = (uint8_t *)&n; 1092 ops.oobbuf = (uint8_t *)&n;
1096 ops.ooboffs = c->fsdata_pos; 1093 ops.ooboffs = c->fsdata_pos;
1097 ops.datbuf = NULL; 1094 ops.datbuf = NULL;
@@ -1105,10 +1102,10 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1105 jeb->offset, ret)); 1102 jeb->offset, ret));
1106 return ret; 1103 return ret;
1107 } 1104 }
1108 if (ops.retlen != ops.len) { 1105 if (ops.oobretlen != ops.ooblen) {
1109 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): " 1106 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): "
1110 "Short write for block at %08x: %zd not %d\n", 1107 "Short write for block at %08x: %zd not %d\n",
1111 jeb->offset, ops.retlen, ops.len)); 1108 jeb->offset, ops.oobretlen, ops.ooblen));
1112 return -EIO; 1109 return -EIO;
1113 } 1110 }
1114 return 0; 1111 return 0;
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 4da09ce1d1f5..4bb3f1897330 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -399,8 +399,6 @@ static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datu
399{ 399{
400 /* must be called under down_write(xattr_sem) */ 400 /* must be called under down_write(xattr_sem) */
401 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) { 401 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) {
402 uint32_t xid = xd->xid, version = xd->version;
403
404 unload_xattr_datum(c, xd); 402 unload_xattr_datum(c, xd);
405 xd->flags |= JFFS2_XFLAGS_DEAD; 403 xd->flags |= JFFS2_XFLAGS_DEAD;
406 if (xd->node == (void *)xd) { 404 if (xd->node == (void *)xd) {
@@ -411,7 +409,8 @@ static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datu
411 } 409 }
412 spin_unlock(&c->erase_completion_lock); 410 spin_unlock(&c->erase_completion_lock);
413 411
414 dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n", xid, version); 412 dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n",
413 xd->xid, xd->version);
415 } 414 }
416} 415}
417 416
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 0dd6be346aa7..fab20d06d936 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -315,14 +315,13 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
315 315
316static int nfs_release_page(struct page *page, gfp_t gfp) 316static int nfs_release_page(struct page *page, gfp_t gfp)
317{ 317{
318 /* 318 /* If PagePrivate() is set, then the page is not freeable */
319 * Avoid deadlock on nfs_wait_on_request(). 319 return 0;
320 */ 320}
321 if (!(gfp & __GFP_FS)) 321
322 return 0; 322static int nfs_launder_page(struct page *page)
323 /* Hack... Force nfs_wb_page() to write out the page */ 323{
324 SetPageDirty(page); 324 return nfs_wb_page(page->mapping->host, page);
325 return !nfs_wb_page(page->mapping->host, page);
326} 325}
327 326
328const struct address_space_operations nfs_file_aops = { 327const struct address_space_operations nfs_file_aops = {
@@ -338,6 +337,7 @@ const struct address_space_operations nfs_file_aops = {
338#ifdef CONFIG_NFS_DIRECTIO 337#ifdef CONFIG_NFS_DIRECTIO
339 .direct_IO = nfs_direct_IO, 338 .direct_IO = nfs_direct_IO,
340#endif 339#endif
340 .launder_page = nfs_launder_page,
341}; 341};
342 342
343static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, 343static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 35cc4b1d60f7..af4ef808fa94 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -17,6 +17,13 @@ ToDo/Notes:
17 happen is unclear however so it is worth waiting until someone hits 17 happen is unclear however so it is worth waiting until someone hits
18 the problem. 18 the problem.
19 19
202.1.28 - Fix a deadlock.
21
22 - Fix deadlock in fs/ntfs/inode.c::ntfs_put_inode(). Thanks to Sergey
23 Vlasov for the report and detailed analysis of the deadlock. The fix
24 involved getting rid of ntfs_put_inode() altogether and hence NTFS no
25 longer has a ->put_inode super operation.
26
202.1.27 - Various bug fixes and cleanups. 272.1.27 - Various bug fixes and cleanups.
21 28
22 - Fix two compiler warnings on Alpha. Thanks to Andrew Morton for 29 - Fix two compiler warnings on Alpha. Thanks to Andrew Morton for
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile
index e27b4eacffbf..825508385565 100644
--- a/fs/ntfs/Makefile
+++ b/fs/ntfs/Makefile
@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
6 index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ 6 index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
7 unistr.o upcase.o 7 unistr.o upcase.o
8 8
9EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.27\" 9EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.28\"
10 10
11ifeq ($(CONFIG_NTFS_DEBUG),y) 11ifeq ($(CONFIG_NTFS_DEBUG),y)
12EXTRA_CFLAGS += -DDEBUG 12EXTRA_CFLAGS += -DDEBUG
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 8296c29ae3b8..74f99a6a369b 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1,7 +1,7 @@
1/** 1/**
2 * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project. 2 * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2005 Anton Altaparmakov 4 * Copyright (c) 2001-2007 Anton Altaparmakov
5 * Copyright (c) 2002 Richard Russon 5 * Copyright (c) 2002 Richard Russon
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -1249,16 +1249,12 @@ skip_index_root:
1249 /* Get the offset into the index allocation attribute. */ 1249 /* Get the offset into the index allocation attribute. */
1250 ia_pos = (s64)fpos - vol->mft_record_size; 1250 ia_pos = (s64)fpos - vol->mft_record_size;
1251 ia_mapping = vdir->i_mapping; 1251 ia_mapping = vdir->i_mapping;
1252 bmp_vi = ndir->itype.index.bmp_ino; 1252 ntfs_debug("Inode 0x%lx, getting index bitmap.", vdir->i_ino);
1253 if (unlikely(!bmp_vi)) { 1253 bmp_vi = ntfs_attr_iget(vdir, AT_BITMAP, I30, 4);
1254 ntfs_debug("Inode 0x%lx, regetting index bitmap.", vdir->i_ino); 1254 if (IS_ERR(bmp_vi)) {
1255 bmp_vi = ntfs_attr_iget(vdir, AT_BITMAP, I30, 4); 1255 ntfs_error(sb, "Failed to get bitmap attribute.");
1256 if (IS_ERR(bmp_vi)) { 1256 err = PTR_ERR(bmp_vi);
1257 ntfs_error(sb, "Failed to get bitmap attribute."); 1257 goto err_out;
1258 err = PTR_ERR(bmp_vi);
1259 goto err_out;
1260 }
1261 ndir->itype.index.bmp_ino = bmp_vi;
1262 } 1258 }
1263 bmp_mapping = bmp_vi->i_mapping; 1259 bmp_mapping = bmp_vi->i_mapping;
1264 /* Get the starting bitmap bit position and sanity check it. */ 1260 /* Get the starting bitmap bit position and sanity check it. */
@@ -1266,7 +1262,7 @@ skip_index_root:
1266 if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) { 1262 if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) {
1267 ntfs_error(sb, "Current index allocation position exceeds " 1263 ntfs_error(sb, "Current index allocation position exceeds "
1268 "index bitmap size."); 1264 "index bitmap size.");
1269 goto err_out; 1265 goto iput_err_out;
1270 } 1266 }
1271 /* Get the starting bit position in the current bitmap page. */ 1267 /* Get the starting bit position in the current bitmap page. */
1272 cur_bmp_pos = bmp_pos & ((PAGE_CACHE_SIZE * 8) - 1); 1268 cur_bmp_pos = bmp_pos & ((PAGE_CACHE_SIZE * 8) - 1);
@@ -1282,7 +1278,7 @@ get_next_bmp_page:
1282 ntfs_error(sb, "Reading index bitmap failed."); 1278 ntfs_error(sb, "Reading index bitmap failed.");
1283 err = PTR_ERR(bmp_page); 1279 err = PTR_ERR(bmp_page);
1284 bmp_page = NULL; 1280 bmp_page = NULL;
1285 goto err_out; 1281 goto iput_err_out;
1286 } 1282 }
1287 bmp = (u8*)page_address(bmp_page); 1283 bmp = (u8*)page_address(bmp_page);
1288 /* Find next index block in use. */ 1284 /* Find next index block in use. */
@@ -1429,6 +1425,7 @@ find_next_index_buffer:
1429 /* @ia_page is already unlocked in this case. */ 1425 /* @ia_page is already unlocked in this case. */
1430 ntfs_unmap_page(ia_page); 1426 ntfs_unmap_page(ia_page);
1431 ntfs_unmap_page(bmp_page); 1427 ntfs_unmap_page(bmp_page);
1428 iput(bmp_vi);
1432 goto abort; 1429 goto abort;
1433 } 1430 }
1434 } 1431 }
@@ -1439,6 +1436,7 @@ unm_EOD:
1439 ntfs_unmap_page(ia_page); 1436 ntfs_unmap_page(ia_page);
1440 } 1437 }
1441 ntfs_unmap_page(bmp_page); 1438 ntfs_unmap_page(bmp_page);
1439 iput(bmp_vi);
1442EOD: 1440EOD:
1443 /* We are finished, set fpos to EOD. */ 1441 /* We are finished, set fpos to EOD. */
1444 fpos = i_size + vol->mft_record_size; 1442 fpos = i_size + vol->mft_record_size;
@@ -1455,8 +1453,11 @@ done:
1455 filp->f_pos = fpos; 1453 filp->f_pos = fpos;
1456 return 0; 1454 return 0;
1457err_out: 1455err_out:
1458 if (bmp_page) 1456 if (bmp_page) {
1459 ntfs_unmap_page(bmp_page); 1457 ntfs_unmap_page(bmp_page);
1458iput_err_out:
1459 iput(bmp_vi);
1460 }
1460 if (ia_page) { 1461 if (ia_page) {
1461 unlock_page(ia_page); 1462 unlock_page(ia_page);
1462 ntfs_unmap_page(ia_page); 1463 ntfs_unmap_page(ia_page);
@@ -1529,14 +1530,22 @@ static int ntfs_dir_open(struct inode *vi, struct file *filp)
1529static int ntfs_dir_fsync(struct file *filp, struct dentry *dentry, 1530static int ntfs_dir_fsync(struct file *filp, struct dentry *dentry,
1530 int datasync) 1531 int datasync)
1531{ 1532{
1532 struct inode *vi = dentry->d_inode; 1533 struct inode *bmp_vi, *vi = dentry->d_inode;
1533 ntfs_inode *ni = NTFS_I(vi);
1534 int err, ret; 1534 int err, ret;
1535 ntfs_attr na;
1535 1536
1536 ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); 1537 ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);
1537 BUG_ON(!S_ISDIR(vi->i_mode)); 1538 BUG_ON(!S_ISDIR(vi->i_mode));
1538 if (NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) 1539 /* If the bitmap attribute inode is in memory sync it, too. */
1539 write_inode_now(ni->itype.index.bmp_ino, !datasync); 1540 na.mft_no = vi->i_ino;
1541 na.type = AT_BITMAP;
1542 na.name = I30;
1543 na.name_len = 4;
1544 bmp_vi = ilookup5(vi->i_sb, vi->i_ino, (test_t)ntfs_test_inode, &na);
1545 if (bmp_vi) {
1546 write_inode_now(bmp_vi, !datasync);
1547 iput(bmp_vi);
1548 }
1540 ret = ntfs_write_inode(vi, 1); 1549 ret = ntfs_write_inode(vi, 1);
1541 write_inode_now(vi, !datasync); 1550 write_inode_now(vi, !datasync);
1542 err = sync_blockdev(vi->i_sb->s_bdev); 1551 err = sync_blockdev(vi->i_sb->s_bdev);
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 247989891b4b..f8bf8da67ee8 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1,7 +1,7 @@
1/** 1/**
2 * inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project. 2 * inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2006 Anton Altaparmakov 4 * Copyright (c) 2001-2007 Anton Altaparmakov
5 * 5 *
6 * This program/include file is free software; you can redistribute it and/or 6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published 7 * modify it under the terms of the GNU General Public License as published
@@ -95,7 +95,7 @@ int ntfs_test_inode(struct inode *vi, ntfs_attr *na)
95 * If initializing the normal file/directory inode, set @na->type to AT_UNUSED. 95 * If initializing the normal file/directory inode, set @na->type to AT_UNUSED.
96 * In that case, @na->name and @na->name_len should be set to NULL and 0, 96 * In that case, @na->name and @na->name_len should be set to NULL and 0,
97 * respectively. Although that is not strictly necessary as 97 * respectively. Although that is not strictly necessary as
98 * ntfs_read_inode_locked() will fill them in later. 98 * ntfs_read_locked_inode() will fill them in later.
99 * 99 *
100 * Return 0 on success and -errno on error. 100 * Return 0 on success and -errno on error.
101 * 101 *
@@ -171,8 +171,8 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi,
171struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no) 171struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
172{ 172{
173 struct inode *vi; 173 struct inode *vi;
174 ntfs_attr na;
175 int err; 174 int err;
175 ntfs_attr na;
176 176
177 na.mft_no = mft_no; 177 na.mft_no = mft_no;
178 na.type = AT_UNUSED; 178 na.type = AT_UNUSED;
@@ -229,8 +229,8 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
229 ntfschar *name, u32 name_len) 229 ntfschar *name, u32 name_len)
230{ 230{
231 struct inode *vi; 231 struct inode *vi;
232 ntfs_attr na;
233 int err; 232 int err;
233 ntfs_attr na;
234 234
235 /* Make sure no one calls ntfs_attr_iget() for indices. */ 235 /* Make sure no one calls ntfs_attr_iget() for indices. */
236 BUG_ON(type == AT_INDEX_ALLOCATION); 236 BUG_ON(type == AT_INDEX_ALLOCATION);
@@ -287,8 +287,8 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
287 u32 name_len) 287 u32 name_len)
288{ 288{
289 struct inode *vi; 289 struct inode *vi;
290 ntfs_attr na;
291 int err; 290 int err;
291 ntfs_attr na;
292 292
293 na.mft_no = base_vi->i_ino; 293 na.mft_no = base_vi->i_ino;
294 na.type = AT_INDEX_ALLOCATION; 294 na.type = AT_INDEX_ALLOCATION;
@@ -402,7 +402,6 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
402 ntfs_init_runlist(&ni->attr_list_rl); 402 ntfs_init_runlist(&ni->attr_list_rl);
403 lockdep_set_class(&ni->attr_list_rl.lock, 403 lockdep_set_class(&ni->attr_list_rl.lock,
404 &attr_list_rl_lock_class); 404 &attr_list_rl_lock_class);
405 ni->itype.index.bmp_ino = NULL;
406 ni->itype.index.block_size = 0; 405 ni->itype.index.block_size = 0;
407 ni->itype.index.vcn_size = 0; 406 ni->itype.index.vcn_size = 0;
408 ni->itype.index.collation_rule = 0; 407 ni->itype.index.collation_rule = 0;
@@ -546,6 +545,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
546{ 545{
547 ntfs_volume *vol = NTFS_SB(vi->i_sb); 546 ntfs_volume *vol = NTFS_SB(vi->i_sb);
548 ntfs_inode *ni; 547 ntfs_inode *ni;
548 struct inode *bvi;
549 MFT_RECORD *m; 549 MFT_RECORD *m;
550 ATTR_RECORD *a; 550 ATTR_RECORD *a;
551 STANDARD_INFORMATION *si; 551 STANDARD_INFORMATION *si;
@@ -780,7 +780,6 @@ skip_attr_list_load:
780 */ 780 */
781 if (S_ISDIR(vi->i_mode)) { 781 if (S_ISDIR(vi->i_mode)) {
782 loff_t bvi_size; 782 loff_t bvi_size;
783 struct inode *bvi;
784 ntfs_inode *bni; 783 ntfs_inode *bni;
785 INDEX_ROOT *ir; 784 INDEX_ROOT *ir;
786 u8 *ir_end, *index_end; 785 u8 *ir_end, *index_end;
@@ -985,13 +984,12 @@ skip_attr_list_load:
985 err = PTR_ERR(bvi); 984 err = PTR_ERR(bvi);
986 goto unm_err_out; 985 goto unm_err_out;
987 } 986 }
988 ni->itype.index.bmp_ino = bvi;
989 bni = NTFS_I(bvi); 987 bni = NTFS_I(bvi);
990 if (NInoCompressed(bni) || NInoEncrypted(bni) || 988 if (NInoCompressed(bni) || NInoEncrypted(bni) ||
991 NInoSparse(bni)) { 989 NInoSparse(bni)) {
992 ntfs_error(vi->i_sb, "$BITMAP attribute is compressed " 990 ntfs_error(vi->i_sb, "$BITMAP attribute is compressed "
993 "and/or encrypted and/or sparse."); 991 "and/or encrypted and/or sparse.");
994 goto unm_err_out; 992 goto iput_unm_err_out;
995 } 993 }
996 /* Consistency check bitmap size vs. index allocation size. */ 994 /* Consistency check bitmap size vs. index allocation size. */
997 bvi_size = i_size_read(bvi); 995 bvi_size = i_size_read(bvi);
@@ -1000,8 +998,10 @@ skip_attr_list_load:
1000 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) " 998 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
1001 "for index allocation (0x%llx).", 999 "for index allocation (0x%llx).",
1002 bvi_size << 3, vi->i_size); 1000 bvi_size << 3, vi->i_size);
1003 goto unm_err_out; 1001 goto iput_unm_err_out;
1004 } 1002 }
1003 /* No longer need the bitmap attribute inode. */
1004 iput(bvi);
1005skip_large_dir_stuff: 1005skip_large_dir_stuff:
1006 /* Setup the operations for this inode. */ 1006 /* Setup the operations for this inode. */
1007 vi->i_op = &ntfs_dir_inode_ops; 1007 vi->i_op = &ntfs_dir_inode_ops;
@@ -1176,7 +1176,8 @@ no_data_attr_special_case:
1176 vi->i_blocks = ni->allocated_size >> 9; 1176 vi->i_blocks = ni->allocated_size >> 9;
1177 ntfs_debug("Done."); 1177 ntfs_debug("Done.");
1178 return 0; 1178 return 0;
1179 1179iput_unm_err_out:
1180 iput(bvi);
1180unm_err_out: 1181unm_err_out:
1181 if (!err) 1182 if (!err)
1182 err = -EIO; 1183 err = -EIO;
@@ -1697,7 +1698,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1697 vi->i_size); 1698 vi->i_size);
1698 goto iput_unm_err_out; 1699 goto iput_unm_err_out;
1699 } 1700 }
1700 ni->itype.index.bmp_ino = bvi; 1701 iput(bvi);
1701skip_large_index_stuff: 1702skip_large_index_stuff:
1702 /* Setup the operations for this index inode. */ 1703 /* Setup the operations for this index inode. */
1703 vi->i_op = NULL; 1704 vi->i_op = NULL;
@@ -1714,7 +1715,6 @@ skip_large_index_stuff:
1714 1715
1715 ntfs_debug("Done."); 1716 ntfs_debug("Done.");
1716 return 0; 1717 return 0;
1717
1718iput_unm_err_out: 1718iput_unm_err_out:
1719 iput(bvi); 1719 iput(bvi);
1720unm_err_out: 1720unm_err_out:
@@ -2191,37 +2191,6 @@ err_out:
2191 return -1; 2191 return -1;
2192} 2192}
2193 2193
2194/**
2195 * ntfs_put_inode - handler for when the inode reference count is decremented
2196 * @vi: vfs inode
2197 *
2198 * The VFS calls ntfs_put_inode() every time the inode reference count (i_count)
2199 * is about to be decremented (but before the decrement itself.
2200 *
2201 * If the inode @vi is a directory with two references, one of which is being
2202 * dropped, we need to put the attribute inode for the directory index bitmap,
2203 * if it is present, otherwise the directory inode would remain pinned for
2204 * ever.
2205 */
2206void ntfs_put_inode(struct inode *vi)
2207{
2208 if (S_ISDIR(vi->i_mode) && atomic_read(&vi->i_count) == 2) {
2209 ntfs_inode *ni = NTFS_I(vi);
2210 if (NInoIndexAllocPresent(ni)) {
2211 struct inode *bvi = NULL;
2212 mutex_lock(&vi->i_mutex);
2213 if (atomic_read(&vi->i_count) == 2) {
2214 bvi = ni->itype.index.bmp_ino;
2215 if (bvi)
2216 ni->itype.index.bmp_ino = NULL;
2217 }
2218 mutex_unlock(&vi->i_mutex);
2219 if (bvi)
2220 iput(bvi);
2221 }
2222 }
2223}
2224
2225static void __ntfs_clear_inode(ntfs_inode *ni) 2194static void __ntfs_clear_inode(ntfs_inode *ni)
2226{ 2195{
2227 /* Free all alocated memory. */ 2196 /* Free all alocated memory. */
@@ -2287,18 +2256,6 @@ void ntfs_clear_big_inode(struct inode *vi)
2287{ 2256{
2288 ntfs_inode *ni = NTFS_I(vi); 2257 ntfs_inode *ni = NTFS_I(vi);
2289 2258
2290 /*
2291 * If the inode @vi is an index inode we need to put the attribute
2292 * inode for the index bitmap, if it is present, otherwise the index
2293 * inode would disappear and the attribute inode for the index bitmap
2294 * would no longer be referenced from anywhere and thus it would remain
2295 * pinned for ever.
2296 */
2297 if (NInoAttr(ni) && (ni->type == AT_INDEX_ALLOCATION) &&
2298 NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) {
2299 iput(ni->itype.index.bmp_ino);
2300 ni->itype.index.bmp_ino = NULL;
2301 }
2302#ifdef NTFS_RW 2259#ifdef NTFS_RW
2303 if (NInoDirty(ni)) { 2260 if (NInoDirty(ni)) {
2304 bool was_bad = (is_bad_inode(vi)); 2261 bool was_bad = (is_bad_inode(vi));
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index f088291e017c..117eaf8032a3 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -2,7 +2,7 @@
2 * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of 2 * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
3 * the Linux-NTFS project. 3 * the Linux-NTFS project.
4 * 4 *
5 * Copyright (c) 2001-2005 Anton Altaparmakov 5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (c) 2002 Richard Russon 6 * Copyright (c) 2002 Richard Russon
7 * 7 *
8 * This program/include file is free software; you can redistribute it and/or 8 * This program/include file is free software; you can redistribute it and/or
@@ -101,8 +101,6 @@ struct _ntfs_inode {
101 runlist attr_list_rl; /* Run list for the attribute list value. */ 101 runlist attr_list_rl; /* Run list for the attribute list value. */
102 union { 102 union {
103 struct { /* It is a directory, $MFT, or an index inode. */ 103 struct { /* It is a directory, $MFT, or an index inode. */
104 struct inode *bmp_ino; /* Attribute inode for the
105 index $BITMAP. */
106 u32 block_size; /* Size of an index block. */ 104 u32 block_size; /* Size of an index block. */
107 u32 vcn_size; /* Size of a vcn in this 105 u32 vcn_size; /* Size of a vcn in this
108 index. */ 106 index. */
@@ -300,8 +298,6 @@ extern void ntfs_clear_extent_inode(ntfs_inode *ni);
300 298
301extern int ntfs_read_inode_mount(struct inode *vi); 299extern int ntfs_read_inode_mount(struct inode *vi);
302 300
303extern void ntfs_put_inode(struct inode *vi);
304
305extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt); 301extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt);
306 302
307#ifdef NTFS_RW 303#ifdef NTFS_RW
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 03a391ac7145..babf94d90def 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project. 2 * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2006 Anton Altaparmakov 4 * Copyright (c) 2001-2007 Anton Altaparmakov
5 * Copyright (c) 2001,2002 Richard Russon 5 * Copyright (c) 2001,2002 Richard Russon
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -2702,9 +2702,6 @@ static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
2702static struct super_operations ntfs_sops = { 2702static struct super_operations ntfs_sops = {
2703 .alloc_inode = ntfs_alloc_big_inode, /* VFS: Allocate new inode. */ 2703 .alloc_inode = ntfs_alloc_big_inode, /* VFS: Allocate new inode. */
2704 .destroy_inode = ntfs_destroy_big_inode, /* VFS: Deallocate inode. */ 2704 .destroy_inode = ntfs_destroy_big_inode, /* VFS: Deallocate inode. */
2705 .put_inode = ntfs_put_inode, /* VFS: Called just before
2706 the inode reference count
2707 is decreased. */
2708#ifdef NTFS_RW 2705#ifdef NTFS_RW
2709 //.dirty_inode = NULL, /* VFS: Called from 2706 //.dirty_inode = NULL, /* VFS: Called from
2710 // __mark_inode_dirty(). */ 2707 // __mark_inode_dirty(). */
@@ -3261,7 +3258,7 @@ static void __exit exit_ntfs_fs(void)
3261} 3258}
3262 3259
3263MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>"); 3260MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
3264MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2006 Anton Altaparmakov"); 3261MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2007 Anton Altaparmakov");
3265MODULE_VERSION(NTFS_VERSION); 3262MODULE_VERSION(NTFS_VERSION);
3266MODULE_LICENSE("GPL"); 3263MODULE_LICENSE("GPL");
3267#ifdef DEBUG 3264#ifdef DEBUG
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index ef6cd30108a9..93628b02ef5d 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -540,8 +540,7 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
540 struct buffer_head *bh_result, int create) 540 struct buffer_head *bh_result, int create)
541{ 541{
542 int ret; 542 int ret;
543 u64 vbo_max; /* file offset, max_blocks from iblock */ 543 u64 p_blkno, inode_blocks;
544 u64 p_blkno;
545 int contig_blocks; 544 int contig_blocks;
546 unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; 545 unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;
547 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; 546 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
@@ -550,12 +549,23 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
550 * nicely aligned and of the right size, so there's no need 549 * nicely aligned and of the right size, so there's no need
551 * for us to check any of that. */ 550 * for us to check any of that. */
552 551
553 vbo_max = ((u64)iblock + max_blocks) << blocksize_bits;
554
555 spin_lock(&OCFS2_I(inode)->ip_lock); 552 spin_lock(&OCFS2_I(inode)->ip_lock);
556 if ((iblock + max_blocks) > 553 inode_blocks = ocfs2_clusters_to_blocks(inode->i_sb,
557 ocfs2_clusters_to_blocks(inode->i_sb, 554 OCFS2_I(inode)->ip_clusters);
558 OCFS2_I(inode)->ip_clusters)) { 555
556 /*
557 * For a read which begins past the end of file, we return a hole.
558 */
559 if (!create && (iblock >= inode_blocks)) {
560 spin_unlock(&OCFS2_I(inode)->ip_lock);
561 ret = 0;
562 goto bail;
563 }
564
565 /*
566 * Any write past EOF is not allowed because we'd be extending.
567 */
568 if (create && (iblock + max_blocks) > inode_blocks) {
559 spin_unlock(&OCFS2_I(inode)->ip_lock); 569 spin_unlock(&OCFS2_I(inode)->ip_lock);
560 ret = -EIO; 570 ret = -EIO;
561 goto bail; 571 goto bail;
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index a25ef5a50386..277ca67a2ad6 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1447,6 +1447,15 @@ out:
1447 return ret; 1447 return ret;
1448} 1448}
1449 1449
1450static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
1451 char *page)
1452{
1453 if (!reg->hr_task)
1454 return 0;
1455
1456 return sprintf(page, "%u\n", reg->hr_task->pid);
1457}
1458
1450struct o2hb_region_attribute { 1459struct o2hb_region_attribute {
1451 struct configfs_attribute attr; 1460 struct configfs_attribute attr;
1452 ssize_t (*show)(struct o2hb_region *, char *); 1461 ssize_t (*show)(struct o2hb_region *, char *);
@@ -1485,11 +1494,19 @@ static struct o2hb_region_attribute o2hb_region_attr_dev = {
1485 .store = o2hb_region_dev_write, 1494 .store = o2hb_region_dev_write,
1486}; 1495};
1487 1496
1497static struct o2hb_region_attribute o2hb_region_attr_pid = {
1498 .attr = { .ca_owner = THIS_MODULE,
1499 .ca_name = "pid",
1500 .ca_mode = S_IRUGO | S_IRUSR },
1501 .show = o2hb_region_pid_read,
1502};
1503
1488static struct configfs_attribute *o2hb_region_attrs[] = { 1504static struct configfs_attribute *o2hb_region_attrs[] = {
1489 &o2hb_region_attr_block_bytes.attr, 1505 &o2hb_region_attr_block_bytes.attr,
1490 &o2hb_region_attr_start_block.attr, 1506 &o2hb_region_attr_start_block.attr,
1491 &o2hb_region_attr_blocks.attr, 1507 &o2hb_region_attr_blocks.attr,
1492 &o2hb_region_attr_dev.attr, 1508 &o2hb_region_attr_dev.attr,
1509 &o2hb_region_attr_pid.attr,
1493 NULL, 1510 NULL,
1494}; 1511};
1495 1512
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index e6220137bf69..e335541727f9 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2718,6 +2718,15 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2718 inode = ocfs2_lock_res_inode(lockres); 2718 inode = ocfs2_lock_res_inode(lockres);
2719 mapping = inode->i_mapping; 2719 mapping = inode->i_mapping;
2720 2720
2721 /*
2722 * We need this before the filemap_fdatawrite() so that it can
2723 * transfer the dirty bit from the PTE to the
2724 * page. Unfortunately this means that even for EX->PR
2725 * downconverts, we'll lose our mappings and have to build
2726 * them up again.
2727 */
2728 unmap_mapping_range(mapping, 0, 0, 0);
2729
2721 if (filemap_fdatawrite(mapping)) { 2730 if (filemap_fdatawrite(mapping)) {
2722 mlog(ML_ERROR, "Could not sync inode %llu for downconvert!", 2731 mlog(ML_ERROR, "Could not sync inode %llu for downconvert!",
2723 (unsigned long long)OCFS2_I(inode)->ip_blkno); 2732 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -2725,7 +2734,6 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2725 sync_mapping_buffers(mapping); 2734 sync_mapping_buffers(mapping);
2726 if (blocking == LKM_EXMODE) { 2735 if (blocking == LKM_EXMODE) {
2727 truncate_inode_pages(mapping, 0); 2736 truncate_inode_pages(mapping, 0);
2728 unmap_mapping_range(mapping, 0, 0, 0);
2729 } else { 2737 } else {
2730 /* We only need to wait on the I/O if we're not also 2738 /* We only need to wait on the I/O if we're not also
2731 * truncating pages because truncate_inode_pages waits 2739 * truncating pages because truncate_inode_pages waits
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 06be6e774cf9..56e1fefc1205 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -60,14 +60,11 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp)
60 60
61 inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0); 61 inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0);
62 62
63 if (IS_ERR(inode)) { 63 if (IS_ERR(inode))
64 mlog_errno(PTR_ERR(inode));
65 return (void *)inode; 64 return (void *)inode;
66 }
67 65
68 if (handle->ih_generation != inode->i_generation) { 66 if (handle->ih_generation != inode->i_generation) {
69 iput(inode); 67 iput(inode);
70 mlog_errno(-ESTALE);
71 return ERR_PTR(-ESTALE); 68 return ERR_PTR(-ESTALE);
72 } 69 }
73 70
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9fd590b9bde3..10953a508f2f 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -149,6 +149,17 @@ int ocfs2_should_update_atime(struct inode *inode,
149 ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))) 149 ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode)))
150 return 0; 150 return 0;
151 151
152 /*
153 * We can be called with no vfsmnt structure - NFSD will
154 * sometimes do this.
155 *
156 * Note that our action here is different than touch_atime() -
157 * if we can't tell whether this is a noatime mount, then we
158 * don't know whether to trust the value of s_atime_quantum.
159 */
160 if (vfsmnt == NULL)
161 return 0;
162
152 if ((vfsmnt->mnt_flags & MNT_NOATIME) || 163 if ((vfsmnt->mnt_flags & MNT_NOATIME) ||
153 ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) 164 ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
154 return 0; 165 return 0;
@@ -966,8 +977,6 @@ int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
966 } 977 }
967 978
968 ret = generic_permission(inode, mask, NULL); 979 ret = generic_permission(inode, mask, NULL);
969 if (ret)
970 mlog_errno(ret);
971 980
972 ocfs2_meta_unlock(inode, 0); 981 ocfs2_meta_unlock(inode, 0);
973out: 982out:
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index e4d91493d7d7..28ab56f2b98c 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -146,7 +146,6 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
146 if (is_bad_inode(inode)) { 146 if (is_bad_inode(inode)) {
147 iput(inode); 147 iput(inode);
148 inode = ERR_PTR(-ESTALE); 148 inode = ERR_PTR(-ESTALE);
149 mlog_errno(PTR_ERR(inode));
150 goto bail; 149 goto bail;
151 } 150 }
152 151
@@ -155,8 +154,7 @@ bail:
155 mlog(0, "returning inode with number %llu\n", 154 mlog(0, "returning inode with number %llu\n",
156 (unsigned long long)OCFS2_I(inode)->ip_blkno); 155 (unsigned long long)OCFS2_I(inode)->ip_blkno);
157 mlog_exit_ptr(inode); 156 mlog_exit_ptr(inode);
158 } else 157 }
159 mlog_errno(PTR_ERR(inode));
160 158
161 return inode; 159 return inode;
162} 160}
@@ -247,7 +245,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
247 * today. change if needed. */ 245 * today. change if needed. */
248 if (!OCFS2_IS_VALID_DINODE(fe) || 246 if (!OCFS2_IS_VALID_DINODE(fe) ||
249 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { 247 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
250 mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%llu, " 248 mlog(0, "Invalid dinode: i_ino=%lu, i_blkno=%llu, "
251 "signature = %.*s, flags = 0x%x\n", 249 "signature = %.*s, flags = 0x%x\n",
252 inode->i_ino, 250 inode->i_ino,
253 (unsigned long long)le64_to_cpu(fe->i_blkno), 7, 251 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
@@ -478,11 +476,8 @@ static int ocfs2_read_locked_inode(struct inode *inode,
478 S_ISBLK(le16_to_cpu(fe->i_mode))) 476 S_ISBLK(le16_to_cpu(fe->i_mode)))
479 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); 477 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
480 478
481 if (ocfs2_populate_inode(inode, fe, 0) < 0) { 479 if (ocfs2_populate_inode(inode, fe, 0) < 0)
482 mlog(ML_ERROR, "populate failed! i_blkno=%llu, i_ino=%lu\n",
483 (unsigned long long)fe->i_blkno, inode->i_ino);
484 goto bail; 480 goto bail;
485 }
486 481
487 BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno)); 482 BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno));
488 483
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 9637039c2633..f3d7803b4b46 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -932,14 +932,15 @@ static int ocfs2_unlink(struct inode *dir,
932 goto leave; 932 goto leave;
933 } 933 }
934 934
935 if (S_ISDIR(inode->i_mode)) { 935 dir->i_ctime = dir->i_mtime = CURRENT_TIME;
936 if (S_ISDIR(inode->i_mode))
936 drop_nlink(dir); 937 drop_nlink(dir);
937 status = ocfs2_mark_inode_dirty(handle, dir, 938
938 parent_node_bh); 939 status = ocfs2_mark_inode_dirty(handle, dir, parent_node_bh);
939 if (status < 0) { 940 if (status < 0) {
940 mlog_errno(status); 941 mlog_errno(status);
942 if (S_ISDIR(inode->i_mode))
941 inc_nlink(dir); 943 inc_nlink(dir);
942 }
943 } 944 }
944 945
945leave: 946leave:
@@ -1068,6 +1069,7 @@ static int ocfs2_rename(struct inode *old_dir,
1068 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; 1069 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
1069 struct buffer_head *orphan_entry_bh = NULL; 1070 struct buffer_head *orphan_entry_bh = NULL;
1070 struct buffer_head *newfe_bh = NULL; 1071 struct buffer_head *newfe_bh = NULL;
1072 struct buffer_head *old_inode_bh = NULL;
1071 struct buffer_head *insert_entry_bh = NULL; 1073 struct buffer_head *insert_entry_bh = NULL;
1072 struct ocfs2_super *osb = NULL; 1074 struct ocfs2_super *osb = NULL;
1073 u64 newfe_blkno; 1075 u64 newfe_blkno;
@@ -1079,7 +1081,7 @@ static int ocfs2_rename(struct inode *old_dir,
1079 struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above 1081 struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above
1080 struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir, 1082 struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir,
1081 // this is the 1st dirent bh 1083 // this is the 1st dirent bh
1082 nlink_t old_dir_nlink = old_dir->i_nlink, new_dir_nlink = new_dir->i_nlink; 1084 nlink_t old_dir_nlink = old_dir->i_nlink;
1083 1085
1084 /* At some point it might be nice to break this function up a 1086 /* At some point it might be nice to break this function up a
1085 * bit. */ 1087 * bit. */
@@ -1139,12 +1141,11 @@ static int ocfs2_rename(struct inode *old_dir,
1139 } 1141 }
1140 1142
1141 /* 1143 /*
1142 * Though we don't require an inode meta data update if 1144 * Aside from allowing a meta data update, the locking here
1143 * old_inode is not a directory, we lock anyway here to ensure 1145 * also ensures that the vote thread on other nodes won't have
1144 * the vote thread on other nodes won't have to concurrently 1146 * to concurrently downconvert the inode and the dentry locks.
1145 * downconvert the inode and the dentry locks.
1146 */ 1147 */
1147 status = ocfs2_meta_lock(old_inode, NULL, 1); 1148 status = ocfs2_meta_lock(old_inode, &old_inode_bh, 1);
1148 if (status < 0) { 1149 if (status < 0) {
1149 if (status != -ENOENT) 1150 if (status != -ENOENT)
1150 mlog_errno(status); 1151 mlog_errno(status);
@@ -1355,6 +1356,7 @@ static int ocfs2_rename(struct inode *old_dir,
1355 1356
1356 old_inode->i_ctime = CURRENT_TIME; 1357 old_inode->i_ctime = CURRENT_TIME;
1357 mark_inode_dirty(old_inode); 1358 mark_inode_dirty(old_inode);
1359 ocfs2_mark_inode_dirty(handle, old_inode, old_inode_bh);
1358 1360
1359 /* now that the name has been added to new_dir, remove the old name */ 1361 /* now that the name has been added to new_dir, remove the old name */
1360 status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); 1362 status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh);
@@ -1384,27 +1386,22 @@ static int ocfs2_rename(struct inode *old_dir,
1384 } 1386 }
1385 } 1387 }
1386 mark_inode_dirty(old_dir); 1388 mark_inode_dirty(old_dir);
1387 if (new_inode) 1389 ocfs2_mark_inode_dirty(handle, old_dir, old_dir_bh);
1390 if (new_inode) {
1388 mark_inode_dirty(new_inode); 1391 mark_inode_dirty(new_inode);
1392 ocfs2_mark_inode_dirty(handle, new_inode, newfe_bh);
1393 }
1389 1394
1390 if (old_dir != new_dir) 1395 if (old_dir != new_dir) {
1391 if (new_dir_nlink != new_dir->i_nlink) { 1396 /* Keep the same times on both directories.*/
1392 if (!new_dir_bh) { 1397 new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
1393 mlog(ML_ERROR, "need to change nlink for new " 1398
1394 "dir %llu from %d to %d but bh is NULL\n", 1399 /*
1395 (unsigned long long)OCFS2_I(new_dir)->ip_blkno, 1400 * This will also pick up the i_nlink change from the
1396 (int)new_dir_nlink, new_dir->i_nlink); 1401 * block above.
1397 } else { 1402 */
1398 struct ocfs2_dinode *fe; 1403 ocfs2_mark_inode_dirty(handle, new_dir, new_dir_bh);
1399 status = ocfs2_journal_access(handle, 1404 }
1400 new_dir,
1401 new_dir_bh,
1402 OCFS2_JOURNAL_ACCESS_WRITE);
1403 fe = (struct ocfs2_dinode *) new_dir_bh->b_data;
1404 fe->i_links_count = cpu_to_le16(new_dir->i_nlink);
1405 status = ocfs2_journal_dirty(handle, new_dir_bh);
1406 }
1407 }
1408 1405
1409 if (old_dir_nlink != old_dir->i_nlink) { 1406 if (old_dir_nlink != old_dir->i_nlink) {
1410 if (!old_dir_bh) { 1407 if (!old_dir_bh) {
@@ -1455,6 +1452,8 @@ bail:
1455 iput(new_inode); 1452 iput(new_inode);
1456 if (newfe_bh) 1453 if (newfe_bh)
1457 brelse(newfe_bh); 1454 brelse(newfe_bh);
1455 if (old_inode_bh)
1456 brelse(old_inode_bh);
1458 if (old_dir_bh) 1457 if (old_dir_bh)
1459 brelse(old_dir_bh); 1458 brelse(old_dir_bh);
1460 if (new_dir_bh) 1459 if (new_dir_bh)
@@ -1826,6 +1825,13 @@ static int __ocfs2_add_entry(handle_t *handle,
1826 (le16_to_cpu(de->rec_len) >= rec_len)) || 1825 (le16_to_cpu(de->rec_len) >= rec_len)) ||
1827 (le16_to_cpu(de->rec_len) >= 1826 (le16_to_cpu(de->rec_len) >=
1828 (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) { 1827 (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) {
1828 dir->i_mtime = dir->i_ctime = CURRENT_TIME;
1829 retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
1830 if (retval < 0) {
1831 mlog_errno(retval);
1832 goto bail;
1833 }
1834
1829 status = ocfs2_journal_access(handle, dir, insert_bh, 1835 status = ocfs2_journal_access(handle, dir, insert_bh,
1830 OCFS2_JOURNAL_ACCESS_WRITE); 1836 OCFS2_JOURNAL_ACCESS_WRITE);
1831 /* By now the buffer is marked for journaling */ 1837 /* By now the buffer is marked for journaling */
@@ -1848,7 +1854,6 @@ static int __ocfs2_add_entry(handle_t *handle,
1848 de->name_len = namelen; 1854 de->name_len = namelen;
1849 memcpy(de->name, name, namelen); 1855 memcpy(de->name, name, namelen);
1850 1856
1851 dir->i_mtime = dir->i_ctime = CURRENT_TIME;
1852 dir->i_version++; 1857 dir->i_version++;
1853 status = ocfs2_journal_dirty(handle, insert_bh); 1858 status = ocfs2_journal_dirty(handle, insert_bh);
1854 retval = 0; 1859 retval = 0;
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index b5c68567077e..c99e9058c198 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -85,7 +85,7 @@
85#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ 85#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask) 86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
87 87
88#define OCFS2_FEATURE_COMPAT_SUPP 0 88#define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB
89#define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 89#define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT
90#define OCFS2_FEATURE_RO_COMPAT_SUPP 0 90#define OCFS2_FEATURE_RO_COMPAT_SUPP 0
91 91
@@ -110,6 +110,20 @@
110#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 110#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
111 111
112/* 112/*
113 * backup superblock flag is used to indicate that this volume
114 * has backup superblocks.
115 */
116#define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
117
118/* The byte offset of the first backup block will be 1G.
119 * The following will be 4G, 16G, 64G, 256G and 1T.
120 */
121#define OCFS2_BACKUP_SB_START 1 << 30
122
123/* the max backup superblock nums */
124#define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
125
126/*
113 * Flags on ocfs2_dinode.i_flags 127 * Flags on ocfs2_dinode.i_flags
114 */ 128 */
115#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ 129#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
@@ -566,6 +580,20 @@ static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
566 580
567 return size / sizeof(struct ocfs2_truncate_rec); 581 return size / sizeof(struct ocfs2_truncate_rec);
568} 582}
583
584static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
585{
586 u64 offset = OCFS2_BACKUP_SB_START;
587
588 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
589 offset <<= (2 * index);
590 offset /= sb->s_blocksize;
591 return offset;
592 }
593
594 return 0;
595
596}
569#else 597#else
570static inline int ocfs2_fast_symlink_chars(int blocksize) 598static inline int ocfs2_fast_symlink_chars(int blocksize)
571{ 599{
@@ -631,6 +659,19 @@ static inline int ocfs2_truncate_recs_per_inode(int blocksize)
631 659
632 return size / sizeof(struct ocfs2_truncate_rec); 660 return size / sizeof(struct ocfs2_truncate_rec);
633} 661}
662
663static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
664{
665 uint64_t offset = OCFS2_BACKUP_SB_START;
666
667 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
668 offset <<= (2 * index);
669 offset /= blocksize;
670 return offset;
671 }
672
673 return 0;
674}
634#endif /* __KERNEL__ */ 675#endif /* __KERNEL__ */
635 676
636 677
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index 957d6878b03e..03b0191534d5 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -158,8 +158,7 @@ static void *ocfs2_follow_link(struct dentry *dentry,
158 } 158 }
159 159
160 status = vfs_follow_link(nd, link); 160 status = vfs_follow_link(nd, link);
161 if (status && status != -ENOENT) 161
162 mlog_errno(status);
163bail: 162bail:
164 if (page) { 163 if (page) {
165 kunmap(page); 164 kunmap(page);
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 92ea7743fe8f..b37ce33f67ea 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -47,7 +47,6 @@
47#include <linux/vmalloc.h> 47#include <linux/vmalloc.h>
48#include <linux/crash_dump.h> 48#include <linux/crash_dump.h>
49#include <linux/pid_namespace.h> 49#include <linux/pid_namespace.h>
50#include <linux/compile.h>
51#include <asm/uaccess.h> 50#include <asm/uaccess.h>
52#include <asm/pgtable.h> 51#include <asm/pgtable.h>
53#include <asm/io.h> 52#include <asm/io.h>
@@ -254,12 +253,7 @@ static int version_read_proc(char *page, char **start, off_t off,
254{ 253{
255 int len; 254 int len;
256 255
257 /* FIXED STRING! Don't touch! */ 256 len = snprintf(page, PAGE_SIZE, linux_proc_banner,
258 len = snprintf(page, PAGE_SIZE,
259 "%s version %s"
260 " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
261 " (" LINUX_COMPILER ")"
262 " %s\n",
263 utsname()->sysname, 257 utsname()->sysname,
264 utsname()->release, 258 utsname()->release,
265 utsname()->version); 259 utsname()->version);
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
index 0947fb57dcf3..54ebbc84207f 100644
--- a/fs/ramfs/file-mmu.c
+++ b/fs/ramfs/file-mmu.c
@@ -25,11 +25,13 @@
25 */ 25 */
26 26
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/mm.h>
28 29
29const struct address_space_operations ramfs_aops = { 30const struct address_space_operations ramfs_aops = {
30 .readpage = simple_readpage, 31 .readpage = simple_readpage,
31 .prepare_write = simple_prepare_write, 32 .prepare_write = simple_prepare_write,
32 .commit_write = simple_commit_write 33 .commit_write = simple_commit_write,
34 .set_page_dirty = __set_page_dirty_nobuffers,
33}; 35};
34 36
35const struct file_operations ramfs_file_operations = { 37const struct file_operations ramfs_file_operations = {
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 61cbe1ef06b9..e9d6c4733282 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/mm.h>
14#include <linux/pagemap.h> 15#include <linux/pagemap.h>
15#include <linux/highmem.h> 16#include <linux/highmem.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -30,7 +31,8 @@ static int ramfs_nommu_setattr(struct dentry *, struct iattr *);
30const struct address_space_operations ramfs_aops = { 31const struct address_space_operations ramfs_aops = {
31 .readpage = simple_readpage, 32 .readpage = simple_readpage,
32 .prepare_write = simple_prepare_write, 33 .prepare_write = simple_prepare_write,
33 .commit_write = simple_commit_write 34 .commit_write = simple_commit_write,
35 .set_page_dirty = __set_page_dirty_nobuffers,
34}; 36};
35 37
36const struct file_operations ramfs_file_operations = { 38const struct file_operations ramfs_file_operations = {
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 99b6f329ba23..5109f1d5e7ff 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -48,6 +48,11 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
48 } 48 }
49 49
50 mutex_lock(&inode->i_mutex); 50 mutex_lock(&inode->i_mutex);
51
52 mutex_lock(&(REISERFS_I(inode)->i_mmap));
53 if (REISERFS_I(inode)->i_flags & i_ever_mapped)
54 REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
55
51 reiserfs_write_lock(inode->i_sb); 56 reiserfs_write_lock(inode->i_sb);
52 /* freeing preallocation only involves relogging blocks that 57 /* freeing preallocation only involves relogging blocks that
53 * are already in the current transaction. preallocation gets 58 * are already in the current transaction. preallocation gets
@@ -100,11 +105,24 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
100 err = reiserfs_truncate_file(inode, 0); 105 err = reiserfs_truncate_file(inode, 0);
101 } 106 }
102 out: 107 out:
108 mutex_unlock(&(REISERFS_I(inode)->i_mmap));
103 mutex_unlock(&inode->i_mutex); 109 mutex_unlock(&inode->i_mutex);
104 reiserfs_write_unlock(inode->i_sb); 110 reiserfs_write_unlock(inode->i_sb);
105 return err; 111 return err;
106} 112}
107 113
114static int reiserfs_file_mmap(struct file *file, struct vm_area_struct *vma)
115{
116 struct inode *inode;
117
118 inode = file->f_path.dentry->d_inode;
119 mutex_lock(&(REISERFS_I(inode)->i_mmap));
120 REISERFS_I(inode)->i_flags |= i_ever_mapped;
121 mutex_unlock(&(REISERFS_I(inode)->i_mmap));
122
123 return generic_file_mmap(file, vma);
124}
125
108static void reiserfs_vfs_truncate_file(struct inode *inode) 126static void reiserfs_vfs_truncate_file(struct inode *inode)
109{ 127{
110 reiserfs_truncate_file(inode, 1); 128 reiserfs_truncate_file(inode, 1);
@@ -1527,7 +1545,7 @@ const struct file_operations reiserfs_file_operations = {
1527#ifdef CONFIG_COMPAT 1545#ifdef CONFIG_COMPAT
1528 .compat_ioctl = reiserfs_compat_ioctl, 1546 .compat_ioctl = reiserfs_compat_ioctl,
1529#endif 1547#endif
1530 .mmap = generic_file_mmap, 1548 .mmap = reiserfs_file_mmap,
1531 .open = generic_file_open, 1549 .open = generic_file_open,
1532 .release = reiserfs_file_release, 1550 .release = reiserfs_file_release,
1533 .fsync = reiserfs_sync_file, 1551 .fsync = reiserfs_sync_file,
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index f3d1c4a77979..9fcbfe316977 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1125,6 +1125,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
1125 REISERFS_I(inode)->i_prealloc_count = 0; 1125 REISERFS_I(inode)->i_prealloc_count = 0;
1126 REISERFS_I(inode)->i_trans_id = 0; 1126 REISERFS_I(inode)->i_trans_id = 0;
1127 REISERFS_I(inode)->i_jl = NULL; 1127 REISERFS_I(inode)->i_jl = NULL;
1128 mutex_init(&(REISERFS_I(inode)->i_mmap));
1128 reiserfs_init_acl_access(inode); 1129 reiserfs_init_acl_access(inode);
1129 reiserfs_init_acl_default(inode); 1130 reiserfs_init_acl_default(inode);
1130 reiserfs_init_xattr_rwsem(inode); 1131 reiserfs_init_xattr_rwsem(inode);
@@ -1832,6 +1833,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1832 REISERFS_I(inode)->i_attrs = 1833 REISERFS_I(inode)->i_attrs =
1833 REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK; 1834 REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK;
1834 sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode); 1835 sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode);
1836 mutex_init(&(REISERFS_I(inode)->i_mmap));
1835 reiserfs_init_acl_access(inode); 1837 reiserfs_init_acl_access(inode);
1836 reiserfs_init_acl_default(inode); 1838 reiserfs_init_acl_default(inode);
1837 reiserfs_init_xattr_rwsem(inode); 1839 reiserfs_init_xattr_rwsem(inode);
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 47e7027ea39f..afb21ea45302 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -1459,7 +1459,7 @@ static void unmap_buffers(struct page *page, loff_t pos)
1459 bh = next; 1459 bh = next;
1460 } while (bh != head); 1460 } while (bh != head);
1461 if (PAGE_SIZE == bh->b_size) { 1461 if (PAGE_SIZE == bh->b_size) {
1462 clear_page_dirty(page); 1462 cancel_dirty_page(page, PAGE_CACHE_SIZE);
1463 } 1463 }
1464 } 1464 }
1465 } 1465 }
diff --git a/fs/super.c b/fs/super.c
index f961e0307997..3e7458c2bb76 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -753,9 +753,9 @@ int get_sb_bdev(struct file_system_type *fs_type,
753 * will protect the lockfs code from trying to start a snapshot 753 * will protect the lockfs code from trying to start a snapshot
754 * while we are mounting 754 * while we are mounting
755 */ 755 */
756 mutex_lock(&bdev->bd_mount_mutex); 756 down(&bdev->bd_mount_sem);
757 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); 757 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
758 mutex_unlock(&bdev->bd_mount_mutex); 758 up(&bdev->bd_mount_sem);
759 if (IS_ERR(s)) 759 if (IS_ERR(s))
760 goto error_s; 760 goto error_s;
761 761
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index b82381475779..2e0021e8f366 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -275,6 +275,25 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk,
275 UFSD("EXIT\n"); 275 UFSD("EXIT\n");
276} 276}
277 277
278static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n,
279 int sync)
280{
281 struct buffer_head *bh;
282 sector_t end = beg + n;
283
284 for (; beg < end; ++beg) {
285 bh = sb_getblk(inode->i_sb, beg);
286 lock_buffer(bh);
287 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
288 set_buffer_uptodate(bh);
289 mark_buffer_dirty(bh);
290 unlock_buffer(bh);
291 if (IS_SYNC(inode) || sync)
292 sync_dirty_buffer(bh);
293 brelse(bh);
294 }
295}
296
278unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, 297unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
279 unsigned goal, unsigned count, int * err, struct page *locked_page) 298 unsigned goal, unsigned count, int * err, struct page *locked_page)
280{ 299{
@@ -350,6 +369,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
350 *p = cpu_to_fs32(sb, result); 369 *p = cpu_to_fs32(sb, result);
351 *err = 0; 370 *err = 0;
352 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 371 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
372 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
373 locked_page != NULL);
353 } 374 }
354 unlock_super(sb); 375 unlock_super(sb);
355 UFSD("EXIT, result %u\n", result); 376 UFSD("EXIT, result %u\n", result);
@@ -363,6 +384,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
363 if (result) { 384 if (result) {
364 *err = 0; 385 *err = 0;
365 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 386 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
387 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
388 locked_page != NULL);
366 unlock_super(sb); 389 unlock_super(sb);
367 UFSD("EXIT, result %u\n", result); 390 UFSD("EXIT, result %u\n", result);
368 return result; 391 return result;
@@ -398,6 +421,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
398 *p = cpu_to_fs32(sb, result); 421 *p = cpu_to_fs32(sb, result);
399 *err = 0; 422 *err = 0;
400 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 423 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
424 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
425 locked_page != NULL);
401 unlock_super(sb); 426 unlock_super(sb);
402 if (newcount < request) 427 if (newcount < request)
403 ufs_free_fragments (inode, result + newcount, request - newcount); 428 ufs_free_fragments (inode, result + newcount, request - newcount);
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index ee1eaa6f4ec2..2fbab0aab688 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -156,36 +156,6 @@ out:
156 return ret; 156 return ret;
157} 157}
158 158
159static void ufs_clear_frag(struct inode *inode, struct buffer_head *bh)
160{
161 lock_buffer(bh);
162 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
163 set_buffer_uptodate(bh);
164 mark_buffer_dirty(bh);
165 unlock_buffer(bh);
166 if (IS_SYNC(inode))
167 sync_dirty_buffer(bh);
168}
169
170static struct buffer_head *
171ufs_clear_frags(struct inode *inode, sector_t beg,
172 unsigned int n, sector_t want)
173{
174 struct buffer_head *res = NULL, *bh;
175 sector_t end = beg + n;
176
177 for (; beg < end; ++beg) {
178 bh = sb_getblk(inode->i_sb, beg);
179 ufs_clear_frag(inode, bh);
180 if (want != beg)
181 brelse(bh);
182 else
183 res = bh;
184 }
185 BUG_ON(!res);
186 return res;
187}
188
189/** 159/**
190 * ufs_inode_getfrag() - allocate new fragment(s) 160 * ufs_inode_getfrag() - allocate new fragment(s)
191 * @inode - pointer to inode 161 * @inode - pointer to inode
@@ -302,7 +272,7 @@ repeat:
302 } 272 }
303 273
304 if (!phys) { 274 if (!phys) {
305 result = ufs_clear_frags(inode, tmp, required, tmp + blockoff); 275 result = sb_getblk(sb, tmp + blockoff);
306 } else { 276 } else {
307 *phys = tmp + blockoff; 277 *phys = tmp + blockoff;
308 result = NULL; 278 result = NULL;
@@ -403,8 +373,7 @@ repeat:
403 373
404 374
405 if (!phys) { 375 if (!phys) {
406 result = ufs_clear_frags(inode, tmp, uspi->s_fpb, 376 result = sb_getblk(sb, tmp + blockoff);
407 tmp + blockoff);
408 } else { 377 } else {
409 *phys = tmp + blockoff; 378 *phys = tmp + blockoff;
410 *new = 1; 379 *new = 1;
@@ -471,13 +440,13 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
471#define GET_INODE_DATABLOCK(x) \ 440#define GET_INODE_DATABLOCK(x) \
472 ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new, bh_result->b_page) 441 ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new, bh_result->b_page)
473#define GET_INODE_PTR(x) \ 442#define GET_INODE_PTR(x) \
474 ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, bh_result->b_page) 443 ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, NULL)
475#define GET_INDIRECT_DATABLOCK(x) \ 444#define GET_INDIRECT_DATABLOCK(x) \
476 ufs_inode_getblock(inode, bh, x, fragment, \ 445 ufs_inode_getblock(inode, bh, x, fragment, \
477 &err, &phys, &new, bh_result->b_page); 446 &err, &phys, &new, bh_result->b_page)
478#define GET_INDIRECT_PTR(x) \ 447#define GET_INDIRECT_PTR(x) \
479 ufs_inode_getblock(inode, bh, x, fragment, \ 448 ufs_inode_getblock(inode, bh, x, fragment, \
480 &err, NULL, NULL, bh_result->b_page); 449 &err, NULL, NULL, NULL)
481 450
482 if (ptr < UFS_NDIR_FRAGMENT) { 451 if (ptr < UFS_NDIR_FRAGMENT) {
483 bh = GET_INODE_DATABLOCK(ptr); 452 bh = GET_INODE_DATABLOCK(ptr);