From c9b149c5ce0dea5f026cffb4033a4c4d80275150 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 13 Feb 2012 22:35:52 +0000 Subject: [PATCH] Let's stay on the safe side away from gcc bugs and separate ints and bitfields with another access rules git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4127 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 9 +++++++-- scst/src/dev_handlers/scst_user.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 8c6923bbb..2b7588b08 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2276,8 +2276,13 @@ struct scst_device { /**************************************************************/ - /* How many cmds alive on this dev */ - atomic_t dev_cmd_count; + /* + * How many cmds alive on this dev. Modified independently to the + * above fields, hence the alignment. Gcc reported to have + * a long standing bug, when it uses 64-bit memory accesses for + * int bit fields, so this alignment must be here to workaroud it. + */ + atomic_t dev_cmd_count __aligned(sizeof(long)); spinlock_t dev_lock; /* device lock */ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 426b83fcd..e684b42cb 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -106,8 +106,12 @@ struct scst_user_cmd { struct scst_cmd *cmd; struct scst_user_dev *dev; - atomic_t ucmd_ref; - + /* + * Note, gcc reported to have a long standing bug, when it uses 64-bit + * memory accesses for int bit fields, so, if any neighbor int field + * modified intependently to those bit fields, it must be 64-bit + * aligned to workaround this gcc bug! + */ unsigned int buff_cached:1; unsigned int buf_dirty:1; unsigned int background_exec:1; @@ -115,6 +119,8 @@ struct scst_user_cmd { struct scst_user_cmd *buf_ucmd; + atomic_t ucmd_ref; + int cur_data_page; int num_data_pages; int first_page_offset;