diff options
author | Jonathan Brassow <jbrassow@redhat.com> | 2009-04-02 14:55:33 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-04-02 14:55:33 -0400 |
commit | 71fab00a6bef7fb53119271a8abdbaf40970d28a (patch) | |
tree | 4881f8f6d1b1c42528889d7a56fb8674d2aa7723 /drivers/md/dm-snap-persistent.c | |
parent | 49beb2b87a972a994ff77633234ca3bf0d30a1d8 (diff) |
dm snapshot: remove dm_snap header use
Move useful functions out of dm-snap.h and stop using dm-snap.h.
Signed-off-by: Jonathan Brassow <jbrassow@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 | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 505afac9976f..3907c4ce2ae5 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "dm-exception-store.h" | 8 | #include "dm-exception-store.h" |
9 | #include "dm-snap.h" | ||
10 | 9 | ||
11 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
12 | #include <linux/pagemap.h> | 11 | #include <linux/pagemap.h> |
@@ -89,7 +88,7 @@ struct commit_callback { | |||
89 | * The top level structure for a persistent exception store. | 88 | * The top level structure for a persistent exception store. |
90 | */ | 89 | */ |
91 | struct pstore { | 90 | struct pstore { |
92 | struct dm_snapshot *snap; /* up pointer to my snapshot */ | 91 | struct dm_exception_store *store; |
93 | int version; | 92 | int version; |
94 | int valid; | 93 | int valid; |
95 | uint32_t exceptions_per_area; | 94 | uint32_t exceptions_per_area; |
@@ -141,7 +140,7 @@ static int alloc_area(struct pstore *ps) | |||
141 | int r = -ENOMEM; | 140 | int r = -ENOMEM; |
142 | size_t len; | 141 | size_t len; |
143 | 142 | ||
144 | len = ps->snap->store->chunk_size << SECTOR_SHIFT; | 143 | len = ps->store->chunk_size << SECTOR_SHIFT; |
145 | 144 | ||
146 | /* | 145 | /* |
147 | * Allocate the chunk_size block of memory that will hold | 146 | * Allocate the chunk_size block of memory that will hold |
@@ -189,9 +188,9 @@ static void do_metadata(struct work_struct *work) | |||
189 | static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata) | 188 | static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata) |
190 | { | 189 | { |
191 | struct dm_io_region where = { | 190 | struct dm_io_region where = { |
192 | .bdev = ps->snap->store->cow->bdev, | 191 | .bdev = ps->store->cow->bdev, |
193 | .sector = ps->snap->store->chunk_size * chunk, | 192 | .sector = ps->store->chunk_size * chunk, |
194 | .count = ps->snap->store->chunk_size, | 193 | .count = ps->store->chunk_size, |
195 | }; | 194 | }; |
196 | struct dm_io_request io_req = { | 195 | struct dm_io_request io_req = { |
197 | .bi_rw = rw, | 196 | .bi_rw = rw, |
@@ -247,15 +246,15 @@ static int area_io(struct pstore *ps, int rw) | |||
247 | 246 | ||
248 | static void zero_memory_area(struct pstore *ps) | 247 | static void zero_memory_area(struct pstore *ps) |
249 | { | 248 | { |
250 | memset(ps->area, 0, ps->snap->store->chunk_size << SECTOR_SHIFT); | 249 | memset(ps->area, 0, ps->store->chunk_size << SECTOR_SHIFT); |
251 | } | 250 | } |
252 | 251 | ||
253 | static int zero_disk_area(struct pstore *ps, chunk_t area) | 252 | static int zero_disk_area(struct pstore *ps, chunk_t area) |
254 | { | 253 | { |
255 | struct dm_io_region where = { | 254 | struct dm_io_region where = { |
256 | .bdev = ps->snap->store->cow->bdev, | 255 | .bdev = ps->store->cow->bdev, |
257 | .sector = ps->snap->store->chunk_size * area_location(ps, area), | 256 | .sector = ps->store->chunk_size * area_location(ps, area), |
258 | .count = ps->snap->store->chunk_size, | 257 | .count = ps->store->chunk_size, |
259 | }; | 258 | }; |
260 | struct dm_io_request io_req = { | 259 | struct dm_io_request io_req = { |
261 | .bi_rw = WRITE, | 260 | .bi_rw = WRITE, |
@@ -278,17 +277,16 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
278 | /* | 277 | /* |
279 | * Use default chunk size (or hardsect_size, if larger) if none supplied | 278 | * Use default chunk size (or hardsect_size, if larger) if none supplied |
280 | */ | 279 | */ |
281 | if (!ps->snap->store->chunk_size) { | 280 | if (!ps->store->chunk_size) { |
282 | ps->snap->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS, | 281 | ps->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS, |
283 | bdev_hardsect_size(ps->snap->store->cow->bdev) >> 9); | 282 | bdev_hardsect_size(ps->store->cow->bdev) >> 9); |
284 | ps->snap->store->chunk_mask = ps->snap->store->chunk_size - 1; | 283 | ps->store->chunk_mask = ps->store->chunk_size - 1; |
285 | ps->snap->store->chunk_shift = ffs(ps->snap->store->chunk_size) | 284 | ps->store->chunk_shift = ffs(ps->store->chunk_size) - 1; |
286 | - 1; | ||
287 | chunk_size_supplied = 0; | 285 | chunk_size_supplied = 0; |
288 | } | 286 | } |
289 | 287 | ||
290 | ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap-> | 288 | ps->io_client = dm_io_client_create(sectors_to_pages(ps->store-> |
291 | store->chunk_size)); | 289 | chunk_size)); |
292 | if (IS_ERR(ps->io_client)) | 290 | if (IS_ERR(ps->io_client)) |
293 | return PTR_ERR(ps->io_client); | 291 | return PTR_ERR(ps->io_client); |
294 | 292 | ||
@@ -318,22 +316,22 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
318 | ps->version = le32_to_cpu(dh->version); | 316 | ps->version = le32_to_cpu(dh->version); |
319 | chunk_size = le32_to_cpu(dh->chunk_size); | 317 | chunk_size = le32_to_cpu(dh->chunk_size); |
320 | 318 | ||
321 | if (!chunk_size_supplied || ps->snap->store->chunk_size == chunk_size) | 319 | if (!chunk_size_supplied || ps->store->chunk_size == chunk_size) |
322 | return 0; | 320 | return 0; |
323 | 321 | ||
324 | DMWARN("chunk size %llu in device metadata overrides " | 322 | DMWARN("chunk size %llu in device metadata overrides " |
325 | "table chunk size of %llu.", | 323 | "table chunk size of %llu.", |
326 | (unsigned long long)chunk_size, | 324 | (unsigned long long)chunk_size, |
327 | (unsigned long long)ps->snap->store->chunk_size); | 325 | (unsigned long long)ps->store->chunk_size); |
328 | 326 | ||
329 | /* We had a bogus chunk_size. Fix stuff up. */ | 327 | /* We had a bogus chunk_size. Fix stuff up. */ |
330 | free_area(ps); | 328 | free_area(ps); |
331 | 329 | ||
332 | ps->snap->store->chunk_size = chunk_size; | 330 | ps->store->chunk_size = chunk_size; |
333 | ps->snap->store->chunk_mask = chunk_size - 1; | 331 | ps->store->chunk_mask = chunk_size - 1; |
334 | ps->snap->store->chunk_shift = ffs(chunk_size) - 1; | 332 | ps->store->chunk_shift = ffs(chunk_size) - 1; |
335 | 333 | ||
336 | r = dm_io_client_resize(sectors_to_pages(ps->snap->store->chunk_size), | 334 | r = dm_io_client_resize(sectors_to_pages(ps->store->chunk_size), |
337 | ps->io_client); | 335 | ps->io_client); |
338 | if (r) | 336 | if (r) |
339 | return r; | 337 | return r; |
@@ -350,13 +348,13 @@ static int write_header(struct pstore *ps) | |||
350 | { | 348 | { |
351 | struct disk_header *dh; | 349 | struct disk_header *dh; |
352 | 350 | ||
353 | memset(ps->area, 0, ps->snap->store->chunk_size << SECTOR_SHIFT); | 351 | memset(ps->area, 0, ps->store->chunk_size << SECTOR_SHIFT); |
354 | 352 | ||
355 | dh = (struct disk_header *) ps->area; | 353 | dh = (struct disk_header *) ps->area; |
356 | dh->magic = cpu_to_le32(SNAP_MAGIC); | 354 | dh->magic = cpu_to_le32(SNAP_MAGIC); |
357 | dh->valid = cpu_to_le32(ps->valid); | 355 | dh->valid = cpu_to_le32(ps->valid); |
358 | dh->version = cpu_to_le32(ps->version); | 356 | dh->version = cpu_to_le32(ps->version); |
359 | dh->chunk_size = cpu_to_le32(ps->snap->store->chunk_size); | 357 | dh->chunk_size = cpu_to_le32(ps->store->chunk_size); |
360 | 358 | ||
361 | return chunk_io(ps, 0, WRITE, 1); | 359 | return chunk_io(ps, 0, WRITE, 1); |
362 | } | 360 | } |
@@ -508,8 +506,8 @@ static int persistent_read_metadata(struct dm_exception_store *store, | |||
508 | /* | 506 | /* |
509 | * Now we know correct chunk_size, complete the initialisation. | 507 | * Now we know correct chunk_size, complete the initialisation. |
510 | */ | 508 | */ |
511 | ps->exceptions_per_area = (ps->snap->store->chunk_size << SECTOR_SHIFT) | 509 | ps->exceptions_per_area = (ps->store->chunk_size << SECTOR_SHIFT) / |
512 | / sizeof(struct disk_exception); | 510 | sizeof(struct disk_exception); |
513 | ps->callbacks = dm_vcalloc(ps->exceptions_per_area, | 511 | ps->callbacks = dm_vcalloc(ps->exceptions_per_area, |
514 | sizeof(*ps->callbacks)); | 512 | sizeof(*ps->callbacks)); |
515 | if (!ps->callbacks) | 513 | if (!ps->callbacks) |
@@ -667,7 +665,7 @@ static int persistent_ctr(struct dm_exception_store *store, | |||
667 | if (!ps) | 665 | if (!ps) |
668 | return -ENOMEM; | 666 | return -ENOMEM; |
669 | 667 | ||
670 | ps->snap = store->snap; | 668 | ps->store = store; |
671 | ps->valid = 1; | 669 | ps->valid = 1; |
672 | ps->version = SNAPSHOT_DISK_VERSION; | 670 | ps->version = SNAPSHOT_DISK_VERSION; |
673 | ps->area = NULL; | 671 | ps->area = NULL; |