mirror of https://github.com/schoebel/mars
main: fix recovery upon defective logfile without successor
Workaround was possible by manually providing an empty next logfile, forcing an internal rotate operation. However, IMHO this should not be exposed to userspace, but functionally migrated to kernelspace in the long term. Otherwise, possible races between userspace and kernelspace may explode. Control over logfiles content is not enough; even the sheer existence should be the responsibility of kernel code (as much as possible). Future fixes and improvements should go in this direction. Thus I don't add an extra marsadm command for creation of empty logfiles. The current marsadm code in cron (and siblings) should be decommissioned some day, after the kernel is fully responsible, even for create-resource and so on.
This commit is contained in:
parent
c1d74684ba
commit
fd62940ed1
|
@ -1737,6 +1737,15 @@ void _update_info(struct trans_logger_info *inf)
|
||||||
done:;
|
done:;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool _is_trans_input_initialized(struct trans_logger_input *trans_input)
|
||||||
|
{
|
||||||
|
if (!trans_input ||
|
||||||
|
!trans_input->is_operating)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool _is_trans_input_fully_working(struct trans_logger_input *trans_input)
|
bool _is_trans_input_fully_working(struct trans_logger_input *trans_input)
|
||||||
{
|
{
|
||||||
|
@ -4549,7 +4558,19 @@ int make_log_init(struct mars_dent *dent)
|
||||||
if (rot->trans_brick) {
|
if (rot->trans_brick) {
|
||||||
struct trans_logger_input *trans_input = rot->trans_brick->inputs[rot->trans_brick->old_input_nr];
|
struct trans_logger_input *trans_input = rot->trans_brick->inputs[rot->trans_brick->old_input_nr];
|
||||||
|
|
||||||
if (_is_trans_input_fully_working(trans_input)) {
|
/* There may be initialized inputs, but not yet fully working
|
||||||
|
* (e.g. after a defective logfile after a crash), or
|
||||||
|
* not even connected (e.g. due to a non-existing logfile
|
||||||
|
* or an unusable /mars/ filesystemc, etc).
|
||||||
|
* Prefer an initialized input, for further setup steps.
|
||||||
|
* When they cannot be connected for a longer time (for
|
||||||
|
* whatever reason), they should be
|
||||||
|
* decommissioned in their current role.
|
||||||
|
* When nothing helps, the last resort in designated primary
|
||||||
|
* role may be creation of an empty new logfile.
|
||||||
|
* If even this fails, we have no chance :(
|
||||||
|
*/
|
||||||
|
if (_is_trans_input_initialized(trans_input)) {
|
||||||
aio_path = path_make("%s/log-%09d-%s",
|
aio_path = path_make("%s/log-%09d-%s",
|
||||||
parent_path,
|
parent_path,
|
||||||
trans_input->inf.inf_sequence,
|
trans_input->inf.inf_sequence,
|
||||||
|
|
Loading…
Reference in New Issue