diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-09-04 15:40:37 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-09-04 15:40:37 -0400 |
commit | 02d2fd31defce6ff77146ad0fef4f19006055d86 (patch) | |
tree | de8103e62595fbc1efcd39ff83bf146018e5180b /drivers/md/dm-snap-persistent.c | |
parent | 7ec23d50949d5062b5b749638dd9380ed75e58e5 (diff) |
dm snapshot: refactor zero_disk_area to use chunk_io
Refactor chunk_io to prepare for the fix in the following patch.
Pass an area pointer to chunk_io and simplify zero_disk_area to use
chunk_io. No functional change.
Cc: stable@kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap-persistent.c')
-rw-r--r-- | drivers/md/dm-snap-persistent.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 6e3fe4f14934..2a3d626a98d9 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
@@ -188,7 +188,8 @@ static void do_metadata(struct work_struct *work) | |||
188 | /* | 188 | /* |
189 | * Read or write a chunk aligned and sized block of data from a device. | 189 | * Read or write a chunk aligned and sized block of data from a device. |
190 | */ | 190 | */ |
191 | static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata) | 191 | static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw, |
192 | int metadata) | ||
192 | { | 193 | { |
193 | struct dm_io_region where = { | 194 | struct dm_io_region where = { |
194 | .bdev = ps->store->cow->bdev, | 195 | .bdev = ps->store->cow->bdev, |
@@ -198,7 +199,7 @@ static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata) | |||
198 | struct dm_io_request io_req = { | 199 | struct dm_io_request io_req = { |
199 | .bi_rw = rw, | 200 | .bi_rw = rw, |
200 | .mem.type = DM_IO_VMA, | 201 | .mem.type = DM_IO_VMA, |
201 | .mem.ptr.vma = ps->area, | 202 | .mem.ptr.vma = area, |
202 | .client = ps->io_client, | 203 | .client = ps->io_client, |
203 | .notify.fn = NULL, | 204 | .notify.fn = NULL, |
204 | }; | 205 | }; |
@@ -240,7 +241,7 @@ static int area_io(struct pstore *ps, int rw) | |||
240 | 241 | ||
241 | chunk = area_location(ps, ps->current_area); | 242 | chunk = area_location(ps, ps->current_area); |
242 | 243 | ||
243 | r = chunk_io(ps, chunk, rw, 0); | 244 | r = chunk_io(ps, ps->area, chunk, rw, 0); |
244 | if (r) | 245 | if (r) |
245 | return r; | 246 | return r; |
246 | 247 | ||
@@ -254,20 +255,7 @@ static void zero_memory_area(struct pstore *ps) | |||
254 | 255 | ||
255 | static int zero_disk_area(struct pstore *ps, chunk_t area) | 256 | static int zero_disk_area(struct pstore *ps, chunk_t area) |
256 | { | 257 | { |
257 | struct dm_io_region where = { | 258 | return chunk_io(ps, ps->zero_area, area_location(ps, area), WRITE, 0); |
258 | .bdev = ps->store->cow->bdev, | ||
259 | .sector = ps->store->chunk_size * area_location(ps, area), | ||
260 | .count = ps->store->chunk_size, | ||
261 | }; | ||
262 | struct dm_io_request io_req = { | ||
263 | .bi_rw = WRITE, | ||
264 | .mem.type = DM_IO_VMA, | ||
265 | .mem.ptr.vma = ps->zero_area, | ||
266 | .client = ps->io_client, | ||
267 | .notify.fn = NULL, | ||
268 | }; | ||
269 | |||
270 | return dm_io(&io_req, 1, &where, NULL); | ||
271 | } | 259 | } |
272 | 260 | ||
273 | static int read_header(struct pstore *ps, int *new_snapshot) | 261 | static int read_header(struct pstore *ps, int *new_snapshot) |
@@ -297,7 +285,7 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
297 | if (r) | 285 | if (r) |
298 | return r; | 286 | return r; |
299 | 287 | ||
300 | r = chunk_io(ps, 0, READ, 1); | 288 | r = chunk_io(ps, ps->area, 0, READ, 1); |
301 | if (r) | 289 | if (r) |
302 | goto bad; | 290 | goto bad; |
303 | 291 | ||
@@ -359,7 +347,7 @@ static int write_header(struct pstore *ps) | |||
359 | dh->version = cpu_to_le32(ps->version); | 347 | dh->version = cpu_to_le32(ps->version); |
360 | dh->chunk_size = cpu_to_le32(ps->store->chunk_size); | 348 | dh->chunk_size = cpu_to_le32(ps->store->chunk_size); |
361 | 349 | ||
362 | return chunk_io(ps, 0, WRITE, 1); | 350 | return chunk_io(ps, ps->area, 0, WRITE, 1); |
363 | } | 351 | } |
364 | 352 | ||
365 | /* | 353 | /* |