All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] cld: pad protocol structures
@ 2009-08-26  0:37 Pete Zaitcev
  2009-08-26  6:25 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-08-26  0:37 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

As it turned out, sizeof produces different results on 64-bit and
32-bit hosts because the size of the structure may aligned on whatever
biggest alignment the gcc decides appropriate. It's not necesserily
the biggest type, as on RISCs and Itanium, where accessing arrays
of structs with misaligned sizeof will cause SIGBUS. As a result,
our structs varied in size despite using fixed-size types.

Our preferred fix is to pad structures so that they become more
portable.

This patch creates a flag day on 32-bit systems (but not on 64-bit
ones). CLD clients and the daemon must be rebuilt.

Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>

diff --git a/include/cld_msg.h b/include/cld_msg.h
index 89ab066..e4c8f28 100644
--- a/include/cld_msg.h
+++ b/include/cld_msg.h
@@ -167,6 +167,7 @@ struct cld_msg_open {
 	uint32_t		mode;		/**< open mode, COM_xxx */
 	uint32_t		events;		/**< events mask, CE_xxx */
 	uint16_t		name_len;	/**< length of file name */
+	uint8_t			res[6];
 	/* inode name */
 };
 
@@ -195,7 +196,7 @@ struct cld_msg_get_resp {
 	uint64_t		time_create;	/**< creation time */
 	uint64_t		time_modify;	/**< last modification time */
 	uint32_t		flags;		/**< inode flags; CIFL_xxx */
-
+	uint8_t			res[4];
 	/* inode name */
 };
 
@@ -205,6 +206,7 @@ struct cld_msg_put {
 
 	uint64_t		fh;		/**< open file handle */
 	uint32_t		data_size;	/**< total size of data */
+	uint8_t			res[4];
 };
 
 /** CLOSE message */
@@ -219,6 +221,7 @@ struct cld_msg_del {
 	struct cld_msg_hdr	hdr;
 
 	uint16_t		name_len;	/**< length of file name */
+	uint8_t			res[6];
 	/* inode name */
 };
 
@@ -235,6 +238,7 @@ struct cld_msg_lock {
 
 	uint64_t		fh;		/**< open file handle */
 	uint32_t		flags;		/**< CLF_xxx */
+	uint8_t			res[4];
 };
 
 /** Server-to-client EVENT message */
@@ -243,6 +247,7 @@ struct cld_msg_event {
 
 	uint64_t		fh;		/**< open file handle */
 	uint32_t		events;		/**< CE_xxx */
+	uint8_t			res[4];
 };
 
 /*

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] cld: pad protocol structures
  2009-08-26  0:37 [Patch] cld: pad protocol structures Pete Zaitcev
@ 2009-08-26  6:25 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-08-26  6:25 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Project Hail List

On 08/25/2009 08:37 PM, Pete Zaitcev wrote:
> As it turned out, sizeof produces different results on 64-bit and
> 32-bit hosts because the size of the structure may aligned on whatever
> biggest alignment the gcc decides appropriate. It's not necesserily
> the biggest type, as on RISCs and Itanium, where accessing arrays
> of structs with misaligned sizeof will cause SIGBUS. As a result,
> our structs varied in size despite using fixed-size types.
>
> Our preferred fix is to pad structures so that they become more
> portable.
>
> This patch creates a flag day on 32-bit systems (but not on 64-bit
> ones). CLD clients and the daemon must be rebuilt.
>
> Signed-Off-By: Pete Zaitcev<zaitcev@redhat.com>

applied



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-26  6:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26  0:37 [Patch] cld: pad protocol structures Pete Zaitcev
2009-08-26  6:25 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.