summaryrefslogtreecommitdiffstats
path: root/drivers/md/persistent-data
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
committerIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
commit2fe5de9ce7d57498abc14b375cad2fcf8c3ee6cc (patch)
tree9478e8cf470c1d5bdb2d89b57a7e35919ab95e72 /drivers/md/persistent-data
parent08f8aeb55d7727d644dbbbbfb798fe937d47751d (diff)
parent2b4cfe64dee0d84506b951d81bf55d9891744d25 (diff)
Merge branch 'sched/urgent' into sched/core, to avoid conflicts
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/md/persistent-data')
-rw-r--r--drivers/md/persistent-data/dm-bitset.c10
-rw-r--r--drivers/md/persistent-data/dm-bitset.h1
-rw-r--r--drivers/md/persistent-data/dm-block-manager.c15
-rw-r--r--drivers/md/persistent-data/dm-block-manager.h3
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.c5
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.h17
6 files changed, 24 insertions, 27 deletions
diff --git a/drivers/md/persistent-data/dm-bitset.c b/drivers/md/persistent-data/dm-bitset.c
index cd9a86d4cdf0..36f7cc2c7109 100644
--- a/drivers/md/persistent-data/dm-bitset.c
+++ b/drivers/md/persistent-data/dm-bitset.c
@@ -65,7 +65,7 @@ int dm_bitset_flush(struct dm_disk_bitset *info, dm_block_t root,
65 int r; 65 int r;
66 __le64 value; 66 __le64 value;
67 67
68 if (!info->current_index_set) 68 if (!info->current_index_set || !info->dirty)
69 return 0; 69 return 0;
70 70
71 value = cpu_to_le64(info->current_bits); 71 value = cpu_to_le64(info->current_bits);
@@ -77,6 +77,8 @@ int dm_bitset_flush(struct dm_disk_bitset *info, dm_block_t root,
77 return r; 77 return r;
78 78
79 info->current_index_set = false; 79 info->current_index_set = false;
80 info->dirty = false;
81
80 return 0; 82 return 0;
81} 83}
82EXPORT_SYMBOL_GPL(dm_bitset_flush); 84EXPORT_SYMBOL_GPL(dm_bitset_flush);
@@ -94,6 +96,8 @@ static int read_bits(struct dm_disk_bitset *info, dm_block_t root,
94 info->current_bits = le64_to_cpu(value); 96 info->current_bits = le64_to_cpu(value);
95 info->current_index_set = true; 97 info->current_index_set = true;
96 info->current_index = array_index; 98 info->current_index = array_index;
99 info->dirty = false;
100
97 return 0; 101 return 0;
98} 102}
99 103
@@ -126,6 +130,8 @@ int dm_bitset_set_bit(struct dm_disk_bitset *info, dm_block_t root,
126 return r; 130 return r;
127 131
128 set_bit(b, (unsigned long *) &info->current_bits); 132 set_bit(b, (unsigned long *) &info->current_bits);
133 info->dirty = true;
134
129 return 0; 135 return 0;
130} 136}
131EXPORT_SYMBOL_GPL(dm_bitset_set_bit); 137EXPORT_SYMBOL_GPL(dm_bitset_set_bit);
@@ -141,6 +147,8 @@ int dm_bitset_clear_bit(struct dm_disk_bitset *info, dm_block_t root,
141 return r; 147 return r;
142 148
143 clear_bit(b, (unsigned long *) &info->current_bits); 149 clear_bit(b, (unsigned long *) &info->current_bits);
150 info->dirty = true;
151
144 return 0; 152 return 0;
145} 153}
146EXPORT_SYMBOL_GPL(dm_bitset_clear_bit); 154EXPORT_SYMBOL_GPL(dm_bitset_clear_bit);
diff --git a/drivers/md/persistent-data/dm-bitset.h b/drivers/md/persistent-data/dm-bitset.h
index e1b9bea14aa1..c2287d672ef5 100644
--- a/drivers/md/persistent-data/dm-bitset.h
+++ b/drivers/md/persistent-data/dm-bitset.h
@@ -71,6 +71,7 @@ struct dm_disk_bitset {
71 uint64_t current_bits; 71 uint64_t current_bits;
72 72
73 bool current_index_set:1; 73 bool current_index_set:1;
74 bool dirty:1;
74}; 75};
75 76
76/* 77/*
diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c
index 455f79279a16..087411c95ffc 100644
--- a/drivers/md/persistent-data/dm-block-manager.c
+++ b/drivers/md/persistent-data/dm-block-manager.c
@@ -595,25 +595,14 @@ int dm_bm_unlock(struct dm_block *b)
595} 595}
596EXPORT_SYMBOL_GPL(dm_bm_unlock); 596EXPORT_SYMBOL_GPL(dm_bm_unlock);
597 597
598int dm_bm_flush_and_unlock(struct dm_block_manager *bm, 598int dm_bm_flush(struct dm_block_manager *bm)
599 struct dm_block *superblock)
600{ 599{
601 int r;
602
603 if (bm->read_only) 600 if (bm->read_only)
604 return -EPERM; 601 return -EPERM;
605 602
606 r = dm_bufio_write_dirty_buffers(bm->bufio);
607 if (unlikely(r)) {
608 dm_bm_unlock(superblock);
609 return r;
610 }
611
612 dm_bm_unlock(superblock);
613
614 return dm_bufio_write_dirty_buffers(bm->bufio); 603 return dm_bufio_write_dirty_buffers(bm->bufio);
615} 604}
616EXPORT_SYMBOL_GPL(dm_bm_flush_and_unlock); 605EXPORT_SYMBOL_GPL(dm_bm_flush);
617 606
618void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b) 607void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b)
619{ 608{
diff --git a/drivers/md/persistent-data/dm-block-manager.h b/drivers/md/persistent-data/dm-block-manager.h
index 13cd58e1fe69..1b95dfc17786 100644
--- a/drivers/md/persistent-data/dm-block-manager.h
+++ b/drivers/md/persistent-data/dm-block-manager.h
@@ -105,8 +105,7 @@ int dm_bm_unlock(struct dm_block *b);
105 * 105 *
106 * This method always blocks. 106 * This method always blocks.
107 */ 107 */
108int dm_bm_flush_and_unlock(struct dm_block_manager *bm, 108int dm_bm_flush(struct dm_block_manager *bm);
109 struct dm_block *superblock);
110 109
111/* 110/*
112 * Request data is prefetched into the cache. 111 * Request data is prefetched into the cache.
diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
index 81da1a26042e..3bc30a0ae3d6 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.c
+++ b/drivers/md/persistent-data/dm-transaction-manager.c
@@ -154,7 +154,7 @@ int dm_tm_pre_commit(struct dm_transaction_manager *tm)
154 if (r < 0) 154 if (r < 0)
155 return r; 155 return r;
156 156
157 return 0; 157 return dm_bm_flush(tm->bm);
158} 158}
159EXPORT_SYMBOL_GPL(dm_tm_pre_commit); 159EXPORT_SYMBOL_GPL(dm_tm_pre_commit);
160 160
@@ -164,8 +164,9 @@ int dm_tm_commit(struct dm_transaction_manager *tm, struct dm_block *root)
164 return -EWOULDBLOCK; 164 return -EWOULDBLOCK;
165 165
166 wipe_shadow_table(tm); 166 wipe_shadow_table(tm);
167 dm_bm_unlock(root);
167 168
168 return dm_bm_flush_and_unlock(tm->bm, root); 169 return dm_bm_flush(tm->bm);
169} 170}
170EXPORT_SYMBOL_GPL(dm_tm_commit); 171EXPORT_SYMBOL_GPL(dm_tm_commit);
171 172
diff --git a/drivers/md/persistent-data/dm-transaction-manager.h b/drivers/md/persistent-data/dm-transaction-manager.h
index b5b139076ca5..2772ed2a781a 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.h
+++ b/drivers/md/persistent-data/dm-transaction-manager.h
@@ -38,18 +38,17 @@ struct dm_transaction_manager *dm_tm_create_non_blocking_clone(struct dm_transac
38/* 38/*
39 * We use a 2-phase commit here. 39 * We use a 2-phase commit here.
40 * 40 *
41 * i) In the first phase the block manager is told to start flushing, and 41 * i) Make all changes for the transaction *except* for the superblock.
42 * the changes to the space map are written to disk. You should interrogate 42 * Then call dm_tm_pre_commit() to flush them to disk.
43 * your particular space map to get detail of its root node etc. to be
44 * included in your superblock.
45 * 43 *
46 * ii) @root will be committed last. You shouldn't use more than the 44 * ii) Lock your superblock. Update. Then call dm_tm_commit() which will
47 * first 512 bytes of @root if you wish the transaction to survive a power 45 * unlock the superblock and flush it. No other blocks should be updated
48 * failure. You *must* have a write lock held on @root for both stage (i) 46 * during this period. Care should be taken to never unlock a partially
49 * and (ii). The commit will drop the write lock. 47 * updated superblock; perform any operations that could fail *before* you
48 * take the superblock lock.
50 */ 49 */
51int dm_tm_pre_commit(struct dm_transaction_manager *tm); 50int dm_tm_pre_commit(struct dm_transaction_manager *tm);
52int dm_tm_commit(struct dm_transaction_manager *tm, struct dm_block *root); 51int dm_tm_commit(struct dm_transaction_manager *tm, struct dm_block *superblock);
53 52
54/* 53/*
55 * These methods are the only way to get hold of a writeable block. 54 * These methods are the only way to get hold of a writeable block.