aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/persistent-data
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2012-07-27 10:08:09 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 10:08:09 -0400
commit384ef0e62e409e52c80adef5b1ff83075377c19e (patch)
tree734db218c323e88a303f64218661286f94f9e52a /drivers/md/persistent-data
parenteb04cf634fc2d5e3bc8fe88fbf434eda4921d875 (diff)
dm persistent data: tidy transaction manager creation fns
Tidy the transaction manager creation functions. They no longer lock the superblock. Superblock locking is pulled out to the caller. Also export dm_bm_write_lock_zero. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/persistent-data')
-rw-r--r--drivers/md/persistent-data/dm-block-manager.c1
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.c47
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.h11
3 files changed, 19 insertions, 40 deletions
diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c
index c70ad6e303d3..4b5c504f47af 100644
--- a/drivers/md/persistent-data/dm-block-manager.c
+++ b/drivers/md/persistent-data/dm-block-manager.c
@@ -565,6 +565,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,
565 565
566 return 0; 566 return 0;
567} 567}
568EXPORT_SYMBOL_GPL(dm_bm_write_lock_zero);
568 569
569int dm_bm_unlock(struct dm_block *b) 570int dm_bm_unlock(struct dm_block *b)
570{ 571{
diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
index 86c3705052a4..b4f05830af07 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.c
+++ b/drivers/md/persistent-data/dm-transaction-manager.c
@@ -310,12 +310,10 @@ struct dm_block_manager *dm_tm_get_bm(struct dm_transaction_manager *tm)
310 310
311static int dm_tm_create_internal(struct dm_block_manager *bm, 311static int dm_tm_create_internal(struct dm_block_manager *bm,
312 dm_block_t sb_location, 312 dm_block_t sb_location,
313 struct dm_block_validator *sb_validator,
314 size_t root_offset, size_t root_max_len,
315 struct dm_transaction_manager **tm, 313 struct dm_transaction_manager **tm,
316 struct dm_space_map **sm, 314 struct dm_space_map **sm,
317 struct dm_block **sblock, 315 int create,
318 int create) 316 void *sm_root, size_t sm_len)
319{ 317{
320 int r; 318 int r;
321 319
@@ -330,64 +328,43 @@ static int dm_tm_create_internal(struct dm_block_manager *bm,
330 } 328 }
331 329
332 if (create) { 330 if (create) {
333 r = dm_bm_write_lock_zero(dm_tm_get_bm(*tm), sb_location,
334 sb_validator, sblock);
335 if (r < 0) {
336 DMERR("couldn't lock superblock");
337 goto bad1;
338 }
339
340 r = dm_sm_metadata_create(*sm, *tm, dm_bm_nr_blocks(bm), 331 r = dm_sm_metadata_create(*sm, *tm, dm_bm_nr_blocks(bm),
341 sb_location); 332 sb_location);
342 if (r) { 333 if (r) {
343 DMERR("couldn't create metadata space map"); 334 DMERR("couldn't create metadata space map");
344 goto bad2; 335 goto bad;
345 } 336 }
346 337
347 } else { 338 } else {
348 r = dm_bm_write_lock(dm_tm_get_bm(*tm), sb_location, 339 r = dm_sm_metadata_open(*sm, *tm, sm_root, sm_len);
349 sb_validator, sblock);
350 if (r < 0) {
351 DMERR("couldn't lock superblock");
352 goto bad1;
353 }
354
355 r = dm_sm_metadata_open(*sm, *tm,
356 dm_block_data(*sblock) + root_offset,
357 root_max_len);
358 if (r) { 340 if (r) {
359 DMERR("couldn't open metadata space map"); 341 DMERR("couldn't open metadata space map");
360 goto bad2; 342 goto bad;
361 } 343 }
362 } 344 }
363 345
364 return 0; 346 return 0;
365 347
366bad2: 348bad:
367 dm_tm_unlock(*tm, *sblock);
368bad1:
369 dm_tm_destroy(*tm); 349 dm_tm_destroy(*tm);
350 dm_sm_destroy(*sm);
370 return r; 351 return r;
371} 352}
372 353
373int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 354int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
374 struct dm_block_validator *sb_validator,
375 struct dm_transaction_manager **tm, 355 struct dm_transaction_manager **tm,
376 struct dm_space_map **sm, struct dm_block **sblock) 356 struct dm_space_map **sm)
377{ 357{
378 return dm_tm_create_internal(bm, sb_location, sb_validator, 358 return dm_tm_create_internal(bm, sb_location, tm, sm, 1, NULL, 0);
379 0, 0, tm, sm, sblock, 1);
380} 359}
381EXPORT_SYMBOL_GPL(dm_tm_create_with_sm); 360EXPORT_SYMBOL_GPL(dm_tm_create_with_sm);
382 361
383int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 362int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
384 struct dm_block_validator *sb_validator, 363 void *sm_root, size_t root_len,
385 size_t root_offset, size_t root_max_len,
386 struct dm_transaction_manager **tm, 364 struct dm_transaction_manager **tm,
387 struct dm_space_map **sm, struct dm_block **sblock) 365 struct dm_space_map **sm)
388{ 366{
389 return dm_tm_create_internal(bm, sb_location, sb_validator, root_offset, 367 return dm_tm_create_internal(bm, sb_location, tm, sm, 0, sm_root, root_len);
390 root_max_len, tm, sm, sblock, 0);
391} 368}
392EXPORT_SYMBOL_GPL(dm_tm_open_with_sm); 369EXPORT_SYMBOL_GPL(dm_tm_open_with_sm);
393 370
diff --git a/drivers/md/persistent-data/dm-transaction-manager.h b/drivers/md/persistent-data/dm-transaction-manager.h
index 6da784871db4..b5b139076ca5 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.h
+++ b/drivers/md/persistent-data/dm-transaction-manager.h
@@ -115,16 +115,17 @@ struct dm_block_manager *dm_tm_get_bm(struct dm_transaction_manager *tm);
115 * 115 *
116 * Returns a tm that has an open transaction to write the new disk sm. 116 * Returns a tm that has an open transaction to write the new disk sm.
117 * Caller should store the new sm root and commit. 117 * Caller should store the new sm root and commit.
118 *
119 * The superblock location is passed so the metadata space map knows it
120 * shouldn't be used.
118 */ 121 */
119int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 122int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
120 struct dm_block_validator *sb_validator,
121 struct dm_transaction_manager **tm, 123 struct dm_transaction_manager **tm,
122 struct dm_space_map **sm, struct dm_block **sblock); 124 struct dm_space_map **sm);
123 125
124int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 126int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
125 struct dm_block_validator *sb_validator, 127 void *sm_root, size_t root_len,
126 size_t root_offset, size_t root_max_len,
127 struct dm_transaction_manager **tm, 128 struct dm_transaction_manager **tm,
128 struct dm_space_map **sm, struct dm_block **sblock); 129 struct dm_space_map **sm);
129 130
130#endif /* _LINUX_DM_TRANSACTION_MANAGER_H */ 131#endif /* _LINUX_DM_TRANSACTION_MANAGER_H */