diff --git a/HISTORY b/HISTORY index 7ece9282..ffadab20 100644 --- a/HISTORY +++ b/HISTORY @@ -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. diff --git a/snapraid.c b/snapraid.c index 65ba1a62..d04aa3c7 100644 --- a/snapraid.c +++ b/snapraid.c @@ -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 diff --git a/state.c b/state.c index 44f73b2e..99d2a493 100644 --- a/state.c +++ b/state.c @@ -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);