Moves the lock file where the first content file resides.

This commit is contained in:
Andrea Mazzoleni 2014-02-22 08:46:11 +01:00
parent 5c27e62cd2
commit 4b93f3e5ab
3 changed files with 14 additions and 6 deletions

View file

@ -23,6 +23,8 @@ SnapRAID HISTORY
to select append mode, and to insert the date and time in the name.
* The options -p, --percentage and -o, --older-than now keep their
default value even if the other one is specified.
* Moved the .lock file in the same dir of the first specified content
file. This avoid to spin the parity disks in all commands.
* New source code organization. The RAID engine is now
an external component usable also in other projects.

View file

@ -86,6 +86,9 @@ void memory(void)
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
}
/****************************************************************************/
/* log */
void log_open(const char* log)
{
char path[PATH_MAX];
@ -185,6 +188,9 @@ void log_close(const char* log)
}
}
/****************************************************************************/
/* main */
#define OPT_TEST_SKIP_SELF 256
#define OPT_TEST_KILL_AFTER_SYNC 257
#define OPT_TEST_EXPECT_UNRECOVERABLE 258

12
state.c
View file

@ -516,12 +516,6 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
state->parity_device[l] = st.st_dev;
/* set lock file if first parity */
if (l == 0) {
pathcpy(state->lockfile, sizeof(state->lockfile), state->parity_path[l]);
pathcat(state->lockfile, sizeof(state->lockfile), ".lock");
}
/* adjust the level */
if (state->level < l + 1)
state->level = l + 1;
@ -640,6 +634,12 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
/* LCOV_EXCL_STOP */
}
/* set the lock file at the first content file */
if (tommy_list_empty(&state->contentlist)) {
pathcpy(state->lockfile, sizeof(state->lockfile), buffer);
pathcat(state->lockfile, sizeof(state->lockfile), ".lock");
}
content = content_alloc(buffer, st.st_dev);
tommy_list_insert_tail(&state->contentlist, &content->node, content);