Tookmund / Swapspace

A fork of Jeroen T. Vermeulen's excellent dynamic swap space manager
GNU General Public License v2.0
128 stars 12 forks source link

activating old swap issue #34

Closed axet closed 2 years ago

axet commented 2 years ago

Hello!

Seems like here is a bug related to activating old swapspace file. If swap file already enabled (service restarted) then I got a error message:

Error: Could not enable swapfile '1': Device or resource busy

Checking source code in 'activate_old_swaps' method, looks like swapspace trying to activate already enabled swapfile because it does not check 'observed_in_wild':

if (valid_swapfile(d->d_name, &seqno) && !swapfiles[seqno].size)

Please double check, but it seems swapspace missing the following:

@@ -590,7 +604,7 @@ bool activate_old_swaps(void)
   for (struct dirent *d = readdir(dir); d; d = readdir(dir))
   {
     int seqno;
-    if (valid_swapfile(d->d_name, &seqno) && !swapfiles[seqno].size)
+    if (valid_swapfile(d->d_name, &seqno) && !swapfiles[seqno].size && !swapfiles[seqno].observed_in_wild)
     {
 #ifndef NO_CONFIG
       if (!quiet) logm(LOG_INFO, "Found old swapfile '%d'", seqno);
axet commented 2 years ago

if you './configure --prefix=/' swapspace failed to find swap files due to additional '/' in the swapath.