fix hard-coded disk header chunk size for persistent snapshot
PATCH 1/1 fix hard-coded disk header chunk size for persistent snapshot
Hi,
This patch fixes hard-coded value for the size of a chunk that includes disk header for persistent snapshot. It should be changed to existing macro NUM_SNAPSHOT_HDR_CHUNKS instead of using hard-coded value 1.
Thanks,
Tomohiro Kusumi
---
drivers/md/dm-snap-persistent.c 2010-05-12 09:21:50.000000000 +0900 renamed from drivers/md/dm-snap-persistent.c 2010-05-10 10:36:28.000000000 +0900 +1 -1
@@ -266,7 +266,7 @@ */ static chunk_t area_location(struct pstore *ps, chunk_t area) { - return 1 + ((ps->exceptions_per_area + 1) * area); + return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); } /*
Alasdair G Kergon
maintainerQuoted 3 lines · Tomohiro Kusumi
This patch fixes hard-coded value for the size of a chunk that includes disk header for persistent snapshot. It should be changed to existing macro
NUM_SNAPSHOT_HDR_CHUNKSinstead of using hard-coded value 1.
Any more places too? (E.g. persistent_commit_merge)
Alasdair
Mikulas Patocka
maintainerQuoted 8 lines · Alasdair G Kergon
Quoted 3 lines · Tomohiro Kusumi
This patch fixes hard-coded value for the size of a chunk that includes disk header for persistent snapshot. It should be changed to existing macro
NUM_SNAPSHOT_HDR_CHUNKSinstead of using hard-coded value 1.Any more places too? (E.g.
persistent_commit_merge)Alasdair
I think the expression in persistent_commit_merge should be changed to:ps->next_free = area_location(ps, ps->current_area) +
ps->current_committed + 1;
It is numerically the same, but will avoid trouble if NUM_SNAPSHOT_HDR_CHUNKS is increased.
Mikulas
Quoted 13 lines · Mikulas Patocka
Quoted 8 lines · Alasdair G Kergon
Quoted 3 lines · Tomohiro Kusumi
This patch fixes hard-coded value for the size of a chunk that includes disk header for persistent snapshot. It should be changed to existing macro
NUM_SNAPSHOT_HDR_CHUNKSinstead of using hard-coded value 1.Any more places too? (E.g.
persistent_commit_merge)Alasdair
Quoted 10 lines
I think the expression in
persistent_commit_mergeshould be changed to:ps->next_free=area_location(ps, ps->current_area)+ps->current_committed + 1;It is numerically the same, but will avoid trouble if
NUM_SNAPSHOT_HDR_CHUNKSis increased.Mikulas
agree,
a single chunk is large enough to contain 16byte disk header
which does not seem necessary to increase NUM_SNAPSHOT_HDR_CHUNKS in the future (unless whole structure get totally changed),
but it should also get fixed to avoid trouble.
I merged it to the patch with your names signed off.
Thanks,
Tomohiro Kusumi
---
drivers/md/dm-snap-persistent.c +3 -3
@@ -266,7 +266,7 @@*/ static chunk_t area_location (struct pstore *ps,chunk_t area) { -return 1 + ((ps->exceptions_per_area +1 ) * area); +return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area +1 ) * area); }/*
@@ -780,8 +780,8 @@* ps->current_area does not get reduced by prepare_merge() until * after commit_merge() has removed the nr_merged previous exceptions. */ - ps->next_free = (area_location (ps, ps->current_area) -1 ) + - (ps->current_committed +1 ) +NUM_SNAPSHOT_HDR_CHUNKS ; + ps->next_free =area_location (ps, ps->current_area) + + ps->current_committed +1 ;return 0 ; }