aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 21:54:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 21:54:50 -0400
commitdfe2c6dcc8ca2cdc662d7c0473e9811b72ef3370 (patch)
tree9ed639a08c16322cdf136d576f42df5b97cd1549 /fs
parenta45d572841a24db02a62cf05e1157c35fdd3705b (diff)
parent64e455079e1bd7787cc47be30b7f601ce682a5f6 (diff)
Merge branch 'akpm' (patches from Andrew Morton)
Merge second patch-bomb from Andrew Morton: - a few hotfixes - drivers/dma updates - MAINTAINERS updates - Quite a lot of lib/ updates - checkpatch updates - binfmt updates - autofs4 - drivers/rtc/ - various small tweaks to less used filesystems - ipc/ updates - kernel/watchdog.c changes * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (135 commits) mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared kernel/param: consolidate __{start,stop}___param[] in <linux/moduleparam.h> ia64: remove duplicate declarations of __per_cpu_start[] and __per_cpu_end[] frv: remove unused declarations of __start___ex_table and __stop___ex_table kvm: ensure hard lockup detection is disabled by default kernel/watchdog.c: control hard lockup detection default staging: rtl8192u: use %*pEn to escape buffer staging: rtl8192e: use %*pEn to escape buffer staging: wlan-ng: use %*pEhp to print SN lib80211: remove unused print_ssid() wireless: hostap: proc: print properly escaped SSID wireless: ipw2x00: print SSID via %*pE wireless: libertas: print esaped string via %*pE lib/vsprintf: add %*pE[achnops] format specifier lib / string_helpers: introduce string_escape_mem() lib / string_helpers: refactoring the test suite lib / string_helpers: move documentation to c-file include/linux: remove strict_strto* definitions arch/x86/mm/numa.c: fix boot failure when all nodes are hotpluggable fs: check bh blocknr earlier when searching lru ...
Diffstat (limited to 'fs')
-rw-r--r--fs/affs/amigaffs.c2
-rw-r--r--fs/affs/file.c39
-rw-r--r--fs/affs/inode.c3
-rw-r--r--fs/affs/super.c6
-rw-r--r--fs/autofs4/autofs_i.h6
-rw-r--r--fs/autofs4/dev-ioctl.c2
-rw-r--r--fs/autofs4/expire.c210
-rw-r--r--fs/autofs4/root.c62
-rw-r--r--fs/befs/btree.c53
-rw-r--r--fs/binfmt_misc.c23
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/cifs/cifs_dfs_ref.c6
-rw-r--r--fs/cifs/connect.c4
-rw-r--r--fs/coredump.c8
-rw-r--r--fs/fat/misc.c2
-rw-r--r--fs/hfs/hfs_fs.h2
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/ncpfs/dir.c3
-rw-r--r--fs/nilfs2/file.c8
-rw-r--r--fs/nilfs2/inode.c13
-rw-r--r--fs/nilfs2/ioctl.c8
-rw-r--r--fs/nilfs2/nilfs.h14
-rw-r--r--fs/nilfs2/segment.c7
-rw-r--r--fs/nilfs2/super.c6
-rw-r--r--fs/nilfs2/the_nilfs.h22
-rw-r--r--fs/ocfs2/cluster/heartbeat.c2
-rw-r--r--fs/ocfs2/cluster/masklog.c6
-rw-r--r--fs/omfs/inode.c10
-rw-r--r--fs/omfs/omfs_fs.h1
-rw-r--r--fs/proc/task_mmu.c19
-rw-r--r--fs/reiserfs/journal.c8
-rw-r--r--fs/ufs/balloc.c3
32 files changed, 355 insertions, 209 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 406b29836b19..abc853968fed 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -10,8 +10,6 @@
10 10
11#include "affs.h" 11#include "affs.h"
12 12
13extern struct timezone sys_tz;
14
15static char ErrorBuffer[256]; 13static char ErrorBuffer[256];
16 14
17/* 15/*
diff --git a/fs/affs/file.c b/fs/affs/file.c
index a7fe57d2cd9a..1ed590aafecf 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -584,11 +584,14 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
584 bh->b_state &= ~(1UL << BH_New); 584 bh->b_state &= ~(1UL << BH_New);
585 mark_buffer_dirty_inode(bh, inode); 585 mark_buffer_dirty_inode(bh, inode);
586 if (prev_bh) { 586 if (prev_bh) {
587 u32 tmp = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); 587 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next);
588 if (tmp) 588
589 affs_warning(sb, "extent_file_ofs", "next block already set for %d (%d)", bidx, tmp); 589 if (tmp_next)
590 affs_warning(sb, "extent_file_ofs",
591 "next block already set for %d (%d)",
592 bidx, tmp_next);
590 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); 593 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr);
591 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp); 594 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next);
592 mark_buffer_dirty_inode(prev_bh, inode); 595 mark_buffer_dirty_inode(prev_bh, inode);
593 affs_brelse(prev_bh); 596 affs_brelse(prev_bh);
594 } 597 }
@@ -727,11 +730,14 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
727 AFFS_DATA_HEAD(bh)->next = 0; 730 AFFS_DATA_HEAD(bh)->next = 0;
728 bh->b_state &= ~(1UL << BH_New); 731 bh->b_state &= ~(1UL << BH_New);
729 if (prev_bh) { 732 if (prev_bh) {
730 u32 tmp = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); 733 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next);
731 if (tmp) 734
732 affs_warning(sb, "commit_write_ofs", "next block already set for %d (%d)", bidx, tmp); 735 if (tmp_next)
736 affs_warning(sb, "commit_write_ofs",
737 "next block already set for %d (%d)",
738 bidx, tmp_next);
733 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); 739 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr);
734 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp); 740 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next);
735 mark_buffer_dirty_inode(prev_bh, inode); 741 mark_buffer_dirty_inode(prev_bh, inode);
736 } 742 }
737 } 743 }
@@ -758,11 +764,14 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
758 AFFS_DATA_HEAD(bh)->next = 0; 764 AFFS_DATA_HEAD(bh)->next = 0;
759 bh->b_state &= ~(1UL << BH_New); 765 bh->b_state &= ~(1UL << BH_New);
760 if (prev_bh) { 766 if (prev_bh) {
761 u32 tmp = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); 767 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next);
762 if (tmp) 768
763 affs_warning(sb, "commit_write_ofs", "next block already set for %d (%d)", bidx, tmp); 769 if (tmp_next)
770 affs_warning(sb, "commit_write_ofs",
771 "next block already set for %d (%d)",
772 bidx, tmp_next);
764 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); 773 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr);
765 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp); 774 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next);
766 mark_buffer_dirty_inode(prev_bh, inode); 775 mark_buffer_dirty_inode(prev_bh, inode);
767 } 776 }
768 } else if (be32_to_cpu(AFFS_DATA_HEAD(bh)->size) < tmp) 777 } else if (be32_to_cpu(AFFS_DATA_HEAD(bh)->size) < tmp)
@@ -842,12 +851,12 @@ affs_truncate(struct inode *inode)
842 struct address_space *mapping = inode->i_mapping; 851 struct address_space *mapping = inode->i_mapping;
843 struct page *page; 852 struct page *page;
844 void *fsdata; 853 void *fsdata;
845 loff_t size = inode->i_size; 854 loff_t isize = inode->i_size;
846 int res; 855 int res;
847 856
848 res = mapping->a_ops->write_begin(NULL, mapping, size, 0, 0, &page, &fsdata); 857 res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, 0, &page, &fsdata);
849 if (!res) 858 if (!res)
850 res = mapping->a_ops->write_end(NULL, mapping, size, 0, 0, page, fsdata); 859 res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, page, fsdata);
851 else 860 else
852 inode->i_size = AFFS_I(inode)->mmu_private; 861 inode->i_size = AFFS_I(inode)->mmu_private;
853 mark_inode_dirty(inode); 862 mark_inode_dirty(inode);
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index bec2d1a0c91c..e217c511459b 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -14,13 +14,11 @@
14#include "affs.h" 14#include "affs.h"
15 15
16extern const struct inode_operations affs_symlink_inode_operations; 16extern const struct inode_operations affs_symlink_inode_operations;
17extern struct timezone sys_tz;
18 17
19struct inode *affs_iget(struct super_block *sb, unsigned long ino) 18struct inode *affs_iget(struct super_block *sb, unsigned long ino)
20{ 19{
21 struct affs_sb_info *sbi = AFFS_SB(sb); 20 struct affs_sb_info *sbi = AFFS_SB(sb);
22 struct buffer_head *bh; 21 struct buffer_head *bh;
23 struct affs_head *head;
24 struct affs_tail *tail; 22 struct affs_tail *tail;
25 struct inode *inode; 23 struct inode *inode;
26 u32 block; 24 u32 block;
@@ -49,7 +47,6 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
49 goto bad_inode; 47 goto bad_inode;
50 } 48 }
51 49
52 head = AFFS_HEAD(bh);
53 tail = AFFS_TAIL(sb, bh); 50 tail = AFFS_TAIL(sb, bh);
54 prot = be32_to_cpu(tail->protect); 51 prot = be32_to_cpu(tail->protect);
55 52
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 51f1a95bff73..f754ab68a840 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -20,8 +20,6 @@
20#include <linux/writeback.h> 20#include <linux/writeback.h>
21#include "affs.h" 21#include "affs.h"
22 22
23extern struct timezone sys_tz;
24
25static int affs_statfs(struct dentry *dentry, struct kstatfs *buf); 23static int affs_statfs(struct dentry *dentry, struct kstatfs *buf);
26static int affs_remount (struct super_block *sb, int *flags, char *data); 24static int affs_remount (struct super_block *sb, int *flags, char *data);
27 25
@@ -308,7 +306,6 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
308 u32 chksum; 306 u32 chksum;
309 int num_bm; 307 int num_bm;
310 int i, j; 308 int i, j;
311 s32 key;
312 kuid_t uid; 309 kuid_t uid;
313 kgid_t gid; 310 kgid_t gid;
314 int reserved; 311 int reserved;
@@ -367,7 +364,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
367 i = j = blocksize; 364 i = j = blocksize;
368 size = size / (blocksize / 512); 365 size = size / (blocksize / 512);
369 } 366 }
370 for (blocksize = i, key = 0; blocksize <= j; blocksize <<= 1, size >>= 1) { 367 for (blocksize = i; blocksize <= j; blocksize <<= 1, size >>= 1) {
371 sbi->s_root_block = root_block; 368 sbi->s_root_block = root_block;
372 if (root_block < 0) 369 if (root_block < 0)
373 sbi->s_root_block = (reserved + size - 1) / 2; 370 sbi->s_root_block = (reserved + size - 1) / 2;
@@ -399,7 +396,6 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
399 be32_to_cpu(AFFS_ROOT_TAIL(sb, root_bh)->stype) == ST_ROOT) { 396 be32_to_cpu(AFFS_ROOT_TAIL(sb, root_bh)->stype) == ST_ROOT) {
400 sbi->s_hashsize = blocksize / 4 - 56; 397 sbi->s_hashsize = blocksize / 4 - 56;
401 sbi->s_root_block += num_bm; 398 sbi->s_root_block += num_bm;
402 key = 1;
403 goto got_root; 399 goto got_root;
404 } 400 }
405 affs_brelse(root_bh); 401 affs_brelse(root_bh);
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 9e359fb20c0a..8e98cf954bab 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -79,6 +79,10 @@ struct autofs_info {
79}; 79};
80 80
81#define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ 81#define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */
82#define AUTOFS_INF_NO_RCU (1<<1) /* the dentry is being considered
83 * for expiry, so RCU_walk is
84 * not permitted
85 */
82#define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */ 86#define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */
83 87
84struct autofs_wait_queue { 88struct autofs_wait_queue {
@@ -148,7 +152,7 @@ void autofs4_free_ino(struct autofs_info *);
148 152
149/* Expiration */ 153/* Expiration */
150int is_autofs4_dentry(struct dentry *); 154int is_autofs4_dentry(struct dentry *);
151int autofs4_expire_wait(struct dentry *dentry); 155int autofs4_expire_wait(struct dentry *dentry, int rcu_walk);
152int autofs4_expire_run(struct super_block *, struct vfsmount *, 156int autofs4_expire_run(struct super_block *, struct vfsmount *,
153 struct autofs_sb_info *, 157 struct autofs_sb_info *,
154 struct autofs_packet_expire __user *); 158 struct autofs_packet_expire __user *);
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 5b570b6efa28..aaf96cb25452 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -450,7 +450,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
450 ino = autofs4_dentry_ino(path.dentry); 450 ino = autofs4_dentry_ino(path.dentry);
451 if (ino) { 451 if (ino) {
452 err = 0; 452 err = 0;
453 autofs4_expire_wait(path.dentry); 453 autofs4_expire_wait(path.dentry, 0);
454 spin_lock(&sbi->fs_lock); 454 spin_lock(&sbi->fs_lock);
455 param->requester.uid = from_kuid_munged(current_user_ns(), ino->uid); 455 param->requester.uid = from_kuid_munged(current_user_ns(), ino->uid);
456 param->requester.gid = from_kgid_munged(current_user_ns(), ino->gid); 456 param->requester.gid = from_kgid_munged(current_user_ns(), ino->gid);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 8fa3895cda02..683a5b9ce22a 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -30,12 +30,6 @@ static inline int autofs4_can_expire(struct dentry *dentry,
30 /* Too young to die */ 30 /* Too young to die */
31 if (!timeout || time_after(ino->last_used + timeout, now)) 31 if (!timeout || time_after(ino->last_used + timeout, now))
32 return 0; 32 return 0;
33
34 /* update last_used here :-
35 - obviously makes sense if it is in use now
36 - less obviously, prevents rapid-fire expire
37 attempts if expire fails the first time */
38 ino->last_used = now;
39 } 33 }
40 return 1; 34 return 1;
41} 35}
@@ -327,10 +321,19 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
327 if (ino->flags & AUTOFS_INF_PENDING) 321 if (ino->flags & AUTOFS_INF_PENDING)
328 goto out; 322 goto out;
329 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { 323 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
330 ino->flags |= AUTOFS_INF_EXPIRING; 324 ino->flags |= AUTOFS_INF_NO_RCU;
331 init_completion(&ino->expire_complete);
332 spin_unlock(&sbi->fs_lock); 325 spin_unlock(&sbi->fs_lock);
333 return root; 326 synchronize_rcu();
327 spin_lock(&sbi->fs_lock);
328 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
329 ino->flags |= AUTOFS_INF_EXPIRING;
330 smp_mb();
331 ino->flags &= ~AUTOFS_INF_NO_RCU;
332 init_completion(&ino->expire_complete);
333 spin_unlock(&sbi->fs_lock);
334 return root;
335 }
336 ino->flags &= ~AUTOFS_INF_NO_RCU;
334 } 337 }
335out: 338out:
336 spin_unlock(&sbi->fs_lock); 339 spin_unlock(&sbi->fs_lock);
@@ -339,6 +342,89 @@ out:
339 return NULL; 342 return NULL;
340} 343}
341 344
345/* Check if 'dentry' should expire, or return a nearby
346 * dentry that is suitable.
347 * If returned dentry is different from arg dentry,
348 * then a dget() reference was taken, else not.
349 */
350static struct dentry *should_expire(struct dentry *dentry,
351 struct vfsmount *mnt,
352 unsigned long timeout,
353 int how)
354{
355 int do_now = how & AUTOFS_EXP_IMMEDIATE;
356 int exp_leaves = how & AUTOFS_EXP_LEAVES;
357 struct autofs_info *ino = autofs4_dentry_ino(dentry);
358 unsigned int ino_count;
359
360 /* No point expiring a pending mount */
361 if (ino->flags & AUTOFS_INF_PENDING)
362 return NULL;
363
364 /*
365 * Case 1: (i) indirect mount or top level pseudo direct mount
366 * (autofs-4.1).
367 * (ii) indirect mount with offset mount, check the "/"
368 * offset (autofs-5.0+).
369 */
370 if (d_mountpoint(dentry)) {
371 DPRINTK("checking mountpoint %p %.*s",
372 dentry, (int)dentry->d_name.len, dentry->d_name.name);
373
374 /* Can we umount this guy */
375 if (autofs4_mount_busy(mnt, dentry))
376 return NULL;
377
378 /* Can we expire this guy */
379 if (autofs4_can_expire(dentry, timeout, do_now))
380 return dentry;
381 return NULL;
382 }
383
384 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) {
385 DPRINTK("checking symlink %p %.*s",
386 dentry, (int)dentry->d_name.len, dentry->d_name.name);
387 /*
388 * A symlink can't be "busy" in the usual sense so
389 * just check last used for expire timeout.
390 */
391 if (autofs4_can_expire(dentry, timeout, do_now))
392 return dentry;
393 return NULL;
394 }
395
396 if (simple_empty(dentry))
397 return NULL;
398
399 /* Case 2: tree mount, expire iff entire tree is not busy */
400 if (!exp_leaves) {
401 /* Path walk currently on this dentry? */
402 ino_count = atomic_read(&ino->count) + 1;
403 if (d_count(dentry) > ino_count)
404 return NULL;
405
406 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now))
407 return dentry;
408 /*
409 * Case 3: pseudo direct mount, expire individual leaves
410 * (autofs-4.1).
411 */
412 } else {
413 /* Path walk currently on this dentry? */
414 struct dentry *expired;
415 ino_count = atomic_read(&ino->count) + 1;
416 if (d_count(dentry) > ino_count)
417 return NULL;
418
419 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
420 if (expired) {
421 if (expired == dentry)
422 dput(dentry);
423 return expired;
424 }
425 }
426 return NULL;
427}
342/* 428/*
343 * Find an eligible tree to time-out 429 * Find an eligible tree to time-out
344 * A tree is eligible if :- 430 * A tree is eligible if :-
@@ -353,11 +439,8 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
353 unsigned long timeout; 439 unsigned long timeout;
354 struct dentry *root = sb->s_root; 440 struct dentry *root = sb->s_root;
355 struct dentry *dentry; 441 struct dentry *dentry;
356 struct dentry *expired = NULL; 442 struct dentry *expired;
357 int do_now = how & AUTOFS_EXP_IMMEDIATE;
358 int exp_leaves = how & AUTOFS_EXP_LEAVES;
359 struct autofs_info *ino; 443 struct autofs_info *ino;
360 unsigned int ino_count;
361 444
362 if (!root) 445 if (!root)
363 return NULL; 446 return NULL;
@@ -369,77 +452,28 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
369 while ((dentry = get_next_positive_subdir(dentry, root))) { 452 while ((dentry = get_next_positive_subdir(dentry, root))) {
370 spin_lock(&sbi->fs_lock); 453 spin_lock(&sbi->fs_lock);
371 ino = autofs4_dentry_ino(dentry); 454 ino = autofs4_dentry_ino(dentry);
372 /* No point expiring a pending mount */ 455 if (ino->flags & AUTOFS_INF_NO_RCU)
373 if (ino->flags & AUTOFS_INF_PENDING) 456 expired = NULL;
374 goto next; 457 else
375 458 expired = should_expire(dentry, mnt, timeout, how);
376 /* 459 if (!expired) {
377 * Case 1: (i) indirect mount or top level pseudo direct mount 460 spin_unlock(&sbi->fs_lock);
378 * (autofs-4.1). 461 continue;
379 * (ii) indirect mount with offset mount, check the "/"
380 * offset (autofs-5.0+).
381 */
382 if (d_mountpoint(dentry)) {
383 DPRINTK("checking mountpoint %p %.*s",
384 dentry, (int)dentry->d_name.len, dentry->d_name.name);
385
386 /* Can we umount this guy */
387 if (autofs4_mount_busy(mnt, dentry))
388 goto next;
389
390 /* Can we expire this guy */
391 if (autofs4_can_expire(dentry, timeout, do_now)) {
392 expired = dentry;
393 goto found;
394 }
395 goto next;
396 } 462 }
397 463 ino = autofs4_dentry_ino(expired);
398 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) { 464 ino->flags |= AUTOFS_INF_NO_RCU;
399 DPRINTK("checking symlink %p %.*s", 465 spin_unlock(&sbi->fs_lock);
400 dentry, (int)dentry->d_name.len, dentry->d_name.name); 466 synchronize_rcu();
401 /* 467 spin_lock(&sbi->fs_lock);
402 * A symlink can't be "busy" in the usual sense so 468 if (should_expire(expired, mnt, timeout, how)) {
403 * just check last used for expire timeout. 469 if (expired != dentry)
404 */
405 if (autofs4_can_expire(dentry, timeout, do_now)) {
406 expired = dentry;
407 goto found;
408 }
409 goto next;
410 }
411
412 if (simple_empty(dentry))
413 goto next;
414
415 /* Case 2: tree mount, expire iff entire tree is not busy */
416 if (!exp_leaves) {
417 /* Path walk currently on this dentry? */
418 ino_count = atomic_read(&ino->count) + 1;
419 if (d_count(dentry) > ino_count)
420 goto next;
421
422 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) {
423 expired = dentry;
424 goto found;
425 }
426 /*
427 * Case 3: pseudo direct mount, expire individual leaves
428 * (autofs-4.1).
429 */
430 } else {
431 /* Path walk currently on this dentry? */
432 ino_count = atomic_read(&ino->count) + 1;
433 if (d_count(dentry) > ino_count)
434 goto next;
435
436 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
437 if (expired) {
438 dput(dentry); 470 dput(dentry);
439 goto found; 471 goto found;
440 }
441 } 472 }
442next: 473
474 ino->flags &= ~AUTOFS_INF_NO_RCU;
475 if (expired != dentry)
476 dput(expired);
443 spin_unlock(&sbi->fs_lock); 477 spin_unlock(&sbi->fs_lock);
444 } 478 }
445 return NULL; 479 return NULL;
@@ -447,8 +481,9 @@ next:
447found: 481found:
448 DPRINTK("returning %p %.*s", 482 DPRINTK("returning %p %.*s",
449 expired, (int)expired->d_name.len, expired->d_name.name); 483 expired, (int)expired->d_name.len, expired->d_name.name);
450 ino = autofs4_dentry_ino(expired);
451 ino->flags |= AUTOFS_INF_EXPIRING; 484 ino->flags |= AUTOFS_INF_EXPIRING;
485 smp_mb();
486 ino->flags &= ~AUTOFS_INF_NO_RCU;
452 init_completion(&ino->expire_complete); 487 init_completion(&ino->expire_complete);
453 spin_unlock(&sbi->fs_lock); 488 spin_unlock(&sbi->fs_lock);
454 spin_lock(&sbi->lookup_lock); 489 spin_lock(&sbi->lookup_lock);
@@ -461,13 +496,18 @@ found:
461 return expired; 496 return expired;
462} 497}
463 498
464int autofs4_expire_wait(struct dentry *dentry) 499int autofs4_expire_wait(struct dentry *dentry, int rcu_walk)
465{ 500{
466 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 501 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
467 struct autofs_info *ino = autofs4_dentry_ino(dentry); 502 struct autofs_info *ino = autofs4_dentry_ino(dentry);
468 int status; 503 int status;
469 504
470 /* Block on any pending expire */ 505 /* Block on any pending expire */
506 if (!(ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU)))
507 return 0;
508 if (rcu_walk)
509 return -ECHILD;
510
471 spin_lock(&sbi->fs_lock); 511 spin_lock(&sbi->fs_lock);
472 if (ino->flags & AUTOFS_INF_EXPIRING) { 512 if (ino->flags & AUTOFS_INF_EXPIRING) {
473 spin_unlock(&sbi->fs_lock); 513 spin_unlock(&sbi->fs_lock);
@@ -519,6 +559,8 @@ int autofs4_expire_run(struct super_block *sb,
519 559
520 spin_lock(&sbi->fs_lock); 560 spin_lock(&sbi->fs_lock);
521 ino = autofs4_dentry_ino(dentry); 561 ino = autofs4_dentry_ino(dentry);
562 /* avoid rapid-fire expire attempts if expiry fails */
563 ino->last_used = now;
522 ino->flags &= ~AUTOFS_INF_EXPIRING; 564 ino->flags &= ~AUTOFS_INF_EXPIRING;
523 complete_all(&ino->expire_complete); 565 complete_all(&ino->expire_complete);
524 spin_unlock(&sbi->fs_lock); 566 spin_unlock(&sbi->fs_lock);
@@ -545,6 +587,8 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
545 ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); 587 ret = autofs4_wait(sbi, dentry, NFY_EXPIRE);
546 588
547 spin_lock(&sbi->fs_lock); 589 spin_lock(&sbi->fs_lock);
590 /* avoid rapid-fire expire attempts if expiry fails */
591 ino->last_used = now;
548 ino->flags &= ~AUTOFS_INF_EXPIRING; 592 ino->flags &= ~AUTOFS_INF_EXPIRING;
549 complete_all(&ino->expire_complete); 593 complete_all(&ino->expire_complete);
550 spin_unlock(&sbi->fs_lock); 594 spin_unlock(&sbi->fs_lock);
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index cdb25ebccc4c..d76d083f2f06 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -210,7 +210,8 @@ next:
210 return NULL; 210 return NULL;
211} 211}
212 212
213static struct dentry *autofs4_lookup_expiring(struct dentry *dentry) 213static struct dentry *autofs4_lookup_expiring(struct dentry *dentry,
214 bool rcu_walk)
214{ 215{
215 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 216 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
216 struct dentry *parent = dentry->d_parent; 217 struct dentry *parent = dentry->d_parent;
@@ -229,6 +230,11 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
229 struct dentry *expiring; 230 struct dentry *expiring;
230 struct qstr *qstr; 231 struct qstr *qstr;
231 232
233 if (rcu_walk) {
234 spin_unlock(&sbi->lookup_lock);
235 return ERR_PTR(-ECHILD);
236 }
237
232 ino = list_entry(p, struct autofs_info, expiring); 238 ino = list_entry(p, struct autofs_info, expiring);
233 expiring = ino->dentry; 239 expiring = ino->dentry;
234 240
@@ -264,13 +270,15 @@ next:
264 return NULL; 270 return NULL;
265} 271}
266 272
267static int autofs4_mount_wait(struct dentry *dentry) 273static int autofs4_mount_wait(struct dentry *dentry, bool rcu_walk)
268{ 274{
269 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 275 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
270 struct autofs_info *ino = autofs4_dentry_ino(dentry); 276 struct autofs_info *ino = autofs4_dentry_ino(dentry);
271 int status = 0; 277 int status = 0;
272 278
273 if (ino->flags & AUTOFS_INF_PENDING) { 279 if (ino->flags & AUTOFS_INF_PENDING) {
280 if (rcu_walk)
281 return -ECHILD;
274 DPRINTK("waiting for mount name=%.*s", 282 DPRINTK("waiting for mount name=%.*s",
275 dentry->d_name.len, dentry->d_name.name); 283 dentry->d_name.len, dentry->d_name.name);
276 status = autofs4_wait(sbi, dentry, NFY_MOUNT); 284 status = autofs4_wait(sbi, dentry, NFY_MOUNT);
@@ -280,20 +288,22 @@ static int autofs4_mount_wait(struct dentry *dentry)
280 return status; 288 return status;
281} 289}
282 290
283static int do_expire_wait(struct dentry *dentry) 291static int do_expire_wait(struct dentry *dentry, bool rcu_walk)
284{ 292{
285 struct dentry *expiring; 293 struct dentry *expiring;
286 294
287 expiring = autofs4_lookup_expiring(dentry); 295 expiring = autofs4_lookup_expiring(dentry, rcu_walk);
296 if (IS_ERR(expiring))
297 return PTR_ERR(expiring);
288 if (!expiring) 298 if (!expiring)
289 return autofs4_expire_wait(dentry); 299 return autofs4_expire_wait(dentry, rcu_walk);
290 else { 300 else {
291 /* 301 /*
292 * If we are racing with expire the request might not 302 * If we are racing with expire the request might not
293 * be quite complete, but the directory has been removed 303 * be quite complete, but the directory has been removed
294 * so it must have been successful, just wait for it. 304 * so it must have been successful, just wait for it.
295 */ 305 */
296 autofs4_expire_wait(expiring); 306 autofs4_expire_wait(expiring, 0);
297 autofs4_del_expiring(expiring); 307 autofs4_del_expiring(expiring);
298 dput(expiring); 308 dput(expiring);
299 } 309 }
@@ -345,7 +355,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
345 * and the directory was removed, so just go ahead and try 355 * and the directory was removed, so just go ahead and try
346 * the mount. 356 * the mount.
347 */ 357 */
348 status = do_expire_wait(dentry); 358 status = do_expire_wait(dentry, 0);
349 if (status && status != -EAGAIN) 359 if (status && status != -EAGAIN)
350 return NULL; 360 return NULL;
351 361
@@ -353,7 +363,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
353 spin_lock(&sbi->fs_lock); 363 spin_lock(&sbi->fs_lock);
354 if (ino->flags & AUTOFS_INF_PENDING) { 364 if (ino->flags & AUTOFS_INF_PENDING) {
355 spin_unlock(&sbi->fs_lock); 365 spin_unlock(&sbi->fs_lock);
356 status = autofs4_mount_wait(dentry); 366 status = autofs4_mount_wait(dentry, 0);
357 if (status) 367 if (status)
358 return ERR_PTR(status); 368 return ERR_PTR(status);
359 goto done; 369 goto done;
@@ -394,7 +404,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
394 } 404 }
395 ino->flags |= AUTOFS_INF_PENDING; 405 ino->flags |= AUTOFS_INF_PENDING;
396 spin_unlock(&sbi->fs_lock); 406 spin_unlock(&sbi->fs_lock);
397 status = autofs4_mount_wait(dentry); 407 status = autofs4_mount_wait(dentry, 0);
398 spin_lock(&sbi->fs_lock); 408 spin_lock(&sbi->fs_lock);
399 ino->flags &= ~AUTOFS_INF_PENDING; 409 ino->flags &= ~AUTOFS_INF_PENDING;
400 if (status) { 410 if (status) {
@@ -423,28 +433,46 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
423 433
424 /* The daemon never waits. */ 434 /* The daemon never waits. */
425 if (autofs4_oz_mode(sbi)) { 435 if (autofs4_oz_mode(sbi)) {
426 if (rcu_walk)
427 return 0;
428 if (!d_mountpoint(dentry)) 436 if (!d_mountpoint(dentry))
429 return -EISDIR; 437 return -EISDIR;
430 return 0; 438 return 0;
431 } 439 }
432 440
433 /* We need to sleep, so we need pathwalk to be in ref-mode */
434 if (rcu_walk)
435 return -ECHILD;
436
437 /* Wait for pending expires */ 441 /* Wait for pending expires */
438 do_expire_wait(dentry); 442 if (do_expire_wait(dentry, rcu_walk) == -ECHILD)
443 return -ECHILD;
439 444
440 /* 445 /*
441 * This dentry may be under construction so wait on mount 446 * This dentry may be under construction so wait on mount
442 * completion. 447 * completion.
443 */ 448 */
444 status = autofs4_mount_wait(dentry); 449 status = autofs4_mount_wait(dentry, rcu_walk);
445 if (status) 450 if (status)
446 return status; 451 return status;
447 452
453 if (rcu_walk) {
454 /* We don't need fs_lock in rcu_walk mode,
455 * just testing 'AUTOFS_INFO_NO_RCU' is enough.
456 * simple_empty() takes a spinlock, so leave it
457 * to last.
458 * We only return -EISDIR when certain this isn't
459 * a mount-trap.
460 */
461 struct inode *inode;
462 if (ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU))
463 return 0;
464 if (d_mountpoint(dentry))
465 return 0;
466 inode = ACCESS_ONCE(dentry->d_inode);
467 if (inode && S_ISLNK(inode->i_mode))
468 return -EISDIR;
469 if (list_empty(&dentry->d_subdirs))
470 return 0;
471 if (!simple_empty(dentry))
472 return -EISDIR;
473 return 0;
474 }
475
448 spin_lock(&sbi->fs_lock); 476 spin_lock(&sbi->fs_lock);
449 /* 477 /*
450 * If the dentry has been selected for expire while we slept 478 * If the dentry has been selected for expire while we slept
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 9c7faa8a9288..0826e91dacda 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -78,11 +78,11 @@
78/* 78/*
79 * In memory structure of each btree node 79 * In memory structure of each btree node
80 */ 80 */
81typedef struct { 81struct befs_btree_node {
82 befs_host_btree_nodehead head; /* head of node converted to cpu byteorder */ 82 befs_host_btree_nodehead head; /* head of node converted to cpu byteorder */
83 struct buffer_head *bh; 83 struct buffer_head *bh;
84 befs_btree_nodehead *od_node; /* on disk node */ 84 befs_btree_nodehead *od_node; /* on disk node */
85} befs_btree_node; 85};
86 86
87/* local constants */ 87/* local constants */
88static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL; 88static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL;
@@ -90,27 +90,30 @@ static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL;
90/* local functions */ 90/* local functions */
91static int befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds, 91static int befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
92 befs_btree_super * bt_super, 92 befs_btree_super * bt_super,
93 befs_btree_node * this_node, 93 struct befs_btree_node *this_node,
94 befs_off_t * node_off); 94 befs_off_t * node_off);
95 95
96static int befs_bt_read_super(struct super_block *sb, befs_data_stream * ds, 96static int befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
97 befs_btree_super * sup); 97 befs_btree_super * sup);
98 98
99static int befs_bt_read_node(struct super_block *sb, befs_data_stream * ds, 99static int befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
100 befs_btree_node * node, befs_off_t node_off); 100 struct befs_btree_node *node,
101 befs_off_t node_off);
101 102
102static int befs_leafnode(befs_btree_node * node); 103static int befs_leafnode(struct befs_btree_node *node);
103 104
104static fs16 *befs_bt_keylen_index(befs_btree_node * node); 105static fs16 *befs_bt_keylen_index(struct befs_btree_node *node);
105 106
106static fs64 *befs_bt_valarray(befs_btree_node * node); 107static fs64 *befs_bt_valarray(struct befs_btree_node *node);
107 108
108static char *befs_bt_keydata(befs_btree_node * node); 109static char *befs_bt_keydata(struct befs_btree_node *node);
109 110
110static int befs_find_key(struct super_block *sb, befs_btree_node * node, 111static int befs_find_key(struct super_block *sb,
112 struct befs_btree_node *node,
111 const char *findkey, befs_off_t * value); 113 const char *findkey, befs_off_t * value);
112 114
113static char *befs_bt_get_key(struct super_block *sb, befs_btree_node * node, 115static char *befs_bt_get_key(struct super_block *sb,
116 struct befs_btree_node *node,
114 int index, u16 * keylen); 117 int index, u16 * keylen);
115 118
116static int befs_compare_strings(const void *key1, int keylen1, 119static int befs_compare_strings(const void *key1, int keylen1,
@@ -191,7 +194,7 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
191 194
192static int 195static int
193befs_bt_read_node(struct super_block *sb, befs_data_stream * ds, 196befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
194 befs_btree_node * node, befs_off_t node_off) 197 struct befs_btree_node *node, befs_off_t node_off)
195{ 198{
196 uint off = 0; 199 uint off = 0;
197 200
@@ -247,7 +250,7 @@ int
247befs_btree_find(struct super_block *sb, befs_data_stream * ds, 250befs_btree_find(struct super_block *sb, befs_data_stream * ds,
248 const char *key, befs_off_t * value) 251 const char *key, befs_off_t * value)
249{ 252{
250 befs_btree_node *this_node = NULL; 253 struct befs_btree_node *this_node = NULL;
251 befs_btree_super bt_super; 254 befs_btree_super bt_super;
252 befs_off_t node_off; 255 befs_off_t node_off;
253 int res; 256 int res;
@@ -260,11 +263,11 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
260 goto error; 263 goto error;
261 } 264 }
262 265
263 this_node = kmalloc(sizeof (befs_btree_node), 266 this_node = kmalloc(sizeof(struct befs_btree_node),
264 GFP_NOFS); 267 GFP_NOFS);
265 if (!this_node) { 268 if (!this_node) {
266 befs_error(sb, "befs_btree_find() failed to allocate %zu " 269 befs_error(sb, "befs_btree_find() failed to allocate %zu "
267 "bytes of memory", sizeof (befs_btree_node)); 270 "bytes of memory", sizeof(struct befs_btree_node));
268 goto error; 271 goto error;
269 } 272 }
270 273
@@ -333,7 +336,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
333 * Use binary search instead of a linear. 336 * Use binary search instead of a linear.
334 */ 337 */
335static int 338static int
336befs_find_key(struct super_block *sb, befs_btree_node * node, 339befs_find_key(struct super_block *sb, struct befs_btree_node *node,
337 const char *findkey, befs_off_t * value) 340 const char *findkey, befs_off_t * value)
338{ 341{
339 int first, last, mid; 342 int first, last, mid;
@@ -417,7 +420,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
417 loff_t key_no, size_t bufsize, char *keybuf, size_t * keysize, 420 loff_t key_no, size_t bufsize, char *keybuf, size_t * keysize,
418 befs_off_t * value) 421 befs_off_t * value)
419{ 422{
420 befs_btree_node *this_node; 423 struct befs_btree_node *this_node;
421 befs_btree_super bt_super; 424 befs_btree_super bt_super;
422 befs_off_t node_off = 0; 425 befs_off_t node_off = 0;
423 int cur_key; 426 int cur_key;
@@ -436,9 +439,10 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
436 goto error; 439 goto error;
437 } 440 }
438 441
439 if ((this_node = kmalloc(sizeof (befs_btree_node), GFP_NOFS)) == NULL) { 442 this_node = kmalloc(sizeof(struct befs_btree_node), GFP_NOFS);
443 if (this_node == NULL) {
440 befs_error(sb, "befs_btree_read() failed to allocate %zu " 444 befs_error(sb, "befs_btree_read() failed to allocate %zu "
441 "bytes of memory", sizeof (befs_btree_node)); 445 "bytes of memory", sizeof(struct befs_btree_node));
442 goto error; 446 goto error;
443 } 447 }
444 448
@@ -545,7 +549,8 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
545 */ 549 */
546static int 550static int
547befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds, 551befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
548 befs_btree_super * bt_super, befs_btree_node * this_node, 552 befs_btree_super *bt_super,
553 struct befs_btree_node *this_node,
549 befs_off_t * node_off) 554 befs_off_t * node_off)
550{ 555{
551 556
@@ -600,7 +605,7 @@ befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
600 * Return 1 if leaf, 0 if interior 605 * Return 1 if leaf, 0 if interior
601 */ 606 */
602static int 607static int
603befs_leafnode(befs_btree_node * node) 608befs_leafnode(struct befs_btree_node *node)
604{ 609{
605 /* all interior nodes (and only interior nodes) have an overflow node */ 610 /* all interior nodes (and only interior nodes) have an overflow node */
606 if (node->head.overflow == befs_bt_inval) 611 if (node->head.overflow == befs_bt_inval)
@@ -623,7 +628,7 @@ befs_leafnode(befs_btree_node * node)
623 * Except that rounding up to 8 works, and rounding up to 4 doesn't. 628 * Except that rounding up to 8 works, and rounding up to 4 doesn't.
624 */ 629 */
625static fs16 * 630static fs16 *
626befs_bt_keylen_index(befs_btree_node * node) 631befs_bt_keylen_index(struct befs_btree_node *node)
627{ 632{
628 const int keylen_align = 8; 633 const int keylen_align = 8;
629 unsigned long int off = 634 unsigned long int off =
@@ -644,7 +649,7 @@ befs_bt_keylen_index(befs_btree_node * node)
644 * of the node pointed to by the node header 649 * of the node pointed to by the node header
645 */ 650 */
646static fs64 * 651static fs64 *
647befs_bt_valarray(befs_btree_node * node) 652befs_bt_valarray(struct befs_btree_node *node)
648{ 653{
649 void *keylen_index_start = (void *) befs_bt_keylen_index(node); 654 void *keylen_index_start = (void *) befs_bt_keylen_index(node);
650 size_t keylen_index_size = node->head.all_key_count * sizeof (fs16); 655 size_t keylen_index_size = node->head.all_key_count * sizeof (fs16);
@@ -660,7 +665,7 @@ befs_bt_valarray(befs_btree_node * node)
660 * of the node pointed to by the node header 665 * of the node pointed to by the node header
661 */ 666 */
662static char * 667static char *
663befs_bt_keydata(befs_btree_node * node) 668befs_bt_keydata(struct befs_btree_node *node)
664{ 669{
665 return (char *) ((void *) node->od_node + sizeof (befs_btree_nodehead)); 670 return (char *) ((void *) node->od_node + sizeof (befs_btree_nodehead));
666} 671}
@@ -676,7 +681,7 @@ befs_bt_keydata(befs_btree_node * node)
676 * Returns NULL on failure (bad input) and sets *@keylen = 0 681 * Returns NULL on failure (bad input) and sets *@keylen = 0
677 */ 682 */
678static char * 683static char *
679befs_bt_get_key(struct super_block *sb, befs_btree_node * node, 684befs_bt_get_key(struct super_block *sb, struct befs_btree_node *node,
680 int index, u16 * keylen) 685 int index, u16 * keylen)
681{ 686{
682 int prev_key_end; 687 int prev_key_end;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index b60500300dd7..fd8beb9657a2 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -62,7 +62,22 @@ static struct file_system_type bm_fs_type;
62static struct vfsmount *bm_mnt; 62static struct vfsmount *bm_mnt;
63static int entry_count; 63static int entry_count;
64 64
65/* 65/*
66 * Max length of the register string. Determined by:
67 * - 7 delimiters
68 * - name: ~50 bytes
69 * - type: 1 byte
70 * - offset: 3 bytes (has to be smaller than BINPRM_BUF_SIZE)
71 * - magic: 128 bytes (512 in escaped form)
72 * - mask: 128 bytes (512 in escaped form)
73 * - interp: ~50 bytes
74 * - flags: 5 bytes
75 * Round that up a bit, and then back off to hold the internal data
76 * (like struct Node).
77 */
78#define MAX_REGISTER_LENGTH 1920
79
80/*
66 * Check if we support the binfmt 81 * Check if we support the binfmt
67 * if we do, return the node, else NULL 82 * if we do, return the node, else NULL
68 * locking is done in load_misc_binary 83 * locking is done in load_misc_binary
@@ -279,7 +294,7 @@ static Node *create_entry(const char __user *buffer, size_t count)
279 294
280 /* some sanity checks */ 295 /* some sanity checks */
281 err = -EINVAL; 296 err = -EINVAL;
282 if ((count < 11) || (count > 256)) 297 if ((count < 11) || (count > MAX_REGISTER_LENGTH))
283 goto out; 298 goto out;
284 299
285 err = -ENOMEM; 300 err = -ENOMEM;
@@ -396,12 +411,12 @@ static int parse_command(const char __user *buffer, size_t count)
396{ 411{
397 char s[4]; 412 char s[4];
398 413
399 if (!count)
400 return 0;
401 if (count > 3) 414 if (count > 3)
402 return -EINVAL; 415 return -EINVAL;
403 if (copy_from_user(s, buffer, count)) 416 if (copy_from_user(s, buffer, count))
404 return -EFAULT; 417 return -EFAULT;
418 if (!count)
419 return 0;
405 if (s[count-1] == '\n') 420 if (s[count-1] == '\n')
406 count--; 421 count--;
407 if (count == 1 && s[0] == '0') 422 if (count == 1 && s[0] == '0')
diff --git a/fs/buffer.c b/fs/buffer.c
index d1f704806264..9614adc7e754 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1331,8 +1331,8 @@ lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned size)
1331 for (i = 0; i < BH_LRU_SIZE; i++) { 1331 for (i = 0; i < BH_LRU_SIZE; i++) {
1332 struct buffer_head *bh = __this_cpu_read(bh_lrus.bhs[i]); 1332 struct buffer_head *bh = __this_cpu_read(bh_lrus.bhs[i]);
1333 1333
1334 if (bh && bh->b_bdev == bdev && 1334 if (bh && bh->b_blocknr == block && bh->b_bdev == bdev &&
1335 bh->b_blocknr == block && bh->b_size == size) { 1335 bh->b_size == size) {
1336 if (i) { 1336 if (i) {
1337 while (i) { 1337 while (i) {
1338 __this_cpu_write(bh_lrus.bhs[i], 1338 __this_cpu_write(bh_lrus.bhs[i],
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 58df174deb10..b8602f199815 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -195,15 +195,15 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
195 else 195 else
196 noff = tkn_e - (sb_mountdata + off) + 1; 196 noff = tkn_e - (sb_mountdata + off) + 1;
197 197
198 if (strnicmp(sb_mountdata + off, "unc=", 4) == 0) { 198 if (strncasecmp(sb_mountdata + off, "unc=", 4) == 0) {
199 off += noff; 199 off += noff;
200 continue; 200 continue;
201 } 201 }
202 if (strnicmp(sb_mountdata + off, "ip=", 3) == 0) { 202 if (strncasecmp(sb_mountdata + off, "ip=", 3) == 0) {
203 off += noff; 203 off += noff;
204 continue; 204 continue;
205 } 205 }
206 if (strnicmp(sb_mountdata + off, "prefixpath=", 11) == 0) { 206 if (strncasecmp(sb_mountdata + off, "prefixpath=", 11) == 0) {
207 off += noff; 207 off += noff;
208 continue; 208 continue;
209 } 209 }
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 36ca2045009b..239e1fb33000 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1718,7 +1718,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1718 goto cifs_parse_mount_err; 1718 goto cifs_parse_mount_err;
1719 } 1719 }
1720 1720
1721 if (strnicmp(string, "default", 7) != 0) { 1721 if (strncasecmp(string, "default", 7) != 0) {
1722 vol->iocharset = kstrdup(string, 1722 vol->iocharset = kstrdup(string,
1723 GFP_KERNEL); 1723 GFP_KERNEL);
1724 if (!vol->iocharset) { 1724 if (!vol->iocharset) {
@@ -1790,7 +1790,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1790 if (string == NULL) 1790 if (string == NULL)
1791 goto out_nomem; 1791 goto out_nomem;
1792 1792
1793 if (strnicmp(string, "1", 1) == 0) { 1793 if (strncasecmp(string, "1", 1) == 0) {
1794 /* This is the default */ 1794 /* This is the default */
1795 break; 1795 break;
1796 } 1796 }
diff --git a/fs/coredump.c b/fs/coredump.c
index a93f7e6ea4cf..b5c86ffd5033 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -199,6 +199,14 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
199 err = cn_printf(cn, "%d", 199 err = cn_printf(cn, "%d",
200 task_tgid_nr(current)); 200 task_tgid_nr(current));
201 break; 201 break;
202 case 'i':
203 err = cn_printf(cn, "%d",
204 task_pid_vnr(current));
205 break;
206 case 'I':
207 err = cn_printf(cn, "%d",
208 task_pid_nr(current));
209 break;
202 /* uid */ 210 /* uid */
203 case 'u': 211 case 'u':
204 err = cn_printf(cn, "%d", cred->uid); 212 err = cn_printf(cn, "%d", cred->uid);
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 628e22a5a543..d8da2d2e30ae 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -164,8 +164,6 @@ int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
164 return 0; 164 return 0;
165} 165}
166 166
167extern struct timezone sys_tz;
168
169/* 167/*
170 * The epoch of FAT timestamp is 1980. 168 * The epoch of FAT timestamp is 1980.
171 * : bits : value 169 * : bits : value
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 0524cda47a6e..95d255219b1e 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -242,8 +242,6 @@ extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
242/* super.c */ 242/* super.c */
243extern void hfs_mark_mdb_dirty(struct super_block *sb); 243extern void hfs_mark_mdb_dirty(struct super_block *sb);
244 244
245extern struct timezone sys_tz;
246
247/* 245/*
248 * There are two time systems. Both are based on seconds since 246 * There are two time systems. Both are based on seconds since
249 * a particular time/date. 247 * a particular time/date.
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 5ddaf8625d3b..881b3bd0143f 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -247,7 +247,7 @@ static int isofs_dentry_cmp_common(
247 } 247 }
248 if (alen == blen) { 248 if (alen == blen) {
249 if (ci) { 249 if (ci) {
250 if (strnicmp(name->name, str, alen) == 0) 250 if (strncasecmp(name->name, str, alen) == 0)
251 return 0; 251 return 0;
252 } else { 252 } else {
253 if (strncmp(name->name, str, alen) == 0) 253 if (strncmp(name->name, str, alen) == 0)
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 314e7add99b8..7cb751dfbeef 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -1178,9 +1178,6 @@ static int day_n[] =
1178{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0}; 1178{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0};
1179/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */ 1179/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
1180 1180
1181
1182extern struct timezone sys_tz;
1183
1184static int utc2local(int time) 1181static int utc2local(int time)
1185{ 1182{
1186 return time - sys_tz.tz_minuteswest * 60; 1183 return time - sys_tz.tz_minuteswest * 60;
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 24978153c0c4..e9e3325f29f3 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -56,11 +56,9 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
56 mutex_unlock(&inode->i_mutex); 56 mutex_unlock(&inode->i_mutex);
57 57
58 nilfs = inode->i_sb->s_fs_info; 58 nilfs = inode->i_sb->s_fs_info;
59 if (!err && nilfs_test_opt(nilfs, BARRIER)) { 59 if (!err)
60 err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 60 err = nilfs_flush_device(nilfs);
61 if (err != -EIO) 61
62 err = 0;
63 }
64 return err; 62 return err;
65} 63}
66 64
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index d071e7f23de2..e1fa69b341b9 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -126,7 +126,7 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,
126 nilfs_transaction_abort(inode->i_sb); 126 nilfs_transaction_abort(inode->i_sb);
127 goto out; 127 goto out;
128 } 128 }
129 nilfs_mark_inode_dirty(inode); 129 nilfs_mark_inode_dirty_sync(inode);
130 nilfs_transaction_commit(inode->i_sb); /* never fails */ 130 nilfs_transaction_commit(inode->i_sb); /* never fails */
131 /* Error handling should be detailed */ 131 /* Error handling should be detailed */
132 set_buffer_new(bh_result); 132 set_buffer_new(bh_result);
@@ -672,7 +672,7 @@ void nilfs_write_inode_common(struct inode *inode,
672 for substitutions of appended fields */ 672 for substitutions of appended fields */
673} 673}
674 674
675void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh) 675void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh, int flags)
676{ 676{
677 ino_t ino = inode->i_ino; 677 ino_t ino = inode->i_ino;
678 struct nilfs_inode_info *ii = NILFS_I(inode); 678 struct nilfs_inode_info *ii = NILFS_I(inode);
@@ -683,7 +683,8 @@ void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh)
683 683
684 if (test_and_clear_bit(NILFS_I_NEW, &ii->i_state)) 684 if (test_and_clear_bit(NILFS_I_NEW, &ii->i_state))
685 memset(raw_inode, 0, NILFS_MDT(ifile)->mi_entry_size); 685 memset(raw_inode, 0, NILFS_MDT(ifile)->mi_entry_size);
686 set_bit(NILFS_I_INODE_DIRTY, &ii->i_state); 686 if (flags & I_DIRTY_DATASYNC)
687 set_bit(NILFS_I_INODE_SYNC, &ii->i_state);
687 688
688 nilfs_write_inode_common(inode, raw_inode, 0); 689 nilfs_write_inode_common(inode, raw_inode, 0);
689 /* XXX: call with has_bmap = 0 is a workaround to avoid 690 /* XXX: call with has_bmap = 0 is a workaround to avoid
@@ -939,7 +940,7 @@ int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty)
939 return 0; 940 return 0;
940} 941}
941 942
942int nilfs_mark_inode_dirty(struct inode *inode) 943int __nilfs_mark_inode_dirty(struct inode *inode, int flags)
943{ 944{
944 struct buffer_head *ibh; 945 struct buffer_head *ibh;
945 int err; 946 int err;
@@ -950,7 +951,7 @@ int nilfs_mark_inode_dirty(struct inode *inode)
950 "failed to reget inode block.\n"); 951 "failed to reget inode block.\n");
951 return err; 952 return err;
952 } 953 }
953 nilfs_update_inode(inode, ibh); 954 nilfs_update_inode(inode, ibh, flags);
954 mark_buffer_dirty(ibh); 955 mark_buffer_dirty(ibh);
955 nilfs_mdt_mark_dirty(NILFS_I(inode)->i_root->ifile); 956 nilfs_mdt_mark_dirty(NILFS_I(inode)->i_root->ifile);
956 brelse(ibh); 957 brelse(ibh);
@@ -983,7 +984,7 @@ void nilfs_dirty_inode(struct inode *inode, int flags)
983 return; 984 return;
984 } 985 }
985 nilfs_transaction_begin(inode->i_sb, &ti, 0); 986 nilfs_transaction_begin(inode->i_sb, &ti, 0);
986 nilfs_mark_inode_dirty(inode); 987 __nilfs_mark_inode_dirty(inode, flags);
987 nilfs_transaction_commit(inode->i_sb); /* never fails */ 988 nilfs_transaction_commit(inode->i_sb); /* never fails */
988} 989}
989 990
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 422fb54b7377..9a20e513d7eb 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -1022,11 +1022,9 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
1022 return ret; 1022 return ret;
1023 1023
1024 nilfs = inode->i_sb->s_fs_info; 1024 nilfs = inode->i_sb->s_fs_info;
1025 if (nilfs_test_opt(nilfs, BARRIER)) { 1025 ret = nilfs_flush_device(nilfs);
1026 ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 1026 if (ret < 0)
1027 if (ret == -EIO) 1027 return ret;
1028 return ret;
1029 }
1030 1028
1031 if (argp != NULL) { 1029 if (argp != NULL) {
1032 down_read(&nilfs->ns_segctor_sem); 1030 down_read(&nilfs->ns_segctor_sem);
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 0696161bf59d..91093cd74f0d 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -104,7 +104,7 @@ enum {
104 constructor */ 104 constructor */
105 NILFS_I_COLLECTED, /* All dirty blocks are collected */ 105 NILFS_I_COLLECTED, /* All dirty blocks are collected */
106 NILFS_I_UPDATED, /* The file has been written back */ 106 NILFS_I_UPDATED, /* The file has been written back */
107 NILFS_I_INODE_DIRTY, /* write_inode is requested */ 107 NILFS_I_INODE_SYNC, /* dsync is not allowed for inode */
108 NILFS_I_BMAP, /* has bmap and btnode_cache */ 108 NILFS_I_BMAP, /* has bmap and btnode_cache */
109 NILFS_I_GCINODE, /* inode for GC, on memory only */ 109 NILFS_I_GCINODE, /* inode for GC, on memory only */
110}; 110};
@@ -273,7 +273,7 @@ struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
273 unsigned long ino); 273 unsigned long ino);
274extern struct inode *nilfs_iget_for_gc(struct super_block *sb, 274extern struct inode *nilfs_iget_for_gc(struct super_block *sb,
275 unsigned long ino, __u64 cno); 275 unsigned long ino, __u64 cno);
276extern void nilfs_update_inode(struct inode *, struct buffer_head *); 276extern void nilfs_update_inode(struct inode *, struct buffer_head *, int);
277extern void nilfs_truncate(struct inode *); 277extern void nilfs_truncate(struct inode *);
278extern void nilfs_evict_inode(struct inode *); 278extern void nilfs_evict_inode(struct inode *);
279extern int nilfs_setattr(struct dentry *, struct iattr *); 279extern int nilfs_setattr(struct dentry *, struct iattr *);
@@ -282,10 +282,18 @@ int nilfs_permission(struct inode *inode, int mask);
282int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh); 282int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh);
283extern int nilfs_inode_dirty(struct inode *); 283extern int nilfs_inode_dirty(struct inode *);
284int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty); 284int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty);
285extern int nilfs_mark_inode_dirty(struct inode *); 285extern int __nilfs_mark_inode_dirty(struct inode *, int);
286extern void nilfs_dirty_inode(struct inode *, int flags); 286extern void nilfs_dirty_inode(struct inode *, int flags);
287int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 287int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
288 __u64 start, __u64 len); 288 __u64 start, __u64 len);
289static inline int nilfs_mark_inode_dirty(struct inode *inode)
290{
291 return __nilfs_mark_inode_dirty(inode, I_DIRTY);
292}
293static inline int nilfs_mark_inode_dirty_sync(struct inode *inode)
294{
295 return __nilfs_mark_inode_dirty(inode, I_DIRTY_SYNC);
296}
289 297
290/* super.c */ 298/* super.c */
291extern struct inode *nilfs_alloc_inode(struct super_block *); 299extern struct inode *nilfs_alloc_inode(struct super_block *);
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index a1a191634abc..7ef18fc656c2 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -930,7 +930,7 @@ static void nilfs_drop_collected_inodes(struct list_head *head)
930 if (!test_and_clear_bit(NILFS_I_COLLECTED, &ii->i_state)) 930 if (!test_and_clear_bit(NILFS_I_COLLECTED, &ii->i_state))
931 continue; 931 continue;
932 932
933 clear_bit(NILFS_I_INODE_DIRTY, &ii->i_state); 933 clear_bit(NILFS_I_INODE_SYNC, &ii->i_state);
934 set_bit(NILFS_I_UPDATED, &ii->i_state); 934 set_bit(NILFS_I_UPDATED, &ii->i_state);
935 } 935 }
936} 936}
@@ -1833,6 +1833,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
1833 nilfs_set_next_segment(nilfs, segbuf); 1833 nilfs_set_next_segment(nilfs, segbuf);
1834 1834
1835 if (update_sr) { 1835 if (update_sr) {
1836 nilfs->ns_flushed_device = 0;
1836 nilfs_set_last_segment(nilfs, segbuf->sb_pseg_start, 1837 nilfs_set_last_segment(nilfs, segbuf->sb_pseg_start,
1837 segbuf->sb_sum.seg_seq, nilfs->ns_cno++); 1838 segbuf->sb_sum.seg_seq, nilfs->ns_cno++);
1838 1839
@@ -2194,7 +2195,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
2194 nilfs_transaction_lock(sb, &ti, 0); 2195 nilfs_transaction_lock(sb, &ti, 0);
2195 2196
2196 ii = NILFS_I(inode); 2197 ii = NILFS_I(inode);
2197 if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || 2198 if (test_bit(NILFS_I_INODE_SYNC, &ii->i_state) ||
2198 nilfs_test_opt(nilfs, STRICT_ORDER) || 2199 nilfs_test_opt(nilfs, STRICT_ORDER) ||
2199 test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || 2200 test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) ||
2200 nilfs_discontinued(nilfs)) { 2201 nilfs_discontinued(nilfs)) {
@@ -2216,6 +2217,8 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
2216 sci->sc_dsync_end = end; 2217 sci->sc_dsync_end = end;
2217 2218
2218 err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); 2219 err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC);
2220 if (!err)
2221 nilfs->ns_flushed_device = 0;
2219 2222
2220 nilfs_transaction_unlock(sb); 2223 nilfs_transaction_unlock(sb);
2221 return err; 2224 return err;
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 228f5bdf0772..2e5b3ec85b8f 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -310,6 +310,9 @@ int nilfs_commit_super(struct super_block *sb, int flag)
310 nilfs->ns_sbsize)); 310 nilfs->ns_sbsize));
311 } 311 }
312 clear_nilfs_sb_dirty(nilfs); 312 clear_nilfs_sb_dirty(nilfs);
313 nilfs->ns_flushed_device = 1;
314 /* make sure store to ns_flushed_device cannot be reordered */
315 smp_wmb();
313 return nilfs_sync_super(sb, flag); 316 return nilfs_sync_super(sb, flag);
314} 317}
315 318
@@ -514,6 +517,9 @@ static int nilfs_sync_fs(struct super_block *sb, int wait)
514 } 517 }
515 up_write(&nilfs->ns_sem); 518 up_write(&nilfs->ns_sem);
516 519
520 if (!err)
521 err = nilfs_flush_device(nilfs);
522
517 return err; 523 return err;
518} 524}
519 525
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index d01ead1bea9a..23778d385836 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -46,6 +46,7 @@ enum {
46/** 46/**
47 * struct the_nilfs - struct to supervise multiple nilfs mount points 47 * struct the_nilfs - struct to supervise multiple nilfs mount points
48 * @ns_flags: flags 48 * @ns_flags: flags
49 * @ns_flushed_device: flag indicating if all volatile data was flushed
49 * @ns_bdev: block device 50 * @ns_bdev: block device
50 * @ns_sem: semaphore for shared states 51 * @ns_sem: semaphore for shared states
51 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts 52 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
@@ -103,6 +104,7 @@ enum {
103 */ 104 */
104struct the_nilfs { 105struct the_nilfs {
105 unsigned long ns_flags; 106 unsigned long ns_flags;
107 int ns_flushed_device;
106 108
107 struct block_device *ns_bdev; 109 struct block_device *ns_bdev;
108 struct rw_semaphore ns_sem; 110 struct rw_semaphore ns_sem;
@@ -371,4 +373,24 @@ static inline int nilfs_segment_is_active(struct the_nilfs *nilfs, __u64 n)
371 return n == nilfs->ns_segnum || n == nilfs->ns_nextnum; 373 return n == nilfs->ns_segnum || n == nilfs->ns_nextnum;
372} 374}
373 375
376static inline int nilfs_flush_device(struct the_nilfs *nilfs)
377{
378 int err;
379
380 if (!nilfs_test_opt(nilfs, BARRIER) || nilfs->ns_flushed_device)
381 return 0;
382
383 nilfs->ns_flushed_device = 1;
384 /*
385 * the store to ns_flushed_device must not be reordered after
386 * blkdev_issue_flush().
387 */
388 smp_wmb();
389
390 err = blkdev_issue_flush(nilfs->ns_bdev, GFP_KERNEL, NULL);
391 if (err != -EIO)
392 err = 0;
393 return err;
394}
395
374#endif /* _THE_NILFS_H */ 396#endif /* _THE_NILFS_H */
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index d13385448168..eb9d48746ab4 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -2244,7 +2244,7 @@ ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group,
2244 return -EINVAL; 2244 return -EINVAL;
2245 2245
2246 for (i = 0; i < O2HB_HEARTBEAT_NUM_MODES; ++i) { 2246 for (i = 0; i < O2HB_HEARTBEAT_NUM_MODES; ++i) {
2247 if (strnicmp(page, o2hb_heartbeat_mode_desc[i], len)) 2247 if (strncasecmp(page, o2hb_heartbeat_mode_desc[i], len))
2248 continue; 2248 continue;
2249 2249
2250 ret = o2hb_global_heartbeat_mode_set(i); 2250 ret = o2hb_global_heartbeat_mode_set(i);
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index 07ac24fd9252..af7598bff1b5 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -49,13 +49,13 @@ static ssize_t mlog_mask_show(u64 mask, char *buf)
49 49
50static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) 50static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count)
51{ 51{
52 if (!strnicmp(buf, "allow", 5)) { 52 if (!strncasecmp(buf, "allow", 5)) {
53 __mlog_set_u64(mask, mlog_and_bits); 53 __mlog_set_u64(mask, mlog_and_bits);
54 __mlog_clear_u64(mask, mlog_not_bits); 54 __mlog_clear_u64(mask, mlog_not_bits);
55 } else if (!strnicmp(buf, "deny", 4)) { 55 } else if (!strncasecmp(buf, "deny", 4)) {
56 __mlog_set_u64(mask, mlog_not_bits); 56 __mlog_set_u64(mask, mlog_not_bits);
57 __mlog_clear_u64(mask, mlog_and_bits); 57 __mlog_clear_u64(mask, mlog_and_bits);
58 } else if (!strnicmp(buf, "off", 3)) { 58 } else if (!strncasecmp(buf, "off", 3)) {
59 __mlog_clear_u64(mask, mlog_not_bits); 59 __mlog_clear_u64(mask, mlog_not_bits);
60 __mlog_clear_u64(mask, mlog_and_bits); 60 __mlog_clear_u64(mask, mlog_and_bits);
61 } else 61 } else
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index ba8819702c56..138321b0c6c2 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -306,9 +306,7 @@ static const struct super_operations omfs_sops = {
306 */ 306 */
307static int omfs_get_imap(struct super_block *sb) 307static int omfs_get_imap(struct super_block *sb)
308{ 308{
309 int bitmap_size; 309 unsigned int bitmap_size, count, array_size;
310 int array_size;
311 int count;
312 struct omfs_sb_info *sbi = OMFS_SB(sb); 310 struct omfs_sb_info *sbi = OMFS_SB(sb);
313 struct buffer_head *bh; 311 struct buffer_head *bh;
314 unsigned long **ptr; 312 unsigned long **ptr;
@@ -473,6 +471,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
473 sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize); 471 sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
474 mutex_init(&sbi->s_bitmap_lock); 472 mutex_init(&sbi->s_bitmap_lock);
475 473
474 if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) {
475 printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n",
476 (unsigned long long)sbi->s_num_blocks);
477 goto out_brelse_bh;
478 }
479
476 if (sbi->s_sys_blocksize > PAGE_SIZE) { 480 if (sbi->s_sys_blocksize > PAGE_SIZE) {
477 printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n", 481 printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
478 sbi->s_sys_blocksize); 482 sbi->s_sys_blocksize);
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h
index ee5e4327de92..83a98330ed66 100644
--- a/fs/omfs/omfs_fs.h
+++ b/fs/omfs/omfs_fs.h
@@ -18,6 +18,7 @@
18#define OMFS_XOR_COUNT 19 18#define OMFS_XOR_COUNT 19
19#define OMFS_MAX_BLOCK_SIZE 8192 19#define OMFS_MAX_BLOCK_SIZE 8192
20#define OMFS_MAX_CLUSTER_SIZE 8 20#define OMFS_MAX_CLUSTER_SIZE 8
21#define OMFS_MAX_BLOCKS (1ul << 31)
21 22
22struct omfs_super_block { 23struct omfs_super_block {
23 char s_fill1[256]; 24 char s_fill1[256];
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index b7a7dc963a35..4e0388cffe3d 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -827,8 +827,21 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
827 .private = &cp, 827 .private = &cp,
828 }; 828 };
829 down_read(&mm->mmap_sem); 829 down_read(&mm->mmap_sem);
830 if (type == CLEAR_REFS_SOFT_DIRTY) 830 if (type == CLEAR_REFS_SOFT_DIRTY) {
831 for (vma = mm->mmap; vma; vma = vma->vm_next) {
832 if (!(vma->vm_flags & VM_SOFTDIRTY))
833 continue;
834 up_read(&mm->mmap_sem);
835 down_write(&mm->mmap_sem);
836 for (vma = mm->mmap; vma; vma = vma->vm_next) {
837 vma->vm_flags &= ~VM_SOFTDIRTY;
838 vma_set_page_prot(vma);
839 }
840 downgrade_write(&mm->mmap_sem);
841 break;
842 }
831 mmu_notifier_invalidate_range_start(mm, 0, -1); 843 mmu_notifier_invalidate_range_start(mm, 0, -1);
844 }
832 for (vma = mm->mmap; vma; vma = vma->vm_next) { 845 for (vma = mm->mmap; vma; vma = vma->vm_next) {
833 cp.vma = vma; 846 cp.vma = vma;
834 if (is_vm_hugetlb_page(vma)) 847 if (is_vm_hugetlb_page(vma))
@@ -848,10 +861,6 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
848 continue; 861 continue;
849 if (type == CLEAR_REFS_MAPPED && !vma->vm_file) 862 if (type == CLEAR_REFS_MAPPED && !vma->vm_file)
850 continue; 863 continue;
851 if (type == CLEAR_REFS_SOFT_DIRTY) {
852 if (vma->vm_flags & VM_SOFTDIRTY)
853 vma->vm_flags &= ~VM_SOFTDIRTY;
854 }
855 walk_page_range(vma->vm_start, vma->vm_end, 864 walk_page_range(vma->vm_start, vma->vm_end,
856 &clear_refs_walk); 865 &clear_refs_walk);
857 } 866 }
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index a88b1b3e7db3..d571e173a990 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -699,11 +699,13 @@ static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh,
699 chunk->bh[chunk->nr++] = bh; 699 chunk->bh[chunk->nr++] = bh;
700 if (chunk->nr >= CHUNK_SIZE) { 700 if (chunk->nr >= CHUNK_SIZE) {
701 ret = 1; 701 ret = 1;
702 if (lock) 702 if (lock) {
703 spin_unlock(lock); 703 spin_unlock(lock);
704 fn(chunk); 704 fn(chunk);
705 if (lock)
706 spin_lock(lock); 705 spin_lock(lock);
706 } else {
707 fn(chunk);
708 }
707 } 709 }
708 return ret; 710 return ret;
709} 711}
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index 7bc20809c99e..2c1036080d52 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -784,7 +784,6 @@ static u64 ufs_bitmap_search(struct super_block *sb,
784 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe 784 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
785 }; 785 };
786 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 786 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
787 struct ufs_cylinder_group *ucg;
788 unsigned start, length, loc; 787 unsigned start, length, loc;
789 unsigned pos, want, blockmap, mask, end; 788 unsigned pos, want, blockmap, mask, end;
790 u64 result; 789 u64 result;
@@ -792,8 +791,6 @@ static u64 ufs_bitmap_search(struct super_block *sb,
792 UFSD("ENTER, cg %u, goal %llu, count %u\n", ucpi->c_cgx, 791 UFSD("ENTER, cg %u, goal %llu, count %u\n", ucpi->c_cgx,
793 (unsigned long long)goal, count); 792 (unsigned long long)goal, count);
794 793
795 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
796
797 if (goal) 794 if (goal)
798 start = ufs_dtogd(uspi, goal) >> 3; 795 start = ufs_dtogd(uspi, goal) >> 3;
799 else 796 else