From 5471a80a96a7ae7e4c34e44ddf9bb200cf1f9195 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 30 Sep 2005 22:20:14 +0000 Subject: [PATCH] Impose chunk size limitation. --- tools/lvcreate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 9dde01331..09097a2f0 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -303,7 +303,12 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd, return 0; } lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8); -// FIXME Restrict chunk_size to power of 2 in range PAGE_SIZE up to 512k (=1024) + if (lp->chunk_size < 8 || lp->chunk_size > 1024 || + (lp->chunk_size & (lp->chunk_size - 1))) { + log_error("Chunk size must be a power of 2 in the " + "range 4K to 512K"); + return 0; + } log_verbose("Setting chunksize to %d sectors.", lp->chunk_size); if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot"))) {