Add infrastructure for splitting commands in multiple phases.
Usually, phase0 will check for some preconditions, while
phase1 will execute the command. The final result will only
be committed if nothing fails.
The difference to the old behaviour will only show up when combined
with 'all' resources. If anything fails in phase0, nothing will be
touched in phase1. The old behaviour could touch some resources,
but omit others when something failed.
The new behaviour is more transactional-like.
Writethrough of bio requests having more than one biovec should
only sync the last one. The others will be written to the transaction
log anyway. No need to wait for each of them to be committed one
by one.
Previously, the 'marsadm primary' and 'marsadm secondary' commands
were successful as soon as the target primary was successfully set
to the new primary or '(none)', respectively. This commit appends
a check to wait until the primary is really changed (actual state).
Changes in marsadm:
- Added check_primary_settled() function
- Do not use local variable named '$host' in _primary_res() since
a global variable with same name exists.
- Do not use/set global variable '$host' in primary_res(). Use
local variable '$new' initially set to '$host' instead.
- Make 'secondary' command idempotent ("is already secondary")
- Call trigger() and check_primary_settled() in primary_res()
Related minor changes:
- marsadm: Added optional parameter 'sleeptime' to sleep_timeout()
- Removed debug output in check_file_aged()
Signed-off-by: Thomas Schoebel-Theuer <tst@1und1.de>
It appears that concurrent reads and writes on AIO seem to
result in inconsistent reads in some very rare cases, due to
races. Sometimes, the inode claims that the file has been already
appended by a write operation, but the data has not actually hit
the page cache, such that a concurrent read gets NULL blocks.
This is a workaround by "misusing" the mapfree infrastructure.
It depends on uniqueness of file names, which is not the right thing
to do.
Best fix would be in the kernel.