aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorLee Schermerhorn <Lee.Schermerhorn@hp.com>2008-04-28 05:12:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:20 -0400
commita43361cf3cb6fb6431fdbfb0f3ef26a334826160 (patch)
tree8ec343f73bb61c1ef08a32c78e912a7506c932bf /mm/shmem.c
parent3e1f064562fcff7bf3856bc1d00dfa84d4f121cc (diff)
mempolicy: fix parsing of tmpfs mpol mount option
Parsing of new mode flags in the tmpfs mpol mount option is slightly broken: Setting a valid flag works OK: #mount -o remount,mpol=bind=static:1-2 /dev/shm #mount ... tmpfs on /dev/shm type tmpfs (rw,mpol=bind=static:1-2) ... However, we can't remove them or change them, once we've set a valid flag: #mount -o remount,mpol=bind:1-2 /dev/shm #mount ... tmpfs on /dev/shm type tmpfs (rw,mpol=bind:1-2) ... It SAYS it removed it, but that's just a copy of the input string. If we now try to set it to a different flag, we get: #mount -o remount,mpol=bind=relative:1-2 /dev/shm mount: /dev/shm not mounted already, or bad option And on the console, we see: tmpfs: Bad value 'bind' for mount option 'mpol' ^ lost remainder of string Furthermore, bogus flags are accepted with out error. Granted, they are a no-op: #mount -o remount,mpol=interleave=foo:0-3 /dev/shm #mount ... tmpfs on /dev/shm type tmpfs (rw,mpol=interleave=foo:0-3) Again, that's just a copy of the input string shown by the mount command. This patch fixes the behavior by pre-zeroing the flags so that only one of the mutually exclusive flags can be set at one time. It also reports an error when an unrecognized flag is specified. The check for both flags being set is removed because it can't happen with this implementation. If we ever want to support multiple non-exclusive flags, this area will need rework and we will need to check that any mutually exclusive flags aren't specified. Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: David Rientjes <rientjes@google.com> Cc: Paul Jackson <pj@sgi.com> Cc: Christoph Lameter <clameter@sgi.com> Cc: Andi Kleen <ak@suse.de> Cc: Eric Whitney <eric.whitney@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 9435f298dd75..177c7a7d2bb3 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1125,20 +1125,26 @@ static int shmem_parse_mpol(char *value, unsigned short *policy,
1125 *policy_nodes = node_states[N_HIGH_MEMORY]; 1125 *policy_nodes = node_states[N_HIGH_MEMORY];
1126 err = 0; 1126 err = 0;
1127 } 1127 }
1128
1129 *mode_flags = 0;
1128 if (flags) { 1130 if (flags) {
1131 /*
1132 * Currently, we only support two mutually exclusive
1133 * mode flags.
1134 */
1129 if (!strcmp(flags, "static")) 1135 if (!strcmp(flags, "static"))
1130 *mode_flags |= MPOL_F_STATIC_NODES; 1136 *mode_flags |= MPOL_F_STATIC_NODES;
1131 if (!strcmp(flags, "relative")) 1137 else if (!strcmp(flags, "relative"))
1132 *mode_flags |= MPOL_F_RELATIVE_NODES; 1138 *mode_flags |= MPOL_F_RELATIVE_NODES;
1133 1139 else
1134 if ((*mode_flags & MPOL_F_STATIC_NODES) && 1140 err = 1; /* unrecognized flag */
1135 (*mode_flags & MPOL_F_RELATIVE_NODES))
1136 err = 1;
1137 } 1141 }
1138out: 1142out:
1139 /* Restore string for error message */ 1143 /* Restore string for error message */
1140 if (nodelist) 1144 if (nodelist)
1141 *--nodelist = ':'; 1145 *--nodelist = ':';
1146 if (flags)
1147 *--flags = '=';
1142 return err; 1148 return err;
1143} 1149}
1144 1150