Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157226
b: refs/heads/master
c: ae0b744
h: refs/heads/master
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Sep 4, 2009
1 parent 7ff3502 commit 2d68415
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2defcc3fb4661e7351cb2ac48d843efc4c64db13
refs/heads/master: ae0b7448e91353ea5f821601a055aca6b58042cd
5 changes: 5 additions & 0 deletions trunk/drivers/md/dm-exception-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
return -EINVAL;
}

if (chunk_size_ulong > INT_MAX >> SECTOR_SHIFT) {
*error = "Chunk size is too high";
return -EINVAL;
}

store->chunk_size = chunk_size_ulong;
store->chunk_mask = chunk_size_ulong - 1;
store->chunk_shift = ffs(chunk_size_ulong) - 1;
Expand Down
22 changes: 14 additions & 8 deletions trunk/drivers/md/dm-snap-persistent.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
struct disk_header *dh;
chunk_t chunk_size;
int chunk_size_supplied = 1;
char *chunk_err;

/*
* Use default chunk size (or hardsect_size, if larger) if none supplied
Expand Down Expand Up @@ -329,20 +330,25 @@ static int read_header(struct pstore *ps, int *new_snapshot)
ps->version = le32_to_cpu(dh->version);
chunk_size = le32_to_cpu(dh->chunk_size);

if (!chunk_size_supplied || ps->store->chunk_size == chunk_size)
if (ps->store->chunk_size == chunk_size)
return 0;

DMWARN("chunk size %llu in device metadata overrides "
"table chunk size of %llu.",
(unsigned long long)chunk_size,
(unsigned long long)ps->store->chunk_size);
if (chunk_size_supplied)
DMWARN("chunk size %llu in device metadata overrides "
"table chunk size of %llu.",
(unsigned long long)chunk_size,
(unsigned long long)ps->store->chunk_size);

/* We had a bogus chunk_size. Fix stuff up. */
free_area(ps);

ps->store->chunk_size = chunk_size;
ps->store->chunk_mask = chunk_size - 1;
ps->store->chunk_shift = ffs(chunk_size) - 1;
r = dm_exception_store_set_chunk_size(ps->store, chunk_size,
&chunk_err);
if (r) {
DMERR("invalid on-disk chunk size %llu: %s.",
(unsigned long long)chunk_size, chunk_err);
return r;
}

r = dm_io_client_resize(sectors_to_pages(ps->store->chunk_size),
ps->io_client);
Expand Down

0 comments on commit 2d68415

Please sign in to comment.