aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-06-22 14:32:45 -0400
committerMike Snitzer <snitzer@redhat.com>2017-08-28 11:47:18 -0400
commit5916a22b83041b07d63191fe06206ae0fff6ec7a (patch)
treec1d154dcb136fe8e82e57e40f667557fc276c762
parent3f2e539359bd0e709eb35127dc04df6bf8c3e8de (diff)
dm: constify argument arrays
The arrays of 'struct dm_arg' are never modified by the device-mapper core, so constify them so that they are placed in .rodata. (Exception: the args array in dm-raid cannot be constified because it is allocated on the stack and modified.) Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-cache-target.c4
-rw-r--r--drivers/md/dm-crypt.c2
-rw-r--r--drivers/md/dm-flakey.c4
-rw-r--r--drivers/md/dm-integrity.c2
-rw-r--r--drivers/md/dm-mpath.c10
-rw-r--r--drivers/md/dm-switch.c2
-rw-r--r--drivers/md/dm-table.c7
-rw-r--r--drivers/md/dm-thin.c2
-rw-r--r--drivers/md/dm-verity-target.c2
-rw-r--r--include/linux/device-mapper.h4
10 files changed, 20 insertions, 19 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index c5ea03fc7ee1..b0a5503a2fd3 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2306,7 +2306,7 @@ static void init_features(struct cache_features *cf)
2306static int parse_features(struct cache_args *ca, struct dm_arg_set *as, 2306static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
2307 char **error) 2307 char **error)
2308{ 2308{
2309 static struct dm_arg _args[] = { 2309 static const struct dm_arg _args[] = {
2310 {0, 2, "Invalid number of cache feature arguments"}, 2310 {0, 2, "Invalid number of cache feature arguments"},
2311 }; 2311 };
2312 2312
@@ -2348,7 +2348,7 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
2348static int parse_policy(struct cache_args *ca, struct dm_arg_set *as, 2348static int parse_policy(struct cache_args *ca, struct dm_arg_set *as,
2349 char **error) 2349 char **error)
2350{ 2350{
2351 static struct dm_arg _args[] = { 2351 static const struct dm_arg _args[] = {
2352 {0, 1024, "Invalid number of policy arguments"}, 2352 {0, 1024, "Invalid number of policy arguments"},
2353 }; 2353 };
2354 2354
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index cdf6b1e12460..abf16559ed49 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2533,7 +2533,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
2533{ 2533{
2534 struct crypt_config *cc = ti->private; 2534 struct crypt_config *cc = ti->private;
2535 struct dm_arg_set as; 2535 struct dm_arg_set as;
2536 static struct dm_arg _args[] = { 2536 static const struct dm_arg _args[] = {
2537 {0, 6, "Invalid number of feature args"}, 2537 {0, 6, "Invalid number of feature args"},
2538 }; 2538 };
2539 unsigned int opt_params, val; 2539 unsigned int opt_params, val;
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index e2c7234931bc..d8bb371e63d7 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -51,7 +51,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
51 unsigned argc; 51 unsigned argc;
52 const char *arg_name; 52 const char *arg_name;
53 53
54 static struct dm_arg _args[] = { 54 static const struct dm_arg _args[] = {
55 {0, 6, "Invalid number of feature args"}, 55 {0, 6, "Invalid number of feature args"},
56 {1, UINT_MAX, "Invalid corrupt bio byte"}, 56 {1, UINT_MAX, "Invalid corrupt bio byte"},
57 {0, 255, "Invalid corrupt value to write into bio byte (0-255)"}, 57 {0, 255, "Invalid corrupt value to write into bio byte (0-255)"},
@@ -178,7 +178,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
178 */ 178 */
179static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) 179static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
180{ 180{
181 static struct dm_arg _args[] = { 181 static const struct dm_arg _args[] = {
182 {0, UINT_MAX, "Invalid up interval"}, 182 {0, UINT_MAX, "Invalid up interval"},
183 {0, UINT_MAX, "Invalid down interval"}, 183 {0, UINT_MAX, "Invalid down interval"},
184 }; 184 };
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 47fd409b2e2a..293a19652d55 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -2780,7 +2780,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
2780 int r; 2780 int r;
2781 unsigned extra_args; 2781 unsigned extra_args;
2782 struct dm_arg_set as; 2782 struct dm_arg_set as;
2783 static struct dm_arg _args[] = { 2783 static const struct dm_arg _args[] = {
2784 {0, 9, "Invalid number of feature args"}, 2784 {0, 9, "Invalid number of feature args"},
2785 }; 2785 };
2786 unsigned journal_sectors, interleave_sectors, buffer_sectors, journal_watermark, sync_msec; 2786 unsigned journal_sectors, interleave_sectors, buffer_sectors, journal_watermark, sync_msec;
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 7406ededf875..bf280a99fa81 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -702,7 +702,7 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
702 struct path_selector_type *pst; 702 struct path_selector_type *pst;
703 unsigned ps_argc; 703 unsigned ps_argc;
704 704
705 static struct dm_arg _args[] = { 705 static const struct dm_arg _args[] = {
706 {0, 1024, "invalid number of path selector args"}, 706 {0, 1024, "invalid number of path selector args"},
707 }; 707 };
708 708
@@ -826,7 +826,7 @@ retain:
826static struct priority_group *parse_priority_group(struct dm_arg_set *as, 826static struct priority_group *parse_priority_group(struct dm_arg_set *as,
827 struct multipath *m) 827 struct multipath *m)
828{ 828{
829 static struct dm_arg _args[] = { 829 static const struct dm_arg _args[] = {
830 {1, 1024, "invalid number of paths"}, 830 {1, 1024, "invalid number of paths"},
831 {0, 1024, "invalid number of selector args"} 831 {0, 1024, "invalid number of selector args"}
832 }; 832 };
@@ -902,7 +902,7 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
902 int ret; 902 int ret;
903 struct dm_target *ti = m->ti; 903 struct dm_target *ti = m->ti;
904 904
905 static struct dm_arg _args[] = { 905 static const struct dm_arg _args[] = {
906 {0, 1024, "invalid number of hardware handler args"}, 906 {0, 1024, "invalid number of hardware handler args"},
907 }; 907 };
908 908
@@ -954,7 +954,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
954 struct dm_target *ti = m->ti; 954 struct dm_target *ti = m->ti;
955 const char *arg_name; 955 const char *arg_name;
956 956
957 static struct dm_arg _args[] = { 957 static const struct dm_arg _args[] = {
958 {0, 8, "invalid number of feature args"}, 958 {0, 8, "invalid number of feature args"},
959 {1, 50, "pg_init_retries must be between 1 and 50"}, 959 {1, 50, "pg_init_retries must be between 1 and 50"},
960 {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"}, 960 {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"},
@@ -1023,7 +1023,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
1023static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv) 1023static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv)
1024{ 1024{
1025 /* target arguments */ 1025 /* target arguments */
1026 static struct dm_arg _args[] = { 1026 static const struct dm_arg _args[] = {
1027 {0, 1024, "invalid number of priority groups"}, 1027 {0, 1024, "invalid number of priority groups"},
1028 {0, 1024, "invalid initial priority group number"}, 1028 {0, 1024, "invalid initial priority group number"},
1029 }; 1029 };
diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c
index 871c18fe000d..83a371d54412 100644
--- a/drivers/md/dm-switch.c
+++ b/drivers/md/dm-switch.c
@@ -251,7 +251,7 @@ static void switch_dtr(struct dm_target *ti)
251 */ 251 */
252static int switch_ctr(struct dm_target *ti, unsigned argc, char **argv) 252static int switch_ctr(struct dm_target *ti, unsigned argc, char **argv)
253{ 253{
254 static struct dm_arg _args[] = { 254 static const struct dm_arg _args[] = {
255 {1, (KMALLOC_MAX_SIZE - sizeof(struct switch_ctx)) / sizeof(struct switch_path), "Invalid number of paths"}, 255 {1, (KMALLOC_MAX_SIZE - sizeof(struct switch_ctx)) / sizeof(struct switch_path), "Invalid number of paths"},
256 {1, UINT_MAX, "Invalid region size"}, 256 {1, UINT_MAX, "Invalid region size"},
257 {0, 0, "Invalid number of optional args"}, 257 {0, 0, "Invalid number of optional args"},
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 28a4071cdf85..ef7b8f201f73 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -806,7 +806,8 @@ int dm_table_add_target(struct dm_table *t, const char *type,
806/* 806/*
807 * Target argument parsing helpers. 807 * Target argument parsing helpers.
808 */ 808 */
809static int validate_next_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 809static int validate_next_arg(const struct dm_arg *arg,
810 struct dm_arg_set *arg_set,
810 unsigned *value, char **error, unsigned grouped) 811 unsigned *value, char **error, unsigned grouped)
811{ 812{
812 const char *arg_str = dm_shift_arg(arg_set); 813 const char *arg_str = dm_shift_arg(arg_set);
@@ -824,14 +825,14 @@ static int validate_next_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
824 return 0; 825 return 0;
825} 826}
826 827
827int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 828int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set,
828 unsigned *value, char **error) 829 unsigned *value, char **error)
829{ 830{
830 return validate_next_arg(arg, arg_set, value, error, 0); 831 return validate_next_arg(arg, arg_set, value, error, 0);
831} 832}
832EXPORT_SYMBOL(dm_read_arg); 833EXPORT_SYMBOL(dm_read_arg);
833 834
834int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set, 835int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set,
835 unsigned *value, char **error) 836 unsigned *value, char **error)
836{ 837{
837 return validate_next_arg(arg, arg_set, value, error, 1); 838 return validate_next_arg(arg, arg_set, value, error, 1);
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 9dec2f8cc739..9736621c2963 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -3041,7 +3041,7 @@ static int parse_pool_features(struct dm_arg_set *as, struct pool_features *pf,
3041 unsigned argc; 3041 unsigned argc;
3042 const char *arg_name; 3042 const char *arg_name;
3043 3043
3044 static struct dm_arg _args[] = { 3044 static const struct dm_arg _args[] = {
3045 {0, 4, "Invalid number of pool feature arguments"}, 3045 {0, 4, "Invalid number of pool feature arguments"},
3046 }; 3046 };
3047 3047
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index b46705ebf01f..79f18d4d7f02 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -839,7 +839,7 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v)
839 struct dm_target *ti = v->ti; 839 struct dm_target *ti = v->ti;
840 const char *arg_name; 840 const char *arg_name;
841 841
842 static struct dm_arg _args[] = { 842 static const struct dm_arg _args[] = {
843 {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"}, 843 {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"},
844 }; 844 };
845 845
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 4f2b3b2076c4..3b5fdf308148 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -387,7 +387,7 @@ struct dm_arg {
387 * Validate the next argument, either returning it as *value or, if invalid, 387 * Validate the next argument, either returning it as *value or, if invalid,
388 * returning -EINVAL and setting *error. 388 * returning -EINVAL and setting *error.
389 */ 389 */
390int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 390int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set,
391 unsigned *value, char **error); 391 unsigned *value, char **error);
392 392
393/* 393/*
@@ -395,7 +395,7 @@ int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
395 * arg->min and arg->max further arguments. Either return the size as 395 * arg->min and arg->max further arguments. Either return the size as
396 * *num_args or, if invalid, return -EINVAL and set *error. 396 * *num_args or, if invalid, return -EINVAL and set *error.
397 */ 397 */
398int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set, 398int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set,
399 unsigned *num_args, char **error); 399 unsigned *num_args, char **error);
400 400
401/* 401/*