diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-snap.c | 72 | ||||
-rw-r--r-- | drivers/md/dm-snap.h | 86 |
2 files changed, 71 insertions, 87 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 467c586e2439..bb28f9782bdd 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -20,9 +20,9 @@ | |||
20 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
21 | #include <linux/log2.h> | 21 | #include <linux/log2.h> |
22 | #include <linux/dm-kcopyd.h> | 22 | #include <linux/dm-kcopyd.h> |
23 | #include <linux/workqueue.h> | ||
23 | 24 | ||
24 | #include "dm-exception-store.h" | 25 | #include "dm-exception-store.h" |
25 | #include "dm-snap.h" | ||
26 | #include "dm-bio-list.h" | 26 | #include "dm-bio-list.h" |
27 | 27 | ||
28 | #define DM_MSG_PREFIX "snapshots" | 28 | #define DM_MSG_PREFIX "snapshots" |
@@ -47,9 +47,79 @@ | |||
47 | */ | 47 | */ |
48 | #define MIN_IOS 256 | 48 | #define MIN_IOS 256 |
49 | 49 | ||
50 | #define DM_TRACKED_CHUNK_HASH_SIZE 16 | ||
51 | #define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \ | ||
52 | (DM_TRACKED_CHUNK_HASH_SIZE - 1)) | ||
53 | |||
54 | struct exception_table { | ||
55 | uint32_t hash_mask; | ||
56 | unsigned hash_shift; | ||
57 | struct list_head *table; | ||
58 | }; | ||
59 | |||
60 | struct dm_snapshot { | ||
61 | struct rw_semaphore lock; | ||
62 | |||
63 | struct dm_dev *origin; | ||
64 | |||
65 | /* List of snapshots per Origin */ | ||
66 | struct list_head list; | ||
67 | |||
68 | /* You can't use a snapshot if this is 0 (e.g. if full) */ | ||
69 | int valid; | ||
70 | |||
71 | /* Origin writes don't trigger exceptions until this is set */ | ||
72 | int active; | ||
73 | |||
74 | /* Used for display of table */ | ||
75 | char type; | ||
76 | |||
77 | mempool_t *pending_pool; | ||
78 | |||
79 | atomic_t pending_exceptions_count; | ||
80 | |||
81 | struct exception_table pending; | ||
82 | struct exception_table complete; | ||
83 | |||
84 | /* | ||
85 | * pe_lock protects all pending_exception operations and access | ||
86 | * as well as the snapshot_bios list. | ||
87 | */ | ||
88 | spinlock_t pe_lock; | ||
89 | |||
90 | /* The on disk metadata handler */ | ||
91 | struct dm_exception_store *store; | ||
92 | |||
93 | struct dm_kcopyd_client *kcopyd_client; | ||
94 | |||
95 | /* Queue of snapshot writes for ksnapd to flush */ | ||
96 | struct bio_list queued_bios; | ||
97 | struct work_struct queued_bios_work; | ||
98 | |||
99 | /* Chunks with outstanding reads */ | ||
100 | mempool_t *tracked_chunk_pool; | ||
101 | spinlock_t tracked_chunk_lock; | ||
102 | struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE]; | ||
103 | }; | ||
104 | |||
50 | static struct workqueue_struct *ksnapd; | 105 | static struct workqueue_struct *ksnapd; |
51 | static void flush_queued_bios(struct work_struct *work); | 106 | static void flush_queued_bios(struct work_struct *work); |
52 | 107 | ||
108 | static sector_t chunk_to_sector(struct dm_exception_store *store, | ||
109 | chunk_t chunk) | ||
110 | { | ||
111 | return chunk << store->chunk_shift; | ||
112 | } | ||
113 | |||
114 | static int bdev_equal(struct block_device *lhs, struct block_device *rhs) | ||
115 | { | ||
116 | /* | ||
117 | * There is only ever one instance of a particular block | ||
118 | * device so we can compare pointers safely. | ||
119 | */ | ||
120 | return lhs == rhs; | ||
121 | } | ||
122 | |||
53 | struct dm_snap_pending_exception { | 123 | struct dm_snap_pending_exception { |
54 | struct dm_snap_exception e; | 124 | struct dm_snap_exception e; |
55 | 125 | ||
diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h deleted file mode 100644 index 4f61bc4c14f6..000000000000 --- a/drivers/md/dm-snap.h +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001-2002 Sistina Software (UK) Limited. | ||
3 | * | ||
4 | * This file is released under the GPL. | ||
5 | */ | ||
6 | |||
7 | #ifndef DM_SNAPSHOT_H | ||
8 | #define DM_SNAPSHOT_H | ||
9 | |||
10 | #include <linux/device-mapper.h> | ||
11 | #include "dm-exception-store.h" | ||
12 | #include "dm-bio-list.h" | ||
13 | #include <linux/blkdev.h> | ||
14 | #include <linux/workqueue.h> | ||
15 | |||
16 | struct exception_table { | ||
17 | uint32_t hash_mask; | ||
18 | unsigned hash_shift; | ||
19 | struct list_head *table; | ||
20 | }; | ||
21 | |||
22 | #define DM_TRACKED_CHUNK_HASH_SIZE 16 | ||
23 | #define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \ | ||
24 | (DM_TRACKED_CHUNK_HASH_SIZE - 1)) | ||
25 | |||
26 | struct dm_snapshot { | ||
27 | struct rw_semaphore lock; | ||
28 | |||
29 | struct dm_dev *origin; | ||
30 | |||
31 | /* List of snapshots per Origin */ | ||
32 | struct list_head list; | ||
33 | |||
34 | /* You can't use a snapshot if this is 0 (e.g. if full) */ | ||
35 | int valid; | ||
36 | |||
37 | /* Origin writes don't trigger exceptions until this is set */ | ||
38 | int active; | ||
39 | |||
40 | /* Used for display of table */ | ||
41 | char type; | ||
42 | |||
43 | mempool_t *pending_pool; | ||
44 | |||
45 | atomic_t pending_exceptions_count; | ||
46 | |||
47 | struct exception_table pending; | ||
48 | struct exception_table complete; | ||
49 | |||
50 | /* | ||
51 | * pe_lock protects all pending_exception operations and access | ||
52 | * as well as the snapshot_bios list. | ||
53 | */ | ||
54 | spinlock_t pe_lock; | ||
55 | |||
56 | /* The on disk metadata handler */ | ||
57 | struct dm_exception_store *store; | ||
58 | |||
59 | struct dm_kcopyd_client *kcopyd_client; | ||
60 | |||
61 | /* Queue of snapshot writes for ksnapd to flush */ | ||
62 | struct bio_list queued_bios; | ||
63 | struct work_struct queued_bios_work; | ||
64 | |||
65 | /* Chunks with outstanding reads */ | ||
66 | mempool_t *tracked_chunk_pool; | ||
67 | spinlock_t tracked_chunk_lock; | ||
68 | struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE]; | ||
69 | }; | ||
70 | |||
71 | static inline sector_t chunk_to_sector(struct dm_exception_store *store, | ||
72 | chunk_t chunk) | ||
73 | { | ||
74 | return chunk << store->chunk_shift; | ||
75 | } | ||
76 | |||
77 | static inline int bdev_equal(struct block_device *lhs, struct block_device *rhs) | ||
78 | { | ||
79 | /* | ||
80 | * There is only ever one instance of a particular block | ||
81 | * device so we can compare pointers safely. | ||
82 | */ | ||
83 | return lhs == rhs; | ||
84 | } | ||
85 | |||
86 | #endif | ||