Commit aad5b23e authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm: fix dm_io and dm_target_io flags race condition on Alpha

Early alpha processors cannot write a single byte or short; they read 8
bytes, modify the value in registers and write back 8 bytes.

This could cause race condition in the structure dm_io - if the fields
flags and io_count are modified simultaneously.

Fix this bug by using 32-bit flags if we are on Alpha and if we are
compiling for a processor that doesn't have the byte-word-extension.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Fixes: bd4a6dd2 ("dm: reduce size of dm_io and dm_target_io structs")
[snitzer: Jens allowed this change since Mikulas owns a relevant Alpha!]
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent cc09e8a9
...@@ -210,7 +210,7 @@ struct dm_table { ...@@ -210,7 +210,7 @@ struct dm_table {
#define DM_TIO_MAGIC 28714 #define DM_TIO_MAGIC 28714
struct dm_target_io { struct dm_target_io {
unsigned short magic; unsigned short magic;
unsigned short flags; blk_short_t flags;
unsigned int target_bio_nr; unsigned int target_bio_nr;
struct dm_io *io; struct dm_io *io;
struct dm_target *ti; struct dm_target *ti;
...@@ -244,7 +244,7 @@ static inline void dm_tio_set_flag(struct dm_target_io *tio, unsigned int bit) ...@@ -244,7 +244,7 @@ static inline void dm_tio_set_flag(struct dm_target_io *tio, unsigned int bit)
#define DM_IO_MAGIC 19577 #define DM_IO_MAGIC 19577
struct dm_io { struct dm_io {
unsigned short magic; unsigned short magic;
unsigned short flags; blk_short_t flags;
atomic_t io_count; atomic_t io_count;
struct mapped_device *md; struct mapped_device *md;
struct bio *orig_bio; struct bio *orig_bio;
......
...@@ -85,8 +85,10 @@ struct block_device { ...@@ -85,8 +85,10 @@ struct block_device {
*/ */
#if defined(CONFIG_ALPHA) && !defined(__alpha_bwx__) #if defined(CONFIG_ALPHA) && !defined(__alpha_bwx__)
typedef u32 __bitwise blk_status_t; typedef u32 __bitwise blk_status_t;
typedef u32 blk_short_t;
#else #else
typedef u8 __bitwise blk_status_t; typedef u8 __bitwise blk_status_t;
typedef u16 blk_short_t;
#endif #endif
#define BLK_STS_OK 0 #define BLK_STS_OK 0
#define BLK_STS_NOTSUPP ((__force blk_status_t)1) #define BLK_STS_NOTSUPP ((__force blk_status_t)1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment