On Monday 03 October 2005 21:50, Nix wrote: > On Mon, 3 Oct 2005, [EMAIL PROTECTED] yowled: > > On Sunday 02 October 2005 22:52, Nix wrote: > >> Size mismatch (140789027962880 vs 209715200) of COW header vs backing > >> file Failed to open '/mirror/uml/esperi-root-cow.image', errno = 22 > >> VFS: Cannot open root device "98:0" or unknown-block(98,0) > >> Please append a correct "root=" boot option > >> Kernel panic - not syncing: VFS: Unable to mount root fs on > >> unknown-block(98,0)
> >> With 2.6.12.5-bs11, it mounts fine. > > Have you checked now? I was wondering if you increased the backing file > > size... but the mismatch is excessive, so ignore this. > Not by that much. I *wish* I had that much disk space ;) > (1.4 exabytes, is that?) > >> This looks more like some sort of byte-ordering problem. > > I hope... > Well, 140789027962880 divides evenly into 2^32. Byte-ordering or a > one-long misalignment of some kind or I'll eat my hat. (I haven't got a > hat so I'll have to get one first and then eat it.) Ok, no need to buy any hat. I would have liked very much to see you doing that, but it will be for next time ;-). Compliments. In fact, between 2.6.13-rc3 and -rc4, a "global style fixup" (which was deemed trivial, and which didn't even reach neither me nor Jeff) affected arch/um/drivers/cow.h. It's the only related change, and it's the culprit one. commit 44456d37b59d8e541936ed26d8b6e08d27e88ac1 [PATCH] turn many #if $undefined_string into #ifdef $undefined_string turn many #if $undefined_string into #ifdef $undefined_string to fix some warnings after -Wno-def was added to global CFLAGS Signed-off-by: Olaf Hering <[EMAIL PROTECTED]> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]> Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]> diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h @@ -3,10 +3,10 @@ #include <asm/types.h> -#if __BYTE_ORDER == __BIG_ENDIAN +#if defined(__BIG_ENDIAN) # define ntohll(x) (x) # define htonll(x) (x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN +#elif defined(__LITTLE_ENDIAN) # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) #else But __BIG_ENDIAN is always defined by /usr/include/endian.h (which is included somehow by callers, for instance via string.h), so we have breakage. grep [nh]to[hn]ll arch/um/drivers/{cow*,ubd*} shows all the culprit calls. And they affect exactly size. Patches are attached - to apply in this order. Actually the first should fix everything, but I'm gonna merge all three ones in -bs4, so you can test all them together (I actually compared the preprocessed source). uml-revert-endianness-breakage uml-cleanup-byteorder-cow uml-cow-byteorder-spacing -- Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade
uml: cleanup byte order macros for COW driver From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> After restoring the existing code, make it work also when included in kernelspace code (which isn't currently the case, but at least this will prevent people from "fixing" it as just happened). Whitespace is fixed in next patch - it cluttered the diff too much. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Index: linux-2.6.13/arch/um/drivers/cow.h =================================================================== --- linux-2.6.13.orig/arch/um/drivers/cow.h +++ linux-2.6.13/arch/um/drivers/cow.h @@ -3,6 +3,26 @@ #include <asm/types.h> +#if defined(__KERNEL__) + +# include <asm/byteorder.h> + +# if defined(__BIG_ENDIAN) +# define ntohll(x) (x) +# define htonll(x) (x) +# elif defined(__LITTLE_ENDIAN) +# define ntohll(x) be64_to_cpu(x) +# define htonll(x) cpu_to_be64(x) +# else +# error "Could not determine byte order" +# endif + +#else +/* For the definition of ntohl, htonl and __BYTE_ORDER */ +#include <endian.h> +#include <netinet/in.h> +#if defined(__BYTE_ORDER) + #if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) @@ -10,8 +30,13 @@ # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) #else -#error "__BYTE_ORDER not defined" +# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" +#endif + +#else /* ! defined(__BYTE_ORDER) */ +# error "Could not determine byte order: __BYTE_ORDER not defined" #endif +#endif /* ! defined(__KERNEL__) */ extern int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize, int alignment, int *bitmap_offset_out, Index: linux-2.6.13/arch/um/drivers/cow_user.c =================================================================== --- linux-2.6.13.orig/arch/um/drivers/cow_user.c +++ linux-2.6.13/arch/um/drivers/cow_user.c @@ -9,7 +9,6 @@ #include <sys/time.h> #include <sys/param.h> #include <sys/user.h> -#include <netinet/in.h> #include "os.h"
uml: cleanup whitespace for COW driver From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Fix whitespace - I split this off the previous patch for easier review. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Index: linux-2.6.13/arch/um/drivers/cow.h =================================================================== --- linux-2.6.13.orig/arch/um/drivers/cow.h +++ linux-2.6.13/arch/um/drivers/cow.h @@ -23,15 +23,15 @@ #include <netinet/in.h> #if defined(__BYTE_ORDER) -#if __BYTE_ORDER == __BIG_ENDIAN -# define ntohll(x) (x) -# define htonll(x) (x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -# define ntohll(x) bswap_64(x) -# define htonll(x) bswap_64(x) -#else -# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" -#endif +# if __BYTE_ORDER == __BIG_ENDIAN +# define ntohll(x) (x) +# define htonll(x) (x) +# elif __BYTE_ORDER == __LITTLE_ENDIAN +# define ntohll(x) bswap_64(x) +# define htonll(x) bswap_64(x) +# else +# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" +# endif #else /* ! defined(__BYTE_ORDER) */ # error "Could not determine byte order: __BYTE_ORDER not defined"
uml: restore include breakage, breaking binary format of COW driver From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Commit 44456d37b59d8e541936ed26d8b6e08d27e88ac1, between 2.6.13-rc3 and -rc4, was a "nice cleanup" which broke something. Revert the offending part. It broke because: a) because this part doesn't fall under the description b) the author didn't know what he was doing here c) the author didn't try to compile the existing code and see that it worked perfectly. d) the author didn't ask us what was happening e) you didn't either, and somebody there should have learned that UML is a bit different. In fact, UML is special in linking to host libc and using its includes. In particular, since host includes always define both __BIG_ENDIAN and __LITTLE_ENDIAN, ntohll() macros started thinking to be in a big-endian world; and on-disk compatibility was broken. Many thanks go to Nix for reporting the problem and correctly diagnosing an endianness problem. Btw, this patch restores the previous code, which worked; but the definitions would be uncorrect if used in kernelspace files. Next patch addresses that. Cc: Nix <[EMAIL PROTECTED]>, Olaf Hering <[EMAIL PROTECTED]> Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Index: linux-2.6.13/arch/um/drivers/cow.h =================================================================== --- linux-2.6.13.orig/arch/um/drivers/cow.h +++ linux-2.6.13/arch/um/drivers/cow.h @@ -3,10 +3,10 @@ #include <asm/types.h> -#if defined(__BIG_ENDIAN) +#if __BYTE_ORDER == __BIG_ENDIAN # define ntohll(x) (x) # define htonll(x) (x) -#elif defined(__LITTLE_ENDIAN) +#elif __BYTE_ORDER == __LITTLE_ENDIAN # define ntohll(x) bswap_64(x) # define htonll(x) bswap_64(x) #else