openwrt/staging/blogic.git
12 years agoswitch mnt_namespace ->root to struct mount
Al Viro [Tue, 6 Dec 2011 18:32:36 +0000 (13:32 -0500)]
switch mnt_namespace ->root to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: take /proc/*/mounts and friends to fs/proc_namespace.c
Al Viro [Tue, 6 Dec 2011 17:21:54 +0000 (12:21 -0500)]
vfs: take /proc/*/mounts and friends to fs/proc_namespace.c

rationale: that stuff is far tighter bound to fs/namespace.c than to
the guts of procfs proper.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: opencode mntget() mnt_set_mountpoint()
Al Viro [Fri, 25 Nov 2011 08:19:09 +0000 (03:19 -0500)]
vfs: opencode mntget() mnt_set_mountpoint()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - remaining argument of next_mnt()
Al Viro [Fri, 25 Nov 2011 08:06:56 +0000 (03:06 -0500)]
vfs: spread struct mount - remaining argument of next_mnt()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: move fsnotify junk to struct mount
Al Viro [Fri, 25 Nov 2011 07:35:16 +0000 (02:35 -0500)]
vfs: move fsnotify junk to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: move mnt_devname
Al Viro [Fri, 25 Nov 2011 07:25:17 +0000 (02:25 -0500)]
vfs: move mnt_devname

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: move mnt_list to struct mount
Al Viro [Fri, 25 Nov 2011 07:19:55 +0000 (02:19 -0500)]
vfs: move mnt_list to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: switch pnode.h macros to struct mount *
Al Viro [Fri, 25 Nov 2011 06:05:37 +0000 (01:05 -0500)]
vfs: switch pnode.h macros to struct mount *

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: move the rest of int fields to struct mount
Al Viro [Fri, 25 Nov 2011 05:57:42 +0000 (00:57 -0500)]
vfs: move the rest of int fields to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: mnt_id/mnt_group_id moved
Al Viro [Fri, 25 Nov 2011 05:50:41 +0000 (00:50 -0500)]
vfs: mnt_id/mnt_group_id moved

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: mnt_ns moved to struct mount
Al Viro [Fri, 25 Nov 2011 05:46:35 +0000 (00:46 -0500)]
vfs: mnt_ns moved to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - mntput_no_expire
Al Viro [Fri, 25 Nov 2011 05:33:11 +0000 (00:33 -0500)]
vfs: spread struct mount - mntput_no_expire

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - do_add_mount and graft_tree
Al Viro [Fri, 25 Nov 2011 05:30:56 +0000 (00:30 -0500)]
vfs: spread struct mount - do_add_mount and graft_tree

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: take mnt_share/mnt_slave/mnt_slave_list and mnt_expire to struct mount
Al Viro [Fri, 25 Nov 2011 05:22:05 +0000 (00:22 -0500)]
vfs: take mnt_share/mnt_slave/mnt_slave_list and mnt_expire to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: and now we can make ->mnt_master point to struct mount
Al Viro [Fri, 25 Nov 2011 05:10:28 +0000 (00:10 -0500)]
vfs: and now we can make ->mnt_master point to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: take mnt_master to struct mount
Al Viro [Fri, 25 Nov 2011 05:07:16 +0000 (00:07 -0500)]
vfs: take mnt_master to struct mount

make IS_MNT_SLAVE take struct mount * at the same time

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - remaining argument of mnt_set_mountpoint()
Al Viro [Fri, 25 Nov 2011 05:01:17 +0000 (00:01 -0500)]
vfs: spread struct mount - remaining argument of mnt_set_mountpoint()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - propagate_mnt()
Al Viro [Fri, 25 Nov 2011 04:59:29 +0000 (23:59 -0500)]
vfs: spread struct mount - propagate_mnt()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - shared subtree iterators
Al Viro [Fri, 25 Nov 2011 04:56:26 +0000 (23:56 -0500)]
vfs: spread struct mount - shared subtree iterators

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - get_dominating_id / do_make_slave
Al Viro [Fri, 25 Nov 2011 04:35:54 +0000 (23:35 -0500)]
vfs: spread struct mount - get_dominating_id / do_make_slave

next pile of horrors, similar to mnt_parent one; this time it's
mnt_master.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: take mnt_child/mnt_mounts to struct mount
Al Viro [Fri, 25 Nov 2011 04:24:33 +0000 (23:24 -0500)]
vfs: take mnt_child/mnt_mounts to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: all counters taken to struct mount
Al Viro [Fri, 25 Nov 2011 03:53:09 +0000 (22:53 -0500)]
vfs: all counters taken to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - work with counters
Al Viro [Fri, 25 Nov 2011 03:37:54 +0000 (22:37 -0500)]
vfs: spread struct mount - work with counters

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: move mnt_mountpoint to struct mount
Al Viro [Fri, 25 Nov 2011 03:25:07 +0000 (22:25 -0500)]
vfs: move mnt_mountpoint to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: now it can be done - make mnt_parent point to struct mount
Al Viro [Fri, 25 Nov 2011 03:19:58 +0000 (22:19 -0500)]
vfs: now it can be done - make mnt_parent point to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: mnt_parent moved to struct mount
Al Viro [Fri, 25 Nov 2011 03:05:19 +0000 (22:05 -0500)]
vfs: mnt_parent moved to struct mount

the second victim...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - is_path_reachable
Al Viro [Fri, 25 Nov 2011 03:00:28 +0000 (22:00 -0500)]
vfs: spread struct mount - is_path_reachable

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - mnt_has_parent
Al Viro [Fri, 25 Nov 2011 02:47:05 +0000 (21:47 -0500)]
vfs: spread struct mount - mnt_has_parent

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - do_umount/propagate_mount_busy
Al Viro [Fri, 25 Nov 2011 02:35:16 +0000 (21:35 -0500)]
vfs: spread struct mount - do_umount/propagate_mount_busy

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount mnt_set_mountpoint child argument
Al Viro [Fri, 25 Nov 2011 02:28:22 +0000 (21:28 -0500)]
vfs: spread struct mount mnt_set_mountpoint child argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - clone_mnt/copy_tree argument
Al Viro [Fri, 25 Nov 2011 02:24:27 +0000 (21:24 -0500)]
vfs: spread struct mount - clone_mnt/copy_tree argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - shrink_submounts/select_submounts
Al Viro [Fri, 25 Nov 2011 02:15:14 +0000 (21:15 -0500)]
vfs: spread struct mount - shrink_submounts/select_submounts

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - umount_tree argument
Al Viro [Fri, 25 Nov 2011 02:07:43 +0000 (21:07 -0500)]
vfs: spread struct mount - umount_tree argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: the first spoils - mnt_hash moved
Al Viro [Fri, 25 Nov 2011 02:01:32 +0000 (21:01 -0500)]
vfs: the first spoils - mnt_hash moved

taken out of struct vfsmount into struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount to remaining users of ->mnt_hash
Al Viro [Fri, 25 Nov 2011 01:58:57 +0000 (20:58 -0500)]
vfs: spread struct mount to remaining users of ->mnt_hash

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - clone_mnt/copy_tree result
Al Viro [Fri, 25 Nov 2011 01:55:08 +0000 (20:55 -0500)]
vfs: spread struct mount - clone_mnt/copy_tree result

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - change_mnt_propagation/set_mnt_shared
Al Viro [Fri, 25 Nov 2011 01:43:10 +0000 (20:43 -0500)]
vfs: spread struct mount - change_mnt_propagation/set_mnt_shared

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - alloc_vfsmnt/free_vfsmnt/mnt_alloc_id/mnt_free_id
Al Viro [Fri, 25 Nov 2011 01:38:33 +0000 (20:38 -0500)]
vfs: spread struct mount - alloc_vfsmnt/free_vfsmnt/mnt_alloc_id/mnt_free_id

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - tree_contains_unbindable
Al Viro [Fri, 25 Nov 2011 01:01:19 +0000 (20:01 -0500)]
vfs: spread struct mount - tree_contains_unbindable

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - attach_recursive_mnt
Al Viro [Fri, 25 Nov 2011 00:59:16 +0000 (19:59 -0500)]
vfs: spread struct mount - attach_recursive_mnt

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - mount group id handling
Al Viro [Fri, 25 Nov 2011 00:54:23 +0000 (19:54 -0500)]
vfs: spread struct mount - mount group id handling

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - commit_tree
Al Viro [Fri, 25 Nov 2011 00:47:15 +0000 (19:47 -0500)]
vfs: spread struct mount - commit_tree

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - attach_mnt/detach_mnt
Al Viro [Fri, 25 Nov 2011 00:41:16 +0000 (19:41 -0500)]
vfs: spread struct mount - attach_mnt/detach_mnt

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - namespace.c internal iterators
Al Viro [Thu, 24 Nov 2011 23:57:30 +0000 (18:57 -0500)]
vfs: spread struct mount - namespace.c internal iterators

next_mnt() return value, first argument
skip_mnt_tree() return value and argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - __propagate_umount() argument
Al Viro [Thu, 24 Nov 2011 23:25:28 +0000 (18:25 -0500)]
vfs: spread struct mount - __propagate_umount() argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: spread struct mount - __lookup_mnt() result
Al Viro [Thu, 24 Nov 2011 23:22:03 +0000 (18:22 -0500)]
vfs: spread struct mount - __lookup_mnt() result

switch __lookup_mnt() to returning struct mount *; callers adjusted.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: start hiding vfsmount guts series
Al Viro [Wed, 23 Nov 2011 17:14:10 +0000 (12:14 -0500)]
vfs: start hiding vfsmount guts series

Almost all fields of struct vfsmount are used only by core VFS (and
a fairly small part of it, at that).  The plan: embed struct vfsmount
into struct mount, making the latter visible only to core parts of VFS.
Then move fields from vfsmount to mount, eventually leaving only
mnt_root/mnt_sb/mnt_flags in struct vfsmount.  Filesystem code still
gets pointers to struct vfsmount and remains unchanged; all such
pointers go to struct vfsmount embedded into the instances of struct
mount allocated by fs/namespace.c.  When fs/namespace.c et.al. get
a pointer to vfsmount, they turn it into pointer to mount (using
container_of) and work with that.

This is the first part of series; struct mount is introduced,
allocation switched to using it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: fix the rest of sget() races
Al Viro [Wed, 4 Jan 2012 02:01:29 +0000 (21:01 -0500)]
vfs: fix the rest of sget() races

unfortunately, just checking MS_BORN after having grabbed ->s_umount in
sget() is not enough; places that pick superblock from a list and
grab s_umount shared need the same check in addition to checking for
->s_root; otherwise three-way race between failing mount, sget() and
such list-walker can leave us with list-walker coming *second*, when
temporary active ref grabbed by sget() (to be dropped when sget()
notices that original mount has failed by checking MS_BORN) has
lead to deactivate_locked_super() from failing ->mount() *not* doing
->kill_sb() and just releasing ->s_umount.  Once sget() gets through
and notices that MS_BORN had never been set it will drop the active
ref and fs will be shut down and kicked out of all lists, but it's
too late for something like sync_supers().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: new helper - vfs_ustat()
Al Viro [Tue, 3 Jan 2012 03:28:36 +0000 (22:28 -0500)]
vfs: new helper - vfs_ustat()

... and bury user_get_super()/statfs_by_dentry() - they are
purely internal now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: live vfsmounts never have NULL ->mnt_sb
Al Viro [Fri, 9 Dec 2011 04:01:06 +0000 (23:01 -0500)]
vfs: live vfsmounts never have NULL ->mnt_sb

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: for usbfs, etc. internal vfsmounts ->mnt_sb->s_root == ->mnt_root
Al Viro [Wed, 7 Dec 2011 23:21:57 +0000 (18:21 -0500)]
vfs: for usbfs, etc. internal vfsmounts ->mnt_sb->s_root == ->mnt_root

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agoget rid of timer in kern/acct.c
Al Viro [Fri, 9 Dec 2011 01:08:42 +0000 (20:08 -0500)]
get rid of timer in kern/acct.c

... and clean it up a bit, while we are at it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: pipe.c is really non-modular
Al Viro [Mon, 19 Dec 2011 01:17:41 +0000 (20:17 -0500)]
vfs: pipe.c is really non-modular

... so no exitcalls there.  Not much would work if pipe(2) would stop
working, after all...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: fix the stupidity with i_dentry in inode destructors
Al Viro [Mon, 12 Dec 2011 20:51:45 +0000 (15:51 -0500)]
vfs: fix the stupidity with i_dentry in inode destructors

Seeing that just about every destructor got that INIT_LIST_HEAD() copied into
it, there is no point whatsoever keeping this INIT_LIST_HEAD in inode_init_once();
the cost of taking it into inode_init_always() will be negligible for pipes
and sockets and negative for everything else.  Not to mention the removal of
boilerplate code from ->destroy_inode() instances...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: mnt_drop_write_file()
Al Viro [Fri, 9 Dec 2011 13:06:57 +0000 (08:06 -0500)]
vfs: mnt_drop_write_file()

new helper (wrapper around mnt_drop_write()) to be used in pair with
mnt_want_write_file().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agoconstify seq_file stuff
Al Viro [Fri, 9 Dec 2011 01:18:57 +0000 (20:18 -0500)]
constify seq_file stuff

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: make do_kern_mount() static
Al Viro [Tue, 13 Dec 2011 04:07:05 +0000 (23:07 -0500)]
vfs: make do_kern_mount() static

the only user outside of fs/namespace.c has died

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: convert fs_supers to hlist
Al Viro [Tue, 13 Dec 2011 03:53:00 +0000 (22:53 -0500)]
vfs: convert fs_supers to hlist

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agomake nfs_follow_remote_path() handle ERR_PTR() passed as root_mnt
Al Viro [Thu, 17 Nov 2011 02:52:06 +0000 (21:52 -0500)]
make nfs_follow_remote_path() handle ERR_PTR() passed as root_mnt

... rather than duplicating that in callers

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: kill ->mnt_devname use in afs printks
Al Viro [Fri, 25 Nov 2011 07:22:06 +0000 (02:22 -0500)]
vfs: kill ->mnt_devname use in afs printks

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agobtrfs, nfs, apparmor: don't pull mnt_namespace.h for no reason...
Al Viro [Fri, 25 Nov 2011 01:14:54 +0000 (20:14 -0500)]
btrfs, nfs, apparmor: don't pull mnt_namespace.h for no reason...

it's not needed anymore; we used to, back when we had to do
mount_subtree() by hand, complete with put_mnt_ns() in it.
No more...  Apparmor didn't need it since the __d_path() fix.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agotomoyo: stop including hell knows what
Al Viro [Fri, 25 Nov 2011 01:08:53 +0000 (20:08 -0500)]
tomoyo: stop including hell knows what

tomoyo/realpath.c needs exactly one include - that of common.h.  It pulls
everything the thing needs, without doing ridiculous garbage such as trying
to include ../../fs/internal.h.  If that alone doesn't scream "layering
violation", I don't know what does; and these days it's all for nothing,
since it fortunately does not use any symbols defined in there...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: dentry_reset_mounted() doesn't use vfsmount argument
Al Viro [Fri, 25 Nov 2011 00:31:36 +0000 (19:31 -0500)]
vfs: dentry_reset_mounted() doesn't use vfsmount argument

lose it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agounexport put_mnt_ns(), make create_mnt_ns() static outright
Al Viro [Thu, 17 Nov 2011 03:01:36 +0000 (22:01 -0500)]
unexport put_mnt_ns(), make create_mnt_ns() static outright

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: add missing parens in pnode.h macros
Al Viro [Wed, 23 Nov 2011 17:27:01 +0000 (12:27 -0500)]
vfs: add missing parens in pnode.h macros

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: more mnt_parent cleanups
Al Viro [Thu, 24 Nov 2011 00:34:49 +0000 (19:34 -0500)]
vfs: more mnt_parent cleanups

a) mount --move is checking that ->mnt_parent is non-NULL before
looking if that parent happens to be shared; ->mnt_parent is never
NULL and it's not even an misspelled !mnt_has_parent()

b) pivot_root open-codes is_path_reachable(), poorly.

c) so does path_is_under(), while we are at it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: new internal helper: mnt_has_parent(mnt)
Al Viro [Thu, 24 Nov 2011 00:26:23 +0000 (19:26 -0500)]
vfs: new internal helper: mnt_has_parent(mnt)

vfsmounts have ->mnt_parent pointing either to a different vfsmount
or to itself; it's never NULL and termination condition in loops
traversing the tree towards root is mnt == mnt->mnt_parent.  At least
one place (see the next patch) is confused about what's going on;
let's add an explicit helper checking it right way and use it in
all places where we need it.  Not that there had been too many,
but...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agovfs: kill pointless helpers in namespace.c
Al Viro [Thu, 24 Nov 2011 00:04:52 +0000 (19:04 -0500)]
vfs: kill pointless helpers in namespace.c

mnt_{inc,dec}_count() is not cleaner than doing the corresponding
mnt_add_count() directly and mnt_set_count() is not used at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agonew helpers: fh_{want,drop}_write()
Al Viro [Wed, 23 Nov 2011 17:03:18 +0000 (12:03 -0500)]
new helpers: fh_{want,drop}_write()

A bunch of places in nfsd does mnt_{want,drop}_write on vfsmount of
export of given fhandle.  Switched to obvious inlined helpers...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agoswitch a bunch of places to mnt_want_write_file()
Al Viro [Wed, 23 Nov 2011 16:57:51 +0000 (11:57 -0500)]
switch a bunch of places to mnt_want_write_file()

it's both faster (in case when file has been opened for write) and cleaner.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agotrim fs/internal.h
Al Viro [Tue, 22 Nov 2011 02:15:42 +0000 (21:15 -0500)]
trim fs/internal.h

some stuff in there can actually become static; some belongs to pnode.h
as it's a private interface between namespace.c and pnode.c...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agopull manipulations of rpc_cred inside alloc_nfs_open_context()
Al Viro [Sun, 23 Oct 2011 22:49:54 +0000 (18:49 -0400)]
pull manipulations of rpc_cred inside alloc_nfs_open_context()

No need to duplicate them in both callers; make it return
ERR_PTR(-ENOMEM) on allocation failure instead of NULL and
it'll be able to report rpc_lookup_cred() failures just
fine.  Callers are much happier that way...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
12 years agoRevert "rtc: Disable the alarm in the hardware"
Linus Torvalds [Wed, 4 Jan 2012 01:32:13 +0000 (17:32 -0800)]
Revert "rtc: Disable the alarm in the hardware"

This reverts commit c0afabd3d553c521e003779c127143ffde55a16f.

It causes failures on Toshiba laptops - instead of disabling the alarm,
it actually seems to enable it on the affected laptops, resulting in
(for example) the laptop powering on automatically five minutes after
shutdown.

There's a patch for it that appears to work for at least some people,
but it's too late to play around with this, so revert for now and try
again in the next merge window.

See for example

http://bugs.debian.org/652869

Reported-and-bisected-by: Andreas Friedrich <afrie@gmx.net> (Toshiba Tecra)
Reported-by: Antonio-M. Corbi Bellot <antonio.corbi@ua.es> (Toshiba Portege R500)
Reported-by: Marco Santos <marco.santos@waynext.com> (Toshiba Portege Z830)
Reported-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr> (Toshiba Portege R830)
Cc: Jonathan Nieder <jrnieder@gmail.com>
Requested-by: John Stultz <john.stultz@linaro.org>
Cc: stable@kernel.org # for the versions that applied this
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agohung_task: fix false positive during vfork
Mandeep Singh Baines [Tue, 3 Jan 2012 22:41:13 +0000 (14:41 -0800)]
hung_task: fix false positive during vfork

vfork parent uninterruptibly and unkillably waits for its child to
exec/exit. This wait is of unbounded length. Ignore such waits
in the hung_task detector.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reported-by: Sasha Levin <levinsasha928@gmail.com>
LKML-Reference: <1325344394.28904.43.camel@lappy>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: John Kacur <jkacur@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agosecurity: Fix security_old_inode_init_security() when CONFIG_SECURITY is not set
Jan Kara [Tue, 3 Jan 2012 12:14:29 +0000 (13:14 +0100)]
security: Fix security_old_inode_init_security() when CONFIG_SECURITY is not set

Commit 1e39f384bb01 ("evm: fix build problems") makes the stub version
of security_old_inode_init_security() return 0 when CONFIG_SECURITY is
not set.

But that makes callers such as reiserfs_security_init() assume that
security_old_inode_init_security() has set name, value, and len
arguments properly - but security_old_inode_init_security() left them
uninitialized which then results in interesting failures.

Revert security_old_inode_init_security() to the old behavior of
returning EOPNOTSUPP since both callers (reiserfs and ocfs2) handle this
just fine.

[ Also fixed the S_PRIVATE(inode) case of the actual non-stub
  security_old_inode_init_security() function to return EOPNOTSUPP
  for the same reason, as pointed out by Mimi Zohar.

  It got incorrectly changed to match the new function in commit
  fb88c2b6cbb1: "evm: fix security/security_old_init_security return
  code".   - Linus ]

Reported-by: Jorge Bastos <mysql.jorge@decimal.pt>
Acked-by: James Morris <jmorris@namei.org>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agodrm/radeon/kms/atom: fix possible segfault in pm setup
Alexander Müller [Fri, 30 Dec 2011 17:55:48 +0000 (12:55 -0500)]
drm/radeon/kms/atom: fix possible segfault in pm setup

If we end up with no power states, don't look up
current vddc.

fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=44130

agd5f: fix patch formatting

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
12 years agoMerge branch 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6
Linus Torvalds [Mon, 2 Jan 2012 20:34:03 +0000 (12:34 -0800)]
Merge branch 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6

* 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6:
  dt/device: Fix auxdata matching to handle entries without a name override

12 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Linus Torvalds [Mon, 2 Jan 2012 03:36:08 +0000 (19:36 -0800)]
Merge git://git./linux/kernel/git/davem/net

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net:
  netfilter: ctnetlink: fix timeout calculation
  ipvs: try also real server with port 0 in backup server
  skge: restore rx multicast filter on resume and after config changes
  mlx4_en: nullify cq->vector field when closing completion queue

12 years agoMerge branch 'fix/asoc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Linus Torvalds [Sat, 31 Dec 2011 19:55:06 +0000 (11:55 -0800)]
Merge branch 'fix/asoc' of git://git./linux/kernel/git/tiwai/sound

* 'fix/asoc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ASoC: wm8776: add missing break in sample size switch

12 years agogspca: Fix falling back to lower isoc alt settings
Mauro Carvalho Chehab [Sat, 31 Dec 2011 13:32:03 +0000 (11:32 -0200)]
gspca: Fix falling back to lower isoc alt settings

The current gspca core code has a regression where it no longer properly
falls back to lower alt settings when there is not enough bandwidth.

This causes many iso based usb-1 cameras to not work when plugged into a
usb2 hub or a sandybridge chipset motherboard!

This patch fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agofutex: Fix uninterruptible loop due to gate_area
Hugh Dickins [Sat, 31 Dec 2011 19:44:01 +0000 (11:44 -0800)]
futex: Fix uninterruptible loop due to gate_area

It was found (by Sasha) that if you use a futex located in the gate
area we get stuck in an uninterruptible infinite loop, much like the
ZERO_PAGE issue.

While looking at this problem, PeterZ realized you'll get into similar
trouble when hitting any install_special_pages() mapping.  And are there
still drivers setting up their own special mmaps without page->mapping,
and without special VM or pte flags to make get_user_pages fail?

In most cases, if page->mapping is NULL, we do not need to retry at all:
Linus points out that even /proc/sys/vm/drop_caches poses no problem,
because it ends up using remove_mapping(), which takes care not to
interfere when the page reference count is raised.

But there is still one case which does need a retry: if memory pressure
called shmem_writepage in between get_user_pages_fast dropping page
table lock and our acquiring page lock, then the page gets switched from
filecache to swapcache (and ->mapping set to NULL) whatever the refcount.
Fault it back in to get the page->mapping needed for key->shared.inode.

Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agonetfilter: ctnetlink: fix timeout calculation
Xi Wang [Fri, 30 Dec 2011 15:40:17 +0000 (10:40 -0500)]
netfilter: ctnetlink: fix timeout calculation

The sanity check (timeout < 0) never works; the dividend is unsigned
and so is the division, which should have been a signed division.

long timeout = (ct->timeout.expires - jiffies) / HZ;
if (timeout < 0)
timeout = 0;

This patch converts the time values to signed for the division.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 years agoipvs: try also real server with port 0 in backup server
Julian Anastasov [Fri, 30 Dec 2011 05:19:02 +0000 (14:19 +0900)]
ipvs: try also real server with port 0 in backup server

We should not forget to try for real server with port 0
in the backup server when processing the sync message. We should
do it in all cases because the backup server can use different
forwarding method.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 years agoskge: restore rx multicast filter on resume and after config changes
Florian Zumbiehl [Fri, 30 Dec 2011 17:30:09 +0000 (17:30 +0000)]
skge: restore rx multicast filter on resume and after config changes

Restore skge hardware registers for multicast filtering to their
appropriate values after system resume and after hardware restarts
that are done when changing certain settings.

Signed-off-by: Florian Zumbiehl <florz@florz.de>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 years agomlx4_en: nullify cq->vector field when closing completion queue
Yevgeny Petrilin [Thu, 29 Dec 2011 05:49:58 +0000 (05:49 +0000)]
mlx4_en: nullify cq->vector field when closing completion queue

Caused loss of connectivity when changing ring size.

Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 years agoMerge branch 'fixes' of http://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur...
Linus Torvalds [Fri, 30 Dec 2011 21:45:34 +0000 (13:45 -0800)]
Merge branch 'fixes' of ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm

* 'fixes' of http://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm:
  ARM: 7237/1: PL330: Fix driver freeze
  ARM: 7197/1: errata: Remove SMP dependency for erratum 751472
  ARM: 7196/1: errata: Remove SMP dependency for erratum 720789
  ARM: 7220/1: mmc: mmci: Fixup error handling for dma
  ARM: 7214/1: mmc: mmci: Fixup handling of MCI_STARTBITERR

12 years agoMerge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Linus Torvalds [Fri, 30 Dec 2011 21:43:45 +0000 (13:43 -0800)]
Merge branch 'fixes' of git://git./linux/kernel/git/arm/arm-soc

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc:
  ARM: plat-orion: make gpiochip label unique
  enable uncompress log on cpuimx35sd
  cpuimx35: fix touchscreen support
  cpuimx35sd: fix Kconfig
  clock-imx35: fix reboot in internal boot mode
  dma: MX3_IPU fix depends
  imx_v4_v5_defconfig: update default configuration
  cpuimx25sd: fix Kconfig
  arm/imx: fix cpufreq section mismatch
  ARM:imx:fix pwm period value
  ARM: OMAP: hwmod data: fix iva and mailbox hwmods for OMAP 3

12 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Linus Torvalds [Fri, 30 Dec 2011 21:42:41 +0000 (13:42 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/dtor/input

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: sentelic - fix retrieving number of buttons
  Input: sentelic - release mutex upon register write failure

12 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
Linus Torvalds [Fri, 30 Dec 2011 21:34:22 +0000 (13:34 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/sage/ceph-client

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
  ceph: disable use of dcache for readdir etc.

12 years agoMerge branch 'v3.2-samsung-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 30 Dec 2011 21:34:00 +0000 (13:34 -0800)]
Merge branch 'v3.2-samsung-fixes-4' of git://git./linux/kernel/git/kgene/linux-samsung

* 'v3.2-samsung-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung:
  ARM: EXYNOS: Remove duplicated SROMC static memory mapping
  ARM: SAMSUNG: Fix build error when selecting CPU_FREQ_S3C24XX_DEBUGFS on S3C2440

12 years agoRevert "clockevents: Set noop handler in clockevents_exchange_device()"
Linus Torvalds [Fri, 30 Dec 2011 21:24:40 +0000 (13:24 -0800)]
Revert "clockevents: Set noop handler in clockevents_exchange_device()"

This reverts commit de28f25e8244c7353abed8de0c7792f5f883588c.

It results in resume problems for various people. See for example

  http://thread.gmane.org/gmane.linux.kernel/1233033
  http://thread.gmane.org/gmane.linux.kernel/1233389
  http://thread.gmane.org/gmane.linux.kernel/1233159
  http://thread.gmane.org/gmane.linux.kernel/1227868/focus=1230877

and the fedora and ubuntu bug reports

  https://bugzilla.redhat.com/show_bug.cgi?id=767248
  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/904569

which got bisected down to the stable version of this commit.

Reported-by: Jonathan Nieder <jrnieder@gmail.com>
Reported-by: Phil Miller <mille121@illinois.edu>
Reported-by: Philip Langdale <philipl@overt.org>
Reported-by: Tim Gardner <tim.gardner@canonical.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg KH <gregkh@suse.de>
Cc: stable@kernel.org # for stable kernels that applied the original
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMerge git://www.linux-watchdog.org/linux-watchdog
Linus Torvalds [Fri, 30 Dec 2011 20:13:03 +0000 (12:13 -0800)]
Merge git://www.linux-watchdog.org/linux-watchdog

* git://www.linux-watchdog.org/linux-watchdog:
  watchdog: iTCO_wdt.c - problems with newer hardware due to SMI clearing (part 2)
  watchdog: hpwdt: Changes to handle NX secure bit in 32bit path
  watchdog: sp805: Fix section mismatch in ID table.
  watchdog: move coh901327 state holders

12 years agoMerge branch 'iommu/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/joro...
Linus Torvalds [Fri, 30 Dec 2011 01:36:15 +0000 (17:36 -0800)]
Merge branch 'iommu/fixes' of git://git./linux/kernel/git/joro/iommu

* 'iommu/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu: Initialize domain->handler in iommu_domain_alloc()

12 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Linus Torvalds [Fri, 30 Dec 2011 01:35:33 +0000 (17:35 -0800)]
Merge git://git./linux/kernel/git/davem/net

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net:
  packet: fix possible dev refcnt leak when bind fail
  netem: dont call vfree() under spinlock and BH disabled
  netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded
  netfilter: ctnetlink: fix return value of ctnetlink_get_expect()

12 years agoMerge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 30 Dec 2011 01:09:16 +0000 (17:09 -0800)]
Merge branch 'perf-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/x86: Fix raw_spin_unlock_irqrestore() usage
  oprofile, arm/sh: Fix oprofile_arch_exit() linkage issue

12 years agoMerge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
Linus Torvalds [Fri, 30 Dec 2011 01:05:45 +0000 (17:05 -0800)]
Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs

* 'for-linus' of git://oss.sgi.com/xfs/xfs:
  xfs: log all dirty inodes in xfs_fs_sync_fs
  xfs: log the inode in ->write_inode calls for kupdate

12 years agoMerge branch 'for-linus' of git://git.kernel.dk/linux-block
Linus Torvalds [Fri, 30 Dec 2011 00:33:37 +0000 (16:33 -0800)]
Merge branch 'for-linus' of git://git.kernel.dk/linux-block

* 'for-linus' of git://git.kernel.dk/linux-block:
  block: fix blk_queue_end_tag()
  block: re-use existing 'reading' variable instead of checking direction again
  block, cfq: fix empty queue crash caused by request merge

12 years agomm: hugetlb: fix non-atomic enqueue of huge page
Hillf Danton [Wed, 28 Dec 2011 23:57:16 +0000 (15:57 -0800)]
mm: hugetlb: fix non-atomic enqueue of huge page

If a huge page is enqueued under the protection of hugetlb_lock, then the
operation is atomic and safe.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: <stable@vger.kernel.org> [2.6.37+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoprocfs: do not confuse jiffies with cputime64_t
Andreas Schwab [Wed, 28 Dec 2011 23:57:15 +0000 (15:57 -0800)]
procfs: do not confuse jiffies with cputime64_t

Commit 2a95ea6c0d129b4 ("procfs: do not overflow get_{idle,iowait}_time
for nohz") did not take into account that one some architectures jiffies
and cputime use different units.

This causes get_idle_time() to return numbers in the wrong units, making
the idle time fields in /proc/stat wrong.

Instead of converting the usec value returned by
get_cpu_{idle,iowait}_time_us to units of jiffies, use the new function
usecs_to_cputime64 to convert it to the correct unit of cputime64_t.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Artem S. Tashkinov" <t.artem@mailcity.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agomm/mempolicy.c: refix mbind_range() vma issue
KOSAKI Motohiro [Wed, 28 Dec 2011 23:57:11 +0000 (15:57 -0800)]
mm/mempolicy.c: refix mbind_range() vma issue

commit 8aacc9f550 ("mm/mempolicy.c: fix pgoff in mbind vma merge") is the
slightly incorrect fix.

Why? Think following case.

1. map 4 pages of a file at offset 0

   [0123]

2. map 2 pages just after the first mapping of the same file but with
   page offset 2

   [0123][23]

3. mbind() 2 pages from the first mapping at offset 2.
   mbind_range() should treat new vma is,

   [0123][23]
     |23|
     mbind vma

   but it does

   [0123][23]
     |01|
     mbind vma

   Oops. then, it makes wrong vma merge and splitting ([01][0123] or similar).

This patch fixes it.

[testcase]
  test result - before the patch

case4: 126: test failed. expect '2,4', actual '2,2,2'
        case5: passed
case6: passed
case7: passed
case8: passed
case_n: 246: test failed. expect '4,2', actual '1,4'

------------[ cut here ]------------
kernel BUG at mm/filemap.c:135!
invalid opcode: 0000 [#4] SMP DEBUG_PAGEALLOC

(snip long bug on messages)

  test result - after the patch

case4: passed
        case5: passed
case6: passed
case7: passed
case8: passed
case_n: passed

  source:  mbind_vma_test.c
============================================================
 #include <numaif.h>
 #include <numa.h>
 #include <sys/mman.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>

static unsigned long pagesize;
void* mmap_addr;
struct bitmask *nmask;
char buf[1024];
FILE *file;
char retbuf[10240] = "";
int mapped_fd;

char *rubysrc = "ruby -e '\
  pid = %d; \
  vstart = 0x%llx; \
  vend = 0x%llx; \
  s = `pmap -q #{pid}`; \
  rary = []; \
  s.each_line {|line|; \
    ary=line.split(\" \"); \
    addr = ary[0].to_i(16); \
    if(vstart <= addr && addr < vend) then \
      rary.push(ary[1].to_i()/4); \
    end; \
  }; \
  print rary.join(\",\"); \
'";

void init(void)
{
void* addr;
char buf[128];

nmask = numa_allocate_nodemask();
numa_bitmask_setbit(nmask, 0);

pagesize = getpagesize();

sprintf(buf, "%s", "mbind_vma_XXXXXX");
mapped_fd = mkstemp(buf);
if (mapped_fd == -1)
perror("mkstemp "), exit(1);
unlink(buf);

if (lseek(mapped_fd, pagesize*8, SEEK_SET) < 0)
perror("lseek "), exit(1);
if (write(mapped_fd, "\0", 1) < 0)
perror("write "), exit(1);

addr = mmap(NULL, pagesize*8, PROT_NONE,
    MAP_SHARED, mapped_fd, 0);
if (addr == MAP_FAILED)
perror("mmap "), exit(1);

if (mprotect(addr+pagesize, pagesize*6, PROT_READ|PROT_WRITE) < 0)
perror("mprotect "), exit(1);

mmap_addr = addr + pagesize;

/* make page populate */
memset(mmap_addr, 0, pagesize*6);
}

void fin(void)
{
void* addr = mmap_addr - pagesize;
munmap(addr, pagesize*8);

memset(buf, 0, sizeof(buf));
memset(retbuf, 0, sizeof(retbuf));
}

void mem_bind(int index, int len)
{
int err;

err = mbind(mmap_addr+pagesize*index, pagesize*len,
    MPOL_BIND, nmask->maskp, nmask->size, 0);
if (err)
perror("mbind "), exit(err);
}

void mem_interleave(int index, int len)
{
int err;

err = mbind(mmap_addr+pagesize*index, pagesize*len,
    MPOL_INTERLEAVE, nmask->maskp, nmask->size, 0);
if (err)
perror("mbind "), exit(err);
}

void mem_unbind(int index, int len)
{
int err;

err = mbind(mmap_addr+pagesize*index, pagesize*len,
    MPOL_DEFAULT, NULL, 0, 0);
if (err)
perror("mbind "), exit(err);
}

void Assert(char *expected, char *value, char *name, int line)
{
if (strcmp(expected, value) == 0) {
fprintf(stderr, "%s: passed\n", name);
return;
}
else {
fprintf(stderr, "%s: %d: test failed. expect '%s', actual '%s'\n",
name, line,
expected, value);
// exit(1);
}
}

/*
      AAAA
    PPPPPPNNNNNN
    might become
    PPNNNNNNNNNN
    case 4 below
*/
void case4(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

mem_bind(0, 4);
mem_unbind(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("2,4", retbuf, "case4", __LINE__);

fin();
}

/*
       AAAA
 PPPPPPNNNNNN
 might become
 PPPPPPPPPPNN
 case 5 below
*/
void case5(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

mem_bind(0, 2);
mem_bind(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("4,2", retbuf, "case5", __LINE__);

fin();
}

/*
    AAAA
PPPPNNNNXXXX
might become
PPPPPPPPPPPP 6
*/
void case6(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

mem_bind(0, 2);
mem_bind(4, 2);
mem_bind(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("6", retbuf, "case6", __LINE__);

fin();
}

/*
    AAAA
PPPPNNNNXXXX
might become
PPPPPPPPXXXX 7
*/
void case7(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

mem_bind(0, 2);
mem_interleave(4, 2);
mem_bind(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("4,2", retbuf, "case7", __LINE__);

fin();
}

/*
    AAAA
PPPPNNNNXXXX
might become
PPPPNNNNNNNN 8
*/
void case8(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

mem_bind(0, 2);
mem_interleave(4, 2);
mem_interleave(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("2,4", retbuf, "case8", __LINE__);

fin();
}

void case_n(void)
{
init();
sprintf(buf, rubysrc, getpid(), mmap_addr, mmap_addr+pagesize*6);

/* make redundunt mappings [0][1234][34][7] */
mmap(mmap_addr + pagesize*4, pagesize*2, PROT_READ|PROT_WRITE,
     MAP_FIXED|MAP_SHARED, mapped_fd, pagesize*3);

/* Expect to do nothing. */
mem_unbind(2, 2);

file = popen(buf, "r");
fread(retbuf, sizeof(retbuf), 1, file);
Assert("4,2", retbuf, "case_n", __LINE__);

fin();
}

int main(int argc, char** argv)
{
case4();
case5();
case6();
case7();
case8();
case_n();

return 0;
}
=============================================================

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: Caspar Zhang <caspar@casparzhang.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: <stable@vger.kernel.org> [3.1.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>