Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resuming a cleared map #9

Closed
htherrien opened this issue Sep 16, 2019 · 3 comments
Closed

Resuming a cleared map #9

htherrien opened this issue Sep 16, 2019 · 3 comments

Comments

@htherrien
Copy link

htherrien commented Sep 16, 2019

Resuming a cleared and synced map does not seem to produce the expected behavior.
I use the pattern (clear the map, then sync it) to perform a quick format of the flash device.
After playing with the simulator, it looks like there is no reset of the journal size cookie after a call to dhara_map_clear followed by dhara_map_sync. This implies that if there is a power failure after the call to dhara_map_sync, a dhara_map_resume will produce a map having the wrong number of allocated sectors. I found 3 solutions to this problem:

  1. Perform a full format of the device by erasing all blocks. This option is costly.
  2. Do a dummy write to any sector between map clear and sync. The resumed map will have 1 sector allocated.
  3. Set the journal size cookie when calling dhara_map_clear

The third option is my preferred solution:

 void dhara_map_clear(struct dhara_map *m)
 {
 	if (m->count) {
 		m->count = 0;
+		ck_set_count(dhara_journal_cookie(&m->journal), m->count);
 		dhara_journal_clear(&m->journal);
 	}
 }
@dlbeer
Copy link
Owner

dlbeer commented Sep 17, 2019 via email

@htherrien
Copy link
Author

Is the problem also fixed if you move the
ck_set_count() call in pad_queue() up so it's the first thing that runs?

This also fixes the bug, but I am unaware if it will break other map operations.
If you move the ck_set_count() up in pad_queue(), should you also move it up in raw_gc()?

@dlbeer
Copy link
Owner

dlbeer commented Sep 18, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants