--- /dev/null
+From 5574169613b40b85d6f4c67208fa4846b897a0a1 Mon Sep 17 00:00:00 2001
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Date: Tue, 23 Mar 2010 13:35:33 -0700
+Subject: doc: add the documentation for mpol=local
+
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+
+commit 5574169613b40b85d6f4c67208fa4846b897a0a1 upstream.
+
+commit 3f226aa1c (mempolicy: support mpol=local tmpfs mount option) added
+new mpol=local mount option. but it didn't add a documentation.
+
+This patch does it.
+
+Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Cc: Ravikiran Thirumalai <kiran@scalex86.org>
+Cc: Christoph Lameter <cl@linux-foundation.org>
+Cc: Mel Gorman <mel@csn.ul.ie>
+Acked-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
+Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ Documentation/filesystems/tmpfs.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/Documentation/filesystems/tmpfs.txt
++++ b/Documentation/filesystems/tmpfs.txt
+@@ -82,11 +82,13 @@ tmpfs has a mount option to set the NUMA
+ all files in that instance (if CONFIG_NUMA is enabled) - which can be
+ adjusted on the fly via 'mount -o remount ...'
+
+-mpol=default prefers to allocate memory from the local node
++mpol=default use the process allocation policy
++ (see set_mempolicy(2))
+ mpol=prefer:Node prefers to allocate memory from the given Node
+ mpol=bind:NodeList allocates memory only from nodes in NodeList
+ mpol=interleave prefers to allocate from each node in turn
+ mpol=interleave:NodeList allocates from each node of NodeList in turn
++mpol=local prefers to allocate memory from the local node
+
+ NodeList format is a comma-separated list of decimal numbers and ranges,
+ a range being two hyphen-separated decimal numbers, the smallest and
+@@ -134,3 +136,5 @@ Author:
+ Christoph Rohland <cr@sap.com>, 1.12.01
+ Updated:
+ Hugh Dickins, 4 June 2007
++Updated:
++ KOSAKI Motohiro, 16 Mar 2010
0005-powerpc-TIF_ABI_PENDING-bit-removal.patch
coredump-suppress-uid-comparison-test-if-core-output-files-are-pipes.patch
v4l-dvb-13961-em28xx-dvb-fix-memleak-in-dvb_fini.patch
+tmpfs-fix-oops-on-mounts-with-mpol-default.patch
+tmpfs-mpol-bind-0-don-t-cause-mount-error.patch
+tmpfs-handle-mpol_local-mount-option-properly.patch
+tmpfs-cleanup-mpol_parse_str.patch
+doc-add-the-documentation-for-mpol-local.patch
--- /dev/null
+From 926f2ae04f183098cf9a30521776fb2759c8afeb Mon Sep 17 00:00:00 2001
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Date: Tue, 23 Mar 2010 13:35:32 -0700
+Subject: tmpfs: cleanup mpol_parse_str()
+
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+
+commit 926f2ae04f183098cf9a30521776fb2759c8afeb upstream.
+
+mpol_parse_str() made lots 'err' variable related bug. Because it is ugly
+and reviewing unfriendly.
+
+This patch simplifies it.
+
+Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Cc: Ravikiran Thirumalai <kiran@scalex86.org>
+Cc: Christoph Lameter <cl@linux-foundation.org>
+Cc: Mel Gorman <mel@csn.ul.ie>
+Acked-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
+Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ mm/mempolicy.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+--- a/mm/mempolicy.c
++++ b/mm/mempolicy.c
+@@ -2122,8 +2122,8 @@ int mpol_parse_str(char *str, struct mem
+ char *rest = nodelist;
+ while (isdigit(*rest))
+ rest++;
+- if (!*rest)
+- err = 0;
++ if (*rest)
++ goto out;
+ }
+ break;
+ case MPOL_INTERLEAVE:
+@@ -2132,7 +2132,6 @@ int mpol_parse_str(char *str, struct mem
+ */
+ if (!nodelist)
+ nodes = node_states[N_HIGH_MEMORY];
+- err = 0;
+ break;
+ case MPOL_LOCAL:
+ /*
+@@ -2141,7 +2140,6 @@ int mpol_parse_str(char *str, struct mem
+ if (nodelist)
+ goto out;
+ mode = MPOL_PREFERRED;
+- err = 0;
+ break;
+ case MPOL_DEFAULT:
+ /*
+@@ -2156,7 +2154,6 @@ int mpol_parse_str(char *str, struct mem
+ */
+ if (!nodelist)
+ goto out;
+- err = 0;
+ }
+
+ mode_flags = 0;
+@@ -2170,13 +2167,14 @@ int mpol_parse_str(char *str, struct mem
+ else if (!strcmp(flags, "relative"))
+ mode_flags |= MPOL_F_RELATIVE_NODES;
+ else
+- err = 1;
++ goto out;
+ }
+
+ new = mpol_new(mode, mode_flags, &nodes);
+ if (IS_ERR(new))
+- err = 1;
+- else {
++ goto out;
++
++ {
+ int ret;
+ NODEMASK_SCRATCH(scratch);
+ if (scratch) {
+@@ -2187,13 +2185,15 @@ int mpol_parse_str(char *str, struct mem
+ ret = -ENOMEM;
+ NODEMASK_SCRATCH_FREE(scratch);
+ if (ret) {
+- err = 1;
+ mpol_put(new);
+- } else if (no_context) {
+- /* save for contextualization */
+- new->w.user_nodemask = nodes;
++ goto out;
+ }
+ }
++ err = 0;
++ if (no_context) {
++ /* save for contextualization */
++ new->w.user_nodemask = nodes;
++ }
+
+ out:
+ /* Restore string for error message */
--- /dev/null
+From 413b43deab8377819aba1dbad2abf0c15d59b491 Mon Sep 17 00:00:00 2001
+From: Ravikiran G Thirumalai <kiran@scalex86.org>
+Date: Tue, 23 Mar 2010 13:35:28 -0700
+Subject: tmpfs: fix oops on mounts with mpol=default
+
+From: Ravikiran G Thirumalai <kiran@scalex86.org>
+
+commit 413b43deab8377819aba1dbad2abf0c15d59b491 upstream.
+
+Fix an 'oops' when a tmpfs mount point is mounted with the mpol=default
+mempolicy.
+
+Upon remounting a tmpfs mount point with 'mpol=default' option, the mount
+code crashed with a null pointer dereference. The initial problem report
+was on 2.6.27, but the problem exists in mainline 2.6.34-rc as well. On
+examining the code, we see that mpol_new returns NULL if default mempolicy
+was requested. This 'NULL' mempolicy is accessed to store the node mask
+resulting in oops.
+
+The following patch fixes it.
+
+Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
+Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Cc: Christoph Lameter <cl@linux-foundation.org>
+Cc: Mel Gorman <mel@csn.ul.ie>
+Acked-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
+Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ mm/mempolicy.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+--- a/mm/mempolicy.c
++++ b/mm/mempolicy.c
+@@ -2142,10 +2142,15 @@ int mpol_parse_str(char *str, struct mem
+ goto out;
+ mode = MPOL_PREFERRED;
+ break;
+-
++ case MPOL_DEFAULT:
++ /*
++ * Insist on a empty nodelist
++ */
++ if (!nodelist)
++ err = 0;
++ goto out;
+ /*
+ * case MPOL_BIND: mpol_new() enforces non-empty nodemask.
+- * case MPOL_DEFAULT: mpol_new() enforces empty nodemask, ignores flags.
+ */
+ }
+
--- /dev/null
+From 12821f5fb942e795f8009ece14bde868893bd811 Mon Sep 17 00:00:00 2001
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Date: Tue, 23 Mar 2010 13:35:31 -0700
+Subject: tmpfs: handle MPOL_LOCAL mount option properly
+
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+
+commit 12821f5fb942e795f8009ece14bde868893bd811 upstream.
+
+commit 71fe804b6d5 (mempolicy: use struct mempolicy pointer in
+shmem_sb_info) added mpol=local mount option. but its feature is broken
+since it was born. because such code always return 1 (i.e. mount
+failure).
+
+This patch fixes it.
+
+Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Cc: Ravikiran Thirumalai <kiran@scalex86.org>
+Cc: Christoph Lameter <cl@linux-foundation.org>
+Cc: Mel Gorman <mel@csn.ul.ie>
+Acked-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
+Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ mm/mempolicy.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/mm/mempolicy.c
++++ b/mm/mempolicy.c
+@@ -2141,6 +2141,7 @@ int mpol_parse_str(char *str, struct mem
+ if (nodelist)
+ goto out;
+ mode = MPOL_PREFERRED;
++ err = 0;
+ break;
+ case MPOL_DEFAULT:
+ /*
--- /dev/null
+From d69b2e63e9172afb4d07c305601b79a55509ac4c Mon Sep 17 00:00:00 2001
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Date: Tue, 23 Mar 2010 13:35:30 -0700
+Subject: tmpfs: mpol=bind:0 don't cause mount error.
+
+From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+
+commit d69b2e63e9172afb4d07c305601b79a55509ac4c upstream.
+
+Currently, following mount operation cause mount error.
+
+% mount -t tmpfs -ompol=bind:0 none /tmp
+
+Because commit 71fe804b6d5 (mempolicy: use struct mempolicy pointer in
+shmem_sb_info) corrupted MPOL_BIND parse code.
+
+This patch restore the needed one.
+
+Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
+Cc: Ravikiran Thirumalai <kiran@scalex86.org>
+Cc: Christoph Lameter <cl@linux-foundation.org>
+Cc: Mel Gorman <mel@csn.ul.ie>
+Acked-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
+Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ mm/mempolicy.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+--- a/mm/mempolicy.c
++++ b/mm/mempolicy.c
+@@ -2149,9 +2149,13 @@ int mpol_parse_str(char *str, struct mem
+ if (!nodelist)
+ err = 0;
+ goto out;
+- /*
+- * case MPOL_BIND: mpol_new() enforces non-empty nodemask.
+- */
++ case MPOL_BIND:
++ /*
++ * Insist on a nodelist
++ */
++ if (!nodelist)
++ goto out;
++ err = 0;
+ }
+
+ mode_flags = 0;