lkml.org 
[lkml]   [2001]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH] swap cleanup, forward compat hooks/LABEL
This patch allocates space in the swap space on-disk struct for a swap label,
which can be used with the LABEL= support for /etc/fstab with the right
user-space tools. This patch uses the same on-disk location for the label
that was used in a previously posted patch that does the same thing.

We also add a duplicate magic field (still holds "SWAPSPACE2") within the
info struct, as well as the PAGE_SIZE at which the swap was created.
Since these are at a fixed offset, it makes detecting the swap space setup
a lot easier, especially on systems (ARM?) which support multiple PAGE_SIZE
settings.

If people agree that "sizeof(int) = 4" then I would also like to change
the use of "int" everywhere to "u32", as it is kind of ugly to store
a (potentially) variable-sized value to the disk.

This does not really affect the kernel, and is totally compatible with
the current swap space setup.

This has been discussed several times previously, with no real objections
except "we should have labels in the partition table", but until something
like the ia64 EFI GUID partition table is in widespread use, swap space will
need to have LABEL support added to them.

I have agreement in principle from Andries to add LABEL support for swap space
to swapon.

Cheers, Andreas
=============================================================================
diff -ru linux.orig/include/linux/swap.h linux/include/linux/swap.h
--- linux.orig/include/linux/swap.h Thu Oct 25 03:05:15 2001
+++ linux/include/linux/swap.h Thu Oct 25 10:02:34 2001
@@ -19,26 +19,48 @@
*
* Having the magic at the end of the PAGE_SIZE makes detecting swap
* areas somewhat tricky on machines that support multiple page sizes.
- * For 2.5 we'll probably want to move the magic to just beyond the
- * bootbits...
+ * So, in addition to the old magic.magic, we add a new info.magic (which
+ * should contain the same string) at a fixed offset to allow easier
+ * detection of swap devices. We also store PAGE_SIZE for this swap space.
+ *
+ * Because we had "unsigned int padding[125]" written to on-disk structs,
+ * there is no guarantee of the size of an unsigned int across platforms.
+ * Hence the union to preserve the alignment of badpages[]. Any new data
+ * structs should be allocated inside info.s.
*/
+
+#define SWAP_MAGIC_OFFSET_OLD (PAGE_SIZE-10)
+#define SWAP_MAGIC_OFFSET_NEW (1024 + 3*sizeof(unsigned int) + 16)
+
union swap_header {
- struct
+ struct
{
- char reserved[PAGE_SIZE - 10];
+ char reserved[SWAP_MAGIC_OFFSET_OLD];
char magic[10]; /* SWAP-SPACE or SWAPSPACE2 */
} magic;
- struct
+ struct
{
char bootbits[1024]; /* Space for disklabel etc. */
unsigned int version;
unsigned int last_page;
unsigned int nr_badpages;
- unsigned int padding[125];
+ union {
+ unsigned int padding[125]; /* Compatibility size */
+ struct {
+ char volume_label[16]; /* LABEL= */
+ char magic[10]; /* SWAPSPACE2 */
+ char unused[6]; /* alignment */
+ unsigned int page_size; /* = PAGE_SIZE */
+ } sw;
+ } u;
unsigned int badpages[1];
} info;
};

+#define sw_volume_label u.sw.volume_label
+#define sw_magic u.sw.magic
+#define sw_page_size u.sw.page_size
+
#ifdef __KERNEL__

/*
@@ -210,9 +233,7 @@
* unfreeable instead of using dirty buffer magic, but the
* next code-change time is when 2.5 is forked...
*/
-#ifndef _LINUX_KDEV_T_H
#include <linux/kdev_t.h>
-#endif
#ifndef _LINUX_MAJOR_H
#include <linux/major.h>
#endif
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:11    [W:0.028 / U:3.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site