From: David Teigland <teigland@redhat.com> Date: Thu, 5 Jun 2008 14:10:10 -0500 Subject: [dlm] align midcomms message buffer Message-id: 20080605191009.GB18635@redhat.com O-Subject: [RHEL5.3 PATCH 02/18] dlm: align midcomms message buffer Bugzilla: 450130 RH-Acked-by: Bob Peterson <rpeterso@redhat.com> bz 450130 dlm: fixes for mixed endian cluster Make the dlm work among cluster nodes with different endianness. brew build including this patch http://brewweb.devel.redhat.com/brew/taskinfo?taskID=1344633 upstream commit: >From e7847d35ac39fe92c94540e88ac3d0e177f52d9e Mon Sep 17 00:00:00 2001 >From: Fabio M. Di Nitto <fabbione@ubuntu.com> >Date: Wed, 30 Jan 2008 10:56:42 -0600 >Subject: [PATCH] dlm: align midcomms message buffer gcc does not guarantee that an auto buffer is 64bit aligned. This change allows sparc64 to work. Signed-off-by: Fabio M. Di Nitto <fabbione@ubuntu.com> Signed-off-by: David Teigland <teigland@redhat.com> diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index f8c69dd..e69926e 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -2,7 +2,7 @@ ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. ** ** This copyrighted material is made available to anyone wishing to use, ** modify, copy, or redistribute it subject to the terms and conditions @@ -58,8 +58,12 @@ static void copy_from_cb(void *dst, const void *base, unsigned offset, int dlm_process_incoming_buffer(int nodeid, const void *base, unsigned offset, unsigned len, unsigned limit) { - unsigned char __tmp[DLM_INBUF_LEN]; - struct dlm_header *msg = (struct dlm_header *) __tmp; + union { + unsigned char __buf[DLM_INBUF_LEN]; + /* this is to force proper alignment on some arches */ + struct dlm_header dlm; + } __tmp; + struct dlm_header *msg = &__tmp.dlm; int ret = 0; int err = 0; uint16_t msglen; @@ -100,8 +104,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base, in the buffer on the stack (which should work for most ordinary messages). */ - if (msglen > sizeof(__tmp) && - msg == (struct dlm_header *) __tmp) { + if (msglen > DLM_INBUF_LEN && msg == &__tmp.dlm) { msg = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); if (msg == NULL) return ret; @@ -119,7 +122,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base, dlm_receive_buffer(msg, nodeid); } - if (msg != (struct dlm_header *) __tmp) + if (msg != &__tmp.dlm) kfree(msg); return err ? err : ret;