diff options
author | Milan Broz <mbroz@redhat.com> | 2009-01-05 22:05:01 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-01-05 22:05:01 -0500 |
commit | 2045e88edb4e0c9ce62d317f77dc59d27d9c530e (patch) | |
tree | 324eeea271b889263d0141fe0c82d4b0e43d0079 | |
parent | 6f3af01cb0eda0ec50fe1e4cbdf028269dc396fe (diff) |
dm log: move region_size validation
Move log size validation from mirror target to log constructor.
Removed PAGE_SIZE restriction we no longer think necessary.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm-log.c | 16 | ||||
-rw-r--r-- | drivers/md/dm-raid1.c | 12 |
2 files changed, 14 insertions, 14 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 691cb9c22b56..40ed70df6736 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
@@ -360,6 +360,17 @@ static int read_header(struct log_c *log) | |||
360 | return 0; | 360 | return 0; |
361 | } | 361 | } |
362 | 362 | ||
363 | static int _check_region_size(struct dm_target *ti, uint32_t region_size) | ||
364 | { | ||
365 | if (region_size < 2 || region_size > ti->len) | ||
366 | return 0; | ||
367 | |||
368 | if (!is_power_of_2(region_size)) | ||
369 | return 0; | ||
370 | |||
371 | return 1; | ||
372 | } | ||
373 | |||
363 | /*---------------------------------------------------------------- | 374 | /*---------------------------------------------------------------- |
364 | * core log constructor/destructor | 375 | * core log constructor/destructor |
365 | * | 376 | * |
@@ -395,8 +406,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, | |||
395 | } | 406 | } |
396 | } | 407 | } |
397 | 408 | ||
398 | if (sscanf(argv[0], "%u", ®ion_size) != 1) { | 409 | if (sscanf(argv[0], "%u", ®ion_size) != 1 || |
399 | DMWARN("invalid region size string"); | 410 | !_check_region_size(ti, region_size)) { |
411 | DMWARN("invalid region size %s", argv[0]); | ||
400 | return -EINVAL; | 412 | return -EINVAL; |
401 | } | 413 | } |
402 | 414 | ||
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 250f401668d5..4d6bc101962e 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -808,12 +808,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, | |||
808 | kfree(ms); | 808 | kfree(ms); |
809 | } | 809 | } |
810 | 810 | ||
811 | static inline int _check_region_size(struct dm_target *ti, uint32_t size) | ||
812 | { | ||
813 | return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) || | ||
814 | size > ti->len); | ||
815 | } | ||
816 | |||
817 | static int get_mirror(struct mirror_set *ms, struct dm_target *ti, | 811 | static int get_mirror(struct mirror_set *ms, struct dm_target *ti, |
818 | unsigned int mirror, char **argv) | 812 | unsigned int mirror, char **argv) |
819 | { | 813 | { |
@@ -872,12 +866,6 @@ static struct dm_dirty_log *create_dirty_log(struct dm_target *ti, | |||
872 | return NULL; | 866 | return NULL; |
873 | } | 867 | } |
874 | 868 | ||
875 | if (!_check_region_size(ti, dl->type->get_region_size(dl))) { | ||
876 | ti->error = "Invalid region size"; | ||
877 | dm_dirty_log_destroy(dl); | ||
878 | return NULL; | ||
879 | } | ||
880 | |||
881 | return dl; | 869 | return dl; |
882 | } | 870 | } |
883 | 871 | ||