From f2d86d97fe9ee7c3ba81c3a8bf337044820950ab Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 29 Mar 2010 11:30:03 -0700 Subject: [PATCH] .31 patches --- ...add-the-documentation-for-mpol-local.patch | 51 +++++++++ queue-2.6.31/series | 5 + .../tmpfs-cleanup-mpol_parse_str.patch | 103 ++++++++++++++++++ ...fix-oops-on-mounts-with-mpol-default.patch | 55 ++++++++++ ...dle-mpol_local-mount-option-properly.patch | 40 +++++++ ...-mpol-bind-0-don-t-cause-mount-error.patch | 51 +++++++++ 6 files changed, 305 insertions(+) create mode 100644 queue-2.6.31/doc-add-the-documentation-for-mpol-local.patch create mode 100644 queue-2.6.31/tmpfs-cleanup-mpol_parse_str.patch create mode 100644 queue-2.6.31/tmpfs-fix-oops-on-mounts-with-mpol-default.patch create mode 100644 queue-2.6.31/tmpfs-handle-mpol_local-mount-option-properly.patch create mode 100644 queue-2.6.31/tmpfs-mpol-bind-0-don-t-cause-mount-error.patch diff --git a/queue-2.6.31/doc-add-the-documentation-for-mpol-local.patch b/queue-2.6.31/doc-add-the-documentation-for-mpol-local.patch new file mode 100644 index 00000000000..62898007ea7 --- /dev/null +++ b/queue-2.6.31/doc-add-the-documentation-for-mpol-local.patch @@ -0,0 +1,51 @@ +From 5574169613b40b85d6f4c67208fa4846b897a0a1 Mon Sep 17 00:00:00 2001 +From: KOSAKI Motohiro +Date: Tue, 23 Mar 2010 13:35:33 -0700 +Subject: doc: add the documentation for mpol=local + +From: KOSAKI Motohiro + +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 +Cc: Ravikiran Thirumalai +Cc: Christoph Lameter +Cc: Mel Gorman +Acked-by: Lee Schermerhorn +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + 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 , 1.12.01 + Updated: + Hugh Dickins, 4 June 2007 ++Updated: ++ KOSAKI Motohiro, 16 Mar 2010 diff --git a/queue-2.6.31/series b/queue-2.6.31/series index 88ffec11e0e..3d16b6b3f85 100644 --- a/queue-2.6.31/series +++ b/queue-2.6.31/series @@ -79,3 +79,8 @@ x86-ia32_aout-do-not-kill-argument-mapping.patch 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 diff --git a/queue-2.6.31/tmpfs-cleanup-mpol_parse_str.patch b/queue-2.6.31/tmpfs-cleanup-mpol_parse_str.patch new file mode 100644 index 00000000000..22974961a4d --- /dev/null +++ b/queue-2.6.31/tmpfs-cleanup-mpol_parse_str.patch @@ -0,0 +1,103 @@ +From 926f2ae04f183098cf9a30521776fb2759c8afeb Mon Sep 17 00:00:00 2001 +From: KOSAKI Motohiro +Date: Tue, 23 Mar 2010 13:35:32 -0700 +Subject: tmpfs: cleanup mpol_parse_str() + +From: KOSAKI Motohiro + +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 +Cc: Ravikiran Thirumalai +Cc: Christoph Lameter +Cc: Mel Gorman +Acked-by: Lee Schermerhorn +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + 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 */ diff --git a/queue-2.6.31/tmpfs-fix-oops-on-mounts-with-mpol-default.patch b/queue-2.6.31/tmpfs-fix-oops-on-mounts-with-mpol-default.patch new file mode 100644 index 00000000000..4ed805dccd5 --- /dev/null +++ b/queue-2.6.31/tmpfs-fix-oops-on-mounts-with-mpol-default.patch @@ -0,0 +1,55 @@ +From 413b43deab8377819aba1dbad2abf0c15d59b491 Mon Sep 17 00:00:00 2001 +From: Ravikiran G Thirumalai +Date: Tue, 23 Mar 2010 13:35:28 -0700 +Subject: tmpfs: fix oops on mounts with mpol=default + +From: Ravikiran G Thirumalai + +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 +Signed-off-by: KOSAKI Motohiro +Cc: Christoph Lameter +Cc: Mel Gorman +Acked-by: Lee Schermerhorn +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + 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. + */ + } + diff --git a/queue-2.6.31/tmpfs-handle-mpol_local-mount-option-properly.patch b/queue-2.6.31/tmpfs-handle-mpol_local-mount-option-properly.patch new file mode 100644 index 00000000000..f1a4f3615f6 --- /dev/null +++ b/queue-2.6.31/tmpfs-handle-mpol_local-mount-option-properly.patch @@ -0,0 +1,40 @@ +From 12821f5fb942e795f8009ece14bde868893bd811 Mon Sep 17 00:00:00 2001 +From: KOSAKI Motohiro +Date: Tue, 23 Mar 2010 13:35:31 -0700 +Subject: tmpfs: handle MPOL_LOCAL mount option properly + +From: KOSAKI Motohiro + +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 +Cc: Ravikiran Thirumalai +Cc: Christoph Lameter +Cc: Mel Gorman +Acked-by: Lee Schermerhorn +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + 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: + /* diff --git a/queue-2.6.31/tmpfs-mpol-bind-0-don-t-cause-mount-error.patch b/queue-2.6.31/tmpfs-mpol-bind-0-don-t-cause-mount-error.patch new file mode 100644 index 00000000000..8cb8a1cc505 --- /dev/null +++ b/queue-2.6.31/tmpfs-mpol-bind-0-don-t-cause-mount-error.patch @@ -0,0 +1,51 @@ +From d69b2e63e9172afb4d07c305601b79a55509ac4c Mon Sep 17 00:00:00 2001 +From: KOSAKI Motohiro +Date: Tue, 23 Mar 2010 13:35:30 -0700 +Subject: tmpfs: mpol=bind:0 don't cause mount error. + +From: KOSAKI Motohiro + +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 +Cc: Ravikiran Thirumalai +Cc: Christoph Lameter +Cc: Mel Gorman +Acked-by: Lee Schermerhorn +Cc: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + 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; -- 2.47.3