[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
linux-swap code
From: |
Richard Hirst |
Subject: |
linux-swap code |
Date: |
Mon, 25 Mar 2002 16:01:54 +0000 |
User-agent: |
Mutt/1.3.24i |
Under parted 1.4, at least, "mkfs N linux-swap" takes over 3 minutes for a 2G
partition on my ia64 box. The reason is that the code reads the whole
partition, in 2MB chunks, looking for bad sectors. It appears that linux-swap
is the only fs code that considers it necessary to search for bad sectors. If
parted really does want to check for bad sectors, can I suggest that the
functionality be moved in to the "check" command?
Also swap_open() throws an exception with a 10 byte random string if it
doesn't find a swapspace signature.
Finally, swap_check() always returns success.
I think the following is a suitable fix for these:
--- parted-1.4.24.ori/libparted/fs_linux_swap/linux_swap.c Tue Sep 18
22:02:39 2001
+++ parted-1.4.24.quickswap/libparted/fs_linux_swap/linux_swap.c Mon Mar
25 15:41:06 2002
@@ -234,12 +234,8 @@
} else if (strncmp (fs_info->sig, "SWAPSPACE2", 10) == 0) {
fs_info->version = 1;
} else {
- char sig [11];
-
- memcpy (sig, fs_info->sig, 10);
- sig [10] = 0;
ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("Unrecognised linux swap signature '%10s'."), sig);
+ _("Unrecognised linux swap signature"));
goto error_free_fs;
}
@@ -383,6 +379,7 @@
if (!ped_geometry_read (fs->geom, fs_info->header, 0, 2))
return 0;
if (!rewrite) {
+ /* Creating a new swapspace */
/* not many people use 2.0 nowadays. If they are, then there's no harm done...
* they'll just get a bit confused when they can't swap on...
*/
@@ -405,8 +402,11 @@
- sizeof (SwapNewHeader)) / 4;
memcpy (fs_info->sig, "SWAPSPACE2", 10);
}
- if (!swap_check_pages (fs))
- return 0;
+ else {
+ /* Checking an existing swapspace */
+ if (!swap_check_pages (fs))
+ return 0;
+ }
return ped_geometry_write (fs->geom, fs_info->header, 0,
fs_info->page_sectors);
}
@@ -472,8 +472,7 @@
static int
swap_check (PedFileSystem* fs)
{
- swap_write (fs, 1, fs->geom);
- return 1;
+ return swap_write (fs, 1, fs->geom);
}
static PedConstraint*
- linux-swap code,
Richard Hirst <=